353 řádky
1.3 MiB
353 řádky
1.3 MiB
function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n,r=arguments[t];for(n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).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";void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}),void 0===Math.sign&&(Math.sign=function(e){return e<0?-1:0<e?1:+e}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");const t=Object(e);for(let e=1;e<arguments.length;e++){var n=arguments[e];if(null!=n)for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}),void 0===Object.values&&(Object.values=function(e){const t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(e[n]);return t}),void 0===Float32Array.prototype.slice&&(Float32Array.prototype.slice=function(e,t){return new this.constructor(this.subarray(e,t))}),String.prototype.endsWith||(String.prototype.endsWith=function(e,t){return(void 0===t||t>this.length)&&(t=this.length),this.substring(t-e.length,t)===e});class n{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){const n=this._listeners[e];void 0===n||-1!==(e=n.indexOf(t))&&n.splice(e,1)}}dispatchEvent(n){if(void 0!==this._listeners){const e=this._listeners[n.type];if(void 0!==e){n.target=this;const r=e.slice(0);for(let e=0,t=r.length;e<t;e++)r[e].call(this,n);n.target=null}}}}const o="3.9.1",fe={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2};const X=0,j=1,Y=2;const te=0,ne=1,ie=2,ae=3,oe=4,se=5,le=6,Ve=0,Fe=1,Ue=2;const ce=0,Z=1,q=2,Q=3,K=4,J=5,$=100,ue=101,me=102,ve=103,ge=104,_e=200,xe=201,ye=202,be=203,Me=204,Ae=205,we=206,Se=207,Te=208,Ce=209,Ee=210,Le=0,Re=1,Pe=2,Ie=3,Ne=4,De=5,Oe=6,Ge=7,ke=0;const s=300,L=301,R=302,P=303,I=304,N=306,D=307,U=1e3,ut=1001,G=1002,dt=1003,W=1004;const H=1005;const ht=1006,We=1007;const He=1008,Mt=1009,l=1010,c=1011,V=1012,u=1013,Xe=1014,At=1015,je=1016,d=1017,h=1018,p=1019,Ye=1020,f=1021,wt=1022,pt=1023,m=1024,v=1025,F=pt,Ze=1026,qe=1027,Qe=1028,M=1029,A=1030,w=1031,B=1032,z=1033,Ke=33776,Je=33777,$e=33778,et=33779,tt=35840,nt=35841,rt=35842,it=35843,at=36196,ot=37492,st=37496,lt=37808,ct=37809,St=37810,Tt=37811,Ct=37812,Et=37813,Lt=37814,Rt=37815,Pt=37816,It=37817,Nt=37818,Dt=37819,Ot=37820,Ft=37821,Bt=36492,zt=37840,Vt=37841,Ut=37842,Gt=37843,kt=37844,Wt=37845,Ht=37846,Xt=37847,jt=37848,Yt=37849,Zt=37850,qt=37851,Qt=37852,Kt=37853,Jt=2300,$t=2301,en=2302,tn=2400,nn=2401,rn=2402,an=3e3,on=3001,sn=3002,ln=3201,cn=3301,un=3302,dn=0,hn=1;const pn=34055,fn=34056;const mn=35044,vn=35048;const gn="300 es",_n="BLENDER",xn="__V3DL__0000000000",yn=[];for(let e=0;e<256;e++)yn[e]=(e<16?"0":"")+e.toString(16);let bn=1234567;const Mn=Math.PI/180,An=180/Math.PI;function wn(){var e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,r=4294967295*Math.random()|0;const i=yn[255&e]+yn[e>>8&255]+yn[e>>16&255]+yn[e>>24&255]+"-"+yn[255&t]+yn[t>>8&255]+"-"+yn[t>>16&15|64]+yn[t>>24&255]+"-"+yn[63&n|128]+yn[n>>8&255]+"-"+yn[n>>16&255]+yn[n>>24&255]+yn[255&r]+yn[r>>8&255]+yn[r>>16&255]+yn[r>>24&255];return i.toUpperCase()}function ft(e,t,n){return Math.max(t,Math.min(n,e))}function Sn(e,t){return(e%t+t)%t}function Tn(e,t,n){return(1-n)*e+n*t}function Cn(e,t,n){return e<=t?0:n<=e?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)}function En(e){return e*Mn}function Ln(e){return e*An}function Rn(e){return 0==(e&e-1)&&0!==e}function Pn(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function In(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Nn(e){let t=5381,n=e.length;for(;n;)t=33*t^e.charCodeAt(--n);return t>>>0}function Dn(e,t,n,r){n=Math.exp(-n/r);return e*n+(1-n)*t}function On(e,t,n,r,i){let a=Dn(e,t,n,r);return a=Math.abs(e-t)<i?t:a}function Fn(e){return ft(e-2*Math.PI*Math.floor(e/(2*Math.PI)),0,2*Math.PI)}function Bn(e){e+=Math.PI;return((e%=2*Math.PI)+2*Math.PI)%(2*Math.PI)-Math.PI}function zn(e,t,n){let r=Fn(e-t);e=Fn(n-t);return(r=r>e?r<e/2+Math.PI?e:0:r)+t}var Vn=Object.freeze({__proto__:null,DEG2RAD:Mn,RAD2DEG:An,generateUUID:wn,clamp:ft,euclideanModulo:Sn,mapLinear:function(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:Tn,damp:function(e,t,n,r){return Tn(e,t,1-Math.exp(-n*r))},pingpong:function(e,t=1){return t-Math.abs(Sn(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:n<=e?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:Cn,randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){return((bn=16807*(bn=void 0!==e?e%2147483647:bn)%2147483647)-1)/2147483646},degToRad:En,radToDeg:Ln,isPowerOfTwo:Rn,ceilPowerOfTwo:Pn,floorPowerOfTwo:In,setQuaternionFromProperEuler:function(e,t,n,r,i){const a=Math.cos,o=Math.sin;var s=a(n/2),l=o(n/2),c=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),h=o((t-r)/2),p=a((r-t)/2),f=o((r-t)/2);switch(i){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: "+i)}},hashString:Nn,expAverage:Dn,expAverageClamp:On,angleToRange_0_2Pi:Fn,angleToRange_mPi_Pi:Bn,clampAngle:zn});class Be{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return void 0!==t?(console.warn("v3d.Vector2: .add() now only accepts one argument. Use .addVectors(a, b) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return void 0!==t?(console.warn("v3d.Vector2: .sub() now only accepts one argument. Use .subVectors(a, b) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){var t=this.x,n=this.y,e=e.elements;return this.x=e[0]*t+e[3]*n+e[6],this.y=e[1]*t+e[4]*n+e[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){var 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){var t=this.x-e.x,e=this.y-e.y;return t*t+e*e}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,n){return void 0!==n&&console.warn("v3d.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){var n=Math.cos(t),t=Math.sin(t),r=this.x-e.x,i=this.y-e.y;return this.x=r*n-i*t+e.x,this.y=r*t+i*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}Be.prototype.isVector2=!0;class Un{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],0<arguments.length&&console.error("v3d.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,r,i,a,o,s,l){const c=this.elements;return c[0]=e,c[1]=r,c[2]=o,c[3]=t,c[4]=i,c[5]=s,c[6]=n,c[7]=a,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements;e=e.elements;return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){e=e.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){e=e.elements,t=t.elements;const n=this.elements;var r=e[0],i=e[3],a=e[6],o=e[1],s=e[4],l=e[7],c=e[2],u=e[5],e=e[8],d=t[0],h=t[3],p=t[6],f=t[1],m=t[4],v=t[7],g=t[2],_=t[5],t=t[8];return n[0]=r*d+i*f+a*g,n[3]=r*h+i*m+a*_,n[6]=r*p+i*v+a*t,n[1]=o*d+s*f+l*g,n[4]=o*h+s*m+l*_,n[7]=o*p+s*v+l*t,n[2]=c*d+u*f+e*g,n[5]=c*h+u*m+e*_,n[8]=c*p+u*v+e*t,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(){var e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],l=e[7],e=e[8];return t*a*e-t*o*l-n*i*e+n*o*s+r*i*l-r*a*s}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=c*a-o*l,d=o*s-c*i,h=l*i-a*s,p=t*u+n*d+r*h;if(0==p)return this.set(0,0,0,0,0,0,0,0,0);var f=1/p;return e[0]=u*f,e[1]=(r*l-c*n)*f,e[2]=(o*n-r*a)*f,e[3]=d*f,e[4]=(c*t-r*s)*f,e[5]=(r*i-o*t)*f,e[6]=h*f,e[7]=(n*s-l*t)*f,e[8]=(a*t-n*i)*f,this}transpose(){var 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){var 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,r,i,a,o){var s=Math.cos(i),i=Math.sin(i);return this.set(n*s,n*i,-n*(s*a+i*o)+a+e,-r*i,r*s,-r*(-i*a+s*o)+o+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){var t=Math.cos(e),e=Math.sin(e);const n=this.elements;var r=n[0],i=n[3],a=n[6],o=n[1],s=n[4],l=n[7];return n[0]=t*r+e*o,n[3]=t*i+e*s,n[6]=t*a+e*l,n[1]=-e*r+t*o,n[4]=-e*i+t*s,n[7]=-e*a+t*l,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){var t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(t,n=0){for(let e=0;e<9;e++)this.elements[e]=t[e+n];return this}toArray(e=[],t=0){var 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)}}Un.prototype.isMatrix3=!0;let Gn;class kn{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{(Gn=void 0===Gn?document.createElementNS("http://www.w3.org/1999/xhtml","canvas"):Gn).width=e.width,Gn.height=e.height;const n=Gn.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Gn}return 2048<t.width||2048<t.height?(console.warn("v3d.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}}let Wn=0;class Hn extends n{constructor(e=Hn.DEFAULT_IMAGE,t=Hn.DEFAULT_MAPPING,n=ut,r=ut,i=ht,a=He,o=pt,s=Mt,l=1,c=an){super(),Object.defineProperty(this,"id",{value:Wn++}),this.uuid=wn(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=r,this.magFilter=i,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=s,this.offset=new Be(0,0),this.repeat=new Be(1,1),this.center=new Be(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Un,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.version=0,this.onUpdate=null}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.image=e.image,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}toJSON(e){var 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,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,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const r=this.image;if(void 0===r.uuid&&(r.uuid=wn()),!t&&void 0===e.images[r.uuid]){let n;if(Array.isArray(r)){n=[];for(let e=0,t=r.length;e<t;e++)r[e].isDataTexture?n.push(Xn(r[e].image)):n.push(Xn(r[e]))}else n=Xn(r);e.images[r.uuid]={uuid:r.uuid,url:n}}n.image=r.uuid}return t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==s)return e;if(e.applyMatrix3(this.matrix),e.x<0||1<e.x)switch(this.wrapS){case U:e.x=e.x-Math.floor(e.x);break;case ut:e.x=e.x<0?0:1;break;case G: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||1<e.y)switch(this.wrapT){case U:e.y=e.y-Math.floor(e.y);break;case ut:e.y=e.y<0?0:1;break;case G:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&this.version++}}function Xn(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?kn.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("v3d.Texture: Unable to serialize Texture."),{})}Hn.DEFAULT_IMAGE=void 0,Hn.DEFAULT_MAPPING=s,Hn.prototype.isTexture=!0;class mt{constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}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,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e,t){return void 0!==t?(console.warn("v3d.Vector4: .add() now only accepts one argument. Use .addVectors(a, b) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return void 0!==t?(console.warn("v3d.Vector4: .sub() now only accepts one argument. Use .subVectors(a, b) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){var t=this.x,n=this.y,r=this.z,i=this.w,e=e.elements;return this.x=e[0]*t+e[4]*n+e[8]*r+e[12]*i,this.y=e[1]*t+e[5]*n+e[9]*r+e[13]*i,this.z=e[2]*t+e[6]*n+e[10]*r+e[14]*i,this.w=e[3]*t+e[7]*n+e[11]*r+e[15]*i,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);var 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,r,i;var e=e.elements,a=e[0],o=e[4],s=e[8],l=e[1],c=e[5],u=e[9],d=e[2],h=e[6],e=e[10];if(Math.abs(o-l)<.01&&Math.abs(s-d)<.01&&Math.abs(u-h)<.01){if(Math.abs(o+l)<.1&&Math.abs(s+d)<.1&&Math.abs(u+h)<.1&&Math.abs(a+c+e-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;var p=(a+1)/2,f=(c+1)/2,m=(e+1)/2,v=(o+l)/4,g=(s+d)/4,_=(u+h)/4;return f<p&&m<p?i=p<.01?(n=0,r=.707106781):(n=Math.sqrt(p),r=v/n,g/n):m<f?i=f<.01?(n=.707106781,r=0,.707106781):(r=Math.sqrt(f),n=v/r,_/r):m<.01?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(m),n=g/i,r=_/i),this.set(n,r,i,t),this}let x=Math.sqrt((h-u)*(h-u)+(s-d)*(s-d)+(l-o)*(l-o));return Math.abs(x)<.001&&(x=1),this.x=(h-u)/x,this.y=(s-d)/x,this.z=(l-o)/x,this.w=Math.acos((a+c+e-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){var 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,n){return void 0!==n&&console.warn("v3d.Vector4: offset has been removed from .fromBufferAttribute()."),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}}mt.prototype.isVector4=!0;class ze extends n{constructor(e,t,n={}){super(),this.width=e,this.height=t,this.depth=1,this.scissor=new mt(0,0,e,t),this.scissorTest=!1,this.viewport=new mt(0,0,e,t),this.texture=new Hn(void 0,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={width:e,height:t,depth:1},this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:ht,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}setTexture(e){e.image={width:this.width,height:this.height,depth:this.depth},this.texture=e}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){return this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),Array.isArray(this.texture.image)?this.texture.image=[...this.texture.image]:this.texture.image=_extends({},this.texture.image),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}ze.prototype.isWebGLRenderTarget=!0;class jn extends ze{constructor(e,t,n){super(e,t);const r=this.texture;this.texture=[];for(let e=0;e<n;e++)this.texture[e]=r.clone()}setSize(n,r,i=1){if(this.width!==n||this.height!==r||this.depth!==i){this.width=n,this.height=r,this.depth=i;for(let e=0,t=this.texture.length;e<t;e++)this.texture[e].image.width=n,this.texture[e].image.height=r,this.texture[e].image.depth=i;this.dispose()}return this.viewport.set(0,0,n,r),this.scissor.set(0,0,n,r),this}copy(n){this.dispose(),this.width=n.width,this.height=n.height,this.depth=n.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.depthTexture=n.depthTexture;for(let e=this.texture.length=0,t=n.texture.length;e<t;e++)this.texture[e]=n.texture[e].clone();return this}}jn.prototype.isWebGLMultipleRenderTargets=!0;class Yn extends ze{constructor(e,t,n){super(e,t,n),this.samples=4}copy(e){return super.copy.call(this,e),this.samples=e.samples,this}}Yn.prototype.isWebGLMultisampleRenderTarget=!0;class de{constructor(e=0,t=0,n=0,r=1){this._x=e,this._y=t,this._z=n,this._w=r}static slerp(e,t,n,r){return console.warn("v3d.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions(qa, qb, t) instead."),n.slerpQuaternions(e,t,r)}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],l=n[r+1],c=n[r+2],u=n[r+3];var n=i[a+0],r=i[a+1],d=i[a+2],i=i[a+3];if(0===o)return e[t+0]=s,e[t+1]=l,e[t+2]=c,void(e[t+3]=u);if(1===o)return e[t+0]=n,e[t+1]=r,e[t+2]=d,void(e[t+3]=i);if(u!==i||s!==n||l!==r||c!==d){let e=1-o;var a=s*n+l*r+c*d+u*i,h=0<=a?1:-1,p=1-a*a,a=(p>Number.EPSILON&&(p=Math.sqrt(p),a=Math.atan2(p,a*h),e=Math.sin(e*a)/p,o=Math.sin(o*a)/p),o*h);s=s*e+n*a,l=l*e+r*a,c=c*e+d*a,u=u*e+i*a,e===1-o&&(p=1/Math.sqrt(s*s+l*l+c*c+u*u),s*=p,l*=p,c*=p,u*=p)}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){var o=n[r],s=n[r+1],l=n[r+2],n=n[r+3],r=i[a],c=i[a+1],u=i[a+2],i=i[a+3];return e[t]=o*i+n*r+s*u-l*c,e[t+1]=s*i+n*c+l*r-o*u,e[t+2]=l*i+n*u+o*c-s*r,e[t+3]=n*i-o*r-s*c-l*u,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,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!e||!e.isEuler)throw new Error("v3d.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=e._x,r=e._y,i=e._z,a=e._order;const o=Math.cos,s=Math.sin;var l=o(n/2),c=o(r/2),u=o(i/2),d=s(n/2),h=s(r/2),p=s(i/2);switch(a){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: "+a)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){var t=t/2,n=Math.sin(t);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(t),this._onChangeCallback(),this}setFromRotationMatrix(e){var e=e.elements,t=e[0],n=e[4],r=e[8],i=e[1],a=e[5],o=e[9],s=e[2],l=e[6],e=e[10],c=t+a+e;return 0<c?(c=.5/Math.sqrt(c+1),this._w=.25/c,this._x=(l-o)*c,this._y=(r-s)*c,this._z=(i-n)*c):a<t&&e<t?(c=2*Math.sqrt(1+t-a-e),this._w=(l-o)/c,this._x=.25*c,this._y=(n+i)/c,this._z=(r+s)/c):e<a?(c=2*Math.sqrt(1+a-t-e),this._w=(r-s)/c,this._x=(n+i)/c,this._y=.25*c,this._z=(o+l)/c):(c=2*Math.sqrt(1+e-t-a),this._w=(i-n)/c,this._x=(r+s)/c,this._y=(o+l)/c,this._z=.25*c),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._x=0,this._y=-e.z,this._z=e.y)):(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(ft(this.dot(e),-1,1)))}rotateTowards(e,t){var n=this.angleTo(e);if(0===n)return this;t=Math.min(1,t/n);return this.slerp(e,t),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(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(this._x=this._x*(e=1/e),this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return void 0!==t?(console.warn("v3d.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions(a, b) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){var n=e._x,r=e._y,i=e._z,e=e._w,a=t._x,o=t._y,s=t._z,t=t._w;return this._x=n*t+e*a+r*s-i*o,this._y=r*t+e*o+i*a-n*s,this._z=i*t+e*s+n*o-r*a,this._w=e*t-n*a-r*o-i*s,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);var n=this._x,r=this._y,i=this._z,a=this._w;let o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),1<=o)return this._w=a,this._x=n,this._y=r,this._z=i,this;e=1-o*o;if(e<=Number.EPSILON)return this._w=(s=1-t)*a+t*this._w,this._x=s*n+t*this._x,this._y=s*r+t*this._y,this._z=s*i+t*this._z,this.normalize(),this._onChangeCallback(),this;var s=Math.sqrt(e),e=Math.atan2(s,o),l=Math.sin((1-t)*e)/s,t=Math.sin(t*e)/s;return this._w=a*l+this._w*t,this._x=n*l+this._x*t,this._y=r*l+this._y*t,this._z=i*l+this._z*t,this._onChangeCallback(),this}slerpQuaternions(e,t,n){this.copy(e).slerp(t,n)}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(){}}de.prototype.isQuaternion=!0;class vt{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return void 0!==t?(console.warn("v3d.Vector3: .add() now only accepts one argument. Use .addVectors(a, b) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return void 0!==t?(console.warn("v3d.Vector3: .sub() now only accepts one argument. Use .subVectors(a, b) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return void 0!==t?(console.warn("v3d.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors(a, b) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("v3d.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(qn.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(qn.setFromAxisAngle(e,t))}applyMatrix3(e){var t=this.x,n=this.y,r=this.z,e=e.elements;return this.x=e[0]*t+e[3]*n+e[6]*r,this.y=e[1]*t+e[4]*n+e[7]*r,this.z=e[2]*t+e[5]*n+e[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){var t=this.x,n=this.y,r=this.z,e=e.elements,i=1/(e[3]*t+e[7]*n+e[11]*r+e[15]);return this.x=(e[0]*t+e[4]*n+e[8]*r+e[12])*i,this.y=(e[1]*t+e[5]*n+e[9]*r+e[13])*i,this.z=(e[2]*t+e[6]*n+e[10]*r+e[14])*i,this}applyQuaternion(e){var t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,e=e.w,s=e*t+a*r-o*n,l=e*n+o*t-i*r,c=e*r+i*n-a*t,t=-i*t-a*n-o*r;return this.x=s*e+t*-i+l*-o-c*-a,this.y=l*e+t*-a+c*-i-s*-o,this.z=c*e+t*-o+s*-a-l*-i,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){var t=this.x,n=this.y,r=this.z,e=e.elements;return this.x=e[0]*t+e[4]*n+e[8]*r,this.y=e[1]*t+e[5]*n+e[9]*r,this.z=e[2]*t+e[6]*n+e[10]*r,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){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e,t){return void 0!==t?(console.warn("v3d.Vector3: .cross() now only accepts one argument. Use .crossVectors(a, b) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){var n=e.x,r=e.y,e=e.z,i=t.x,a=t.y,t=t.z;return this.x=r*t-e*a,this.y=e*i-n*t,this.z=n*a-r*i,this}projectOnVector(e){var t=e.lengthSq();if(0===t)return this.set(0,0,0);t=e.dot(this)/t;return this.copy(e).multiplyScalar(t)}projectOnPlane(e){return Zn.copy(this).projectOnVector(e),this.sub(Zn)}reflect(e){return this.sub(Zn.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;e=this.dot(e)/t;return Math.acos(ft(e,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){var t=this.x-e.x,n=this.y-e.y,e=this.z-e.z;return t*t+n*n+e*e}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){var r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*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){e=e.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(e){var t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),e=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=e,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,n){return void 0!==n&&console.warn("v3d.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}vt.prototype.isVector3=!0;const Zn=new vt,qn=new de;class g{constructor(e=new vt(1/0,1/0,1/0),t=new vt(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(n){let r=1/0,i=1/0,a=1/0,o=-1/0,s=-1/0,l=-1/0;for(let e=0,t=n.length;e<t;e+=3){var c=n[e],u=n[e+1],d=n[e+2];c<r&&(r=c),u<i&&(i=u),d<a&&(a=d),c>o&&(o=c),u>s&&(s=u),d>l&&(l=d)}return this.min.set(r,i,a),this.max.set(o,s,l),this}setFromBufferAttribute(n){let r=1/0,i=1/0,a=1/0,o=-1/0,s=-1/0,l=-1/0;for(let e=0,t=n.count;e<t;e++){var c=n.getX(e),u=n.getY(e),d=n.getZ(e);c<r&&(r=c),u<i&&(i=u),d<a&&(a=d),c>o&&(o=c),u>s&&(s=u),d>l&&(l=d)}return this.min.set(r,i,a),this.max.set(o,s,l),this}setFromPoints(n){this.makeEmpty();for(let e=0,t=n.length;e<t;e++)this.expandByPoint(n[e]);return this}setFromCenterAndSize(e,t){t=Kn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(t),this.max.copy(e).add(t),this}setFromObject(e){return this.makeEmpty(),this.expandByObject(e)}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){e.updateWorldMatrix(!1,!1);const t=e.geometry;void 0!==t&&(null===t.boundingBox&&t.computeBoundingBox(),Jn.copy(t.boundingBox),Jn.applyMatrix4(e.matrixWorld),this.union(Jn));var n=e.children;for(let e=0,t=n.length;e<t;e++)this.expandByObject(n[e]);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,Kn),Kn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return n=0<e.normal.x?(t=e.normal.x*this.min.x,e.normal.x*this.max.x):(t=e.normal.x*this.max.x,e.normal.x*this.min.x),0<e.normal.y?(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),0<e.normal.z?(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){return!this.isEmpty()&&(this.getCenter(ar),or.subVectors(this.max,ar),$n.subVectors(e.a,ar),er.subVectors(e.b,ar),tr.subVectors(e.c,ar),nr.subVectors(er,$n),rr.subVectors(tr,er),ir.subVectors($n,tr),!!cr([0,-nr.z,nr.y,0,-rr.z,rr.y,0,-ir.z,ir.y,nr.z,0,-nr.x,rr.z,0,-rr.x,ir.z,0,-ir.x,-nr.y,nr.x,0,-rr.y,rr.x,0,-ir.y,ir.x,0],$n,er,tr,or)&&(!!cr([1,0,0,0,1,0,0,0,1],$n,er,tr,or)&&(sr.crossVectors(nr,rr),cr([sr.x,sr.y,sr.z],$n,er,tr,or))))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){const t=Kn.copy(e).clamp(this.min,this.max);return t.sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(Kn).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()||(Qn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Qn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Qn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Qn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Qn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Qn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Qn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Qn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Qn)),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)}}g.prototype.isBox3=!0;const Qn=[new vt,new vt,new vt,new vt,new vt,new vt,new vt,new vt],Kn=new vt,Jn=new g,$n=new vt,er=new vt,tr=new vt,nr=new vt,rr=new vt,ir=new vt,ar=new vt,or=new vt,sr=new vt,lr=new vt;function cr(n,r,i,a,o){for(let e=0,t=n.length-3;e<=t;e+=3){lr.fromArray(n,e);var s=o.x*Math.abs(lr.x)+o.y*Math.abs(lr.y)+o.z*Math.abs(lr.z),l=r.dot(lr),c=i.dot(lr),u=a.dot(lr);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>s)return!1}return!0}const ur=new g,dr=new vt,hr=new vt,pr=new vt;class fr{constructor(e=new vt,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(n,e){const r=this.center;void 0!==e?r.copy(e):ur.setFromPoints(n).getCenter(r);let i=0;for(let e=0,t=n.length;e<t;e++)i=Math.max(i,r.distanceToSquared(n[e]));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){var 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){var 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.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){pr.subVectors(e,this.center);var t,e=pr.lengthSq();return e>this.radius*this.radius&&(t=.5*((e=Math.sqrt(e))-this.radius),this.center.add(pr.multiplyScalar(t/e)),this.radius+=t),this}union(e){return 0===this.center.distanceToSquared(e.center)?this.radius=Math.max(this.radius,e.radius):(hr.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(dr.copy(e.center).add(hr)),this.expandByPoint(dr.copy(e.center).sub(hr))),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const mr=new vt,vr=new vt,gr=new vt,_r=new vt,xr=new vt,yr=new vt,br=new vt;class Mr{constructor(e=new vt,t=new vt(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,mr)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);e=t.dot(this.direction);return e<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(e).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){var t=mr.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(mr.copy(this.direction).multiplyScalar(t).add(this.origin),mr.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){vr.copy(e).add(t).multiplyScalar(.5),gr.copy(t).sub(e).normalize(),_r.copy(this.origin).sub(vr);var e=.5*e.distanceTo(t),t=-this.direction.dot(gr),i=_r.dot(this.direction),a=-_r.dot(gr),o=_r.lengthSq(),s=Math.abs(1-t*t);let l,c,u,d;return u=0<s?(l=t*a-i,c=t*i-a,d=e*s,0<=l?c>=-d?c<=d?(s=1/s,l*=s,c*=s,l*(l+t*c+2*i)+c*(t*l+c+2*a)+o):(c=e,-(l=Math.max(0,-(t*c+i)))*l+c*(c+2*a)+o):(c=-e,-(l=Math.max(0,-(t*c+i)))*l+c*(c+2*a)+o):c<=-d?(l=Math.max(0,-(-t*e+i)),c=0<l?-e:Math.min(Math.max(-e,-a),e),-l*l+c*(c+2*a)+o):c<=d?(l=0,(c=Math.min(Math.max(-e,-a),e))*(c+2*a)+o):(l=Math.max(0,-(t*e+i)),c=0<l?e:Math.min(Math.max(-e,-a),e),-l*l+c*(c+2*a)+o)):(c=0<t?-e:e,-(l=Math.max(0,-(t*c+i)))*l+c*(c+2*a)+o),n&&n.copy(this.direction).multiplyScalar(l).add(this.origin),r&&r.copy(gr).multiplyScalar(c).add(vr),u}intersectSphere(e,t){mr.subVectors(e.center,this.origin);var n=mr.dot(this.direction),r=mr.dot(mr)-n*n,e=e.radius*e.radius;if(e<r)return null;e=Math.sqrt(e-r),r=n-e,n+=e;return r<0&&n<0?null:r<0?this.at(n,t):this.at(r,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;e=-(this.origin.dot(e.normal)+e.constant)/t;return 0<=e?e:null}intersectPlane(e,t){e=this.distanceToPlane(e);return null===e?null:this.at(e,t)}intersectsPlane(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s;var l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,d=this.origin;return r=0<=l?(n=(e.min.x-d.x)*l,(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,(e.min.x-d.x)*l),a=0<=c?(i=(e.min.y-d.y)*c,(e.max.y-d.y)*c):(i=(e.max.y-d.y)*c,(e.min.y-d.y)*c),n>a||i>r?null:((i>n||n!=n)&&(n=i),(a<r||r!=r)&&(r=a),s=0<=u?(o=(e.min.z-d.z)*u,(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,(e.min.z-d.z)*u),n>s||o>r?null:((o>n||n!=n)&&(n=o),(r=s<r||r!=r?s:r)<0?null:this.at(0<=n?n:r,t)))}intersectsBox(e){return null!==this.intersectBox(e,mr)}intersectTriangle(e,t,n,r,i){xr.subVectors(t,e),yr.subVectors(n,e),br.crossVectors(xr,yr);let a=this.direction.dot(br),o;if(0<a){if(r)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}_r.subVectors(this.origin,e);t=o*this.direction.dot(yr.crossVectors(_r,yr));if(t<0)return null;n=o*this.direction.dot(xr.cross(_r));if(n<0)return null;if(t+n>a)return null;r=-o*_r.dot(br);return r<0?null:this.at(r/a,i)}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 gt{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0<arguments.length&&console.error("v3d.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,r,i,a,o,s,l,c,u,d,h,p,f,m){const v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=r,v[1]=i,v[5]=a,v[9]=o,v[13]=s,v[2]=l,v[6]=c,v[10]=u,v[14]=d,v[3]=h,v[7]=p,v[11]=f,v[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 gt).fromArray(this.elements)}copy(e){const t=this.elements;e=e.elements;return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[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){e=e.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[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;var n=e.elements,r=1/Ar.setFromMatrixColumn(e,0).length(),i=1/Ar.setFromMatrixColumn(e,1).length(),e=1/Ar.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*e,t[9]=n[9]*e,t[10]=n[10]*e,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("v3d.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements;var n,r,i,a,o=e.x,s=e.y,l=e.z,c=Math.cos(o),o=Math.sin(o),u=Math.cos(s),s=Math.sin(s),d=Math.cos(l),l=Math.sin(l);return"XYZ"===e.order?(i=c*d,r=c*l,n=o*d,a=o*l,t[0]=u*d,t[4]=-u*l,t[8]=s,t[1]=r+n*s,t[5]=i-a*s,t[9]=-o*u,t[2]=a-i*s,t[6]=n+r*s,t[10]=c*u):"YXZ"===e.order?(a=u*d,i=u*l,n=s*d,r=s*l,t[0]=a+r*o,t[4]=n*o-i,t[8]=c*s,t[1]=c*l,t[5]=c*d,t[9]=-o,t[2]=i*o-n,t[6]=r+a*o,t[10]=c*u):"ZXY"===e.order?(i=u*d,n=u*l,r=s*d,a=s*l,t[0]=i-a*o,t[4]=-c*l,t[8]=r+n*o,t[1]=n+r*o,t[5]=c*d,t[9]=a-i*o,t[2]=-c*s,t[6]=o,t[10]=c*u):"ZYX"===e.order?(n=c*d,r=c*l,a=o*d,i=o*l,t[0]=u*d,t[4]=a*s-r,t[8]=n*s+i,t[1]=u*l,t[5]=i*s+n,t[9]=r*s-a,t[2]=-s,t[6]=o*u,t[10]=c*u):"YZX"===e.order?(i=c*u,n=c*s,r=o*u,a=o*s,t[0]=u*d,t[4]=a-i*l,t[8]=r*l+n,t[1]=l,t[5]=c*d,t[9]=-o*d,t[2]=-s*d,t[6]=n*l+r,t[10]=i-a*l):"XZY"===e.order&&(n=c*u,r=c*s,i=o*u,a=o*s,t[0]=u*d,t[4]=-l,t[8]=s*d,t[1]=n*l+a,t[5]=c*d,t[9]=r*l-i,t[2]=i*l-r,t[6]=o*d,t[10]=a*l+n),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(Sr,e,Tr)}lookAt(e,t,n){const r=this.elements;return Lr.subVectors(e,t),0===Lr.lengthSq()&&(Lr.z=1),Lr.normalize(),Cr.crossVectors(n,Lr),0===Cr.lengthSq()&&(1===Math.abs(n.z)?Lr.x+=1e-4:Lr.z+=1e-4,Lr.normalize(),Cr.crossVectors(n,Lr)),Cr.normalize(),Er.crossVectors(Lr,Cr),r[0]=Cr.x,r[4]=Er.x,r[8]=Lr.x,r[1]=Cr.y,r[5]=Er.y,r[9]=Lr.y,r[2]=Cr.z,r[6]=Er.z,r[10]=Lr.z,this}multiply(e,t){return void 0!==t?(console.warn("v3d.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices(a, b) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){e=e.elements,t=t.elements;const n=this.elements;var r=e[0],i=e[4],a=e[8],o=e[12],s=e[1],l=e[5],c=e[9],u=e[13],d=e[2],h=e[6],p=e[10],f=e[14],m=e[3],v=e[7],g=e[11],e=e[15],_=t[0],x=t[4],y=t[8],b=t[12],M=t[1],A=t[5],w=t[9],S=t[13],T=t[2],C=t[6],E=t[10],L=t[14],R=t[3],P=t[7],I=t[11],t=t[15];return n[0]=r*_+i*M+a*T+o*R,n[4]=r*x+i*A+a*C+o*P,n[8]=r*y+i*w+a*E+o*I,n[12]=r*b+i*S+a*L+o*t,n[1]=s*_+l*M+c*T+u*R,n[5]=s*x+l*A+c*C+u*P,n[9]=s*y+l*w+c*E+u*I,n[13]=s*b+l*S+c*L+u*t,n[2]=d*_+h*M+p*T+f*R,n[6]=d*x+h*A+p*C+f*P,n[10]=d*y+h*w+p*E+f*I,n[14]=d*b+h*S+p*L+f*t,n[3]=m*_+v*M+g*T+e*R,n[7]=m*x+v*A+g*C+e*P,n[11]=m*y+v*w+g*E+e*I,n[15]=m*b+v*S+g*L+e*t,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(){var e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],l=e[13],c=e[2],u=e[6],d=e[10],h=e[14];return e[3]*(+i*s*u-r*l*u-i*o*d+n*l*d+r*o*h-n*s*h)+e[7]*(+t*s*h-t*l*d+i*a*d-r*a*h+r*l*c-i*s*c)+e[11]*(+t*l*u-t*o*h-i*a*u+n*a*h+i*o*c-n*l*c)+e[15]*(-r*o*c-t*s*u+t*o*d+r*a*u-n*a*d+n*s*c)}transpose(){const e=this.elements;var t=e[1];return 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 r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=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],v=e[15],g=u*m*l-f*d*l+f*s*h-o*m*h-u*s*v+o*d*v,_=p*d*l-c*m*l-p*s*h+a*m*h+c*s*v-a*d*v,x=c*f*l-p*u*l+p*o*h-a*f*h-c*o*v+a*u*v,y=p*u*s-c*f*s-p*o*d+a*f*d+c*o*m-a*u*m;var b=t*g+n*_+r*x+i*y;if(0==b)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);b=1/b;return e[0]=g*b,e[1]=(f*d*i-u*m*i-f*r*h+n*m*h+u*r*v-n*d*v)*b,e[2]=(o*m*i-f*s*i+f*r*l-n*m*l-o*r*v+n*s*v)*b,e[3]=(u*s*i-o*d*i-u*r*l+n*d*l+o*r*h-n*s*h)*b,e[4]=_*b,e[5]=(c*m*i-p*d*i+p*r*h-t*m*h-c*r*v+t*d*v)*b,e[6]=(p*s*i-a*m*i-p*r*l+t*m*l+a*r*v-t*s*v)*b,e[7]=(a*d*i-c*s*i+c*r*l-t*d*l-a*r*h+t*s*h)*b,e[8]=x*b,e[9]=(p*u*i-c*f*i-p*n*h+t*f*h+c*n*v-t*u*v)*b,e[10]=(a*f*i-p*o*i+p*n*l-t*f*l-a*n*v+t*o*v)*b,e[11]=(c*o*i-a*u*i-c*n*l+t*u*l+a*n*h-t*o*h)*b,e[12]=y*b,e[13]=(c*f*r-p*u*r+p*n*d-t*f*d-c*n*m+t*u*m)*b,e[14]=(p*o*r-a*f*r-p*n*s+t*f*s+a*n*m-t*o*m)*b,e[15]=(a*u*r-c*o*r+c*n*s-t*u*s-a*n*d+t*o*d)*b,this}scale(e){const t=this.elements;var n=e.x,r=e.y,e=e.z;return t[0]*=n,t[4]*=r,t[8]*=e,t[1]*=n,t[5]*=r,t[9]*=e,t[2]*=n,t[6]*=r,t[10]*=e,t[3]*=n,t[7]*=r,t[11]*=e,this}getMaxScaleOnAxis(){var 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],e=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,e))}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){var t=Math.cos(e),e=Math.sin(e);return this.set(1,0,0,0,0,t,-e,0,0,e,t,0,0,0,0,1),this}makeRotationY(e){var t=Math.cos(e),e=Math.sin(e);return this.set(t,0,e,0,0,1,0,0,-e,0,t,0,0,0,0,1),this}makeRotationZ(e){var t=Math.cos(e),e=Math.sin(e);return this.set(t,-e,0,0,e,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){var n=Math.cos(t),t=Math.sin(t),r=1-n,i=e.x,a=e.y,e=e.z,o=r*i,s=r*a;return this.set(o*i+n,o*a-t*e,o*e+t*a,0,o*a+t*e,s*a+n,s*e-t*i,0,o*e-t*a,s*e+t*i,r*e*e+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,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements;var i=t._x,a=t._y,o=t._z,t=t._w,s=i+i,l=a+a,c=o+o,u=i*s,d=i*l,i=i*c,h=a*l,a=a*c,o=o*c,s=t*s,l=t*l,t=t*c,c=n.x,p=n.y,n=n.z;return r[0]=(1-(h+o))*c,r[1]=(d+t)*c,r[2]=(i-l)*c,r[3]=0,r[4]=(d-t)*p,r[5]=(1-(u+o))*p,r[6]=(a+s)*p,r[7]=0,r[8]=(i+l)*n,r[9]=(a-s)*n,r[10]=(1-(u+h))*n,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){var r=this.elements;let i=Ar.set(r[0],r[1],r[2]).length();var a=Ar.set(r[4],r[5],r[6]).length(),o=Ar.set(r[8],r[9],r[10]).length(),e=(this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],wr.copy(this),1/i),r=1/a,s=1/o;return wr.elements[0]*=e,wr.elements[1]*=e,wr.elements[2]*=e,wr.elements[4]*=r,wr.elements[5]*=r,wr.elements[6]*=r,wr.elements[8]*=s,wr.elements[9]*=s,wr.elements[10]*=s,t.setFromRotationMatrix(wr),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a){void 0===a&&console.warn("v3d.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const o=this.elements;var s=2*i/(n-r),l=(t+e)/(t-e),n=(n+r)/(n-r),r=-(a+i)/(a-i),a=-2*a*i/(a-i);return o[0]=2*i/(t-e),o[4]=0,o[8]=l,o[12]=0,o[1]=0,o[5]=s,o[9]=n,o[13]=0,o[2]=0,o[6]=0,o[10]=r,o[14]=a,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,r,i,a){const o=this.elements;var s=1/(t-e),l=1/(n-r),c=1/(a-i),t=(t+e)*s,e=(n+r)*l,n=(a+i)*c;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-t,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-e,o[2]=0,o[6]=0,o[10]=-2*c,o[14]=-n,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){var t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(t,n=0){for(let e=0;e<16;e++)this.elements[e]=t[e+n];return this}toArray(e=[],t=0){var 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 r=this.elements;this.makeRotationFromEuler(t);var t=n.x,i=n.y,n=n.z;return r[0]*=t,r[1]*=t,r[2]*=t,r[3]=0,r[4]*=i,r[5]*=i,r[6]*=i,r[7]=0,r[8]*=n,r[9]*=n,r[10]*=n,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decomposeE(e,t,n,r=t.order){var i=this.elements;let a=Ar.set(i[0],i[1],i[2]).length();var o=Ar.set(i[4],i[5],i[6]).length(),s=Ar.set(i[8],i[9],i[10]).length(),e=(this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],wr.copy(this),1/a),i=1/o,l=1/s;return wr.elements[0]*=e,wr.elements[1]*=e,wr.elements[2]*=e,wr.elements[4]*=i,wr.elements[5]*=i,wr.elements[6]*=i,wr.elements[8]*=l,wr.elements[9]*=l,wr.elements[10]*=l,t.setFromRotationMatrix(wr,r),n.x=a,n.y=o,n.z=s,this}}gt.prototype.isMatrix4=!0;const Ar=new vt,wr=new gt,Sr=new vt(0,0,0),Tr=new vt(1,1,1),Cr=new vt,Er=new vt,Lr=new vt,Rr=new gt,Pr=new de;class Ir{constructor(e=0,t=0,n=0,r=Ir.DefaultOrder){this._x=e,this._y=t,this._z=n,this._order=r}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,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,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){var e=e.elements,r=e[0],i=e[4],a=e[8],o=e[1],s=e[5],l=e[9],c=e[2],u=e[6],d=e[10];switch(t){case"XYZ":this._y=Math.asin(ft(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-i,r)):(this._x=Math.atan2(u,s),this._z=0);break;case"YXZ":this._x=Math.asin(-ft(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,s)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(ft(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-i,s)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-ft(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-i,s));break;case"YZX":this._z=Math.asin(ft(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,s),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-ft(i,-1,1)),Math.abs(i)<.9999999?(this._x=Math.atan2(u,s),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-l,d),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 Rr.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Rr,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Pr.setFromEuler(this),this.setFromQuaternion(Pr,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new vt(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}makeAlternative(){var e="X"===this._order[1]?-1:1,t="Y"===this._order[1]?-1:1,n="Z"===this._order[1]?-1:1;return this._x=Bn(e*(this._x+Math.PI)),this._y=Bn(t*(this._y+Math.PI)),this._z=Bn(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}}Ir.prototype.isEuler=!0,Ir.DefaultOrder="XYZ",Ir.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class Nr{constructor(){this.mask=1}set(e){this.mask=1<<e|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)}}const Dr={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},Or={h:0,s:0,l:0},Fr={h:0,s:0,l:0};function Br(e,t,n){return n<0&&(n+=1),1<n&&--n,n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}function zr(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Vr(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}function Ur(e,t){return e*Math.pow(2,255*t-128)}class _t{constructor(e,t,n){return void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this}setRGB(e,t,n){return this.r=e,this.g=t,this.b=n,this}setHSL(e,t,n){return e=Sn(e,1),t=ft(t,0,1),n=ft(n,0,1),0===t?this.r=this.g=this.b=n:(this.r=Br(t=2*n-(n=n<=.5?n*(1+t):n+t-n*t),n,e+1/3),this.g=Br(t,n,e),this.b=Br(t,n,e-1/3)),this}setStyle(t){function n(e){void 0!==e&&parseFloat(e)<1&&console.warn("v3d.Color: Alpha component of "+t+" will be ignored.")}let r;if(r=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let e;var i,a,o,s=r[1],l=r[2];switch(s){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))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,n(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))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,n(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return i=parseFloat(e[1])/360,a=parseInt(e[2],10)/100,o=parseInt(e[3],10)/100,n(e[4]),this.setHSL(i,a,o)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(t)){const e=r[1];s=e.length;if(3===s)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,this;if(6===s)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,this}return t&&0<t.length?this.setColorName(t):this}setColorName(e){var t=Dr[e.toLowerCase()];return void 0!==t?this.setHex(t):console.warn("v3d.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyGammaToLinear(e,t=2){return this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this}copyLinearToGamma(e,t=2){t=0<t?1/t:1;return this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this}convertGammaToLinear(e){return this.copyGammaToLinear(this,e),this}convertLinearToGamma(e){return this.copyLinearToGamma(this,e),this}copySRGBToLinear(e){return this.r=zr(e.r),this.g=zr(e.g),this.b=zr(e.b),this}copyLinearToSRGB(e){return this.r=Vr(e.r),this.g=Vr(e.g),this.b=Vr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){var t=this.r,n=this.g,r=this.b,i=Math.max(t,n,r),a=Math.min(t,n,r);let o,s;var l=(a+i)/2;if(a===i)o=0,s=0;else{var c=i-a;switch(s=l<=.5?c/(i+a):c/(2-i-a),i){case t:o=(n-r)/c+(n<r?6:0);break;case n:o=(r-t)/c+2;break;case r:o=(t-n)/c+4}o/=6}return e.h=o,e.s=s,e.l=l,e}getStyle(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"}offsetHSL(e,t,n){return this.getHSL(Or),Or.h+=e,Or.s+=t,Or.l+=n,this.setHSL(Or.h,Or.s,Or.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(Or),e.getHSL(Fr);var e=Tn(Or.h,Fr.h,t),n=Tn(Or.s,Fr.s,t),t=Tn(Or.l,Fr.l,t);return this.setHSL(e,n,t),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),!0===e.normalized&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}copyRGBEToLinear(e,t){return this.r=Ur(e.r,t),this.g=Ur(e.g,t),this.b=Ur(e.b,t),this}convertRGBEToLinear(e){return this.copyRGBEToLinear(this,e),this}}_t.NAMES=Dr,_t.prototype.isColor=!0,_t.prototype.r=1,_t.prototype.g=1,_t.prototype.b=1;let Gr=0;const kr=new vt,Wr=new de,Hr=new gt,Xr=new vt,jr=new vt,Yr=new vt,Zr=new de,qr=new vt(1,0,0),Qr=new vt(0,1,0),Kr=new vt(0,0,1),Jr={type:"added"},$r={type:"removed"};class he extends n{constructor(){super(),Object.defineProperty(this,"id",{value:Gr++}),this.uuid=wn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=he.DefaultUp.clone();var e=new vt;const t=new Ir,n=new de;var r=new vt(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:r},modelViewMatrix:{value:new gt},normalMatrix:{value:new Un}}),this.matrix=new gt,this.matrixWorld=new gt,this.matrixAutoUpdate=he.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Nr,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={v3d:{}},this.internVisible=!0,this.externVisible=!0,this.constraints=[],this.disableChildRendering=!1,this.hidpiCompositing=!1,this.groupNames=[],this.objectIndex=0,this.objectColor=new _t}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 Wr.setFromAxisAngle(e,t),this.quaternion.multiply(Wr),this}rotateOnWorldAxis(e,t){return Wr.setFromAxisAngle(e,t),this.quaternion.premultiply(Wr),this}rotateX(e){return this.rotateOnAxis(qr,e)}rotateY(e){return this.rotateOnAxis(Qr,e)}rotateZ(e){return this.rotateOnAxis(Kr,e)}translateOnAxis(e,t){return kr.copy(e).applyQuaternion(this.quaternion),this.position.add(kr.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(qr,e)}translateY(e){return this.translateOnAxis(Qr,e)}translateZ(e){return this.translateOnAxis(Kr,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(Hr.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Xr.copy(e):Xr.set(e,t,n);e=this.parent;this.updateWorldMatrix(!0,!1),jr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Hr.lookAt(jr,Xr,this.up):Hr.lookAt(Xr,jr,this.up),this.quaternion.setFromRotationMatrix(Hr),e&&(Hr.extractRotation(e.matrixWorld),Wr.setFromRotationMatrix(Hr),this.quaternion.premultiply(Wr.invert()))}add(e){if(1<arguments.length){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):e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),(e.parent=this).children.push(e),e.dispatchEvent(Jr)):console.error("v3d.Object3D.add: object not an instance of v3d.Object3D.",e),this}remove(e){if(1<arguments.length){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}var t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent($r)),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($r)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Hr.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),Hr.multiply(e.parent.matrixWorld)),e.applyMatrix4(Hr),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(n,r){if(this[n]===r)return this;for(let e=0,t=this.children.length;e<t;e++){const a=this.children[e];var i=a.getObjectByProperty(n,r);if(void 0!==i)return i}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(jr,e,Yr),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(jr,Zr,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);var t=this.matrixWorld.elements;return e.set(t[4],t[5],t[6]).normalize()}raycast(){}traverse(n){n(this);const r=this.children;for(let e=0,t=r.length;e<t;e++)r[e].traverse(n)}traverseVisible(n){if(!1!==this.visible){n(this);const r=this.children;for(let e=0,t=r.length;e<t;e++)r[e].traverseVisible(n)}}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(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n=!(this.matrixWorldNeedsUpdate=!1));const r=this.children;for(let e=0,t=r.length;e<t;e++)r[e].updateMatrixWorld(n)}updateWorldMatrix(e,t){const n=this.parent;if(!0===e&&null!==n&&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 r=this.children;for(let e=0,t=r.length;e<t;e++)r[e].updateWorldMatrix(!1,!0)}}toJSON(n){var e,t,r,i,a,o=void 0===n||"string"==typeof n;const s={},l=(o&&(n={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},s.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"}),{});function c(e,t){return void 0===e[t.uuid]&&(e[t.uuid]=t.toJSON(n)),t.uuid}if(l.uuid=this.uuid,l.type=this.type,""!==this.name&&(l.name=this.name),!0===this.castShadow&&(l.castShadow=!0),!0===this.receiveShadow&&(l.receiveShadow=!0),!1===this.visible&&(l.visible=!1),!1===this.frustumCulled&&(l.frustumCulled=!1),0!==this.renderOrder&&(l.renderOrder=this.renderOrder),!1===this.disableChildRendering&&(l.disableChildRendering=!1),!0===this.hidpiCompositing&&(l.hidpiCompositing=!0),0!==this.objectIndex&&(l.objectIndex=this.objectIndex),this.objectColor&&this.objectColor.isColor&&(l.objectColor=this.objectColor.getHex()),"{}"!==JSON.stringify(this.userData)&&(l.userData=this.userData),l.layers=this.layers.mask,l.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(l.matrixAutoUpdate=!1),this.isInstancedMesh&&(l.type="InstancedMesh",l.count=this.count,l.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(l.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?l.background=this.background.toJSON():this.background.isTexture&&(l.background=this.background.toJSON(n).uuid)),this.environment&&this.environment.isTexture&&(l.environment=this.environment.toJSON(n).uuid);else if(this.isMesh||this.isLine||this.isPoints){l.geometry=c(n.geometries,this.geometry);var u=this.geometry.parameters;if(void 0!==u&&void 0!==u.shapes){var d=u.shapes;if(Array.isArray(d))for(let e=0,t=d.length;e<t;e++){var h=d[e];c(n.shapes,h)}else c(n.shapes,d)}}if(this.isSkinnedMesh&&(l.bindMode=this.bindMode,l.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(c(n.skeletons,this.skeleton),l.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const m=[];for(let e=0,t=this.material.length;e<t;e++)m.push(c(n.materials,this.material[e]));l.material=m}else l.material=c(n.materials,this.material);if(0<this.children.length){l.children=[];for(let e=0;e<this.children.length;e++)l.children.push(this.children[e].toJSON(n).object)}if(0<this.animations.length){l.animations=[];for(let e=0;e<this.animations.length;e++){var p=this.animations[e];l.animations.push(c(n.animations,p))}}return o&&(u=f(n.geometries),o=f(n.materials),e=f(n.textures),t=f(n.images),r=f(n.shapes),i=f(n.skeletons),a=f(n.animations),0<u.length&&(s.geometries=u),0<o.length&&(s.materials=o),0<e.length&&(s.textures=e),0<t.length&&(s.images=t),0<r.length&&(s.shapes=r),0<i.length&&(s.skeletons=i),0<a.length&&(s.animations=a)),s.object=l,s;function f(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(t,e=!0){this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.disableChildRendering=t.disableChildRendering,this.hidpiCompositing=t.hidpiCompositing,this.objectIndex=t.objectIndex,this.objectColor.copy(t.objectColor),this.constraints=[];for(let e=0;e<t.constraints.length;e++)this.constraints.push(t.constraints[e].clone());if(this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const n=t.children[e];this.add(n.clone())}return this}copyTransform(e){this.matrix.copy(e.matrixWorld),this.parent&&this.matrix.multiplyMatrices(Hr.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){var t=this.matrix.elements;return(this.isCamera||this.isLight?e.set(-t[8],-t[9],-t[10]):e.set(t[8],t[9],t[10])).normalize()}lookAtLocal(e,t,n){e.isVector3?Xr.copy(e):Xr.set(e,t,n),jr.setFromMatrixPosition(this.matrix),this.isCamera||this.isLight?Hr.lookAt(jr,Xr,this.up):Hr.lookAt(Xr,jr,this.up),this.quaternion.setFromRotationMatrix(Hr)}findRoot(){let t=this;return this.traverseAncestors(function(e){t=e}),t}resolveMultiMaterial(){const t=[];for(let e=0;e<this.children.length;e++){var n=this.children[e];n.isMesh&&n.isMaterialGeneratedMesh&&t.push(n)}return t.length||t.push(this),t}getAuxClippingMeshes(){const t=[];for(let e=0;e<this.children.length;e++){var n=this.children[e];n.isMesh&&n.isAuxClippingMesh&&t.push(n)}return t}getWorldEuler(e,t=e._order){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decomposeE(jr,e,Yr,t),e}}he.DefaultUp=new vt(0,1,0),he.DefaultMatrixAutoUpdate=!0,he.prototype.isObject3D=!0;const ei=new vt,ti=new vt,ni=new vt,ri=new vt,ii=new vt,ai=new vt,oi=new vt,si=new vt,li=new vt,ci=new vt;class ui{constructor(e=new vt,t=new vt,n=new vt){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),ei.subVectors(e,t),r.cross(ei);n=r.lengthSq();return 0<n?r.multiplyScalar(1/Math.sqrt(n)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){ei.subVectors(r,t),ti.subVectors(n,t),ni.subVectors(e,t);var r=ei.dot(ei),n=ei.dot(ti),e=ei.dot(ni),t=ti.dot(ti),a=ti.dot(ni),o=r*t-n*n;if(0==o)return i.set(-2,-1,-1);o=1/o,t=(t*e-n*a)*o,r=(r*a-n*e)*o;return i.set(1-t-r,r,t)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,ri),0<=ri.x&&0<=ri.y&&ri.x+ri.y<=1}static getUV(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,ri),s.set(0,0),s.addScaledVector(i,ri.x),s.addScaledVector(a,ri.y),s.addScaledVector(o,ri.z),s}static isFrontFacing(e,t,n,r){return ei.subVectors(n,t),ti.subVectors(e,t),ei.cross(ti).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),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 ei.subVectors(this.c,this.b),ti.subVectors(this.a,this.b),.5*ei.cross(ti).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ui.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ui.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,r,i){return ui.getUV(e,this.a,this.b,this.c,t,n,r,i)}containsPoint(e){return ui.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ui.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){var n=this.a,r=this.b,i=this.c;let a,o;ii.subVectors(r,n),ai.subVectors(i,n),si.subVectors(e,n);var s=ii.dot(si),l=ai.dot(si);if(s<=0&&l<=0)return t.copy(n);li.subVectors(e,r);var c=ii.dot(li),u=ai.dot(li);if(0<=c&&u<=c)return t.copy(r);var d=s*u-c*l;if(d<=0&&0<=s&&c<=0)return a=s/(s-c),t.copy(n).addScaledVector(ii,a);ci.subVectors(e,i);var e=ii.dot(ci),h=ai.dot(ci);if(0<=h&&e<=h)return t.copy(i);s=e*l-s*h;if(s<=0&&0<=l&&h<=0)return o=l/(l-h),t.copy(n).addScaledVector(ai,o);l=c*h-e*u;if(l<=0&&0<=u-c&&0<=e-h)return oi.subVectors(i,r),o=(u-c)/(u-c+(e-h)),t.copy(r).addScaledVector(oi,o);i=1/(l+s+d);return a=s*i,o=d*i,t.copy(n).addScaledVector(ii,a).addScaledVector(ai,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class di{constructor(e,t,n,r,i,a=0){this.a=e,this.b=t,this.c=n,this.normal=r&&r.isVector3?r:new vt,this.vertexNormals=Array.isArray(r)?r:[],this.color=i&&i.isColor?i:new _t,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=a}clone(){return(new this.constructor).copy(this)}copy(n){this.a=n.a,this.b=n.b,this.c=n.c,this.normal.copy(n.normal),this.color.copy(n.color),this.materialIndex=n.materialIndex;for(let e=0,t=n.vertexNormals.length;e<t;e++)this.vertexNormals[e]=n.vertexNormals[e].clone();for(let e=0,t=n.vertexColors.length;e<t;e++)this.vertexColors[e]=n.vertexColors[e].clone();return this}}let hi=0;class pi extends n{constructor(){super(),Object.defineProperty(this,"id",{value:hi++}),this.uuid=wn(),this.name="",this.type="Material",this.fog=!0,this.blending=Z,this.side=Ve,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=Me,this.blendDst=Ae,this.blendEquation=$,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Ie,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,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.alphaTest=0,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this.receiveShadow=!1,this.castShadow=!1,this.useHDR=!1,this.profile="",this.defines={},this.DefaultEnvMapAutoAssign=!0,this.envMapAutoAssign=this.DefaultEnvMapAutoAssign,this.gtaoVisible=!0}onBuild(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const n in e){var t=e[n];if(void 0===t)console.warn("v3d.Material: '"+n+"' parameter is undefined.");else if("shading"===n)console.warn("v3d."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===t;else{const r=this[n];void 0===r?console.warn("v3d."+this.type+": '"+n+"' is not a property of this material."):r&&r.isColor?r.set(t):r&&r.isVector3&&t&&t.isVector3?r.copy(t):this[n]=t}}}toJSON(e){var t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function r(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}return 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),this.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),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.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&!this.isMeshNodeMaterial&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Z&&(n.blending=this.blending),this.side!==Ve&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),0<this.alphaTest&&(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),1<this.wireframeLinewidth&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(n.morphTargets=!0),!0===this.morphNormals&&(n.morphNormals=!0),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t&&(t=r(e.textures),e=r(e.images),0<t.length&&(n.textures=t),0<e.length&&(n.images=e)),n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){var r=t.length;n=new Array(r);for(let e=0;e!==r;++e)n[e]=t[e].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this.defines=Object.assign({},e.defines),this.receiveShadow=e.receiveShadow,this.castShadow=e.castShadow,this.useHDR=e.useHDR,this.profile=e.profile,this.envMapAutoAssign=e.envMapAutoAssign,this.gtaoVisible=e.gtaoVisible,this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}get needsUpdate(){return 0!=this.version}}pi.prototype.isMaterial=!0;class fi extends pi{constructor(e){super(),this.type="MeshBasicMaterial",this.color=new _t(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.morphTargets=!1,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.morphTargets=e.morphTargets,this}}fi.prototype.isMeshBasicMaterial=!0;const r=new vt,mi=new Be;class re{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("v3d.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===n,this.usage=mn,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(n,r,i){n*=this.itemSize,i*=r.itemSize;for(let e=0,t=this.itemSize;e<t;e++)this.array[n+e]=r.array[i+e];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(n){const r=this.array;let i=0;for(let t=0,e=n.length;t<e;t++){let e=n[t];void 0===e&&(console.warn("v3d.BufferAttribute.copyColorsArray(): color is undefined",t),e=new _t),r[i++]=e.r,r[i++]=e.g,r[i++]=e.b}return this}copyVector2sArray(n){const r=this.array;let i=0;for(let t=0,e=n.length;t<e;t++){let e=n[t];void 0===e&&(console.warn("v3d.BufferAttribute.copyVector2sArray(): vector is undefined",t),e=new Be),r[i++]=e.x,r[i++]=e.y}return this}copyVector3sArray(n){const r=this.array;let i=0;for(let t=0,e=n.length;t<e;t++){let e=n[t];void 0===e&&(console.warn("v3d.BufferAttribute.copyVector3sArray(): vector is undefined",t),e=new vt),r[i++]=e.x,r[i++]=e.y,r[i++]=e.z}return this}copyVector4sArray(n){const r=this.array;let i=0;for(let t=0,e=n.length;t<e;t++){let e=n[t];void 0===e&&(console.warn("v3d.BufferAttribute.copyVector4sArray(): vector is undefined",t),e=new mt),r[i++]=e.x,r[i++]=e.y,r[i++]=e.z,r[i++]=e.w}return this}applyMatrix3(n){if(2===this.itemSize)for(let e=0,t=this.count;e<t;e++)mi.fromBufferAttribute(this,e),mi.applyMatrix3(n),this.setXY(e,mi.x,mi.y);else if(3===this.itemSize)for(let e=0,t=this.count;e<t;e++)r.fromBufferAttribute(this,e),r.applyMatrix3(n),this.setXYZ(e,r.x,r.y,r.z);return this}applyMatrix4(n){for(let e=0,t=this.count;e<t;e++)r.x=this.getX(e),r.y=this.getY(e),r.z=this.getZ(e),r.applyMatrix4(n),this.setXYZ(e,r.x,r.y,r.z);return this}applyNormalMatrix(n){for(let e=0,t=this.count;e<t;e++)r.x=this.getX(e),r.y=this.getY(e),r.z=this.getZ(e),r.applyNormalMatrix(n),this.setXYZ(e,r.x,r.y,r.z);return this}transformDirection(n){for(let e=0,t=this.count;e<t;e++)r.x=this.getX(e),r.y=this.getY(e),r.z=this.getZ(e),r.transformDirection(n),this.setXYZ(e,r.x,r.y,r.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){return this.array[e*this.itemSize]}setX(e,t){return this.array[e*this.itemSize]=t,this}getY(e){return this.array[e*this.itemSize+1]}setY(e,t){return this.array[e*this.itemSize+1]=t,this}getZ(e){return this.array[e*this.itemSize+2]}setZ(e,t){return this.array[e*this.itemSize+2]=t,this}getW(e){return this.array[e*this.itemSize+3]}setW(e,t){return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,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.prototype.slice.call(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==mn&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}}re.prototype.isBufferAttribute=!0;class vi extends re{constructor(e,t,n){super(new Int8Array(e),t,n)}}class gi extends re{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class _i extends re{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class xi extends re{constructor(e,t,n){super(new Int16Array(e),t,n)}}class yi extends re{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class bi extends re{constructor(e,t,n){super(new Int32Array(e),t,n)}}class Mi extends re{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Ai extends re{constructor(e,t,n){super(new Uint16Array(e),t,n)}}Ai.prototype.isFloat16BufferAttribute=!0;class k extends re{constructor(e,t,n){super(new Float32Array(e),t,n)}}class wi extends re{constructor(e,t,n){super(new Float64Array(e),t,n)}}function Si(n){if(0===n.length)return-1/0;let r=n[0];for(let e=1,t=n.length;e<t;++e)n[e]>r&&(r=n[e]);return r}const Ti={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!=typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function Ci(e,t){return new Ti[e](t)}function xt(e){return void 0!==e}function Ei(t,n,r){for(let e=0;e<t.length;e++)t[e]=ft(t[e],n,r);return t}function Li(){switch(_n){case"BLENDER":return"for Blender";case"MAX":return"for 3ds Max";case"MAYA":return"for Maya";case"ALL":return"Ultimate";default:return"Unknown"}}function Ri(e){return""+(e%1?e:e+".0")}function Pi(){return"undefined"!=typeof window?window:"undefined"!=typeof self?self:global}const Ii={};function Ni(n,e=function(e){},t=function(e){}){Ii[n]=Ii[n]||{status:0,loadCallbacks:[],errorCallbacks:[]};const r=Ii[n];if(4==r.status)e(n);else if(r.loadCallbacks.push(e),r.errorCallbacks.push(t),!(0<r.status)){var i,a=document.getElementsByTagName("script");let t=n;for(let e=a.length-1;0<=e;--e){const l=a[e].src;var o=l.search(/\/v3d[\w.]+js/);-1<o&&(t=l.substr(0,o)+"/"+n)}const s=document.createElement("script");s.type="text/javascript",s.src=t,i=n,s.onload=function(){Ii[i].loadCallbacks.forEach(function(e){e(i)}),Ii[i].status=4},s.onerror=function(){Ii[i].errorCallbacks.forEach(function(e){e(i)}),Ii[i].status=0},document.getElementsByTagName("head")[0].appendChild(s),r.status=3}}function Di(e,a,o=0){let r=Promise.resolve(performance.now());e.forEach(function(e,t,n){r=r.then(function(e,t,n,r){var i=performance.now();return a(e,t,n),o<i-r?(r=i,new Promise(function(e){setTimeout(function(){e(r)},1)})):r}.bind(null,e,t,n))}),r}let Oi=0;const Fi=new gt,Bi=new he,zi=new vt,Vi=new g,Ui=new g,Gi=new vt;class S extends n{constructor(){super(),Object.defineProperty(this,"id",{value:Oi++}),this.uuid=wn(),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(65535<Si(e)?Mi:yi)(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,n=(void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0),this.attributes.normal);var r;void 0!==n&&(r=(new Un).getNormalMatrix(e),n.applyNormalMatrix(r),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 Fi.makeRotationFromQuaternion(e),this.applyMatrix4(Fi),this}rotateX(e){return Fi.makeRotationX(e),this.applyMatrix4(Fi),this}rotateY(e){return Fi.makeRotationY(e),this.applyMatrix4(Fi),this}rotateZ(e){return Fi.makeRotationZ(e),this.applyMatrix4(Fi),this}translate(e,t,n){return Fi.makeTranslation(e,t,n),this.applyMatrix4(Fi),this}scale(e,t,n){return Fi.makeScale(e,t,n),this.applyMatrix4(Fi),this}lookAt(e){return Bi.lookAt(e),Bi.updateMatrix(),this.applyMatrix4(Bi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(zi).negate(),this.translate(zi.x,zi.y,zi.z),this}setFromPoints(n){const r=[];for(let e=0,t=n.length;e<t;e++){var i=n[e];r.push(i.x,i.y,i.z||0)}return this.setAttribute("position",new k(r,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new g);var e=this.attributes.position,n=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 vt(-1/0,-1/0,-1/0),new vt(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),n)for(let e=0,t=n.length;e<t;e++){var r=n[e];Vi.setFromBufferAttribute(r),this.morphTargetsRelative?(Gi.addVectors(this.boundingBox.min,Vi.min),this.boundingBox.expandByPoint(Gi),Gi.addVectors(this.boundingBox.max,Vi.max),this.boundingBox.expandByPoint(Gi)):(this.boundingBox.expandByPoint(Vi.min),this.boundingBox.expandByPoint(Vi.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 fr);var r=this.attributes.position,i=this.morphAttributes.position;if(r&&r.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 vt,1/0);if(r){const l=this.boundingSphere.center;if(Vi.setFromBufferAttribute(r),i)for(let e=0,t=i.length;e<t;e++){var a=i[e];Ui.setFromBufferAttribute(a),this.morphTargetsRelative?(Gi.addVectors(Vi.min,Ui.min),Vi.expandByPoint(Gi),Gi.addVectors(Vi.max,Ui.max),Vi.expandByPoint(Gi)):(Vi.expandByPoint(Ui.min),Vi.expandByPoint(Ui.max))}Vi.getCenter(l);let n=0;for(let e=0,t=r.count;e<t;e++)Gi.fromBufferAttribute(r,e),n=Math.max(n,l.distanceToSquared(Gi));if(i)for(let e=0,t=i.length;e<t;e++){var o=i[e],s=this.morphTargetsRelative;for(let e=0,t=o.count;e<t;e++)Gi.fromBufferAttribute(o,e),s&&(zi.fromBufferAttribute(r,e),Gi.add(zi)),n=Math.max(n,l.distanceToSquared(Gi))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('v3d.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeFaceNormals(){}computeTangents(){var e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)console.error("v3d.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");else{var r=e.array;const f=t.position.array,m=t.normal.array,v=t.uv.array;var i,a,o,s,l=f.length/3;void 0===t.tangent&&this.setAttribute("tangent",new re(new Float32Array(4*l),4));const g=t.tangent.array,_=[],x=[];for(let e=0;e<l;e++)_[e]=new vt,x[e]=new vt;const y=new vt,b=new vt,M=new vt,A=new Be,w=new Be,S=new Be,T=new vt,C=new vt;let n=this.groups;for(let e=0,t=(n=0===n.length?[{start:0,count:r.length}]:n).length;e<t;++e){var c=n[e],u=c.start;for(let e=u,t=u+c.count;e<t;e+=3)i=r[e+0],a=r[e+1],o=r[e+2],s=void 0,y.fromArray(f,3*i),b.fromArray(f,3*a),M.fromArray(f,3*o),A.fromArray(v,2*i),w.fromArray(v,2*a),S.fromArray(v,2*o),b.sub(y),M.sub(y),w.sub(A),S.sub(A),s=1/(w.x*S.y-S.x*w.y),isFinite(s)&&(T.copy(b).multiplyScalar(S.y).addScaledVector(M,-w.y).multiplyScalar(s),C.copy(M).multiplyScalar(w.x).addScaledVector(b,-S.x).multiplyScalar(s),_[i].add(T),_[a].add(T),_[o].add(T),x[i].add(C),x[a].add(C),x[o].add(C))}const E=new vt,L=new vt,R=new vt,P=new vt;for(let e=0,t=n.length;e<t;++e){var d=n[e],h=d.start;for(let e=h,t=h+d.count;e<t;e+=3)p(r[e+0]),p(r[e+1]),p(r[e+2])}function p(e){R.fromArray(m,3*e),P.copy(R);var t=_[e],t=(E.copy(t),E.sub(R.multiplyScalar(R.dot(t))).normalize(),L.crossVectors(P,t),L.dot(x[e])),t=t<0?-1:1;g[4*e]=E.x,g[4*e+1]=E.y,g[4*e+2]=E.z,g[4*e+3]=t}}}computeVertexNormals(){const r=this.index;var i=this.getAttribute("position");if(void 0!==i){let n=this.getAttribute("normal");if(void 0===n)n=new re(new Float32Array(3*i.count),3),this.setAttribute("normal",n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);const l=new vt,c=new vt,u=new vt,d=new vt,h=new vt,p=new vt,f=new vt,m=new vt;if(r)for(let e=0,t=r.count;e<t;e+=3){var a=r.getX(e+0),o=r.getX(e+1),s=r.getX(e+2);l.fromBufferAttribute(i,a),c.fromBufferAttribute(i,o),u.fromBufferAttribute(i,s),f.subVectors(u,c),m.subVectors(l,c),f.cross(m),d.fromBufferAttribute(n,a),h.fromBufferAttribute(n,o),p.fromBufferAttribute(n,s),d.add(f),h.add(f),p.add(f),n.setXYZ(a,d.x,d.y,d.z),n.setXYZ(o,h.x,h.y,h.z),n.setXYZ(s,p.x,p.y,p.z)}else for(let e=0,t=i.count;e<t;e+=3)l.fromBufferAttribute(i,e+0),c.fromBufferAttribute(i,e+1),u.fromBufferAttribute(i,e+2),f.subVectors(u,c),m.subVectors(l,c),f.cross(m),n.setXYZ(e+0,f.x,f.y,f.z),n.setXYZ(e+1,f.x,f.y,f.z),n.setXYZ(e+2,f.x,f.y,f.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(e,t){if(e&&e.isBufferGeometry){void 0===t&&(t=0,console.warn("v3d.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));var n=this.attributes;for(const o in n)if(void 0!==e.attributes[o]){const s=n[o].array;var r=e.attributes[o],i=r.array,r=r.itemSize*t,a=Math.min(i.length,s.length-r);for(let e=0,t=r;e<a;e++,t++)s[t]=i[e]}return this}console.error("v3d.BufferGeometry.merge(): geometry not an instance of v3d.BufferGeometry.",e)}normalizeNormals(){const n=this.attributes.normal;for(let e=0,t=n.count;e<t;e++)Gi.fromBufferAttribute(n,e),Gi.normalize(),n.setXYZ(e,Gi.x,Gi.y,Gi.z)}toNonIndexed(){function n(n,r){const i=n.array;var a=n.itemSize,e=n.normalized;const o=new i.constructor(r.length*a);let s=0,l=0;for(let e=0,t=r.length;e<t;e++){s=n.isInterleavedBufferAttribute?r[e]*n.data.stride+n.offset:r[e]*a;for(let e=0;e<a;e++)o[l++]=i[s++]}return new re(o,a,e)}if(null===this.index)return console.warn("v3d.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const r=new S;var i=this.index.array,e=this.attributes;for(const u in e){var t=n(e[u],i);r.setAttribute(u,t)}var a=this.morphAttributes;for(const d in a){const h=[];var o=a[d];for(let e=0,t=o.length;e<t;e++){var s=n(o[e],i);h.push(s)}r.morphAttributes[d]=h}r.morphTargetsRelative=this.morphTargetsRelative;var l=this.groups;for(let e=0,t=l.length;e<t;e++){var c=l[e];r.addGroup(c.start,c.count,c.materialIndex)}return r}toJSON(){const n={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),0<Object.keys(this.userData).length&&(n.userData=this.userData),void 0!==this.parameters){var e=this.parameters;for(const l in e)void 0!==e[l]&&(n[l]=e[l]);return n}n.data={attributes:{}};var t=this.index,r=(null!==t&&(n.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)}),this.attributes);for(const c in r){const u=r[c];n.data.attributes[c]=u.toJSON(n.data)}const i={};let a=!1;for(const d in this.morphAttributes){var o=this.morphAttributes[d];const h=[];for(let e=0,t=o.length;e<t;e++){const p=o[e];h.push(p.toJSON(n.data))}0<h.length&&(i[d]=h,a=!0)}a&&(n.data.morphAttributes=i,n.data.morphTargetsRelative=this.morphTargetsRelative);t=this.groups;0<t.length&&(n.data.groups=JSON.parse(JSON.stringify(t)));const s=this.boundingSphere;return null!==s&&(n.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),n}clone(){return(new S).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;var n={};this.name=e.name;const t=e.index;null!==t&&this.setIndex(t.clone(n));var r=e.attributes;for(const c in r){const u=r[c];this.setAttribute(c,u.clone(n))}var i=e.morphAttributes;for(const d in i){const h=[],p=i[d];for(let e=0,t=p.length;e<t;e++)h.push(p[e].clone(n));this.morphAttributes[d]=h}this.morphTargetsRelative=e.morphTargetsRelative;var a=e.groups;for(let e=0,t=a.length;e<t;e++){var o=a[e];this.addGroup(o.start,o.count,o.materialIndex)}const s=e.boundingBox,l=(null!==s&&(this.boundingBox=s.clone()),e.boundingSphere);return null!==l&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}S.prototype.isBufferGeometry=!0;const ki=new gt,Wi=new Mr,Hi=new fr,Xi=new vt,ji=new vt,Yi=new vt,Zi=new vt,qi=new vt,Qi=new vt,Ki=new vt,Ji=new vt,$i=new vt,ea=new Be,ta=new Be,na=new Be,ra=new vt,ia=new vt;class ee extends he{constructor(e=new S,t=new fi){super(),this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets(),this.isMaterialGeneratedMesh=!1,this.isAuxClippingMesh=!1}copy(e){return super.copy(e),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(){var e=this.geometry;if(e.isBufferGeometry){var t=e.morphAttributes,n=Object.keys(t);if(0<n.length){var r=t[n[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){var i=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{t=e.morphTargets;void 0!==t&&0<t.length&&console.error("v3d.Mesh.updateMorphTargets() no longer supports v3d.Geometry. Use v3d.BufferGeometry instead.")}}raycast(r,i){if(!this.isAuxClippingMesh){const t=this.geometry;var a=this.material,e=this.matrixWorld;if(void 0!==a&&(null===t.boundingSphere&&t.computeBoundingSphere(),Hi.copy(t.boundingSphere),Hi.applyMatrix4(e),!1!==r.ray.intersectsSphere(Hi)&&(ki.copy(e).invert(),Wi.copy(r.ray).applyMatrix4(ki),null===t.boundingBox||!1!==Wi.intersectsBox(t.boundingBox)))){let n;if(t.isBufferGeometry){const L=t.index;var o=t.attributes.position,s=t.morphAttributes.position,l=t.morphTargetsRelative,c=t.attributes.uv,u=t.attributes.uv2,d=t.groups,h=t.drawRange;if(null!==L)if(Array.isArray(a))for(let e=0,t=d.length;e<t;e++){var p=d[e],f=a[p.materialIndex];for(let e=Math.max(p.start,h.start),t=Math.min(p.start+p.count,h.start+h.count);e<t;e+=3){var m=L.getX(e),v=L.getX(e+1),g=L.getX(e+2);(n=aa(this,f,r,Wi,o,s,l,c,u,m,v,g))&&(n.faceIndex=Math.floor(e/3),n.face.materialIndex=p.materialIndex,i.push(n))}}else for(let e=Math.max(0,h.start),t=Math.min(L.count,h.start+h.count);e<t;e+=3){var _=L.getX(e),x=L.getX(e+1),y=L.getX(e+2);(n=aa(this,a,r,Wi,o,s,l,c,u,_,x,y))&&(n.faceIndex=Math.floor(e/3),i.push(n))}else if(void 0!==o)if(Array.isArray(a))for(let e=0,t=d.length;e<t;e++){var b=d[e],M=a[b.materialIndex];for(let e=Math.max(b.start,h.start),t=Math.min(b.start+b.count,h.start+h.count);e<t;e+=3){var A=e,w=e+1,S=e+2;(n=aa(this,M,r,Wi,o,s,l,c,u,A,w,S))&&(n.faceIndex=Math.floor(e/3),n.face.materialIndex=b.materialIndex,i.push(n))}}else for(let e=Math.max(0,h.start),t=Math.min(o.count,h.start+h.count);e<t;e+=3){var T=e,C=e+1,E=e+2;(n=aa(this,a,r,Wi,o,s,l,c,u,T,C,E))&&(n.faceIndex=Math.floor(e/3),i.push(n))}}else t.isGeometry&&console.error("v3d.Mesh.raycast() no longer supports v3d.Geometry. Use v3d.BufferGeometry instead.")}}}clone(){return new this.constructor(this.geometry,this.material).copy(this)}getWorldDirection(e){this.updateMatrixWorld(!0);var 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 aa(e,t,n,r,i,a,o,s,l,c,u,d){Xi.fromBufferAttribute(i,c),ji.fromBufferAttribute(i,u),Yi.fromBufferAttribute(i,d);var h=e.morphTargetInfluences;if(t.morphTargets&&a&&h){Ki.set(0,0,0),Ji.set(0,0,0),$i.set(0,0,0);for(let e=0,t=a.length;e<t;e++){var p=h[e],f=a[e];0!==p&&(Zi.fromBufferAttribute(f,c),qi.fromBufferAttribute(f,u),Qi.fromBufferAttribute(f,d),o?(Ki.addScaledVector(Zi,p),Ji.addScaledVector(qi,p),$i.addScaledVector(Qi,p)):(Ki.addScaledVector(Zi.sub(Xi),p),Ji.addScaledVector(qi.sub(ji),p),$i.addScaledVector(Qi.sub(Yi),p)))}Xi.add(Ki),ji.add(Ji),Yi.add($i)}e.isSkinnedMesh&&(e.boneTransform(c,Xi),e.boneTransform(u,ji),e.boneTransform(d,Yi));const m=function(e,t,n,r,i,a,o,s){let l;return null===(l=t.side===Fe?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side!==Ue,s))?null:(ia.copy(s),ia.applyMatrix4(e.matrixWorld),(r=n.ray.origin.distanceTo(ia))<n.near||r>n.far?null:{distance:r,point:ia.clone(),object:e})}(e,t,n,r,Xi,ji,Yi,ra);return m&&(s&&(ea.fromBufferAttribute(s,c),ta.fromBufferAttribute(s,u),na.fromBufferAttribute(s,d),m.uv=ui.getUV(ra,Xi,ji,Yi,ea,ta,na,new Be)),l&&(ea.fromBufferAttribute(l,c),ta.fromBufferAttribute(l,u),na.fromBufferAttribute(l,d),m.uv2=ui.getUV(ra,Xi,ji,Yi,ea,ta,na,new Be)),i={a:c,b:u,c:d,normal:new vt,materialIndex:0},ui.getNormal(Xi,ji,Yi,i.normal),m.face=i),m}ee.prototype.isMesh=!0;class oa extends S{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};const C=this,E=(r=Math.floor(r),i=Math.floor(i),a=Math.floor(a),[]),L=[],R=[],P=[];let I=0,N=0;function o(n,r,i,a,o,e,t,s,l,c,u){var d=e/l,h=t/c,p=e/2,f=t/2,m=s/2,v=l+1,g=c+1;let _=0,x=0;const y=new vt;for(let t=0;t<g;t++){var b=t*h-f;for(let e=0;e<v;e++){var M=e*d-p;y[n]=M*a,y[r]=b*o,y[i]=m,L.push(y.x,y.y,y.z),y[n]=0,y[r]=0,y[i]=0<s?1:-1,R.push(y.x,y.y,y.z),P.push(e/l),P.push(1-t/c),_+=1}}for(let t=0;t<c;t++)for(let e=0;e<l;e++){var A=I+e+v*t,w=I+e+v*(t+1),S=I+(e+1)+v*(t+1),T=I+(e+1)+v*t;E.push(A,w,T),E.push(w,S,T),x+=6}C.addGroup(N,x,u),N+=x,I+=_}o("z","y","x",-1,-1,n,t,e,a,i,0),o("z","y","x",1,-1,n,t,-e,a,i,1),o("x","z","y",1,1,e,n,t,r,a,2),o("x","z","y",1,-1,e,n,-t,r,a,3),o("x","y","z",1,-1,e,t,n,r,i,4),o("x","y","z",-1,-1,e,t,-n,r,i,5),this.setIndex(E),this.setAttribute("position",new k(L,3)),this.setAttribute("normal",new k(R,3)),this.setAttribute("uv",new k(P,2))}static fromJSON(e){return new oa(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function sa(e){const t={};for(const n in e){t[n]={};for(const r in e[n]){const i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}}return t}function la(t){const n={};for(let e=0;e<t.length;e++){var r=sa(t[e]);for(const i in r)n[i]=r[i]}return n}const ca={clone:sa,merge:la};class T extends pi{constructor(e){super(),this.type="ShaderMaterial",this.defines={},this.uniforms={},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.morphTargets=!1,this.morphNormals=!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&&(void 0!==e.attributes&&console.error("v3d.ShaderMaterial: attributes should now be defined in v3d.BufferGeometry instead."),this.setValues(e))}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=sa(e.uniforms),this.defines=Object.assign({},e.defines),this.customPrepTokens=Object.assign({},e.customPrepTokens),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const i=this.uniforms[r].value;i&&i.isTexture?t.uniforms[r]={type:"t",value:i.toJSON(e).uuid}:i&&i.isColor?t.uniforms[r]={type:"c",value:i.getHex()}:i&&i.isVector2?t.uniforms[r]={type:"v2",value:i.toArray()}:i&&i.isVector3?t.uniforms[r]={type:"v3",value:i.toArray()}:i&&i.isVector4?t.uniforms[r]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?t.uniforms[r]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?t.uniforms[r]={type:"m4",value:i.toArray()}:t.uniforms[r]={value:i}}0<Object.keys(this.defines).length&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const a in this.extensions)!0===this.extensions[a]&&(n[a]=!0);return 0<Object.keys(n).length&&(t.extensions=n),t}}T.prototype.isShaderMaterial=!0;class ua extends he{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new gt,this.projectionMatrix=new gt,this.projectionMatrixInverse=new gt,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);var 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)}}ua.prototype.isCamera=!0;class da extends ua{constructor(e=50,t=1,n=.1,r=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){e=.5*this.getFilmHeight()/e;this.fov=2*An*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){var e=Math.tan(.5*Mn*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*An*Math.atan(Math.tan(.5*Mn*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,r,i,a){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=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){var e=this.near;let t=e*Math.tan(.5*Mn*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r;var a,o=this.view,s=(null!==this.view&&this.view.enabled&&(s=o.fullWidth,a=o.fullHeight,i+=o.offsetX*r/s,t-=o.offsetY*n/a,r*=o.width/s,n*=o.height/a),this.filmOffset);0!==s&&(i+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,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}}da.prototype.isPerspectiveCamera=!0;class ha extends he{constructor(e,t,n){if(super(),this.type="CubeCamera",!0!==n.isWebGLCubeRenderTarget)console.error("v3d.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");else{this.renderTarget=n;const r=new da(90,1,e,t),i=(r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new vt(1,0,0)),this.add(r),new da(90,1,e,t)),a=(i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new vt(-1,0,0)),this.add(i),new da(90,1,e,t)),o=(a.layers=this.layers,a.up.set(0,0,1),a.lookAt(new vt(0,1,0)),this.add(a),new da(90,1,e,t)),s=(o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new vt(0,-1,0)),this.add(o),new da(90,1,e,t)),l=(s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new vt(0,0,1)),this.add(s),new da(90,1,e,t));l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new vt(0,0,-1)),this.add(l)}}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget;var[r,i,a,o,s,l]=this.children,c=e.xr.enabled,u=e.getRenderTarget(),d=(e.xr.enabled=!1,n.texture.generateMipmaps);n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,r),e.setRenderTarget(n,1),e.render(t,i),e.setRenderTarget(n,2),e.render(t,a),e.setRenderTarget(n,3),e.render(t,o),e.setRenderTarget(n,4),e.render(t,s),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(u),e.xr.enabled=c}}class pa extends Hn{constructor(e,t,n,r,i,a,o,s,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:L,n,r,i,a,o=void 0!==o?o:wt,s,l,c),this._needsFlipEnvMap=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}copy(e){return super.copy(e),this.image=e.image.slice(),this._needsFlipEnvMap=e._needsFlipEnvMap,this}}pa.prototype.isCubeTexture=!0;class fa extends ze{constructor(e,t,n){Number.isInteger(t)&&(console.warn("v3d.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget(size, options)"),t=n),super(e,e,t),t=t||{},this.texture=new pa(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:ht,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=pt,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;var n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
|
|
varying vec3 vWorldDirection;
|
|
|
|
vec3 transformDirection(in vec3 dir, in mat4 matrix) {
|
|
|
|
return normalize((matrix * vec4(dir, 0.0)).xyz);
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vWorldDirection = transformDirection(position, modelMatrix);
|
|
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
|
|
}
|
|
`,fragmentShader:`
|
|
|
|
uniform sampler2D tEquirect;
|
|
|
|
varying vec3 vWorldDirection;
|
|
|
|
#include <common>
|
|
|
|
void main() {
|
|
|
|
vec3 direction = normalize(vWorldDirection);
|
|
|
|
vec2 sampleUV = equirectUv(direction);
|
|
|
|
gl_FragColor = texture2D(tEquirect, sampleUV);
|
|
|
|
}
|
|
`},r=new oa(5,5,5);const i=new T({name:"CubemapFromEquirect",uniforms:sa(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Fe,blending:ce}),a=(i.uniforms.tEquirect.value=t,new ee(r,i));n=t.minFilter;t.minFilter===He&&(t.minFilter=ht);const o=new ha(1,10,this);return o.update(e,a),t.minFilter=n,a.geometry.dispose(),a.material.dispose(),this}clear(t,n,r,i){var e=t.getRenderTarget();for(let e=0;e<6;e++)t.setRenderTarget(this,e),t.clear(n,r,i);t.setRenderTarget(e)}}fa.prototype.isWebGLCubeRenderTarget=!0;const ma={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>.']:["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(ma.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&&1<navigator.maxTouchPoints)&&!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"))},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");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");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(){var e="polyfill"in window&&"WebXRPolyfill"in window&&polyfill instanceof WebXRPolyfill;return"xr"in navigator&&(!e||polyfill.nativeWebXR)},checkCardboard:function(){return!1},checkSwiftShader:function(e){return"Google SwiftShader"==this.getGPUModel(e)},checkWebAudio:function(){return void 0!==(window.AudioContext||window.webkitAudioContext)},isSafariWithMultisamplingBug:function(){if(!this.checkSafari())return!1;const e=navigator.userAgent;return e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/)}},va=new vt,ga=new vt,_a=new Un;class xa{constructor(e=new vt(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){n=va.subVectors(n,t).cross(ga.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){var 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){var n=e.delta(va),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;r=-(e.start.dot(this.normal)+this.constant)/r;return r<0||1<r?null:t.copy(n).multiplyScalar(r).add(e.start)}intersectsLine(e){var t=this.distanceToPoint(e.start),e=this.distanceToPoint(e.end);return t<0&&0<e||e<0&&0<t}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){t=t||_a.getNormalMatrix(e);const n=this.coplanarPoint(va).applyMatrix4(e);e=this.normal.applyMatrix3(t).normalize();return this.constant=-n.dot(e),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)}}xa.prototype.isPlane=!0;const ya=new fr,ba=new vt;class Ma{constructor(e=new xa,t=new xa,n=new xa,r=new xa,i=new xa,a=new xa){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(t){const n=this.planes;for(let e=0;e<6;e++)n[e].copy(t.planes[e]);return this}setFromProjectionMatrix(e){const t=this.planes;var e=e.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],d=e[9],h=e[10],p=e[11],f=e[12],m=e[13],v=e[14],e=e[15];return t[0].setComponents(a-n,c-o,p-u,e-f).normalize(),t[1].setComponents(a+n,c+o,p+u,e+f).normalize(),t[2].setComponents(a+r,c+s,p+d,e+m).normalize(),t[3].setComponents(a-r,c-s,p-d,e-m).normalize(),t[4].setComponents(a-i,c-l,p-h,e-v).normalize(),t[5].setComponents(a+i,c+l,p+h,e+v).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),ya.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(ya)}intersectsSprite(e){return ya.center.set(0,0,0),ya.radius=.7071067811865476,ya.applyMatrix4(e.matrixWorld),this.intersectsSphere(ya)}intersectsSphere(e){const t=this.planes;var n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(t){var n=this.planes;for(let e=0;e<6;e++){const r=n[e];if(ba.x=(0<r.normal.x?t.max:t.min).x,ba.y=(0<r.normal.y?t.max:t.min).y,ba.z=(0<r.normal.z?t.max:t.min).z,r.distanceToPoint(ba)<0)return!1}return!0}containsPoint(t){const n=this.planes;for(let e=0;e<6;e++)if(n[e].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function Aa(){let n=null,e=!1,r=null,i=null;function a(e,t){r(e,t),i=n.requestAnimationFrame(a)}return{start:function(){!0!==e&&null!==r&&(i=n.requestAnimationFrame(a),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(e){r=e},setContext:function(e){n=e}}}function wa(s,e){const l=e.isWebGL2;let c=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),c.get(e)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);var t=c.get(e);t&&(s.deleteBuffer(t.buffer),c.delete(e))},update:function(e,t){if(e.isGLBufferAttribute)(!(n=c.get(e))||n.version<e.version)&&c.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version});else{e.isInterleavedBufferAttribute&&(e=e.data);const i=c.get(e);if(void 0===i)c.set(e,function(e,t){var n=e.array,r=e.usage,i=s.createBuffer();s.bindBuffer(t,i),s.bufferData(t,n,r),e.onUploadCallback();let a=5126;return n instanceof Float32Array?a=5126:n instanceof Float64Array?console.warn("v3d.WebGLAttributes: Unsupported data buffer format: Float64Array."):n instanceof Uint16Array?e.isFloat16BufferAttribute?l?a=5131:console.warn("v3d.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):a=5123:n instanceof Int16Array?a=5122:n instanceof Uint32Array?a=5125:n instanceof Int32Array?a=5124:n instanceof Int8Array?a=5120:(n instanceof Uint8Array||n instanceof Uint8ClampedArray)&&(a=5121),{buffer:i,type:a,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version}}(e,t));else if(i.version<e.version){{var n=i.buffer;var r=e;const a=r.array,o=r.updateRange;s.bindBuffer(t,n),-1===o.count?s.bufferSubData(t,0,a):(l?s.bufferSubData(t,o.offset*a.BYTES_PER_ELEMENT,a,o.offset,o.count):s.bufferSubData(t,o.offset*a.BYTES_PER_ELEMENT,a.subarray(o.offset,o.offset+o.count)),o.count=-1)}i.version=e.version}}},dispose:function(){c=new WeakMap}}}class Sa extends S{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};var i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),l=o+1,c=s+1,u=e/o,d=t/s;const h=[],p=[],f=[],m=[];for(let t=0;t<c;t++){var v=t*d-a;for(let e=0;e<l;e++){var g=e*u-i;p.push(g,-v,0),f.push(0,0,1),m.push(e/o),m.push(1-t/s)}}for(let t=0;t<s;t++)for(let e=0;e<o;e++){var _=e+l*t,x=e+l*(t+1),y=e+1+l*(t+1),b=e+1+l*t;h.push(_,x,b),h.push(x,y,b)}this.setIndex(h),this.setAttribute("position",new k(p,3)),this.setAttribute("normal",new k(f,3)),this.setAttribute("uv",new k(m,2))}static fromJSON(e){return new Sa(e.width,e.height,e.widthSegments,e.heightSegments)}}const yt={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 ALPHATEST\nif (diffuseColor.a < ALPHATEST)\ndiscard;\nelse\ndiffuseColor.a = 1.0;\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.specularRoughness);\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}\nfloat punctualLightIntensityToIrradianceFactor(float lightDistance, const in float cutoffDistance, const in float decayExponent) {\n#if defined (PHYSICALLY_CORRECT_LIGHTS)\nlightDistance = UNITS_SCALE_FACTOR * lightDistance;\n#ifdef MT_MAYA\nfloat distanceFalloff = 1.0 / pow(lightDistance + 1.0, decayExponent);\n#else\nfloat distanceFalloff = 1.0 / max(pow(lightDistance, decayExponent), 0.01);\n#endif\nif(cutoffDistance > 0.0) {\ndistanceFalloff *= pow2(saturate(1.0 - pow4(lightDistance / cutoffDistance)));\n}\nreturn distanceFalloff;\n#else\nif(cutoffDistance > 0.0 && decayExponent > 0.0) {\nreturn pow(saturate(-lightDistance / cutoffDistance + 1.0), decayExponent);\n}\nreturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert(const in vec3 diffuseColor) {\nreturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick(const in vec3 specularColor, const in float dotVH) {\nfloat fresnel = exp2((-5.55473 * dotVH - 6.98316) * dotVH);\nreturn (1.0 - specularColor) * fresnel + specularColor;\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 G_GGX_Smith(const in float alpha, const in float dotNL, const in float dotNV) {\nfloat a2 = pow2(alpha);\nfloat gl = dotNL + sqrt(a2 + (1.0 - a2) * pow2(dotNL));\nfloat gv = dotNV + sqrt(a2 + (1.0 - a2) * pow2(dotNV));\nreturn 1.0 / (gl * gv);\n}\nfloat G_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_Specular_GGX(const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness) {\nfloat alpha = pow2(clamp(roughness, 0.04, 1.0));\nvec3 halfDir = normalize(incidentLight.direction + viewDir);\nfloat dotNL = saturate(dot(normal, incidentLight.direction));\nfloat dotNV = saturate(dot(normal, viewDir));\nfloat dotNH = saturate(dot(normal, halfDir));\nfloat dotLH = saturate(dot(incidentLight.direction, halfDir));\nvec3 F = F_Schlick(specularColor, dotLH);\nfloat G = G_GGX_SmithCorrelated(alpha, dotNL, dotNV);\nfloat D = D_GGX(alpha, dotNH);\nreturn F * (G * D);\n}\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 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_Specular_BlinnPhong(const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess) {\nvec3 halfDir = normalize(incidentLight.direction + geometry.viewDir);\nfloat dotNH = saturate(dot(geometry.normal, halfDir));\nfloat dotLH = saturate(dot(incidentLight.direction, halfDir));\nvec3 F = F_Schlick(specularColor, dotLH);\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 NoH) {\nfloat invAlpha = 1.0 / roughness;\nfloat cos2h = NoH * NoH;\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 NoV, float NoL) {\nreturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen(const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor) {\nvec3 N = geometry.normal;\nvec3 V = geometry.viewDir;\nvec3 H = normalize(V + L);\nfloat dotNH = saturate(dot(N, H));\nreturn specularColor * D_Charlie(roughness, dotNH) * V_Neubelt(dot(N, V), dot(N, L));\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\nuniform sampler2D bumpMap;\nuniform float bumpScale;\nvec2 dHdxy_fwd() {\nvec2 dSTdx = dFdx(vUv);\nvec2 dSTdy = dFdy(vUv);\nfloat Hll = bumpScale * texture2D(bumpMap, vUv).x;\nfloat dBx = bumpScale * texture2D(bumpMap, vUv + dSTdx).x - Hll;\nfloat dBy = bumpScale * texture2D(bumpMap, vUv + dSTdy).x - Hll;\nreturn vec2(dBx, dBy);\n}\nvec3 perturbNormalArb(vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection) {\nvec3 vSigmaX = vec3(dFdx(surf_pos.x), dFdx(surf_pos.y), dFdx(surf_pos.z));\nvec3 vSigmaY = vec3(dFdy(surf_pos.x), dFdy(surf_pos.y), dFdy(surf_pos.z));\nvec3 vN = surf_norm;\nvec3 R1 = cross(vSigmaY, vN);\nvec3 R2 = cross(vN, vSigmaX);\nfloat fDet = dot(vSigmaX, R1) * faceDirection;\nvec3 vGrad = sign(fDet) * (dHdxy.x * R1 + dHdxy.y * R2);\nreturn normalize(abs(fDet) * surf_norm - vGrad);\n}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\nvec4 plane;\n#pragma unroll_loop_start\nfor (int i = 0; i < UNION_CLIPPING_PLANES; i++) {\nplane = clippingPlanes[i];\nif (dot(vClipPosition, plane.xyz) > plane.w) discard;\n}\n#pragma unroll_loop_end\n#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\nbool clipped = true;\n#pragma unroll_loop_start\nfor (int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i++) {\nplane = clippingPlanes[i];\nclipped = (dot(vClipPosition, plane.xyz) > plane.w) && clipped;\n}\n#pragma unroll_loop_end\nif (clipped) discard;\n#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\nvarying vec3 vClipPosition;\nuniform vec4 clippingPlanes[NUM_CLIPPING_PLANES];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\nvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\nvClipPosition = -mvPosition.xyz;\n#endif",color_fragment:"#if defined(USE_COLOR_ALPHA)\ndiffuseColor *= vColor;\n#elif defined(USE_COLOR)\ndiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined(USE_COLOR_ALPHA)\nvarying vec4 vColor;\n#elif defined(USE_COLOR)\nvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined(USE_COLOR_ALPHA)\nvarying vec4 vColor;\n#elif defined(USE_COLOR) || defined(USE_INSTANCING_COLOR)\nvarying vec3 vColor;\n#endif",color_vertex:"#if defined(USE_COLOR_ALPHA)\nvColor = vec4(1.0);\n#elif defined(USE_COLOR) || defined(USE_INSTANCING_COLOR)\nvColor = vec3(1.0);\n#endif\n#ifdef USE_COLOR\nvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\nvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp(a, 0.0, 1.0)\n#endif\n#define whiteComplement(a) (1.0 - saturate(a))\n#define RECIPROCAL_3 0.333333333333\nfloat pow2(const in float x) { return x*x; }\nfloat pow3(const in float x) { return x*x*x; }\nfloat pow4(const in float x) { float x2 = x*x; return x2*x2; }\nfloat average(const in vec3 color) { return dot(color, vec3(0.3333)); }\nhighp float rand(const in vec2 uv) {\nconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\nhighp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, PI);\nreturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\nfloat precisionSafeLength(vec3 v) { return length(v); }\n#else\nfloat max3(vec3 v) { return max(max(v.x, v.y), v.z); }\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 CLEARCOAT\nvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection(in vec3 dir, in mat4 matrix) {\nreturn normalize((matrix * vec4(dir, 0.0)).xyz);\n}\nvec3 inverseTransformDirection(in vec3 dir, in mat4 matrix) {\nreturn normalize((vec4(dir, 0.0) * matrix).xyz);\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) {\nfloat distance = dot(planeNormal, point - pointOnPlane);\nreturn - distance * planeNormal + point;\n}\nfloat sideOfPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) {\nreturn sign(dot(point - pointOnPlane, planeNormal));\n}\nvec3 linePlaneIntersect(in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal) {\nreturn lineDirection * (dot(planeNormal, pointOnPlane - pointOnLine) / dot(planeNormal, lineDirection)) + pointOnLine;\n}\nmat3 transposeMat3(const in mat3 m) {\nmat3 tmp;\ntmp[0] = vec3(m[0].x, m[1].x, m[2].x);\ntmp[1] = vec3(m[0].y, m[1].y, m[2].y);\ntmp[2] = vec3(m[0].z, m[1].z, m[2].z);\nreturn tmp;\n}\nfloat linearToRelativeLuminance(const in vec3 color) {\nvec3 weights = vec3(0.2126, 0.7152, 0.0722);\nreturn dot(weights, color.rgb);\n}\nbool isPerspectiveMatrix(mat4 m) {\nreturn m[2][3] == - 1.0;\n}\nvec2 equirectUv(in vec3 dir) {\nfloat u = atan(dir.z, dir.x) * RECIPROCAL_PI2 + 0.5;\nfloat v = asin(clamp(dir.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nreturn vec2(u, v);\n}\nfloat smootherstep(float edge0, float edge1, float x) {\nfloat t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);\nreturn t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\nhighp vec3 rand3(const in vec3 v) {\nconst highp float c = 43758.5453;\nconst highp mat3 coeffs = mat3(\n165.15, 253.34, 323.22,\n241.49, 329.07, 147.79,\n376.31, 143.45, 281.63\n);\nhighp vec3 sn = mod(coeffs * v, PI);\nreturn fract(sin(sn) * c);\n}\nfloat powCompat(const in float val, const in float power) {\nif (power == 0.0)\nreturn 1.0;\nelse if (val < 0.0) {\nif (mod(-power, 2.0) == 0.0)\nreturn pow(abs(val), power);\nelse\nreturn -pow(abs(val), power);\n} else if (val == 0.0)\nreturn 0.0;\nreturn pow(abs(val), power);\n}\nfloat maxFromRGB(vec3 rgb) {\nreturn max(max(rgb.r, rgb.g), rgb.b);\n}\nbool isOrtho(const in mat4 m) {\nif (m[3][3] != 0.0)\nreturn true;\nelse\nreturn false;\n}\nvec3 swizzleUpZ(const vec3 vec) {\nreturn vec3(vec[0], -vec[2], vec[1]);\n}\nvec3 swizzleUpY(const vec3 vec) {\nreturn vec3(vec[0], vec[2], -vec[1]);\n}\nvec3 xyz_to_sRGB(vec3 xyz) {\nmat3 convMat = mat3(\n3.2406, -0.9689, 0.0557,\n-1.5372, 1.8758, -0.2040,\n-0.4986, 0.0415, 1.0570\n);\nreturn convMat * xyz;\n}\nvec3 xyY_to_XYZ(float x, float y, float Y) {\nfloat X = 0.0;\nfloat Z = 0.0;\nif (y != 0.0) {\nX = (Y / y) * x;\nZ = (Y / y) * (1.0 - x - y);\n}\nreturn vec3(X, Y, Z);\n}\nvec3 octUVToCubeVec(vec2 octUV, vec2 texelSize) {\noctUV = (1.0 + 2.0 * texelSize) * octUV - texelSize;\noctUV = octUV * 2.0 - 1.0;\nfloat x = octUV.x;\nfloat z = -octUV.y;\nfloat absX = abs(x);\nfloat absZ = abs(z);\nvec3 cubeVec = vec3(x, 1.0 - absX - absZ, z);\nif (absX + absZ > 1.0) {\ncubeVec.xz = -(vec2(absZ, absX) - 1.0) * sign(vec2(x, z));\n}\nreturn cubeVec;\n}\nvec2 cubeVecToOctUV(vec3 cubeVec, vec2 texelSize) {\ncubeVec /= dot(vec3(1.0), abs(cubeVec));\nvec2 octUV = vec2(cubeVec.x, -cubeVec.z);\nif (cubeVec.y < 0.0) {\noctUV = sign(octUV) * (1.0 - abs(octUV.ts));\n}\noctUV = (octUV + 1.0) / 2.0;\noctUV = (1.0 - 2.0 * texelSize) * octUV + texelSize;\nreturn octUV;\n}\n#if __VERSION__ == 100\nfloat cosh(float x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nvec2 cosh(vec2 x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nvec3 cosh(vec3 x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nvec4 cosh(vec4 x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nfloat sinh(float x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nvec2 sinh(vec2 x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nvec3 sinh(vec3 x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nvec4 sinh(vec4 x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nfloat tanh(float x) {\nfloat exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nvec2 tanh(vec2 x) {\nvec2 exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nvec3 tanh(vec3 x) {\nvec3 exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nvec4 tanh(vec4 x) {\nvec4 exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nfloat trunc(float x) {\nreturn floor(abs(x)) * sign(x);\n}\nvec2 trunc(vec2 x) {\nreturn floor(abs(x)) * sign(x);\n}\nvec3 trunc(vec3 x) {\nreturn floor(abs(x)) * sign(x);\n}\nvec4 trunc(vec4 x) {\nreturn floor(abs(x)) * sign(x);\n}\n#endif\nfloat getSmoothFactor(float a, float b, float smoothness) {\nreturn max(smoothness - abs(a - b), 0.0) / smoothness;\n}\nfloat smoothMin(float a, float b, float smoothness) {\nfloat smoothFac = getSmoothFactor(a, b, smoothness);\nreturn min(a, b) - smoothFac * smoothFac * smoothFac * smoothness * (1.0 / 6.0);\n}\nfloat smoothMax(float a, float b, float smoothness) {\nfloat smoothFac = getSmoothFactor(a, b, smoothness);\nreturn max(a, b) + smoothFac * smoothFac * smoothFac * smoothness * (1.0 / 6.0);\n}\nvec3 vec3RotateAxisAngle(vec3 vector, vec3 axis, float angle) {\nvec3 axisNorm = normalize(axis);\nfloat x = axisNorm.x, y = axisNorm.y, z = axisNorm.z;\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(\nx * x * (1.0 - c) + c, x * y * (1.0 - c) + z * s, x * z * (1.0 - c) - y * s,\nx * y * (1.0 - c) - z * s, y * y * (1.0 - c) + c, y * z * (1.0 - c) + x * s,\nx * z * (1.0 - c) + y * s, y * z * (1.0 - c) - x * s, z * z * (1.0 - c) + c\n) * vector;\n}\nmat3 mat3RotateX(float angle) {\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(1.0, 0.0, 0.0,\n0.0, c, s,\n0.0, -s, c);\n}\nmat3 mat3RotateY(float angle) {\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(c, 0.0, -s,\n0.0, 1.0, 0.0,\ns, 0.0, c);\n}\nmat3 mat3RotateZ(float angle) {\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(c, s, 0.0,\n-s, c, 0.0,\n0.0, 0.0, 1.0);\n}\nvec3 vec3RotateXAngle(vec3 vector, float angle) {\nreturn mat3RotateX(angle) * vector;\n}\nvec3 vec3RotateYAngle(vec3 vector, float angle) {\nreturn mat3RotateY(angle) * vector;\n}\nvec3 vec3RotateZAngle(vec3 vector, float angle) {\nreturn mat3RotateZ(angle) * vector;\n}\nvec4 eulerToAxisAngle(vec3 euler) {\nfloat c1 = cos(euler.x / 2.0), c2 = cos(euler.y / 2.0), c3 = cos(euler.z / 2.0);\nfloat s1 = sin(euler.x / 2.0), s2 = sin(euler.y / 2.0), s3 = sin(euler.z / 2.0);\nvec4 axisAngle = vec4(\ns1 * c2 * c3 - c1 * s2 * s3,\nc1 * s2 * c3 + s1 * c2 * s3,\nc1 * c2 * s3 - s1 * s2 * c3,\n2.0 * acos(c1 * c2 * c3 + s1 * s2 * s3)\n);\naxisAngle.xyz = length(axisAngle.xyz) > 0.0 ? normalize(axisAngle.xyz) : vec3(1.0, 0.0, 0.0);\nreturn axisAngle;\n}\nfloat mat3GetDeterminant(mat3 mat) {\nreturn mat[0][0] * mat[1][1] * mat[2][2]\n+ mat[0][2] * mat[1][0] * mat[2][1]\n+ mat[0][1] * mat[1][2] * mat[2][0]\n- mat[0][2] * mat[1][1] * mat[2][0]\n- mat[0][0] * mat[1][2] * mat[2][1]\n- mat[0][1] * mat[1][0] * mat[2][2];\n}\nmat3 mat3GetInverseTransposed(mat3 mat) {\nfloat det = mat3GetDeterminant(mat);\nfloat a00 = (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) / det;\nfloat a01 = - (mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0]) / det;\nfloat a02 = (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]) / det;\nfloat a10 = - (mat[0][1] * mat[2][2] - mat[0][2] * mat[2][1]) / det;\nfloat a11 = (mat[0][0] * mat[2][2] - mat[0][2] * mat[2][0]) / det;\nfloat a12 = - (mat[0][0] * mat[2][1] - mat[0][1] * mat[2][0]) / det;\nfloat a20 = (mat[0][1] * mat[1][2] - mat[0][2] * mat[1][1]) / det;\nfloat a21 = - (mat[0][0] * mat[1][2] - mat[0][2] * mat[1][0]) / det;\nfloat a22 = (mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]) / det;\nreturn mat3(\na00, a01, a02,\na10, a11, a12,\na20, a21, a22\n);\n}\nmat3 toMat3(mat4 mat) {\nreturn mat3(mat[0][0], mat[0][1], mat[0][2],\nmat[1][0], mat[1][1], mat[1][2],\nmat[2][0], mat[2][1], mat[2][2]);\n}\nmat4 toMat4(mat3 mat) {\nreturn mat4(mat[0][0], mat[0][1], mat[0][2], 0.0,\nmat[1][0], mat[1][1], mat[1][2], 0.0,\nmat[2][0], mat[2][1], mat[2][2], 0.0,\n0.0, 0.0, 0.0, 1.0);\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\nfloat getFace(vec3 direction) {\nvec3 absDirection = abs(direction);\nfloat face = -1.0;\nif (absDirection.x > absDirection.z) {\nif (absDirection.x > absDirection.y) {\nface = direction.x > 0.0 ? 0.0 : 3.0;\n} else {\nface = direction.y > 0.0 ? 1.0 : 4.0;\n}\n} else {\nif (absDirection.z > absDirection.y) {\nface = direction.z > 0.0 ? 2.0 : 5.0;\n} else {\nface = direction.y > 0.0 ? 1.0 : 4.0;\n}\n}\nreturn face;\n}\nvec2 getUV(vec3 direction, float face) {\nvec2 uv;\nif (face == 0.0) {\nuv = vec2(-direction.z, direction.y) / abs(direction.x);\n} else if (face == 1.0) {\nuv = vec2(direction.x, -direction.z) / abs(direction.y);\n} else if (face == 2.0) {\nuv = direction.xy / abs(direction.z);\n} else if (face == 3.0) {\nuv = vec2(direction.z, direction.y) / abs(direction.x);\n} else if (face == 4.0) {\nuv = direction.xz / abs(direction.y);\n} else {\nuv = vec2(-direction.x, direction.y) / abs(direction.z);\n}\nreturn 0.5 * (uv + 1.0);\n}\n#ifndef cubeUV_maxTileSize\n#define cubeUV_maxTileSize 256.0\n#endif\n#define cubeUV_lodIdxMin 0.0\n#define cubeUV_lodIdxLastDownscaled 4.0\n#define cubeUV_lodIdxMax 10.0\n#define cubeUV_minTileSize (cubeUV_maxTileSize / exp2(cubeUV_lodIdxLastDownscaled))\nfloat getLodTileSize(float lodIdx) {\nreturn cubeUV_maxTileSize / exp2(min(lodIdx, cubeUV_lodIdxLastDownscaled));\n}\nfloat getLodFilterLevel(float lodIdx) {\nreturn max(lodIdx - cubeUV_lodIdxLastDownscaled, 0.0);\n}\nvec2 fixCubeUVSeams(vec2 uv, float faceSize) {\nfloat BORDER_WIDTH_PX = max(cubeUV_maxTileSize / 256.0 - 1.0, 0.0);\nfloat scale = (faceSize - BORDER_WIDTH_PX) / faceSize;\nfloat offset = 0.5 * BORDER_WIDTH_PX / faceSize;\nreturn uv * scale + offset;\n}\nvec2 getUVPixels(vec3 direction, float lodIdx) {\nfloat face = getFace(direction);\nfloat faceSize = getLodTileSize(lodIdx);\nfloat filterLevel = getLodFilterLevel(lodIdx);\nvec2 uv = getUV(direction, face);\nuv = fixCubeUVSeams(uv, faceSize);\nuv *= (faceSize - 1.0);\nif (face > 2.0) {\nuv.y += faceSize;\nface -= 3.0;\n}\nuv.x += face * faceSize;\nif (lodIdx > 0.0) {\nuv.y += 2.0 * cubeUV_maxTileSize;\n}\nuv.y += filterLevel * 2.0 * cubeUV_minTileSize;\nuv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\nreturn uv;\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float lodIdx) {\nfloat texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\nvec2 uv = getUVPixels(direction, lodIdx);\nvec2 f = fract(uv);\nuv += 0.5 - f;\nuv *= texelSize;\nvec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\nuv.x += texelSize;\nvec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\nuv.y += texelSize;\nvec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\nuv.x -= texelSize;\nvec3 bl = envMapTexelToLinear(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 envMapTexelToLinear(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);\nemissiveColor.rgb = emissiveMapTexelToLinear(emissiveColor).rgb;\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:"\nvec4 LinearToLinear(in vec4 value) {\nreturn value;\n}\nvec4 GammaToLinear(in vec4 value, in float gammaFactor) {\nvalue = max(value, vec4(0.0));\nreturn vec4(pow(value.rgb, vec3(gammaFactor)), value.a);\n}\nvec4 LinearToGamma(in vec4 value, in float gammaFactor) {\nvalue = max(value, vec4(0.0));\nreturn vec4(pow(value.rgb, vec3(1.0 / gammaFactor)), value.a);\n}\nvec4 sRGBToLinear(in vec4 value) {\n#ifdef COMPAT_SIMPLIFIED_SRGB\nreturn vec4(pow(value.rgb, vec3(2.2)), value.a);\n#else\nvalue = max(value, vec4(0.0));\nreturn vec4(mix(pow(value.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.a);\n#endif\n}\nvec4 LinearTosRGB(in vec4 value) {\n#ifdef COMPAT_SIMPLIFIED_SRGB\nreturn vec4(pow(value.rgb, vec3(1.0/2.2)), value.a);\n#else\nvalue = max(value, vec4(0.0));\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#endif\n}\nvec4 RGBEToLinear(in vec4 value) {\nreturn vec4(value.rgb * exp2(value.a * 255.0 - 128.0), 1.0);\n}\nvec4 LinearToRGBE(in vec4 value) {\nfloat maxComponent = max(max(value.r, value.g), value.b);\nfloat fExp = clamp(ceil(log2(maxComponent)), -128.0, 127.0);\nreturn vec4(value.rgb / exp2(fExp), (fExp + 128.0) / 255.0);\n}\nvec4 RGBMToLinear(in vec4 value, in float maxRange) {\nreturn vec4(value.rgb * value.a * maxRange, 1.0);\n}\nvec4 LinearToRGBM(in vec4 value, in float maxRange) {\nfloat maxRGB = max(value.r, max(value.g, value.b));\nfloat M = clamp(maxRGB / maxRange, 0.0, 1.0);\nM = ceil(M * 255.0) / 255.0;\nreturn vec4(value.rgb / (M * maxRange), M);\n}\nvec4 RGBDToLinear(in vec4 value, in float maxRange) {\nreturn vec4(value.rgb * ((maxRange / 255.0) / value.a), 1.0);\n}\nvec4 LinearToRGBD(in vec4 value, in float maxRange) {\nfloat maxRGB = max(value.r, max(value.g, value.b));\nfloat D = max(maxRange / maxRGB, 1.0);\nD = clamp(floor(D) / 255.0, 0.0, 1.0);\nreturn vec4(value.rgb * (D * (255.0 / maxRange)), D);\n}\nconst mat3 cLogLuvM = mat3(0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969);\nvec4 LinearToLogLuv(in vec4 value) {\nvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\nXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\nvec4 vResult;\nvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\nfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\nvResult.w = fract(Le);\nvResult.z = (Le - (floor(vResult.w * 255.0)) / 255.0) / 255.0;\nreturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3(6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268);\nvec4 LogLuvToLinear(in vec4 value) {\nfloat Le = value.z * 255.0 + value.w;\nvec3 Xp_Y_XYZp;\nXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\nXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\nXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\nvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\nreturn vec4(max(vRGB, 0.0), 1.0);\n}",envmap_fragment:"#ifdef USE_ENVMAP\n#ifdef ENV_WORLDPOS\nvec3 cameraToFrag;\nif (isOrthographic) {\ncameraToFrag = normalize(vec3(- viewMatrix[0][2], - viewMatrix[1][2], - viewMatrix[2][2]));\n} else {\ncameraToFrag = normalize(vWorldPosition - cameraPosition);\n}\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\n#ifdef ENVMAP_MODE_REFLECTION\nvec3 reflectVec = reflect(cameraToFrag, worldNormal);\n#else\nvec3 reflectVec = refract(cameraToFrag, worldNormal, refractionRatio);\n#endif\n#else\nvec3 reflectVec = vReflect;\n#endif\n#ifdef ENVMAP_TYPE_CUBE\nvec4 envColor = textureCube(envMap, vec3(flipEnvMap * reflectVec.x, reflectVec.yz));\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec4 envColor = textureCubeUV(envMap, reflectVec, 0.0);\n#elif defined(ENVMAP_TYPE_EQUIREC)\nvec2 sampleUV;\nreflectVec = normalize(reflectVec);\nsampleUV.y = asin(clamp(reflectVec.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nsampleUV.x = atan(reflectVec.z, reflectVec.x) * RECIPROCAL_PI2 + 0.5;\nvec4 envColor = texture2D(envMap, sampleUV);\n#else\nvec4 envColor = vec4(0.0);\n#endif\n#ifndef ENVMAP_TYPE_CUBE_UV\nenvColor = envMapTexelToLinear(envColor);\n#endif\n#ifdef ENVMAP_BLENDING_MULTIPLY\noutgoingLight = mix(outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity);\n#elif defined(ENVMAP_BLENDING_MIX)\noutgoingLight = mix(outgoingLight, envColor.xyz, specularStrength * reflectivity);\n#elif defined(ENVMAP_BLENDING_ADD)\noutgoingLight += envColor.xyz * specularStrength * reflectivity;\n#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\nuniform float envMapIntensity;\nuniform float flipEnvMap;\nuniform int maxMipLevel;\n#ifdef ENVMAP_TYPE_CUBE\nuniform samplerCube envMap;\n#else\nuniform sampler2D envMap;\n#endif\n#if defined(ENVMAP_TYPE_CUBE) && defined(NODE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat calcGeometryRoughness(vec3 geometryNormal) {\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nreturn max(max(dxy.x, dxy.y), dxy.z);\n}\nfloat calcCubeUVAdjustedRoughness(float origRoughness, float geomRoughness) {\nreturn min(max(origRoughness, 0.0525) + geomRoughness, 1.0);\n}\n#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nuniform float reflectivity;\n#if defined(USE_BUMPMAP) || defined(USE_NORMALMAP) || defined(PHONG)\n#define ENV_WORLDPOS\n#endif\n#ifdef ENV_WORLDPOS\nvarying vec3 vWorldPosition;\nuniform float refractionRatio;\n#else\nvarying vec3 vReflect;\n#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n#if defined(USE_BUMPMAP) || defined(USE_NORMALMAP) ||defined(PHONG)\n#define ENV_WORLDPOS\n#endif\n#ifdef ENV_WORLDPOS\n\nvarying vec3 vWorldPosition;\n#else\nvarying vec3 vReflect;\nuniform float refractionRatio;\n#endif\n#endif",envmap_physical_pars_fragment:"#if defined(USE_ENVMAP)\n#define ENVMAP_PARALLAX_INFINITE 0\n#define ENVMAP_PARALLAX_SPHERE 1\n#define ENVMAP_PARALLAX_BOX 2\n#ifdef ENVMAP_MODE_REFRACTION\nuniform float refractionRatio;\n#endif\nuniform int envMapParallaxType;\nuniform mat4 envMapParallaxMatrix;\nuniform mat4 envMapParallaxMatrixInv;\nvec3 correctParallax(vec3 directionVecWorld, vec3 posWorld, int parallaxType) {\nvec3 posProbe = (envMapParallaxMatrix * vec4(posWorld, 1.0)).xyz;\nvec3 reflectVecProbe = transformDirection(directionVecWorld, envMapParallaxMatrix);\nif (parallaxType == ENVMAP_PARALLAX_SPHERE) {\nfloat b = 2.0 * dot(reflectVecProbe, posProbe);\nfloat c = dot(posProbe, posProbe) - 1.0;\nfloat D = b * b - 4.0 * c;\nif (D >= 0.0) {\nfloat x = (sqrt(D) - b) / 2.0;\nreflectVecProbe = posProbe + x * reflectVecProbe;\n}\n} else if (parallaxType == ENVMAP_PARALLAX_BOX) {\nvec3 scalePos = (vec3(1.0) - posProbe) / reflectVecProbe;\nvec3 scaleNeg = (vec3(-1.0) - posProbe) / reflectVecProbe;\nvec3 scalePosNeg = mix(scaleNeg, scalePos, step(vec3(0.0), reflectVecProbe));\nfloat x = min(scalePosNeg.x, min(scalePosNeg.y, scalePosNeg.z));\nreflectVecProbe = posProbe + x * reflectVecProbe;\n}\nvec3 directionVecWorldCorrected = transformDirection(reflectVecProbe,\nenvMapParallaxMatrixInv);\nreturn directionVecWorldCorrected;\n}\nvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel) {\nvec3 worldNormal = inverseTransformDirection(geometry.probeNormal, viewMatrix);\n#ifdef ENVMAP_TYPE_CUBE\nvec3 queryVec = vec3(flipEnvMap * worldNormal.x, worldNormal.yz);\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor = textureCubeLodEXT(envMap, queryVec, float(maxMIPLevel));\n#else\nvec4 envMapColor = textureCube(envMap, queryVec, float(maxMIPLevel));\n#endif\nenvMapColor.rgb = envMapTexelToLinear(envMapColor).rgb;\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec3 queryVec = vec3(flipEnvMap * worldNormal.x, worldNormal.yz);\nvec4 envMapColor = textureCubeUV(envMap, queryVec, 1.0);\n#else\nvec4 envMapColor = vec4(0.0);\n#endif\nreturn PI * envMapColor.rgb * envMapIntensity;\n}\nfloat getSpecularMIPLevel(const in float blinnShininessExponent, const in int maxMIPLevel) {\nfloat maxMIPLevelScalar = float(maxMIPLevel);\nfloat clapmedBlinnShininessExponent = min(blinnShininessExponent, 30000.0);\nfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248\n- 0.5 * log2(pow2(clapmedBlinnShininessExponent) + 1.0);\nreturn clamp(desiredMIPLevel, 0.0, maxMIPLevelScalar);\n}\nvec3 _getLightProbeIndirect(const float blinnShininessExponent,\nconst int maxMIPLevel, vec3 directionVec) {\nfloat specularMIPLevel = getSpecularMIPLevel(blinnShininessExponent, maxMIPLevel);\n#ifdef ENVMAP_TYPE_CUBE\nvec3 queryVec = vec3(flipEnvMap * directionVec.x, directionVec.yz);\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor = textureCubeLodEXT(envMap, queryVec, specularMIPLevel);\n#else\nvec4 envMapColor = textureCube(envMap, queryVec, specularMIPLevel);\n#endif\nenvMapColor.rgb = envMapTexelToLinear(envMapColor).rgb;\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec3 queryVec = vec3(flipEnvMap * directionVec.x, directionVec.yz);\nvec4 envMapColor = textureCubeUV(envMap, queryVec,\nBlinnExponentToGGXRoughness(blinnShininessExponent));\n#elif defined(ENVMAP_TYPE_EQUIREC)\nvec2 sampleUV;\nsampleUV.y = asin(clamp(directionVec.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nsampleUV.x = atan(directionVec.z, directionVec.x) * RECIPROCAL_PI2 + 0.5;\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor = texture2DLodEXT(envMap, sampleUV, specularMIPLevel);\n#else\nvec4 envMapColor = texture2D(envMap, sampleUV, specularMIPLevel);\n#endif\nenvMapColor.rgb = envMapTexelToLinear(envMapColor).rgb;\n#endif\nreturn envMapColor.rgb * envMapIntensity;\n}\nvec3 getLightProbeIndirectRadiance(\nconst GeometricContext geometry, const float blinnShininessExponent,\nconst int maxMIPLevel, const int useCoat) {\nvec3 normal = geometry.normal;\n#ifdef CLEARCOAT\nif (useCoat == 1) {\nnormal = geometry.clearcoatNormal;\n}\n#endif\n#ifdef ENVMAP_MODE_REFLECTION\nvec3 directionVec = reflect(-geometry.viewDir, normal);\n#else\nvec3 directionVec = refract(-geometry.viewDir, normal, refractionRatio);\n#endif\ndirectionVec = inverseTransformDirection(directionVec, viewMatrix);\nvec3 posWorld = (invViewMatrix * vec4(geometry.position, 1.0)).xyz;\nif (envMapParallaxType != ENVMAP_PARALLAX_INFINITE) {\ndirectionVec = correctParallax(directionVec, posWorld, envMapParallaxType);\n}\nreturn _getLightProbeIndirect(blinnShininessExponent, maxMIPLevel,\ndirectionVec);\n}\nvec3 getLightProbeIndirectRefraction(\nconst GeometricContext geometry, const float blinnShininessExponent,\nconst int maxMIPLevel, const float refrRatio) {\nvec3 directionVec = refract(-geometry.viewDir, geometry.normal, refrRatio);\ndirectionVec = inverseTransformDirection(directionVec, viewMatrix);\nvec3 posWorld = (invViewMatrix * vec4(geometry.position, 1.0)).xyz;\nif (envMapParallaxType != ENVMAP_PARALLAX_INFINITE) {\ndirectionVec = correctParallax(directionVec, posWorld, envMapParallaxType);\n}\nreturn _getLightProbeIndirect(blinnShininessExponent, maxMIPLevel,\ndirectionVec);\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\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\nvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n#ifdef FOG_EXP2\nfloat fogFactor = 1.0 - exp(- fogDensity * fogDensity * fogDepth * fogDepth);\n#else\nfloat fogFactor = smoothstep(fogNear, fogFar, fogDepth);\n#endif\ngl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, fogFactor);\n#endif",fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\nvarying float fogDepth;\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 texture2D(gradientMap, coord).rgb;\n#else\nreturn (coord.x < 0.7) ? vec3(0.7) : vec3(1.0);\n#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\nvec4 lightMapTexel= texture2D(lightMap, vUv2);\nreflectedLight.indirectDiffuse += PI * lightMapTexelToLinear(lightMapTexel).rgb * lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nuniform sampler2D lightMap;\nuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3(1.0);\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.probeNormal = geometry.normal = normalize(transformedNormal);\ngeometry.viewDir = (isOrthographic) ? vec3(0, 0, 1) : normalize(-mvPosition.xyz);\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.probeNormal = backGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3(0.0);\nvIndirectFront = vec3(0.0);\n#ifdef DOUBLE_SIDED\nvLightBack = vec3(0.0);\nvIndirectBack = vec3(0.0);\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance(ambientLightColor);\nvIndirectFront += getLightProbeIrradiance(lightProbe, geometry);\n#ifdef DOUBLE_SIDED\nvIndirectBack += getAmbientLightIrradiance(ambientLightColor);\nvIndirectBack += getLightProbeIrradiance(lightProbe, backGeometry);\n#endif\n#if NUM_POINT_LIGHTS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\ngetPointDirectLightIrradiance(pointLights[i], geometry, directLight);\ndotNL = dot(geometry.normal, directLight.direction);\ndirectLightColor_Diffuse = PI * directLight.color;\nvLightFront += saturate(dotNL) * directLightColor_Diffuse;\n#ifdef DOUBLE_SIDED\nvLightBack += saturate(-dotNL) * directLightColor_Diffuse;\n#endif\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\ngetSpotDirectLightIrradiance(spotLights[i], geometry, directLight);\ndotNL = dot(geometry.normal, directLight.direction);\ndirectLightColor_Diffuse = PI * directLight.color;\nvLightFront += saturate(dotNL) * directLightColor_Diffuse;\n#ifdef DOUBLE_SIDED\nvLightBack += saturate(-dotNL) * directLightColor_Diffuse;\n#endif\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_DIR_LIGHTS; i++) {\ngetDirectionalDirectLightIrradiance(directionalLights[i], geometry, directLight);\ndotNL = dot(geometry.normal, directLight.direction);\ndirectLightColor_Diffuse = PI * directLight.color;\nvLightFront += saturate(dotNL) * directLightColor_Diffuse;\n#ifdef DOUBLE_SIDED\nvLightBack += saturate(-dotNL) * directLightColor_Diffuse;\n#endif\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_HEMI_LIGHTS; i++) {\nvIndirectFront += getHemisphereLightIrradiance(hemisphereLights[i], geometry);\n#ifdef DOUBLE_SIDED\nvIndirectBack += getHemisphereLightIrradiance(hemisphereLights[i], backGeometry);\n#endif\n}\n#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[9];\nvec3 shGetIrradianceAt(in vec3 normal, in vec3 shCoefficients[9]) {\nfloat x = normal.x, y = normal.y, z = normal.z;\nvec3 result = shCoefficients[0] * 0.886227;\nresult += shCoefficients[1] * 2.0 * 0.511664 * y;\nresult += shCoefficients[2] * 2.0 * 0.511664 * z;\nresult += shCoefficients[3] * 2.0 * 0.511664 * x;\nresult += shCoefficients[4] * 2.0 * 0.429043 * x * y;\nresult += shCoefficients[5] * 2.0 * 0.429043 * y * z;\nresult += shCoefficients[6] * (0.743125 * z * z - 0.247708);\nresult += shCoefficients[7] * 2.0 * 0.429043 * x * z;\nresult += shCoefficients[8] * 0.429043 * (x * x - y * y);\nreturn result;\n}\nvec3 getLightProbeIrradiance(const in vec3 lightProbe[9], const in GeometricContext geometry) {\nvec3 worldNormal = inverseTransformDirection(geometry.probeNormal, viewMatrix);\nvec3 irradiance = shGetIrradianceAt(worldNormal, lightProbe);\nreturn irradiance;\n}\nvec3 getAmbientLightIrradiance(const in vec3 ambientLightColor) {\nvec3 irradiance = ambientLightColor;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\nreturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\nstruct DirectionalLight {\nvec3 direction;\nvec3 color;\n};\nuniform DirectionalLight directionalLights[NUM_DIR_LIGHTS];\nvoid getDirectionalDirectLightIrradiance(const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight) {\ndirectLight.color = directionalLight.color;\ndirectLight.direction = directionalLight.direction;\ndirectLight.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 getPointDirectLightIrradiance(const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight) {\nvec3 lVector = pointLight.position - geometry.position;\ndirectLight.direction = normalize(lVector);\nfloat lightDistance = length(lVector);\ndirectLight.color = pointLight.color;\ndirectLight.color *= punctualLightIntensityToIrradianceFactor(lightDistance, pointLight.distance, pointLight.decay);\ndirectLight.visible = (directLight.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 getSpotDirectLightIrradiance(const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight) {\nvec3 lVector = spotLight.position - geometry.position;\ndirectLight.direction = normalize(lVector);\nfloat lightDistance = length(lVector);\nfloat angleCos = dot(directLight.direction, spotLight.direction);\n#if defined(MT_MAX) && defined(PHYSICALLY_CORRECT_LIGHTS)\nfloat coneCosDecayed = 2.0 * spotLight.coneCos - spotLight.penumbraCos;\nif (angleCos > coneCosDecayed) {\nfloat spotEffect = 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);\nspotEffect *= pow2(decayFac) * (3.0 - 2.0 * decayFac);\n}\ndirectLight.color = spotLight.color * spotEffect\n* punctualLightIntensityToIrradianceFactor(lightDistance,\nspotLight.distance, spotLight.decay);\ndirectLight.visible = true;\n} else {\ndirectLight.color = vec3(0.0);\ndirectLight.visible = false;\n}\n#else\nif (angleCos > spotLight.coneCos) {\nfloat spotEffect = smoothstep(spotLight.coneCos, spotLight.penumbraCos, angleCos);\ndirectLight.color = spotLight.color * spotEffect\n* punctualLightIntensityToIrradianceFactor(lightDistance,\nspotLight.distance, spotLight.decay);\ndirectLight.visible = true;\n} else {\ndirectLight.color = vec3(0.0);\ndirectLight.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 GeometricContext geometry) {\nfloat dotNL = dot(geometry.probeNormal, hemiLight.direction);\nfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\nvec3 irradiance = mix(hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight);\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\nreturn irradiance;\n}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\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;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\nreflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\nvoid RE_IndirectDiffuse_Toon(const in vec3 irradiance, const in vec3 iblIrradiance,\nconst in GeometricContext geometry, const in ToonMaterial material,\ninout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD(material) (0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\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;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\nreflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\nreflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(directLight, geometry, material.specularColor, material.specularShininess) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong(const in vec3 irradiance, const in vec3 iblIrradiance,\nconst in GeometricContext geometry, const in BlinnPhongMaterial material,\ninout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD(material) (0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * (1.0 - metalnessFactor);\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\nmaterial.specularRoughness = max(roughnessFactor, 0.0525);\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min(material.specularRoughness, 1.0);\n#ifdef REFLECTIVITY\nmaterial.specularColor = mix(vec3(MAXIMUM_SPECULAR_COEFFICIENT * pow2(reflectivity)), diffuseColor.rgb, metalnessFactor);\n#else\nmaterial.specularColor = mix(vec3(DEFAULT_SPECULAR_COEFFICIENT), diffuseColor.rgb, metalnessFactor);\n#endif\n#ifdef CLEARCOAT\nmaterial.clearcoat = clearcoat;\nmaterial.clearcoatRoughness = clearcoatRoughness;\n#ifdef USE_CLEARCOATMAP\nmaterial.clearcoat *= texture2D(clearcoatMap, vUv).x;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\nmaterial.clearcoatRoughness *= texture2D(clearcoatRoughnessMap, vUv).y;\n#endif\nmaterial.clearcoat = saturate(material.clearcoat);\nmaterial.clearcoatRoughness = max(material.clearcoatRoughness, 0.0525);\nmaterial.clearcoatRoughness += geometryRoughness;\nmaterial.clearcoatRoughness = min(material.clearcoatRoughness, 1.0);\n#endif\n#ifdef USE_SHEEN\nmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\nvec3 diffuseColor;\nfloat specularRoughness;\nvec3 specularColor;\n#ifdef CLEARCOAT\nfloat clearcoat;\nfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\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_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.specularRoughness;\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#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\n#ifdef CLEARCOAT\nfloat ccDotNL = saturate(dot(geometry.clearcoatNormal, directLight.direction));\nvec3 ccIrradiance = ccDotNL * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nccIrradiance *= PI;\n#endif\nfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox(material.clearcoatRoughness, ccDotNL);\nreflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.clearcoatNormal, vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\n#else\nfloat clearcoatDHR = 0.0;\n#endif\n#ifdef USE_SHEEN\nreflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_Sheen(\nmaterial.specularRoughness,\ndirectLight.direction,\ngeometry,\nmaterial.sheenColor\n);\n#else\nreflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n#endif\nreflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\nvoid RE_IndirectDiffuse_Physical(const in vec3 irradiance, const in vec3 iblIrradiance,\nconst in GeometricContext geometry, const in PhysicalMaterial material,\ninout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_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 CLEARCOAT\nfloat ccDotNV = saturate(dot(geometry.clearcoatNormal, geometry.viewDir));\nreflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment(geometry.viewDir, geometry.clearcoatNormal, vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\nfloat ccDotNL = ccDotNV;\nfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox(material.clearcoatRoughness, ccDotNL);\n#else\nfloat clearcoatDHR = 0.0;\n#endif\nfloat clearcoatInv = 1.0 - clearcoatDHR;\nvec3 singleScattering = vec3(0.0);\nvec3 multiScattering = vec3(0.0);\nvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\nBRDF_Specular_Multiscattering_Environment(geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering);\nvec3 diffuse = material.diffuseColor * (1.0 - (singleScattering + multiScattering));\nreflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\nreflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\nreflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.specularRoughness)\n#define Material_ClearCoat_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.clearcoatRoughness)\nfloat computeSpecularOcclusion(const in float dotNV, const in float ambientOcclusion, const in float roughness) {\nreturn saturate(pow(abs(dotNV + ambientOcclusion), exp2(- 16.0 * roughness - 1.0)) - 1.0 + ambientOcclusion);\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = (isOrthographic) ? vec3(0, 0, 1) : normalize(vViewPosition);\n#ifdef CLEARCOAT\ngeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef PROBE_NORMAL\ngeometry.probeNormal = PROBE_NORMAL;\n#else\ngeometry.probeNormal = normal;\n#endif\nIncidentLight directLight;\n#if (NUM_POINT_LIGHTS > 0) && (defined(RE_Direct) || defined(RE_DirectDiffuse) || defined(RE_DirectSpecular))\nPointLight pointLight;\n#if defined(USE_SHADOWMAP) && NUM_POINT_LIGHT_SHADOWS > 0\nPointLightShadow pointLightShadow;\n#endif\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\npointLight = pointLights[i];\ngetPointDirectLightIrradiance(pointLight, geometry, directLight);\n#if defined(USE_SHADOWMAP) && ((i) < NUM_POINT_LIGHT_SHADOWS)\npointLightShadow = pointLightShadows[i];\ndirectLight.color *= all(bvec2(directLight.visible, receiveShadow)) ?\ngetPointShadow(pointLightShadow, pointShadowMap[i], vPointShadowCoord[i]) : 1.0;\n#endif\n#if defined(RE_Direct)\nRE_Direct(directLight, geometry, material, reflectedLight);\n#else\n#if defined(RE_DirectDiffuse)\nRE_DirectDiffuse(directLight, geometry, material, reflectedLight);\n#endif\n#if defined(RE_DirectSpecular)\nRE_DirectSpecular(directLight, geometry, material, reflectedLight);\n#endif\n#endif\n}\n#pragma unroll_loop_end\n#endif\n#if (NUM_SPOT_LIGHTS > 0) && (defined(RE_Direct) || defined(RE_DirectDiffuse) || defined(RE_DirectSpecular))\nSpotLight spotLight;\n#if defined(USE_SHADOWMAP) && NUM_SPOT_LIGHT_SHADOWS > 0\nSpotLightShadow spotLightShadow;\n#endif\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\nspotLight = spotLights[i];\ngetSpotDirectLightIrradiance(spotLight, geometry, directLight);\n#if defined(USE_SHADOWMAP) && ((i) < NUM_SPOT_LIGHT_SHADOWS)\nspotLightShadow = spotLightShadows[i];\nif (all(bvec2(directLight.visible, receiveShadow))) {\nif (spotLightShadow.shadow == 1) {\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(spotLight.position\n- geometry.position, 0.0)).xyz);\n#endif\ndirectLight.color *= getSpotShadow(spotLightShadow, spotShadowMap[i],\nvSpotShadowCoord[i], distWorld);\n} else if (spotLightShadow.shadow == 2) {\ndirectLight.color *= getSpotOmniShadow(spotLightShadow,\nspotShadowMap[i], vSpotShadowCoord[i]);\n}\n}\n#endif\n#if defined(RE_Direct)\nRE_Direct(directLight, geometry, material, reflectedLight);\n#else\n#if defined(RE_DirectDiffuse)\nRE_DirectDiffuse(directLight, geometry, material, reflectedLight);\n#endif\n#if defined(RE_DirectSpecular)\nRE_DirectSpecular(directLight, geometry, material, reflectedLight);\n#endif\n#endif\n}\n#pragma unroll_loop_end\n#endif\n#if (NUM_DIR_LIGHTS > 0) && (defined(RE_Direct) || defined(RE_DirectDiffuse) || defined(RE_DirectSpecular))\nDirectionalLight directionalLight;\n#if defined(USE_SHADOWMAP) && NUM_DIR_LIGHT_SHADOWS > 0\nDirectionalLightShadow directionalLightShadow;\n#endif\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_DIR_LIGHTS; i++) {\ndirectionalLight = directionalLights[i];\ngetDirectionalDirectLightIrradiance(directionalLight, geometry, directLight);\n#if defined(USE_SHADOWMAP) && ((i) < NUM_DIR_LIGHT_SHADOWS)\ndirectionalLightShadow = directionalLightShadows[i];\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(directionalLightShadow.position\n- directionalLight.direction * directionalLightShadow.shadowCameraNear\n- geometry.position, 0.0)).xyz);\n#endif\ndirectLight.color *= all(bvec3(directLight.visible, receiveShadow,\nvViewPosition.z < directionalLightShadow.maxDistance))\n? getDirShadow(directionalLightShadow, directionalShadowMap[i],\nvDirectionalShadowCoord[i], distWorld) : 1.0;\n#endif\n#if defined(RE_Direct)\nRE_Direct(directLight, geometry, material, reflectedLight);\n#else\n#if defined(RE_DirectDiffuse)\nRE_DirectDiffuse(directLight, geometry, material, reflectedLight);\n#endif\n#if defined(RE_DirectSpecular)\nRE_DirectSpecular(directLight, geometry, material, reflectedLight);\n#endif\n#endif\n}\n#pragma unroll_loop_end\n#endif\n#if (NUM_RECT_AREA_LIGHTS > 0) && defined(RE_Direct_RectArea)\nRectAreaLight rectAreaLight;\n#if defined(USE_SHADOWMAP) && NUM_RECT_AREA_LIGHT_SHADOWS > 0\nRectAreaLightShadow rectAreaLightShadow;\n#endif\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_RECT_AREA_LIGHTS; i++) {\nrectAreaLight = rectAreaLights[i];\n#if defined(USE_SHADOWMAP) && ((i) < NUM_RECT_AREA_LIGHT_SHADOWS)\nrectAreaLightShadow = rectAreaLightShadows[i];\nrectAreaLight.color *= receiveShadow ?\ngetRectAreaShadow(rectAreaLightShadow, rectAreaShadowMap[i], vRectAreaShadowCoord[i]) : 1.0;\n#endif\nRE_Direct_RectArea(rectAreaLight, geometry, material, reflectedLight);\n}\n#pragma unroll_loop_end\n#endif\n#if defined(RE_IndirectDiffuse) || defined(RE_IndirectSpecular)\nvec3 iblIrradiance = vec3(0.0);\n#endif\n#if defined(RE_IndirectDiffuse)\nvec3 irradiance = getAmbientLightIrradiance(ambientLightColor);\nirradiance += getLightProbeIrradiance(lightProbe, geometry);\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);\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 = lightMapTexelToLinear(lightMapTexel).rgb * lightMapIntensity;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nlightMapIrradiance *= PI;\n#endif\nirradiance += lightMapIrradiance;\n#endif\n#if defined(USE_ENVMAP) && defined(STANDARD) && defined(ENVMAP_TYPE_CUBE_UV)\niblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel);\n#endif\n#endif\n#if defined(USE_ENVMAP) && (defined(STANDARD) || defined(PHYSICAL)) && defined(RE_IndirectSpecular)\nradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent(material), maxMipLevel, 0);\n#if defined(USE_SSR) && !defined(USE_SSR_REFRACT)\nradiance = computeSSR(radiance, geometry.normal, 0.0);\n#endif\n#if defined(USE_PLANE_REFLECTION)\nradiance = computePlaneReflection(radiance, material.specularRoughness, geometry.position, geometry.normal);\n#endif\n#ifdef CLEARCOAT\nclearcoatRadiance += getLightProbeIndirectRadiance(geometry, Material_ClearCoat_BlinnShininessExponent(material), maxMipLevel, 1);\n#endif\n#endif\n#if defined(USE_ENVMAP) && defined(RE_Refraction)\nrefraction += getLightProbeIndirectRefraction(geometry,\nMaterial_Refraction_BlinnShininessExponent(material), maxMipLevel,\n1.0 / material.refractionIOR);\n#ifdef USE_SSR_REFRACT\nrefraction = computeSSR(refraction, geometry.normal, material.refractionIOR);\n#endif\n#endif",lights_fragment_end:"#if defined(RE_IndirectDiffuse)\nRE_IndirectDiffuse(irradiance, iblIrradiance, geometry, material, reflectedLight);\n#endif\n#if defined(RE_IndirectSpecular)\nRE_IndirectSpecular(radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight);\n#endif\n#if defined(RE_Refraction)\nRE_Refraction(refraction, material, refractedLight);\n#endif",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\ngl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\nuniform float logDepthBufFC;\nvarying float vFragDepth;\nvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n#ifdef USE_LOGDEPTHBUF_EXT\nvarying float vFragDepth;\nvarying float vIsPerspective;\n#else\nuniform float logDepthBufFC;\n#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n#ifdef USE_LOGDEPTHBUF_EXT\nvFragDepth = 1.0 + gl_Position.w;\nvIsPerspective = float(isPerspectiveMatrix(projectionMatrix));\n#else\nif (isPerspectiveMatrix(projectionMatrix)) {\ngl_Position.z = log2(max(EPSILON, gl_Position.w + 1.0)) * logDepthBufFC - 1.0;\ngl_Position.z *= gl_Position.w;\n}\n#endif\n#endif",map_fragment:"#ifdef USE_MAP\nvec4 texelColor = texture2D(map, vUv);\ntexelColor = mapTexelToLinear(texelColor);\ndiffuseColor *= texelColor;\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\nvec4 mapTexel = texture2D(map, uv);\ndiffuseColor *= mapTexelToLinear(mapTexel);\n#endif\n#ifdef USE_ALPHAMAP\ndiffuseColor.a *= texture2D(alphaMap, uv).g;\n#endif",map_particle_pars_fragment:"#if defined(USE_MAP) || defined(USE_ALPHAMAP)\nuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\nuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\nvec4 texelMetalness = texture2D(metalnessMap, vUv);\nmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\nuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n#if NUM_MORPH_TARGETS > 0\nobjectNormal += (morphNormal0 - normal) * morphTargetInfluences[0];\n#endif\n#if NUM_MORPH_TARGETS > 1\nobjectNormal += (morphNormal1 - normal) * morphTargetInfluences[1];\n#endif\n#if NUM_MORPH_TARGETS > 2\nobjectNormal += (morphNormal2 - normal) * morphTargetInfluences[2];\n#endif\n#if NUM_MORPH_TARGETS > 3\nobjectNormal += (morphNormal3 - normal) * morphTargetInfluences[3];\n#endif\n#if NUM_MORPH_TARGETS > 4\nobjectNormal += (morphNormal4 - normal) * morphTargetInfluences[4];\n#endif\n#if NUM_MORPH_TARGETS > 5\nobjectNormal += (morphNormal5 - normal) * morphTargetInfluences[5];\n#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetBaseInfluence;\n#ifndef USE_MORPHNORMALS\nuniform float morphTargetInfluences[12];\n#else\nuniform float morphTargetInfluences[6];\n#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\ntransformed *= morphTargetBaseInfluence;\n#if NUM_MORPH_TARGETS > 0\ntransformed += morphTarget0 * morphTargetInfluences[0];\n#endif\n#if NUM_MORPH_TARGETS > 1\ntransformed += morphTarget1 * morphTargetInfluences[1];\n#endif\n#if NUM_MORPH_TARGETS > 2\ntransformed += morphTarget2 * morphTargetInfluences[2];\n#endif\n#if NUM_MORPH_TARGETS > 3\ntransformed += morphTarget3 * morphTargetInfluences[3];\n#endif\n#if NUM_MORPH_TARGETS > 4\ntransformed += morphTarget4 * morphTargetInfluences[4];\n#endif\n#if NUM_MORPH_TARGETS > 5\ntransformed += morphTarget5 * morphTargetInfluences[5];\n#endif\n#ifndef USE_MORPHNORMALS\n#if NUM_MORPH_TARGETS > 6\ntransformed += morphTarget6 * morphTargetInfluences[6];\n#endif\n#if NUM_MORPH_TARGETS > 7\ntransformed += morphTarget7 * morphTargetInfluences[7];\n#endif\n#if NUM_MORPH_TARGETS > 8\ntransformed += morphTarget8 * morphTargetInfluences[8];\n#endif\n#if NUM_MORPH_TARGETS > 9\ntransformed += morphTarget9 * morphTargetInfluences[9];\n#endif\n#if NUM_MORPH_TARGETS > 10\ntransformed += morphTarget10 * morphTargetInfluences[10];\n#endif\n#if NUM_MORPH_TARGETS > 11\ntransformed += morphTarget1 * morphTargetInfluences[11];\n#endif\n#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\nvec3 fdx = vec3(dFdx(vViewPosition.x), dFdx(vViewPosition.y), dFdx(vViewPosition.z));\nvec3 fdy = vec3(dFdy(vViewPosition.x), dFdy(vViewPosition.y), dFdy(vViewPosition.z));\nvec3 normal = normalize(cross(fdx, fdy));\n#else\nvec3 normal = normalize(vNormal);\n#ifdef DOUBLE_SIDED\n#ifdef FRONT_FACING_VALUE\nbool frontFacing = FRONT_FACING_VALUE;\n#else\nbool frontFacing = gl_FrontFacing;\n#endif\nnormal = normal * (float(frontFacing) * 2.0 - 1.0);\n#endif\n#ifdef USE_TANGENT\nvec3 tangent = normalize(vTangent);\nvec3 bitangent = normalize(vBitangent);\n#ifdef DOUBLE_SIDED\ntangent = tangent * faceDirection;\nbitangent = bitangent * faceDirection;\n#endif\n#if defined(TANGENTSPACE_NORMALMAP) || defined(USE_CLEARCOAT_NORMALMAP)\nmat3 vTBN = mat3(tangent, bitangent, normal);\n#endif\n#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\nnormal = texture2D(normalMap, vUv).xyz * 2.0 - 1.0;\n#ifdef FLIP_SIDED\nnormal = - normal;\n#endif\n#ifdef DOUBLE_SIDED\nnormal = normal * faceDirection;\n#endif\nnormal = normalize(normalMatrix * normal);\n#elif defined(TANGENTSPACE_NORMALMAP)\nvec3 mapN = texture2D(normalMap, vUv).xyz * 2.0 - 1.0;\nmapN.xy *= normalScale;\n#ifdef USE_TANGENT\nnormal = normalize(vTBN * mapN);\n#else\nnormal = perturbNormal2Arb(-vViewPosition, normal, mapN, faceDirection);\n#endif\n#elif defined(USE_BUMPMAP)\nnormal = perturbNormalArb(-vViewPosition, normal, dHdxy_fwd(), faceDirection);\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\nuniform sampler2D normalMap;\nuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat3 normalMatrix;\n#endif\n#if !defined (USE_TANGENT) && (defined (TANGENTSPACE_NORMALMAP) || defined (USE_CLEARCOAT_NORMALMAP))\nvec3 perturbNormal2Arb(vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection) {\nvec3 q0 = vec3(dFdx(eye_pos.x), dFdx(eye_pos.y), dFdx(eye_pos.z));\nvec3 q1 = vec3(dFdy(eye_pos.x), dFdy(eye_pos.y), dFdy(eye_pos.z));\nvec2 st0 = dFdx(vUv.st);\nvec2 st1 = dFdy(vUv.st);\nvec3 N = surf_norm;\nvec3 q1perp = cross(q1, N);\nvec3 q0perp = cross(N, q0);\nvec3 T = q1perp * st0.x + q0perp * st1.x;\nvec3 B = q1perp * st0.y + q0perp * st1.y;\nfloat det = max(dot(T, T), dot(B, B));\nfloat scale = (det == 0.0) ? 0.0 : faceDirection * inversesqrt(det);\nreturn normalize(T * (mapN.x * scale) + B * (mapN.y * scale) + N * mapN.z);\n}\n#endif",clearcoat_normal_fragment_begin:"#ifdef 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",packing:"vec3 packNormalToRGB(const in vec3 normal) {\nreturn normalize(normal) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal(const in vec3 rgb) {\nreturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;\nconst float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3(256. * 256. * 256., 256. * 256., 256.);\nconst vec4 UnpackFactors = UnpackDownscale / vec4(PackFactors, 1.);\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA(const in float v) {\nvec4 r = vec4(fract(v * PackFactors), v);\nr.yzw -= r.xyz * ShiftRight8;\nreturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth(const in vec4 v) {\nreturn dot(v, UnpackFactors);\n}\nvec4 pack2HalfToRGBA(vec2 v) {\nvec4 r = vec4(v.x, fract(v.x * 255.0), v.y, fract(v.y * 255.0));\nreturn vec4(r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half(vec4 v) {\nreturn vec2(v.x + (v.y / 255.0), v.z + (v.w / 255.0));\n}\nfloat viewZToOrthographicDepth(const in float viewZ, const in float near, const in float far) {\nreturn (viewZ + near) / (near - far);\n}\nfloat orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) {\nreturn linearClipZ * (near - far) - near;\n}\nfloat viewZToPerspectiveDepth(const in float viewZ, const in float near, const in float far) {\nreturn ((near + viewZ) * far) / ((far - near) * viewZ);\n}\nfloat perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) {\nreturn (near * far) / ((far - near) * invClipZ - far);\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\ngl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4(transformed, 1.0);\n#ifdef USE_INSTANCING\nmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;\n#if defined(BACKGROUND_DEPTH)\ngl_Position.z = gl_Position.w;\n#endif",dithering_fragment:"#ifdef DITHERING\ngl_FragColor.rgb = dithering(gl_FragColor.rgb);\n#endif",dithering_pars_fragment:"#ifdef DITHERING\nvec3 dithering(vec3 color) {\nfloat grid_position = rand(gl_FragCoord.xy);\nvec3 dither_shift_RGB = vec3(0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0);\ndither_shift_RGB = mix(2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position);\nreturn color + dither_shift_RGB;\n}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\nvec4 texelRoughness = texture2D(roughnessMap, vUv);\nroughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\nuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"\n#define BIAS_FRUSTUM_SCALE_COEFF 30.0\n#define ESM_SPOT_SINGLE_BLUR_COEFF 0.25\n#define PCF_POISSON_SPOT_OMNI_BLUR_COEFF 4.0\n#define PCF_POISSON_POINT_BLUR_COEFF 2.5\n#define PCF_PCF_SOFT_DIR_SPOT_BLUR_COEFF 0.5\n#define ESM_BIAS_COEFF 100.0\n#ifndef ESM_DISTANCE_SCALE\n#define ESM_DISTANCE_SCALE 1.0\n#endif\n#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS > 0\nuniform sampler2D directionalShadowMap[NUM_DIR_LIGHT_SHADOWS];\nvarying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];\nstruct DirectionalLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nvec3 position;\nfloat shadowCameraNear;\nfloat maxDistance;\nfloat expBias;\n};\nuniform DirectionalLightShadow directionalLightShadows[NUM_DIR_LIGHT_SHADOWS];\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nuniform sampler2D spotShadowMap[NUM_SPOT_LIGHT_SHADOWS];\nvarying vec4 vSpotShadowCoord[NUM_SPOT_LIGHT_SHADOWS];\nstruct SpotLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nint shadow;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform SpotLightShadow spotLightShadows[NUM_SPOT_LIGHT_SHADOWS];\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\nuniform sampler2D pointShadowMap[NUM_POINT_LIGHT_SHADOWS];\nvarying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];\nstruct PointLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform PointLightShadow pointLightShadows[NUM_POINT_LIGHT_SHADOWS];\n#endif\n#if NUM_RECT_AREA_LIGHT_SHADOWS > 0\nuniform sampler2D rectAreaShadowMap[NUM_RECT_AREA_LIGHT_SHADOWS];\nvarying vec4 vRectAreaShadowCoord[NUM_RECT_AREA_LIGHT_SHADOWS];\nstruct RectAreaLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform RectAreaLightShadow rectAreaLightShadows[NUM_RECT_AREA_LIGHT_SHADOWS];\n#endif\nconst vec3 PERMUTE_DIR_X = vec3(1.0, 0.0, 0.0);\nconst vec3 PERMUTE_DIR_Y = vec3(0.0, 1.0, 0.0);\nconst vec3 PERMUTE_DIR_Z = vec3(0.0, 0.0, 1.0);\nconst mat4 POISSON_DISK_0 = mat4(\n0.954845, 0.242214, -0.623893, -0.235473,\n-0.173288, 0.799228, 0.605969, -0.548050,\n-0.560406, 0.327647, -0.448307, -0.774344,\n0.308258, 0.417332, -0.125623, -0.056098\n);\nconst mat4 POISSON_DISK_1 = mat4(\n0.145585, -0.305634, 0.264060, -0.661648,\n0.617942, 0.652121, -0.041412, -0.893582,\n0.463911, 0.039752, 0.212664, 0.810727,\n-0.955989, -0.014390, -0.652588, 0.671204\n);\nfloat texture2DCompare(sampler2D depths, vec2 uv, float compare) {\nreturn step(compare, unpackRGBAToDepth(texture2D(depths, uv)));\n}\nvec2 texture2DDistribution(sampler2D shadow, vec2 uv) {\nreturn unpackRGBATo2Half(texture2D(shadow, uv));\n}\nfloat VSMShadow (sampler2D shadow, vec2 uv, float compare){\nfloat occlusion = 1.0;\nvec2 distribution = texture2DDistribution(shadow, uv);\nfloat hard_shadow = step(compare , distribution.x);\nif (hard_shadow != 1.0) {\nfloat distance = compare - distribution.x ;\nfloat variance = max(0.00000, distribution.y * distribution.y);\nfloat softness_probability = variance / (variance + distance * distance);\nsoftness_probability = clamp((softness_probability - 0.3) / (0.95 - 0.3), 0.0, 1.0);\nocclusion = clamp(max(hard_shadow, softness_probability), 0.0, 1.0);\n}\nreturn occlusion;\n}\nfloat texture2DShadowLerp(sampler2D depths, vec2 size, vec2 uv, float compare) {\nconst vec2 offset = vec2(0.0, 1.0);\nvec2 texelSize = vec2(1.0) / size;\nvec2 centroidUV = floor(uv * size + 0.5) / size;\nfloat lb = texture2DCompare(depths, centroidUV + texelSize * offset.xx, compare);\nfloat lt = texture2DCompare(depths, centroidUV + texelSize * offset.xy, compare);\nfloat rb = texture2DCompare(depths, centroidUV + texelSize * offset.yx, compare);\nfloat rt = texture2DCompare(depths, centroidUV + texelSize * offset.yy, compare);\nvec2 f = fract(uv * size + 0.5);\nfloat a = mix(lb, lt, f.y);\nfloat b = mix(rb, rt, f.y);\nfloat c = mix(a, b, f.x);\nreturn c;\n}\nvec2 cubeToUV(vec3 v, float texelSizeY) {\nvec3 absV = abs(v);\nfloat scaleToCube = 1.0 / max(absV.x, max(absV.y, absV.z));\nabsV *= scaleToCube;\nv *= scaleToCube * (1.0 - 2.0 * texelSizeY);\nvec2 planar = v.xy;\nfloat almostATexel = 1.5 * texelSizeY;\nfloat almostOne = 1.0 - almostATexel;\nif (absV.z >= almostOne) {\nif (v.z > 0.0)\nplanar.x = 4.0 - v.x;\n} else if (absV.x >= almostOne) {\nfloat signX = sign(v.x);\nplanar.x = v.z * signX + 2.0 * signX;\n} else if (absV.y >= almostOne) {\nfloat signY = sign(v.y);\nplanar.x = v.x + 2.0 * signY + 2.0;\nplanar.y = v.z * signY - 2.0;\n}\nreturn vec2(0.125, 0.25) * planar + vec2(0.375, 0.75);\n}\nfloat texture2DShadowAvgCube(sampler2D depths, vec2 size, vec3 bd3D, float compare) {\nvec2 texelSize = vec2(1.0) / size;\nvec3 dirX = normalize(abs(bd3D.y) < 0.99999 ? vec3(bd3D.z, 0.0, -bd3D.x)\n: vec3(0.0, -bd3D.z, bd3D.y));\nvec3 dirY = cross(bd3D, dirX);\nfloat theta = PI_HALF * texelSize.y;\nvec3 sX = sin(theta) * dirX;\nvec3 sY = sin(theta) * dirY;\nfloat cosT = cos(theta);\nvec3 sampleVec[4];\nsampleVec[0] = bd3D;\nsampleVec[1] = bd3D * cosT + sY;\nsampleVec[2] = bd3D * cosT + sX;\nsampleVec[3] = sampleVec[2] * cosT + sY;\nfloat avg = 0.0;\nfor (int i = 0; i < 4; i++) {\navg += texture2DCompare(depths, cubeToUV(sampleVec[i], texelSize.y), compare);\n}\navg /= 4.0;\nreturn avg;\n}\nfloat getShadow(sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord,\nfloat expBias, float distWorld) {\nfloat shadow = 1.0;\nshadowCoord.xyz /= shadowCoord.w;\nbvec4 inFrustumVec = bvec4 (shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0);\nbool inFrustum = all(inFrustumVec);\nbvec3 frustumTestVec = bvec3(inFrustum, shadowCoord.z <= 1.0, shadowCoord.z >= 0.0);\nbool frustumTest = all(frustumTestVec);\nif (frustumTest) {\n#if defined(SHADOWMAP_TYPE_BILINEAR)\nshadowCoord.z += shadowBias;\nshadow = texture2DShadowLerp(shadowMap, shadowMapSize,\nshadowCoord.xy, shadowCoord.z);\n#elif defined(SHADOWMAP_TYPE_PCF)\nshadowCoord.z += shadowBias;\nvec2 texelSize = vec2(1.0) / shadowMapSize;\nfloat dx0 = - texelSize.x * shadowRadius;\nfloat dy0 = - texelSize.y * shadowRadius;\nfloat dx1 = + texelSize.x * shadowRadius;\nfloat dy1 = + texelSize.y * shadowRadius;\nvec2 offsetVec[9];\noffsetVec[0] = vec2(dx0, dy0);\noffsetVec[1] = vec2(0.0, dy0);\noffsetVec[2] = vec2(dx1, dy0);\noffsetVec[3] = vec2(dx0, 0.0);\noffsetVec[4] = vec2(0.0);\noffsetVec[5] = vec2(dx1, 0.0);\noffsetVec[6] = vec2(dx0, dy1);\noffsetVec[7] = vec2(0.0, dy1);\noffsetVec[8] = vec2(dx1, dy1);\nshadow = 0.0;\nfor (int i = 0; i < 9; i++) {\nshadow += texture2DCompare(shadowMap, shadowCoord.xy + offsetVec[i], shadowCoord.z);\n}\nshadow /= 9.0;\n#elif defined(SHADOWMAP_TYPE_PCF_SOFT)\nshadowCoord.z += shadowBias;\nvec2 texelSize = vec2(1.0) / shadowMapSize;\nfloat dx0 = - texelSize.x * shadowRadius;\nfloat dy0 = - texelSize.y * shadowRadius;\nfloat dx1 = + texelSize.x * shadowRadius;\nfloat dy1 = + texelSize.y * shadowRadius;\nvec2 offsetVec[9];\noffsetVec[0] = vec2(dx0, dy0);\noffsetVec[1] = vec2(0.0, dy0);\noffsetVec[2] = vec2(dx1, dy0);\noffsetVec[3] = vec2(dx0, 0.0);\noffsetVec[4] = vec2(0.0);\noffsetVec[5] = vec2(dx1, 0.0);\noffsetVec[6] = vec2(dx0, dy1);\noffsetVec[7] = vec2(0.0, dy1);\noffsetVec[8] = vec2(dx1, dy1);\nshadow = 0.0;\nfor (int i = 0; i < 9; i++) {\nshadow += texture2DShadowLerp(shadowMap, shadowMapSize,\nshadowCoord.xy + offsetVec[i], shadowCoord.z);\n}\nshadow /= 9.0;\n#elif defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowCoord.z += shadowBias;\nvec2 texelSize = vec2(1.0) / shadowMapSize;\nfloat randAngle = rand(gl_FragCoord.xy) * PI2;\nfloat c = cos(randAngle), s = sin(randAngle);\nmat2 sampleMat = mat2(c, s, -s, c)\n* mat2(shadowRadius * texelSize.x, 0.0, 0.0, shadowRadius * texelSize.y);\nvec2 sampleVec[16];\nsampleVec[0] = POISSON_DISK_0[0].xy;\nsampleVec[1] = POISSON_DISK_0[0].zw;\nsampleVec[2] = POISSON_DISK_0[1].xy;\nsampleVec[3] = POISSON_DISK_0[1].zw;\nsampleVec[4] = POISSON_DISK_0[2].xy;\nsampleVec[5] = POISSON_DISK_0[2].zw;\nsampleVec[6] = POISSON_DISK_0[3].xy;\nsampleVec[7] = POISSON_DISK_0[3].zw;\nsampleVec[8] = POISSON_DISK_1[0].xy;\nsampleVec[9] = POISSON_DISK_1[0].zw;\nsampleVec[10] = POISSON_DISK_1[1].xy;\nsampleVec[11] = POISSON_DISK_1[1].zw;\nsampleVec[12] = POISSON_DISK_1[2].xy;\nsampleVec[13] = POISSON_DISK_1[2].zw;\nsampleVec[14] = POISSON_DISK_1[3].xy;\nsampleVec[15] = POISSON_DISK_1[3].zw;\nshadow = 0.0;\nfor (int i = 0; i < 16; i++) {\nshadow += texture2DCompare(shadowMap, shadowCoord.xy\n+ sampleMat * sampleVec[i], shadowCoord.z);\n}\nshadow /= 16.0;\n#elif defined(SHADOWMAP_TYPE_VSM)\nshadow = VSMShadow(shadowMap, shadowCoord.xy, shadowCoord.z);\n#elif defined(SHADOWMAP_TYPE_ESM)\nshadow = saturate(exp(expBias * (texture2D(shadowMap, shadowCoord.xy).x\n- length(distWorld) * ESM_DISTANCE_SCALE\n- ESM_BIAS_COEFF * shadowBias)));\n#else\nshadowCoord.z += shadowBias;\nshadow = texture2DCompare(shadowMap, shadowCoord.xy, shadowCoord.z);\n#endif\n}\nreturn shadow;\n}\nfloat getShadow(sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord) {\nreturn getShadow(shadowMap, shadowMapSize, shadowBias, shadowRadius, shadowCoord, 0.0, 0.0);\n}\nfloat getOmniShadow(sampler2D shadowMap, vec2 shadowMapSize, float shadowBias,\nfloat expBias, float shadowRadius, vec4 shadowCoord,\nfloat shadowCameraNear, float shadowCameraFar) {\nfloat shadow = 1.0;\nvec3 lightToPosition = shadowCoord.xyz;\nfloat dp = (length(lightToPosition) - shadowCameraNear)\n/ (shadowCameraFar - shadowCameraNear);\nbvec2 frustumTestVec = bvec2(dp <= 1.0, dp >= 0.0);\nbool frustumTest = all(frustumTestVec);\nif (frustumTest) {\nfloat biasScaleCoeff = BIAS_FRUSTUM_SCALE_COEFF\n/ (shadowCameraFar - shadowCameraNear);\ndp += shadowBias * biasScaleCoeff;\nvec3 bd3D = normalize(lightToPosition);\nvec2 texelSize = 1.0 / shadowMapSize;\n#if defined(SHADOWMAP_TYPE_BILINEAR)\nshadow = texture2DShadowAvgCube(shadowMap, shadowMapSize, bd3D, dp);\n#elif defined(SHADOWMAP_TYPE_ESM)\nshadow = saturate(exp(expBias * (texture2D(shadowMap,\ncubeVecToOctUV(bd3D, texelSize)).x\n- length(lightToPosition) * ESM_DISTANCE_SCALE\n- ESM_BIAS_COEFF * shadowBias)));\n#elif defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT)\nvec2 offset = vec2(-1, 1) * shadowRadius * texelSize.y;\nvec3 offsetVec[9];\noffsetVec[0] = offset.xyy;\noffsetVec[1] = offset.yyy;\noffsetVec[2] = offset.xyx;\noffsetVec[3] = offset.yyx;\noffsetVec[4] = vec3(0.0);\noffsetVec[5] = offset.xxy;\noffsetVec[6] = offset.yxy;\noffsetVec[7] = offset.xxx;\noffsetVec[8] = offset.yxx;\nshadow = 0.0;\nfor (int i = 0; i < 9; i++) {\nshadow += texture2DCompare(shadowMap, cubeToUV(bd3D + offsetVec[i], texelSize.y), dp);\n}\nshadow /= 9.0;\n#elif defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nfloat randAngle = rand(gl_FragCoord.xy) * PI2;\nfloat c = cos(randAngle), s = sin(randAngle);\nmat2 sampleMat = mat2(c, s, -s, c)\n* mat2(shadowRadius * texelSize.y, 0.0, 0.0, shadowRadius * texelSize.y);\nvec3 absBd3D = abs(bd3D);\nabsBd3D /= max(absBd3D.x, max(absBd3D.y, absBd3D.z));\nbvec2 isPointingCubeFace = greaterThan(absBd3D.xy, vec2(0.999));\nmat3 permuteMat = mat3(\nisPointingCubeFace.x ? PERMUTE_DIR_Y : PERMUTE_DIR_X,\nisPointingCubeFace.x || isPointingCubeFace.y ? PERMUTE_DIR_Z : PERMUTE_DIR_Y,\nisPointingCubeFace.x ? PERMUTE_DIR_X : isPointingCubeFace.y ? PERMUTE_DIR_Y : PERMUTE_DIR_Z\n);\nvec2 sampleVec[16];\nsampleVec[0] = POISSON_DISK_0[0].xy;\nsampleVec[1] = POISSON_DISK_0[0].zw;\nsampleVec[2] = POISSON_DISK_0[1].xy;\nsampleVec[3] = POISSON_DISK_0[1].zw;\nsampleVec[4] = POISSON_DISK_0[2].xy;\nsampleVec[5] = POISSON_DISK_0[2].zw;\nsampleVec[6] = POISSON_DISK_0[3].xy;\nsampleVec[7] = POISSON_DISK_0[3].zw;\nsampleVec[8] = POISSON_DISK_1[0].xy;\nsampleVec[9] = POISSON_DISK_1[0].zw;\nsampleVec[10] = POISSON_DISK_1[1].xy;\nsampleVec[11] = POISSON_DISK_1[1].zw;\nsampleVec[12] = POISSON_DISK_1[2].xy;\nsampleVec[13] = POISSON_DISK_1[2].zw;\nsampleVec[14] = POISSON_DISK_1[3].xy;\nsampleVec[15] = POISSON_DISK_1[3].zw;\nshadow = 0.0;\nfor (int i = 0; i < 16; i++) {\nshadow += texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * sampleVec[i], 0.0), texelSize.y), dp);\n}\nshadow /= 16.0;\n#else\nshadow = texture2DCompare(shadowMap, cubeToUV(bd3D, texelSize.y), dp);\n#endif\n}\nreturn shadow;\n}\n#if NUM_DIR_LIGHT_SHADOWS > 0\nfloat getDirShadow(DirectionalLightShadow light, sampler2D shadowMap,\nvec4 shadowCoord, float distWorld) {\nfloat shadowRadius = light.shadowRadius;\n#if defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT)\nshadowRadius *= PCF_PCF_SOFT_DIR_SPOT_BLUR_COEFF;\n#endif\nreturn getShadow(shadowMap, light.shadowMapSize, light.shadowBias, shadowRadius, shadowCoord, \nlight.expBias, distWorld);\n}\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\nfloat getPointShadow(PointLightShadow light, sampler2D shadowMap, vec4 shadowCoord) {\nfloat shadowRadius = light.shadowRadius;\nvec2 mapSize = light.shadowMapSize;\n#if defined(SHADOWMAP_TYPE_ESM)\nmapSize *= 2.0;\n#else\nmapSize *= vec2(4.0, 2.0);\n#if defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowRadius *= PCF_POISSON_POINT_BLUR_COEFF;\n#endif\n#endif\nreturn getOmniShadow(shadowMap, mapSize, light.shadowBias, light.expBias,\nshadowRadius, shadowCoord, light.shadowCameraNear,\nlight.shadowCameraFar);\n}\n#endif\n#if NUM_RECT_AREA_LIGHT_SHADOWS > 0\nfloat getRectAreaShadow(RectAreaLightShadow light, sampler2D shadowMap, vec4 shadowCoord) {\nfloat shadowRadius = light.shadowRadius;\nvec2 mapSize = light.shadowMapSize;\n#if defined(SHADOWMAP_TYPE_ESM)\nmapSize *= 2.0;\n#else\nmapSize *= vec2(4.0, 2.0);\n#if defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowRadius *= PCF_POISSON_POINT_BLUR_COEFF;\n#endif\n#endif\nreturn getOmniShadow(shadowMap, mapSize, light.shadowBias, light.expBias,\nshadowRadius, shadowCoord, light.shadowCameraNear,\nlight.shadowCameraFar);\n}\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nfloat getSpotOmniShadow(SpotLightShadow light, sampler2D shadowMap, vec4 shadowCoord) {\nfloat shadowRadius = light.shadowRadius;\nvec2 mapSize = light.shadowMapSize;\n#if defined(SHADOWMAP_TYPE_ESM)\n#else\nmapSize *= vec2(4.0, 2.0);\n#if defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowRadius *= PCF_POISSON_SPOT_OMNI_BLUR_COEFF;\n#endif\n#endif\nreturn getOmniShadow(shadowMap, mapSize, light.shadowBias, light.expBias,\nshadowRadius, shadowCoord, light.shadowCameraNear,\nlight.shadowCameraFar);\n}\nfloat biasLinearNormalizedToNonlinear(float bias, float near, float far,\nfloat projZ, float projW) {\nreturn (bias * (far + near) + 2.0 * projZ) / (bias * (far - near) + 2.0 * projW)\n- projZ / projW;\n}\nfloat getSpotShadow(SpotLightShadow light, sampler2D shadowMap, vec4 shadowCoord,\nfloat distWorld) {\nfloat shadowRadius = light.shadowRadius;\nfloat shadowBias = light.shadowBias;\n#if defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT)\nshadowRadius *= PCF_PCF_SOFT_DIR_SPOT_BLUR_COEFF;\n#elif defined(SHADOWMAP_TYPE_ESM)\nshadowRadius *= ESM_SPOT_SINGLE_BLUR_COEFF;\n#endif\nshadowBias *= BIAS_FRUSTUM_SCALE_COEFF\n/ (light.shadowCameraFar - light.shadowCameraNear);\n#if defined(SHADOWMAP_TYPE_BASIC) || defined(SHADOWMAP_TYPE_BILINEAR) || defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT) || defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowBias = biasLinearNormalizedToNonlinear(shadowBias,\nlight.shadowCameraNear, light.shadowCameraFar, shadowCoord.z,\nshadowCoord.w);\n#endif\nreturn getShadow(shadowMap, light.shadowMapSize, shadowBias, shadowRadius, shadowCoord,\nlight.expBias, distWorld);\n}\n#endif\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS > 0\nuniform mat4 directionalShadowMatrix[NUM_DIR_LIGHT_SHADOWS];\nvarying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];\nstruct DirectionalLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nvec3 position;\nfloat shadowCameraNear;\nfloat maxDistance;\nfloat expBias;\n};\nuniform DirectionalLightShadow directionalLightShadows[NUM_DIR_LIGHT_SHADOWS];\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nuniform mat4 spotShadowMatrix[NUM_SPOT_LIGHT_SHADOWS];\nvarying vec4 vSpotShadowCoord[NUM_SPOT_LIGHT_SHADOWS];\nstruct SpotLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nint shadow;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform SpotLightShadow spotLightShadows[NUM_SPOT_LIGHT_SHADOWS];\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\nuniform mat4 pointShadowMatrix[NUM_POINT_LIGHT_SHADOWS];\nvarying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];\nstruct PointLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform PointLightShadow pointLightShadows[NUM_POINT_LIGHT_SHADOWS];\n#endif\n#if NUM_RECT_AREA_LIGHT_SHADOWS > 0\nuniform mat4 rectAreaShadowMatrix[NUM_RECT_AREA_LIGHT_SHADOWS];\nvarying vec4 vRectAreaShadowCoord[NUM_RECT_AREA_LIGHT_SHADOWS];\nstruct RectAreaLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform RectAreaLightShadow rectAreaLightShadows[NUM_RECT_AREA_LIGHT_SHADOWS];\n#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 || NUM_RECT_AREA_LIGHT_SHADOWS > 0\nvec3 shadowWorldNormal = inverseTransformDirection(transformedNormal, viewMatrix);\nvec4 shadowWorldPosition;\n#endif\n#if NUM_DIR_LIGHT_SHADOWS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i++) {\nshadowWorldPosition = worldPosition + vec4(shadowWorldNormal * directionalLightShadows[i].shadowNormalBias, 0);\nvDirectionalShadowCoord[i] = directionalShadowMatrix[i] * shadowWorldPosition;\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i++) {\nshadowWorldPosition = worldPosition + vec4(shadowWorldNormal * spotLightShadows[i].shadowNormalBias, 0);\nvSpotShadowCoord[i] = spotShadowMatrix[i] * shadowWorldPosition;\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i++) {\nshadowWorldPosition = worldPosition + vec4(shadowWorldNormal * pointLightShadows[i].shadowNormalBias, 0);\nvPointShadowCoord[i] = pointShadowMatrix[i] * shadowWorldPosition;\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_RECT_AREA_LIGHT_SHADOWS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_RECT_AREA_LIGHT_SHADOWS; i++) {\nshadowWorldPosition = worldPosition + vec4(shadowWorldNormal * rectAreaLightShadows[i].shadowNormalBias, 0);\nvRectAreaShadowCoord[i] = rectAreaShadowMatrix[i] * shadowWorldPosition;\n}\n#pragma unroll_loop_end\n#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\nfloat shadow = 1.0;\n#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS > 0\nDirectionalLightShadow directionalLight;\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i++) {\ndirectionalLight = directionalLightShadows[i];\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(directionalLight.position\n- directionalLight.direction * directionalLight.shadowCameraNear\n+ vViewPosition, 0.0)).xyz);\n#endif\nshadow *= all(bvec2(vViewPosition.z < directionalLight.maxDistance,\nreceiveShadow)) ? getDirShadow(directionalLight,\ndirectionalShadowMap[i], vDirectionalShadowCoord[i], distWorld)\n: 1.0;\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nSpotLightShadow spotLight;\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i++) {\nspotLight = spotLightShadows[i];\nif (receiveShadow) {\nif (spotLight.shadow == 1) {\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(spotLight.position\n+ vViewPosition, 0.0)).xyz);\n#endif\nshadow *= getSpotShadow(spotLight, spotShadowMap[i], vSpotShadowCoord[i],\ndistWorld);\n} else if (spotLight.shadow == 2) {\nshadow *= getSpotOmniShadow(spotLight, spotShadowMap[i],\nvSpotShadowCoord[i]);\n}\n}\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\nPointLightShadow pointLight;\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i++) {\npointLight = pointLightShadows[i];\nshadow *= receiveShadow ? getPointShadow(pointLight, pointShadowMap[i], vPointShadowCoord[i]) : 1.0;\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_RECT_AREA_LIGHT_SHADOWS > 0\nRectAreaLightShadow rectAreaLight;\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_RECT_AREA_LIGHT_SHADOWS; i++) {\nrectAreaLight = rectAreaLightShadows[i];\nshadow *= receiveShadow ? getRectAreaShadow(rectAreaLight, rectAreaShadowMap[i], vRectAreaShadowCoord[i]) : 1.0;\n}\n#pragma unroll_loop_end\n#endif\n#endif\nreturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\nmat4 boneMatX = getBoneMatrix(skinIndex.x);\nmat4 boneMatY = getBoneMatrix(skinIndex.y);\nmat4 boneMatZ = getBoneMatrix(skinIndex.z);\nmat4 boneMatW = getBoneMatrix(skinIndex.w);\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 bindMatrix;\nuniform mat4 bindMatrixInverse;\n#ifdef BONE_TEXTURE\nuniform highp sampler2D boneTexture;\nuniform int boneTextureSize;\nmat4 getBoneMatrix(const in float i) {\nfloat j = i * 4.0;\nfloat x = mod(j, float(boneTextureSize));\nfloat y = floor(j / float(boneTextureSize));\nfloat dx = 1.0 / float(boneTextureSize);\nfloat dy = 1.0 / float(boneTextureSize);\ny = dy * (y + 0.5);\nvec4 v1 = texture2D(boneTexture, vec2(dx * (x + 0.5), y));\nvec4 v2 = texture2D(boneTexture, vec2(dx * (x + 1.5), y));\nvec4 v3 = texture2D(boneTexture, vec2(dx * (x + 2.5), y));\nvec4 v4 = texture2D(boneTexture, vec2(dx * (x + 3.5), y));\nmat4 bone = mat4(v1, v2, v3, v4);\nreturn bone;\n}\n#else\nuniform mat4 boneMatrices[MAX_BONES];\nmat4 getBoneMatrix(const in float i) {\nmat4 bone = boneMatrices[int(i)];\nreturn bone;\n}\n#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\nvec4 skinVertex = bindMatrix * vec4(transformed, 1.0);\nvec4 skinned = vec4(0.0);\nskinned += boneMatX * skinVertex * skinWeight.x;\nskinned += boneMatY * skinVertex * skinWeight.y;\nskinned += boneMatZ * skinVertex * skinWeight.z;\nskinned += boneMatW * skinVertex * skinWeight.w;\ntransformed = (bindMatrixInverse * skinned).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\nmat4 skinMatrix = mat4(0.0);\nskinMatrix += skinWeight.x * boneMatX;\nskinMatrix += skinWeight.y * boneMatY;\nskinMatrix += skinWeight.z * boneMatZ;\nskinMatrix += skinWeight.w * boneMatW;\nskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\nobjectNormal = vec4(skinMatrix * vec4(objectNormal, 0.0)).xyz;\n#ifdef USE_TANGENT\nobjectTangent = vec4(skinMatrix * vec4(objectTangent, 0.0)).xyz;\n#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\nvec4 texelSpecular = texture2D(specularMap, vUv);\nspecularStrength = texelSpecular.r;\n#else\nspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\nuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined(TONE_MAPPING)\ngl_FragColor.rgb = toneMapping(gl_FragColor.rgb);\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp(a, 0.0, 1.0)\n#endif\n#ifndef PI\n#define PI 3.14159265359\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\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;\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;\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;\nfloat filmISO = toneMappingISO;\nfloat camShutter = 1.0 / toneMappingShutter;\nfloat fNumber = toneMappingAperture;\nfloat cm2 = 1.0;\nfloat burnHighlights = toneMappingHighlights;\nfloat crushBlacks = toneMappingShadows;\nfloat saturation = toneMappingSaturation;\nvec3 whitePointInfluence = toneMappingWhiteBalance;\nif (whitePointInfluence.r > 0.0) {\nwhitePointInfluence.r = 1.0 / whitePointInfluence.r;\n} else {\nwhitePointInfluence.r = 1.0;\n}\nif (whitePointInfluence.g > 0.0) {\nwhitePointInfluence.g = 1.0 / whitePointInfluence.g;\n} else {\nwhitePointInfluence.g = 1.0;\n}\nif (whitePointInfluence.b > 0.0) {\nwhitePointInfluence.b = 1.0 / whitePointInfluence.b;\n} else {\nwhitePointInfluence.b = 1.0;\n}\nvec4 lumFactor = vec4(0.212671, 0.715160, 0.072169, 0.0);\nfloat whiteLumFactor = maxExposurePhotographic(lumFactor, vec4(whitePointInfluence, 0.0));\nwhitePointInfluence.r /= whiteLumFactor;\nwhitePointInfluence.g /= whiteLumFactor;\nwhitePointInfluence.b /= whiteLumFactor;\nfloat isoInfluence = 0.0;\nfloat camShutterInv = 1.0 / camShutter;\nif (filmISO > 0.0) {\nisoInfluence = ((cm2 * 0.169811) * (filmISO * camShutterInv)) / ((15.4 * fNumber) * fNumber);\n} else {\nisoInfluence = cm2;\n}\nvec3 outColor = inputScaleFactor * color;\noutColor.r = outColor.r * whitePointInfluence.r * isoInfluence * vignettingInfluence;\noutColor.g = outColor.g * whitePointInfluence.g * isoInfluence * vignettingInfluence;\noutColor.b = outColor.b * whitePointInfluence.b * isoInfluence * vignettingInfluence;\noutColor.r = (outColor.r * (1.0 + (outColor.r * burnHighlights))) / (1.0 + outColor.r);\noutColor.g = (outColor.g * (1.0 + (outColor.g * burnHighlights))) / (1.0 + outColor.g);\noutColor.b = (outColor.b * (1.0 + (outColor.b * burnHighlights))) / (1.0 + outColor.b);\nfloat lumFactor2 = maxExposurePhotographic(lumFactor, vec4(outColor, 0.0));\nfloat tmpFloat = 1.0 - saturation;\noutColor.r = outColor.r * saturation + lumFactor2 * tmpFloat;\noutColor.g = outColor.g * saturation + lumFactor2 * tmpFloat;\noutColor.b = outColor.b * saturation + lumFactor2 * tmpFloat;\noutColor = max(vec3(0.0), outColor);\nfloat crushBlacksFac = crushBlacks * 2.0 + 1.0;\nfloat crushBlacksFac2 = pow(maxExposurePhotographic(lumFactor, vec4(outColor, 0.0)), 0.5);\ntmpFloat = (1.0 - crushBlacksFac2);\nif (crushBlacksFac2 < 1.0) {\noutColor.r = outColor.r * crushBlacksFac2 + pow(outColor.r, crushBlacksFac) * tmpFloat;\noutColor.g = outColor.g * crushBlacksFac2 + pow(outColor.g, crushBlacksFac) * tmpFloat;\noutColor.b = outColor.b * crushBlacksFac2 + pow(outColor.b, crushBlacksFac) * tmpFloat;\n}\nreturn outColor;\n}\nfloat filmicBlenderDesaturationMinIntensity(vec3 color) {\nfloat maxChannel = max(color.r, max(color.g, color.b));\nfloat x = max(maxChannel, 0.6251);\nreturn (1.2192868 * x - 0.63221059)\n* ((x - 0.65069831) / (abs(x - 0.65069831) + 0.00952982) + 0.73015231);\n}\nvec3 filmicBlenderDesaturationTransform(vec3 color) {\nconst float CURVE_SMOOTHNESS = 0.03;\nfloat minIntensity = filmicBlenderDesaturationMinIntensity(color);\nvec4 x = vec4(color, 1.0) - minIntensity;\nx = pow(x, vec4(2.0)) / (abs(x) + CURVE_SMOOTHNESS);\nreturn (x.rgb - x.a + color + 1.0) / 2.0;\n}\nvec3 filmicBlenderDynamicRangeTransform(vec3 color) {\nreturn pow(\n(0.28882259 * color - 0.15880336)\n/ (pow(color - 0.6229693, vec3(2.0)) + 0.16965022)\n+ 0.20453365 * color + 0.37847142,\nvec3(3.0)\n);\n}\nvec3 FilmicBlenderToneMapping(vec3 color) {\ncolor *= toneMappingExposure;\ncolor = max(color, 0.000175);\ncolor = clamp((log2(color) - FILMIC_BLENDER_LOG_MIN)\n/ (FILMIC_BLENDER_LOG_MAX - FILMIC_BLENDER_LOG_MIN), 0.0, 1.0);\ncolor = filmicBlenderDesaturationTransform(color);\ncolor = clamp(color / FILMIC_BLENDER_EXPOSURE_LATITUDE_RATIO, 0.0, 1.0);\ncolor = filmicBlenderDynamicRangeTransform(color);\nreturn color;\n}",transmission_fragment:"#ifdef USE_TRANSMISSION\nfloat transmissionFactor = transmission;\nfloat thicknessFactor = thickness;\n#ifdef USE_TRANSMISSIONMAP\ntransmissionFactor *= texture2D(transmissionMap, vUv).r;\n#endif\n#ifdef USE_THICKNESSNMAP\nthicknessFactor *= texture2D(thicknessMap, vUv).g;\n#endif\nvec3 pos = vWorldPosition.xyz / vWorldPosition.w;\nvec3 v = normalize(cameraPosition - pos);\nfloat ior = (1.0 + 0.4 * reflectivity) / (1.0 - 0.4 * reflectivity);\nvec3 transmission = transmissionFactor * getIBLVolumeRefraction(\nnormal, v, roughnessFactor, material.diffuseColor, totalSpecular,\npos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\nattenuationColor, attenuationDistance);\ntotalDiffuse = mix(totalDiffuse, transmission, transmissionFactor);\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\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 vec4 vWorldPosition;\nvec3 getVolumeTransmissionRay(vec3 n, vec3 v, float thickness, float ior, 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(float roughness, float ior) {\nreturn roughness * clamp(ior * 2.0 - 2.0, 0.0, 1.0);\n}\nvec3 getTransmissionSample(vec2 fragCoord, float roughness, float ior) {\nfloat framebufferLod = log2(transmissionSamplerSize.x) * applyIorToRoughness(roughness, ior);\nreturn texture2DLodEXT(transmissionSamplerMap, fragCoord.xy, framebufferLod).rgb;\n}\nvec3 applyVolumeAttenuation(vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance) {\nif (attenuationDistance == 0.0) {\nreturn radiance;\n} else {\nvec3 attenuationCoefficient = -log(attenuationColor) / attenuationDistance;\nvec3 transmittance = exp(-attenuationCoefficient * transmissionDistance);\nreturn transmittance * radiance;\n}\n}\nvec3 getIBLVolumeRefraction(vec3 n, vec3 v, float perceptualRoughness, vec3 baseColor, vec3 specularColor,\nvec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,\nvec3 attenuationColor, 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;\nvec3 transmittedLight = getTransmissionSample(refractionCoords, perceptualRoughness, ior);\nvec3 attenuatedColor = applyVolumeAttenuation(transmittedLight, length(transmissionRay), attenuationColor, attenuationDistance);\nreturn (1.0 - specularColor) * attenuatedColor * baseColor;\n}\n#endif",uv_pars_fragment:"#if (defined(USE_UV) && !defined(UVS_VERTEX_ONLY))\nvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n#ifdef UVS_VERTEX_ONLY\nvec2 vUv;\n#else\nvarying vec2 vUv;\n#endif\nuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\nvUv = (uvTransform * vec3(uv, 1)).xy;\n#endif",uv2_pars_fragment:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\nvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\nattribute vec2 uv2;\nvarying vec2 vUv2;\nuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\nvUv2 = (uv2Transform * vec3(uv2, 1)).xy;\n#endif",worldpos_vertex:"#if defined(USE_ENVMAP) || defined(DISTANCE) || defined (USE_SHADOWMAP) || defined (USE_TRANSMISSION) || defined(MASK) || defined(NODE)\nvec4 worldPosition = vec4(transformed, 1.0);\n#ifdef USE_INSTANCING\nworldPosition = instanceMatrix * worldPosition;\n#endif\nworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\nvec4 texColor = texture2D(t2D, vUv);\ngl_FragColor = mapTexelToLinear(texColor);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n}",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}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\nvec3 vReflect = vWorldDirection;\n#include <envmap_fragment>\ngl_FragColor = envColor;\ngl_FragColor.a *= opacity;\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}",depth_frag:"#define DEPTH\nvarying vec3 vViewPosition;\nvarying vec2 vProjectedPosZW;\n#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 <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\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}",depth_vert:"#define DEPTH\nvarying vec3 vViewPosition;\nvarying vec2 vProjectedPosZW;\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>\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}",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 <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}",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}",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;\n\nif (invertU) {\nsampleUV.x = 1.0 - sampleUV.x;\n}\n\nsampleUV.x += offsetU;\nvec4 texColor = texture2D(tEquirect, sampleUV);\ngl_FragColor = mapTexelToLinear(texColor);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\nvWorldDirection = transformDirection(position, modelMatrix);\n#include <begin_vertex>\n#include <project_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;\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_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 <begin_vertex>\n#include <morphtarget_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_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 <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_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\n\nvec4 lightMapTexel= texture2D(lightMap, vUv2);\nreflectedLight.indirectDiffuse += lightMapTexelToLinear(lightMapTexel).rgb * lightMapIntensity;\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>\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_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 <skinbase_vertex>\n#ifdef USE_ENVMAP\n#include <beginnormal_vertex>\n#include <morphnormal_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 <worldpos_vertex>\n#include <clipping_planes_vertex>\n#include <envmap_vertex>\n#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\nvarying vec3 vIndirectBack;\n#endif\nvarying vec3 vViewPosition;\n#ifdef SHADOWMAP_TYPE_ESM\nuniform mat4 invViewMatrix;\n#endif\n#include <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 <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 <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_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 <emissivemap_fragment>\n#ifdef DOUBLE_SIDED\nreflectedLight.indirectDiffuse += (gl_FrontFacing) ? vIndirectFront : vIndirectBack;\n#else\nreflectedLight.indirectDiffuse += vIndirectFront;\n#endif\n#include <lightmap_fragment>\nreflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert(diffuseColor.rgb);\n#ifdef DOUBLE_SIDED\nreflectedLight.directDiffuse = (gl_FrontFacing) ? vLightFront : vLightBack;\n#else\nreflectedLight.directDiffuse = vLightFront;\n#endif\nreflectedLight.directDiffuse *= BRDF_Diffuse_Lambert(diffuseColor.rgb) * getShadowMask();\n#include <aomap_fragment>\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n#include <envmap_fragment>\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\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 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\nvarying vec3 vIndirectBack;\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_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>\nvoid main() {\n#include <uv_vertex>\n#include <uv2_vertex>\n#include <color_vertex>\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 <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\nvViewPosition = - mvPosition.xyz;\n#include <worldpos_vertex>\n#include <envmap_vertex>\n#include <lights_lambert_vertex>\n#include <shadowmap_vertex>\n#include <fog_vertex>\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\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 <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_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);\nmatcapColor = matcapTexelToLinear(matcapColor);\n#else\nvec4 matcapColor = vec4(1.0);\n#endif\nvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\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#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\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 <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 <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 <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <fog_vertex>\nvViewPosition = - mvPosition.xyz;\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 <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 <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;\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\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 <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 <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 <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\nvViewPosition = - mvPosition.xyz;\n#include <worldpos_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#ifdef SHADOWMAP_TYPE_ESM\nuniform mat4 invViewMatrix;\n#endif\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 <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 <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\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>\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\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 <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 <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 <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}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n#define REFLECTIVITY\n#define CLEARCOAT\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef USE_TRANSMISSION\nuniform float transmission;\nuniform float thickness;\nuniform vec3 attenuationColor;\nuniform float attenuationDistance;\n#endif\n#ifdef REFLECTIVITY\nuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\nuniform float clearcoat;\nuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nuniform vec3 sheen;\n#endif\n#if defined(SHADOWMAP_TYPE_ESM) || defined(USE_ENVMAP)\nuniform mat4 invViewMatrix;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;\nvarying vec3 vBitangent;\n#endif\n#endif\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 <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <transmission_pars_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 <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_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>\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;\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\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#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;\nvarying vec3 vBitangent;\n#endif\n#endif\n#ifdef USE_TRANSMISSION\nvarying vec4 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 <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 <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#ifdef USE_TANGENT\nvTangent = normalize(transformedTangent);\nvBitangent = normalize(cross(vNormal, vTangent) * tangent.w);\n#endif\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#ifdef USE_TRANSMISSION\nvWorldPosition = worldPosition;\n#endif\n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || defined(TANGENTSPACE_NORMALMAP)\nvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;\nvarying vec3 vBitangent;\n#endif\n#endif\n#include <packing>\n#include <uv_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}",normal_vert:"#define NORMAL\n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || defined(TANGENTSPACE_NORMALMAP)\nvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;\nvarying vec3 vBitangent;\n#endif\n#endif\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>\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#ifndef FLAT_SHADED\nvNormal = normalize(transformedNormal);\n#ifdef USE_TANGENT\nvTangent = normalize(transformedTangent);\nvBitangent = normalize(cross(vNormal, vTangent) * tangent.w);\n#endif\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>\n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || defined(TANGENTSPACE_NORMALMAP)\nvViewPosition = - mvPosition.xyz;\n#endif\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 <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;\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_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 <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}",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}",shadow_vert:"#include <common>\n#ifdef USE_SHADOWMAP\nvarying vec3 vViewPosition;\n#endif\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n#include <begin_vertex>\n#include <project_vertex>\n#include <worldpos_vertex>\n#ifdef USE_SHADOWMAP\nvViewPosition = - mvPosition.xyz;\n#endif\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#include <shadowmap_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 <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;\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);\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}",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}\n\nsampleUV.x += offsetU;\ngl_FragColor = texture2D(tEquirect, sampleUV);\n}",equicube_vert:"varying vec2 vUv;\n#include <common>\nvoid main() {\nvUv = uv;\n#include <begin_vertex>\n#include <project_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 mat4 projectionMatrix;\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 (isOrtho(projectionMatrix))\nviewZ = -orthographicDepthToViewZ(depth,\ncameraNearFar.x, cameraNearFar.y);\nelse\nviewZ = -perspectiveDepthToViewZ(depth,\ncameraNearFar.x, cameraNearFar.y);\nfloat depthTest = (vViewPosition.z > viewZ) ? 1.0 : 0.0;\ngl_FragColor = vec4(0.0, depthTest, 1.0, 0.0);\n}",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}",meshnode_frag:"#define NODE\n#include <common>\n#include <packing>\n#include <dithering_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(NODE_NEW_GEOMETRY_BL) || defined(NODE_LAYER_WEIGHT_BL) || defined(NODE_FRESNEL_BL) || defined(NODE_BSDF_GLASS_BL) || defined(NODE_BSDF_PRINCIPLED_BL) || defined(USE_SSR) || (defined(NODE_NORMAL) && defined(MT_BLENDER)) || defined(USE_OSL)\nuniform mat4 projectionMatrix;\n#endif\n#if defined(NODE_VECT_TRANSFORM_BL) || defined(NODE_TEX_COORD_BL) || defined(NODE_NEW_GEOMETRY_BL) || defined(NODE_TANGENT_BL) || defined(NODE_OBJECT_INFO_BL) || defined(NODE_BITMAP_MX) || defined(NODE_GRADIENT_RAMP_MX) || defined(NODE_NOISE_MX) || defined(NODE_SAMPLER_INFO_MY) || defined(NODE_TRANSFORM_MY) || defined(USE_OSL)\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>\nvoid main() {\nbool _frontFacingValue = gl_FrontFacing;\n#define FRONT_FACING_VALUE _frontFacingValue\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 ALPHATEST\nif (outgoingLight.a < ALPHATEST)\ndiscard;\nelse\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}",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}",lights_node_pars_fragment:"\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\nstruct NodeMaterial {\nvec3 diffuseColor;\nvec3 specularColor;\nvec3 refractionColor;\nfloat refractionRoughness;\nfloat refractionIOR;\n#ifdef CLEARCOAT\nfloat clearcoat;\nfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nvec3 sheenColor;\nfloat sheenRoughness;\n#endif\n#ifdef PHYSICAL\nvec3 fresnelRefl90;\nfloat specularRoughness;\n#else\nfloat diffuseIntensity;\nfloat specularIntensity;\nfloat specularHardness;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\n#define BLENDER_SPECULAR_COEFFICIENT 0.08\nfloat shadeSpecPhong(vec3 normal, vec3 lightDir, vec3 viewDir, float hard)\n{\nfloat specFac;\nvec3 h = normalize(lightDir + viewDir);\nfloat rslt = max(dot(h, normal), 0.0);\nspecFac = pow(rslt, hard);\nreturn specFac;\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.specularRoughness;\nvec3 rectCoords[4];\nrectCoords[0] = lightPos + halfWidth - halfHeight;\nrectCoords[1] = lightPos - halfWidth - halfHeight;\nrectCoords[2] = lightPos - halfWidth + halfHeight;\nrectCoords[3] = lightPos + halfWidth + halfHeight;\nvec2 uv = LTC_Uv(normal, viewDir, roughness);\nvec4 t1 = texture2D(ltc_1, uv);\nvec4 t2 = texture2D(ltc_2, uv);\nmat3 mInv = mat3(\nvec3(t1.x, 0, t1.y),\nvec3( 0, 1, 0),\nvec3(t1.z, 0, t1.w)\n);\nvec3 fresnel = (material.specularColor * t2.x + (vec3(1.0) - material.specularColor) * t2.y);\nreflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate(normal, viewDir, position, mInv, rectCoords);\nreflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate(normal, viewDir, position, mat3(1.0), rectCoords);\n}\n#endif\nvoid RE_DirectDiffuse_Node(const in IncidentLight directLight,\nconst in GeometricContext geometry, const in NodeMaterial material,\ninout ReflectedLight reflectedLight) {\nfloat dotNL = saturate(dot(geometry.normal, directLight.direction));\nvec3 irradiance = dotNL * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\n#ifdef PHYSICAL\n#ifdef CLEARCOAT\nfloat ccDotNL = saturate(dot(geometry.clearcoatNormal, directLight.direction));\nfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox(material.clearcoatRoughness, ccDotNL);\n#else\nfloat clearcoatDHR = 0.0;\n#endif\nreflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance\n* BRDF_Diffuse_Lambert(material.diffuseColor);\n#else\nreflectedLight.directDiffuse += irradiance * material.diffuseIntensity\n* BRDF_Diffuse_Lambert(material.diffuseColor);\n#endif\n}\nvoid RE_DirectSpecular_Node(const in IncidentLight directLight,\nconst in GeometricContext geometry, const in NodeMaterial material,\ninout ReflectedLight reflectedLight) {\nfloat dotNL = saturate(dot(geometry.normal, directLight.direction));\nvec3 irradiance = dotNL * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\n#ifdef PHYSICAL\n#ifdef CLEARCOAT\nfloat ccDotNL = saturate(dot(geometry.clearcoatNormal, directLight.direction));\nvec3 ccIrradiance = ccDotNL * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nccIrradiance *= PI;\n#endif\n#endif\n#ifdef CLEARCOAT\nfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox(material.clearcoatRoughness, ccDotNL);\n#else\nfloat clearcoatDHR = 0.0;\n#endif\nreflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance\n* BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.normal,\nmaterial.specularColor, material.specularRoughness);\n#ifdef CLEARCOAT\nreflectedLight.directSpecular += ccIrradiance * material.clearcoat\n* BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.clearcoatNormal,\nvec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\n#endif\n#ifdef USE_SHEEN\nreflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_Sheen(\nmaterial.sheenRoughness,\ndirectLight.direction,\ngeometry,\nmaterial.sheenColor\n);\n#endif\n#else\nreflectedLight.directSpecular += material.specularIntensity *\nshadeSpecPhong(geometry.normal, directLight.direction,\ngeometry.viewDir, material.specularHardness) *\ndirectLight.color * material.specularColor;\n#endif\n}\nvoid RE_IndirectDiffuse_Node(const in vec3 irradiance, const in vec3 iblIrradiance,\nconst in GeometricContext geometry, const in NodeMaterial material,\ninout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += (irradiance + iblIrradiance)\n* BRDF_Diffuse_Lambert(material.diffuseColor);\n}\nvoid RE_IndirectSpecular_Node(const in vec3 radiance, const in vec3 irradiance,\nconst in vec3 clearcoatRadiance, const in GeometricContext geometry,\nconst in NodeMaterial material, inout ReflectedLight reflectedLight) {\n#ifdef PHYSICAL\n#ifdef CLEARCOAT\nfloat ccDotNL = saturate(dot(geometry.clearcoatNormal, geometry.viewDir));\nfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox(\nmaterial.clearcoatRoughness, ccDotNL);\n#else\nfloat clearcoatDHR = 0.0;\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.specularRoughness, 0);\n#else\nvec3 specEnv = BRDF_Specular_GGX_Environment(geometry.viewDir,\ngeometry.normal, material.specularColor,\nmaterial.specularRoughness);\n#endif\n#elif defined(MT_MAX)\nfloat alphaEnv = pow2(pow2(material.specularRoughness));\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.specularRoughness);\n#else\nvec3 specEnv = vec3(1.0);\n#endif\nreflectedLight.indirectSpecular += (1.0 - clearcoatDHR) * radiance * specEnv;\n#ifdef CLEARCOAT\n#ifdef MT_BLENDER\nvec3 specEnvCC = BRDF_Specular_GGX_Environment(geometry.viewDir, geometry.clearcoatNormal, vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\n#elif defined(MT_MAX) || defined(MT_MAYA)\nvec3 specEnvCC = BRDF_Specular_GGX_Environment(geometry.viewDir, geometry.clearcoatNormal, vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\n#else\nvec3 specEnvCC = vec3(1.0);\n#endif\nreflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * specEnvCC;\n#endif\n#endif\n}\nvoid RE_Refraction_Node(const vec3 refraction, const NodeMaterial material,\ninout vec3 refractedLight) {\nrefractedLight += refraction * material.refractionColor;\n}\n#ifdef MT_BLENDER\n#define Material_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.specularRoughness)\n#define Material_Refraction_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.refractionRoughness)\n#elif defined(MT_MAX)\n#define Material_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.specularRoughness * exp(0.35*(1.0-pow2(material.specularRoughness))))\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.specularRoughness)\n#define Material_Refraction_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.refractionRoughness)\n#endif\n#define Material_ClearCoat_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.clearcoatRoughness)\nfloat computeSpecularOcclusion(const in float dotNV, const in float ambientOcclusion, const in float roughness) {\nreturn saturate(pow(abs(dotNV + ambientOcclusion), exp2(- 16.0 * roughness - 1.0)) - 1.0 + ambientOcclusion);\n}\n#define RE_Direct_RectArea RE_Direct_RectArea_Node",lights_node_gtao_pars_fragment:"#ifdef USE_GTAO\nuniform sampler2D gtaoMap;\nuniform vec2 currResolution;\nfloat calcGTAOVisibilityFix(vec3 viewDir, vec3 normal) {\nfloat slopeCoeff = saturate(dot(viewDir, normal));\nreturn pow(2.0 / (slopeCoeff + 1.0), log2(PI) - 1.0);\n}\nfloat calcSolidAngle(float radiusAngle) {\nreturn PI2 * (1.0 - cos(radiusAngle));\n}\nfloat calcSolidAnglesIntersectionApprox(float radiusAngle0, float radiusAngle1,\nfloat distanceAngle) {\nfloat rp = radiusAngle0, rl = radiusAngle1, d = distanceAngle;\nfloat rDiff = abs(rp - rl);\nreturn PI2 * (1.0 - cos(min(rp, rl))) * smoothstep(0.0, 1.0, 1.0 -\n(d - rDiff) / (rp + rl - rDiff));\n}\nfloat calcGTSOVisibility(float aoVisibility, vec3 bentNormal, vec3 viewDir, vec3 normal,\nfloat roughness) {\naoVisibility = saturate(aoVisibility * calcGTAOVisibilityFix(viewDir, normal));\nfloat radiusAngleVisCone = acos(clamp(sqrt(1.0 - aoVisibility), -1.0, 1.0));\nfloat radiusAngleSpecCone = acos(clamp(exp2(-3.32193 * pow2(roughness)), -1.0, 1.0));\nradiusAngleSpecCone = max(0.001, radiusAngleSpecCone);\nvec3 specularConeAxis = -reflect(viewDir, normal);\nfloat distanceAngle = acos(clamp(dot(bentNormal, specularConeAxis), -1.0, 1.0));\nfloat solidAngleIntersection = calcSolidAnglesIntersectionApprox(\nradiusAngleVisCone, radiusAngleSpecCone, distanceAngle);\nfloat solidAngleSpecular = calcSolidAngle(radiusAngleSpecCone);\nfloat specVisibility = solidAngleIntersection / solidAngleSpecular;\nreturn mix(specVisibility, 1.0, aoVisibility);\n}\n#endif",lights_fragment_gtso:"#ifdef USE_GTAO\nreflectedLight.indirectSpecular *= calcGTSOVisibility(gtaoVisibility,\ngtaoBentNormal, gtaoViewDir, gtaoNormal, gtaoRoughness);\n#endif",normal_output_fragment:"#if NORMAL_OUTPUT == 1\ngl_FragColor = vec4(packNormalToRGB(normal), gl_FragColor.a);\n#endif",ssr_pars_fragment:"#ifdef USE_SSR\nuniform sampler2D ssrSourceBuffer;\nuniform sampler2D ssrDepthBuffer;\nuniform sampler2D ssrBackfaceDepthBuffer;\nuniform mat4 invProjectionMatrix;\nuniform vec2 ssrResolution;\nuniform float ssrThickness;\nuniform float ssrStride;\nuniform float ssrJitter;\nuniform float ssrMaxDistance;\n#ifdef USE_SSR_REFRACT\n#define STEPS_FADE_AMOUNT 0.1\n#define SCREEN_FADE_THRESHOLD 0.6\n#else\n#define STEPS_FADE_AMOUNT 1.0\n#define SCREEN_FADE_THRESHOLD 0.4\n#endif\nvec3 deproject(vec3 p) {\nvec4 res = invProjectionMatrix * vec4(p, 1);\nreturn res.xyz / res.w;\n}\nbool doesIntersect(float rayzmax, float rayzmin, vec2 uv) {\nfloat sceneZMin = texture2D(ssrDepthBuffer, uv).r;\n#ifdef USE_SSR_REFRACT\nreturn rayzmin >= (sceneZMin-ssrThickness) && rayzmax <= sceneZMin;\n#else\nfloat sceneZMax = texture2D(ssrBackfaceDepthBuffer, uv).r;\nreturn rayzmin >= sceneZMax && rayzmax <= sceneZMin;\n#endif\n}\nfloat distanceSquared(vec2 a, vec2 b) { a -= b; return dot(a, a); }\nvoid swapIfBigger(inout float a, inout float b) {\nif (a > b) {\nfloat t = a;\na = b;\nb = t;\n}\n}\nbool isOutsideUvBounds(float x) { return x < 0.0 || x > 1.0; }\nbool isOutsideUvBounds(vec2 uv) { return isOutsideUvBounds(uv.x) || isOutsideUvBounds(uv.y); }\nvec3 computeSSR(vec3 color, vec3 normal, float ior) {\nvec2 uv = gl_FragCoord.xy / ssrResolution;\nvec2 screenCoord = uv * 2.0 - vec2(1, 1);\nfloat nearClip = deproject(vec3(0, 0, -1)).z;\nvec3 ray = deproject(vec3(screenCoord, -1));\nray /= ray.z;\nfloat depthSample = -vViewPosition.z;\nvec3 vpos = depthSample * ray;\n#ifdef USE_SSR_REFRACT\nvec3 dir = normalize(refract(normalize(vpos), normalize(normal), 1.0/ior));\n#else\nvec3 dir = normalize(reflect(normalize(vpos), normalize(normal)));\n#endif\nfloat maxDist = ssrMaxDistance;\nfloat rayLength = (vpos.z + dir.z * maxDist) > nearClip ? (nearClip - vpos.z) / dir.z : maxDist;\nvec3 csOrig = vpos;\nvec3 csEndPoint = csOrig + dir * rayLength;\nvec4 H0 = projectionMatrix * vec4(csOrig, 1.0);\nvec4 H1 = projectionMatrix * vec4(csEndPoint, 1.0);\nfloat k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;\nvec3 Q0 = csOrig.xyz * k0, Q1 = csEndPoint.xyz * k1;\nvec2 P0 = H0.xy * k0, P1 = H1.xy * k1;\nP0 = P0 * 0.5 + vec2(0.5), P1 = P1 * 0.5 + vec2(0.5);\n#ifndef SSR_SIMPLE_REFRACT\nP0 *= ssrResolution, P1 *= ssrResolution;\nP1 += vec2((distanceSquared(P0, P1) < 0.0001) ? 0.01 : 0.0);\nvec2 delta = P1 - P0;\nbool permute = false;\nif (abs(delta.x) < abs(delta.y)) {\npermute = true; delta = delta.yx; P0 = P0.yx; P1 = P1.yx;\n}\nfloat stepDir = sign(delta.x);\nfloat invdx = stepDir / delta.x;\nvec3 dQ = (Q1 - Q0) * invdx;\nfloat dk = (k1 - k0) * invdx;\nvec2 dP = vec2(stepDir, delta.y * invdx);\nfloat pixelStride = ssrStride;\nfloat jitterMod = (gl_FragCoord.x + gl_FragCoord.y) * 0.25;\nvec4 PQK = vec4(P0, Q0.z, k0);\nvec4 dPQK = vec4(dP, dQ.z, dk);\ndPQK *= pixelStride;\nPQK += dPQK * mod(jitterMod, 1.0) * ssrJitter;\nfloat end = P1.x * stepDir;\nfloat prevZMaxEstimate = PQK.z / PQK.w;\nfloat rayZMin = prevZMaxEstimate, rayZMax = prevZMaxEstimate;\nfloat stepped = 0.0;\nvec2 hitUV;\nbool intersected = false;\nfor (float stepCount = 1.0; stepCount <= float(MAX_STEPS); stepCount ++) {\nPQK += dPQK;\nrayZMin = prevZMaxEstimate;\nrayZMax = (dPQK.z * 0.5 + PQK.z) / (dPQK.w * 0.5 + PQK.w);\nprevZMaxEstimate = rayZMax;\nswapIfBigger(rayZMax, rayZMin);\n\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 = sRGBToLinear(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 = sRGBToLinear(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) {\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);\nvec4 uvNormalOffset = planeReflTextureMatrix * vec4(norWorld - planeReflDir, 0.0);\nvec3 result = planeReflProbeTexelToLinear(texture2DProj(planeReflTexture, vPlaneReflUv + uvNormalOffset)).rgb;\nfloat falloffFactor;\nif (planeReflFalloff < EPSILON)\nfalloffFactor = 0.0;\nelse if (posRefl.y > 0.0)\nfalloffFactor = 1.0 - clamp((planeReflBoundingBoxMax.y - posRefl.y) / (planeReflBoundingBoxMax.y * (planeReflFalloff)), 0.0, 1.0);\nelse\nfalloffFactor = 1.0 - clamp((planeReflBoundingBoxMin.y - posRefl.y) / (planeReflBoundingBoxMin.y * (planeReflFalloff)), 0.0, 1.0);\nresult = mix(result, radiance, falloffFactor);\nresult = mix(result, radiance, (roughness < 0.0526) ? 0.0 : saturate(10.0*roughness));\nreturn result;\n}\n#endif",plane_reflection_vertex:"#ifdef USE_PLANE_REFLECTION\nvPlaneReflUv = planeReflTextureMatrix * modelMatrix * vec4(position, 1.0);\n#endif",node_common_frag:"\n#define LUM_WEIGHTS vec3(0.2126, 0.7152, 0.0722)\n#define LUM_WEIGHTS_MAYA vec3(0.3, 0.59, 0.11)\n#define LUMENS_PER_WATT 683.0\n#define MAX_ENV_COORDS_DIR 0\n#define MAX_ENV_COORDS_REFLECT 1\n#define MAX_ENV_COORDS_REFRACT 2\nvec4 nodeTexelToLinear(in vec4 color, in int sourceType) {\nif (sourceType == 1)\nreturn sRGBToLinear(color);\nelse if (sourceType == 2)\nreturn RGBEToLinear(color);\nelse\nreturn color;\n}\n#if defined(NODE_COLOR_CONVERT_AR) || defined(NODE_COLOR_CORRECT_AR) || 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\n#if defined HSV_NODES\nvoid hsvToRGB(vec4 hsv, out vec4 outCol)\n{\nfloat i, f, p, q, t, h, s, v;\nvec3 rgb;\nh = hsv[0];\ns = hsv[1];\nv = hsv[2];\nif (s == 0.0)\nrgb = vec3(v, v, v);\nelse {\nif (h == 1.0)\nh = 0.0;\nh *= 6.0;\ni = floor(h);\nf = h - i;\nrgb = vec3(f, f, f);\np = v * (1.0 - s);\nq = v * (1.0 - (s * f));\nt = v * (1.0 - (s * (1.0 - f)));\nif (i == 0.0)\nrgb = vec3(v, t, p);\nelse if (i == 1.0)\nrgb = vec3(q, v, p);\nelse if (i == 2.0)\nrgb = vec3(p, v, t);\nelse if (i == 3.0)\nrgb = vec3(p, q, v);\nelse if (i == 4.0)\nrgb = vec3(t, p, v);\nelse\nrgb = vec3(v, p, q);\n}\noutCol = vec4(rgb, hsv.w);\n}\nvoid rgbToHSV(vec4 rgb, out vec4 outCol)\n{\nfloat cmax, cmin, h, s, v, cdelta;\nvec3 c;\ncmax = max(rgb[0], max(rgb[1], rgb[2]));\ncmin = min(rgb[0], min(rgb[1], rgb[2]));\ncdelta = cmax - cmin;\nv = cmax;\nif (cmax != 0.0)\ns = cdelta / cmax;\nelse {\ns = 0.0;\nh = 0.0;\n}\nif (s == 0.0)\nh = 0.0;\nelse {\nc = (vec3(cmax, cmax, cmax) - rgb.xyz) / cdelta;\nif (rgb.x == cmax) h = c[2] - c[1];\nelse if (rgb.y == cmax) h = 2.0 + c[0] - c[2];\nelse h = 4.0 + c[1] - c[0];\nh /= 6.0;\nif (h < 0.0)\nh += 1.0;\n}\noutCol = vec4(h, s, v, rgb.w);\n}\n#endif\nbool isPerspective(const mat4 projMatrix)\n{\nreturn (projMatrix[3][3] == 0.0);\n}\n#if defined(NODE_REFLECT_REFRACT_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_SKYDOME_LIGHT_AR) || defined(NODE_ENV_SPHERE_MY)\nvec4 sampleEquirectangular(sampler2D map, vec3 reflectVec, mat3 uvTransform, int encoding)\n{\nreflectVec = normalize(reflectVec);\nvec2 sampleUV;\nsampleUV.y = asin(clamp(reflectVec.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nsampleUV.x = atan(reflectVec.x, reflectVec.z) * RECIPROCAL_PI2 + 0.5;\nsampleUV.y *= -1.0;\nconst float seamWidth = 0.15;\nconst float seamBiasFactor = -10.0;\nfloat seam = max(0.0, 1.0 - abs (reflectVec.x) / seamWidth) *\nclamp (1.0 - reflectVec.z / seamWidth, 0.0, 1.0);\nsampleUV = (uvTransform * vec3(sampleUV, 1.0)).xy;\nvec4 color = texture2D(map, sampleUV, seamBiasFactor * seam);\ncolor = nodeTexelToLinear(color, encoding);\nreturn color;\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);\nreturn retColor;\n}\n#endif\n#ifdef USE_OSL\n#define M_PI PI\n#define M_PI_2 PI / 2.0\n#define M_PI_4 PI / 4.0\n#define M_2_PI 2.0 / PI\n#define M_2PI 2.0 * PI\n#define M_4PI 4.0 * PI\n#define M_2_SQRTPI 2.0 / sqrt(PI)\n#define M_E 2.718281828459\n#define M_LN2 0.69314718056\n#define M_LN10 2.30258509299\n#define M_LOG2E 1.4426950409\n#define M_LOG10E 0.43429448190\n#define M_SQRT2 sqrt(2.0)\n#define M_SQRT1_2 sqrt(0.5)\n#define OSL_ALPHA 33633\n#define OSL_ANISOTROPIC 40205\n#define OSL_AVERAGEALPHA 57701\n#define OSL_AVERAGECOLOR 46077\n#define OSL_BANDWIDTH 37485\n#define OSL_BEZIER 27645\n#define OSL_BLACK 62409\n#define OSL_BSPLINE 16959\n#define OSL_CAMERA 8198\n#define OSL_CAMERA_CLIP 34380\n#define OSL_CAMERA_CLIP_FAR 31933\n#define OSL_CAMERA_CLIP_NEAR 21485\n#define OSL_CAMERA_FOV 60706\n#define OSL_CAMERA_PIXELASPECT 4950\n#define OSL_CAMERA_PROJECTION 29369\n#define OSL_CAMERA_RESOLUTION 39679\n#define OSL_CAMERA_SCREEN_WINDOW 47009\n#define OSL_CAMERA_SHUTTER 7107\n#define OSL_CAMERA_SHUTTER_CLOSE 34406\n#define OSL_CAMERA_SHUTTER_OPEN 40085\n#define OSL_CATMULL_ROM 31642\n#define OSL_CELL 20984\n#define OSL_CHANNELS 8726\n#define OSL_CLAMP 20052\n#define OSL_COLOR 53753\n#define OSL_COMMON 49871\n#define OSL_CONSTANT 25144\n#define OSL_DATAWINDOW 54276\n#define OSL_DEFAULT 54870\n#define OSL_DIFFUSE 40389\n#define OSL_DIRECTION 42220\n#define OSL_DISPLAYWINDOW 30728\n#define OSL_DISTANCE 51337\n#define OSL_DO_FILTER 35765\n#define OSL_EMPTY 9314\n#define OSL_ERRORMESSAGE 38305\n#define OSL_EXISTS 41510\n#define OSL_FILL 39132\n#define OSL_FIRSTCHANNEL 48155\n#define OSL_GABOR 57764\n#define OSL_GEOM_NAME 63686\n#define OSL_GLOSSY 47998\n#define OSL_HASH 49390\n#define OSL_HERMITE 63643\n#define OSL_HIT 48491\n#define OSL_HITDIST 22029\n#define OSL_HSL 49898\n#define OSL_HSV 29073\n#define OSL_IMPULSES 56191\n#define OSL_INDEX 1731\n#define OSL_INTERP 10557\n#define OSL_LINEAR 2182\n#define OSL_MIRROR 64591\n#define OSL_MISSINGALPHA 39755\n#define OSL_MISSINGCOLOR 51667\n#define OSL_NDC 48899\n#define OSL_NORMAL 16520\n#define OSL_OBJECT 59084\n#define OSL_OSL_VERSION 47920\n#define OSL_PERIODIC 8749\n#define OSL_PERLIN 730\n#define OSL_POSITION 43041\n#define OSL_RASTER 2618\n#define OSL_REFLECTION 37621\n#define OSL_REFRACTION 37287\n#define OSL_RESOLUTION 48704\n#define OSL_RGB 26673\n#define OSL_RWRAP 47801\n#define OSL_SCREEN 55875\n#define OSL_SHADER 21066\n#define OSL_SHADER_GROUPNAME 62327\n#define OSL_SHADER_LAYERNAME 51796\n#define OSL_SHADER_SHADERNAME 65123\n#define OSL_SHADOW 60708\n#define OSL_SIMPLEX 61636\n#define OSL_SUBIMAGE 33526\n#define OSL_SUBIMAGES 2366\n#define OSL_SWRAP 4328\n#define OSL_TEXTUREFORMAT 17851\n#define OSL_TIME 52235\n#define OSL_TRACE 62908\n#define OSL_TWRAP 30524\n#define OSL_TYPE 64071\n#define OSL_UPERLIN 65308\n#define OSL_USIMPLEX 11314\n#define OSL_WIDTH 48751\n#define OSL_WORLD 9059\n#define OSL_WORLDTOCAMERA 32273\n#define OSL_WORLDTOSCREEN 33876\n#define OSL_WRAP 58300\n#define OSL_XYY 2228\n#define OSL_XYZ 47351\n#define OSL_YIQ 15839\nvec3 oslGetP(vec3 viewPos) {\n#if WORLD_NODES == 1\nreturn swizzleUpZ((invViewMatrix * vec4(-viewPos, 0.0)).xyz);\n#else\nreturn swizzleUpZ((invViewMatrix * vec4(-viewPos, 1.0)).xyz);\n#endif\n}\nvec3 oslGetI(vec3 viewPos) {\n#if WORLD_NODES == 1\nreturn swizzleUpZ((invViewMatrix * vec4(normalize(-viewPos), 0.0)).xyz);\n#else\nreturn swizzleUpZ((invViewMatrix * vec4(normalize(-viewPos), 0.0)).xyz);\n#endif\n}\nvec3 oslGetN(vec3 viewNorm) {\nreturn swizzleUpZ(normalize(invViewMatrix * vec4(viewNorm, 0.0)).xyz);\n}\nvec3 oslBlackbody(float temperatureK) {\nreturn sRGBToLinear(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 = isOrtho(projectionMatrix) ? vec4(0.0, 0.0, -1.0, 0.0) : vec4(normalize(-vViewPosition), 0.0);\nviewDir = invViewMatrix * viewDir;\nnorOut = -swizzleUpZ(viewDir.xyz);\n#else\nnorOut = normalize(invViewMatrix * vec4(norParam, 0.0)).xyz;\nnorOut = swizzleUpZ(norOut);\n#endif\n#else\nnorOut = norParam;\n#endif\n}",node_position_frag:"void node_position(vec3 posParam, out vec3 posOut)\n{\n#if defined(MT_BLENDER) || defined(MT_MAX)\nposOut = swizzleUpZ(-posParam);\n#else\nposOut = -posParam;\n#endif\n}",node_rgb_alpha_frag:"\nuniform vec4 nodeRGB[NODE_RGB_NUM];\nvoid node_rgb_alpha(vec4 color, out vec3 outColor, out float outAlpha)\n{\noutColor = color.rgb;\noutAlpha = color.a;\n}",node_value_frag:"uniform float nodeValue[NODE_VALUE_NUM];\nvoid node_value(float val, out float outVal)\n{\noutVal = val;\n}",node_u_float_frag:"void node_u_float(vec2 inUv, out float u)\n{\nu = inUv.x;\n}",node_abs_ar_frag:"void node_abs(\nvec3 inputVal,\nout vec3 outColor)\n{\noutColor = abs(inputVal);\n}",node_add_ar_frag:"void node_add(\nvec3 input1, vec3 input2,\nout vec3 outColor)\n{\noutColor = input1 + input2;\n}",node_atan_ar_frag:"void node_atan(\nint units,\nvec3 x, vec3 y,\nout vec3 outColor)\n{\noutColor = atan(y, x);\nif (units == 1)\noutColor = degrees(outColor);\n}",node_checkerboard_ar_frag:"void node_checkerboard(\nconst vec2 inUv, vec3 color1, vec3 color2, float uFrequency, float vFrequency, float uOffset, float vOffset, float contrast,\nout vec3 outColor) {\nvec2 uv = -1.0 + 2.0 * inUv;\nfloat fmodResult = mod(floor(uOffset * 2.0 + uFrequency * uv.x) + floor(vOffset * 2.0 + vFrequency * uv.y), 2.0);\nfloat final = max(sign(fmodResult), 0.0);\nvec3 col = vec3(final);\nif (final == 0.0)\ncol = color1;\nelse\ncol = color2;\noutColor = col * vec3(contrast) + vec3(1.0 - contrast);\n}",node_clamp_ar_frag:"void node_clamp(\nconst int mode,\nvec3 inputValue, float minValue, float maxValue, vec3 minColor, vec3 maxColor,\nout vec3 outColor, out vec3 outTransparency)\n{\nif (mode == 0)\noutColor = clamp(inputValue, vec3(minValue), vec3(maxValue));\nelse\noutColor = clamp(inputValue, minColor, maxColor);\noutTransparency = outColor;\n}",node_color_convert_ar_frag:"void node_color_convert(\nconst int from, const int to,\nvec3 inputValue,\nout vec3 outColor, out vec3 outTransparency)\n{\nvec4 c;\nif (from == to)\nc = vec4(inputValue, 1.0);\nelse if (from == 0) \nrgbToHSV(vec4(inputValue, 1.0), c);\nelse if (from == 1)\nhsvToRGB(vec4(inputValue, 1.0), c);\noutColor = c.rgb;\noutTransparency = outColor;\n}",node_color_correct_ar_frag:"void node_color_correct(\nvec3 inputValue, float mask, float gamma, float hueShift, float saturation, float contrast, float contrastPivot,\nfloat exposure, vec3 multiply, vec3 add, bool invert, bool alphaIsLuminance, float alphaMultiply, float alphaAdd, bool invertAlpha,\nout vec3 outColor, out float outAlpha)\n{ \noutColor = inputValue;\noutColor = invert ? 1.0 - outColor : outColor;\noutColor = vec3(pow(abs(outColor.r), gamma), pow(abs(outColor.g), gamma), pow(abs(outColor.b), gamma));\nvec4 hsv;\nrgbToHSV(vec4(outColor, 1.0), hsv);\nhsv[0] += hueShift / 360.0;\nif (hsv[0] > 1.0)\nhsv[0] -= 1.0;\nelse if (hsv[0] < 0.0)\nhsv[0] += 1.0;\n\nhsv[1] *= (saturation);\nhsv[1] = saturate(hsv[1]);\nhsv[2] += exposure * 2.0;\nvec4 c = hsv;\nhsvToRGB(hsv, c);\nc = ((c - contrastPivot) * contrast + contrastPivot) * vec4(multiply, 1.0) + vec4(add, 1.0);\noutColor = c.rgb;\noutAlpha = 1.0;\n}",node_color_to_float_ar_frag:"void node_color_to_float(\nconst int mode,\nvec3 inputValue,\nout float outValue)\n{\nif (mode == 0)\noutValue = min(min(inputValue.r, inputValue.g), inputValue.b);\nelse if (mode == 1)\noutValue = max(max(inputValue.r, inputValue.g), inputValue.b);\nelse if (mode == 2)\noutValue = (inputValue.r + inputValue.g + inputValue.b) / 3.0;\nelse if (mode == 3)\noutValue = inputValue.r + inputValue.g + inputValue.b;\nelse if (mode == 4) {\noutValue = dot(inputValue, LUM_WEIGHTS);\n}\nelse if (mode == 5)\noutValue = inputValue.r;\nelse if (mode == 6)\noutValue = inputValue.g;\nelse if (mode == 7)\noutValue = inputValue.b;\n}",node_compare_ar_frag:"void node_compare(\nint test,\nfloat input1, float input2,\nout bool outValue)\n{\nif (test == 0)\noutValue = input1 == input2;\nelse if (test == 1)\noutvalue = input1 != input2;\nelse if (test == 2)\noutValue = input1 < input2;\nelse if (test == 3)\noutValue = input1 > input2;\nelse if (test == 4)\noutValue = input1 <= input2;\nelse if (test == 5)\noutValue = input1 >= input2;\n}",node_complement_ar_frag:"void node_complement(\nvec3 inputValue,\nout vec3 outColor)\n{\noutColor = 1.0 - inputValue;\n}",node_composite_ar_frag:"void node_composite(\nconst int operation, const int alphaOperation,\nvec3 A, vec3 B, float AA, float BA,\nout float outAlpha, out vec3 outColor, out vec3 outTransparency)\n{\nvec4 A1 = vec4(A, AA);\nvec4 B1 = vec4(B, BA);\nvec4 color = vec4(0.0);\nif (operation == 0)\ncolor = A1;\nelse if (operation == 1)\ncolor = B1;\nelse if (operation == 2)\ncolor = A1 * B1.a + B1 * (1.0 - A1.a);\nelse if (operation == 3)\ncolor = (A1 + B1) / 2.0;\nelse if (operation == 4)\ncolor = A1.a > B1.a ? A1 : (A1 + B1 * (1.0 - A1.a) / B1.a);\nelse if (operation == 5)\ncolor = abs(A1 - B1);\nelse if (operation == 6)\ncolor = A1.a + B1.a < 1.0 ? A1 + B1 : A1 + B1 * (1.0 - A1.a) / B1.a;\nelse if (operation == 7)\nfor (int i = 0; i < 4; i++)\ncolor[i] = B1[i] == 0.0 ? 0.0 : (A1[i] / B1[i]);\nelse if (operation == 8)\ncolor = A1 + B1 - 2.0 * A1 * B1;\nelse if (operation == 9)\ncolor = B1 - A1;\nelse if (operation == 10)\ncolor = 2.0 * A1 * B1 / (A1 + B1);\nelse if (operation == 11)\nfor (int i = 0; i < 4; i++)\ncolor[i] = A1[i] < 0.5 ? (A1[i] * B1[i]) : (A1[i] >= 0.0 && A1[i] <= 1.0 && B1[i] >= 0.0 && B1[i] <= 1.0) ? (A1[i] + B1[i] - A1[i] * B1[i]) : max(A1[i], B1[i]);\nelse if (operation == 12)\ncolor = sqrt(A1 * A1 + B1 * B1);\nelse if (operation == 13)\ncolor = A1 * B1.a;\nelse if (operation == 14)\ncolor = B1 * A1.a;\nelse if (operation == 15)\ncolor = A1 * A1.a + B1 * (1.0 - A1.a);\nelse if (operation == 16)\ncolor = max(A1, B1);\nelse if (operation == 17)\ncolor = min(A1, B1);\nelse if (operation == 18)\ncolor = A1 - B1;\nelse if (operation == 19)\ncolor = A1 * B1;\nelse if (operation == 20)\ncolor = A1 * (1.0 - B1.a);\nelse if (operation == 21)\ncolor = A1 + B1 * (1.0 - A1.a);\nelse if (operation == 22)\nfor (int i = 0; i < 4; i++)\ncolor[i] = B1[i] < 0.5 ? (A1[i] * B1[i]) : (A1[i] >= 0.0 && A1[i] <= 1.0 && B1[i] >= 0.0 && B1[i] <= 1.0) ? (A1[i] + B1[i] - A1[i] * B1[i]) : max(A1[i], B1[i]);\nelse if (operation == 23)\ncolor = A1 + B1;\nelse if (operation == 24)\nfor (int i = 0; i < 4; i++)\ncolor[i] = (A1[i] >= 0.0 && A1[i] <= 1.0 && B1[i] >= 0.0 && B1[i] <= 1.0) ? (A1[i] + B1[i] - A1[i] * B1[i]) : max(A1[i], B1[i]);\n\nelse if (operation == 25)\nfor (int i = 0; i < 4; i++)\ncolor[i] = (A1[i] < .75) ? (A1[i] * B1[i]) : (A1[i] >= 0.0 && A1[i] <= 1.0 && B1[i] >= 0.0 && B1[i] <= 1.0) ? (A1[i] + B1[i] - A1[i] * B1[i]) : max(A1[i], B1[i]);\nelse if (operation == 26)\ncolor = B1 * (1.0 - A1.a);\nelse if (operation == 27)\ncolor = A1 * (1.0 - B1.a) + B1;\nelse if (operation == 28)\ncolor = A1 * (1.0 - B1.a) + B1 * (1.0 - A1.a);\nif (alphaOperation == 1)\ncolor.a = AA;\nelse if (alphaOperation ==2)\ncolor.a = BA;\noutColor = color.rgb;\noutAlpha = color.a;\noutTransparency = outColor;\n}",node_cross_ar_frag:"void node_cross(\nvec3 input1, vec3 input2,\nout vec3 outValue)\n{\noutValue = cross(input1, input2);\n}",node_divide_ar_frag:"void node_divide(\nvec3 input1, vec3 input2,\nout vec3 outColor)\n{\noutColor = input1 / input2;\n}",node_dot_ar_frag:"void node_dot(\nvec3 input1, vec3 input2,\nout vec3 outValue)\n{\noutValue = dot(input1, input2);\n}",node_exp_ar_frag:"void node_exp(\nvec3 inputVal,\nout vec3 outColor)\n{\noutColor = exp(inputVal);\n}",node_facing_ratio_ar_frag:"void node_facing_ratio(\nvec3 viewNorm,\nconst float bias, const float gain, const bool invert, const bool linear,\nout float outValue)\n{\noutValue = dot(normalize(viewNorm), normalize(vViewPosition));\n}",node_flat_ar_frag:"void node_flat(vec3 color, out vec3 outColor)\n{\noutColor = color;\n}",node_float_to_int_ar_frag:"void node_float_to_int(\nconst int mode, \nfloat inputValue,\nout int outValue)\n{\nif (mode == 0)\noutValue = round(inputValue);\nelse if (mode == 1)\noutValue = trunc(inputValue);\nelse if (mode == 2)\noutValue = floor(inputValue);\nelse if (mode == 3)\noutValue = ceil(inputValue);\n}",node_float_to_matrix_ar_frag:"void node_float_to_matrix(\nfloat input00, float input01, float input02, float input03, float input10, float input11, float input12, float input13, float input20, float input21, float input22, float input23, float input30, float input31, float input32, float input33,\nout mat4 outValue)\n{\noutValue = mat4(input00, input01, input02, input03,\ninput10, input11, input12, input13,\ninput20, input21, input22, input23,\ninput30, input31, input32, input33);\n}",node_float_to_rgba_ar_frag:"void node_float_to_rgba(\nfloat r, float g, float b, float a,\nout vec4 outColor, out float outAlpha, out vec3 outTransparency)\n{\noutAlpha = a;\noutColor = vec4(r, g, b, a);\noutTransparency = vec3(1.0 - a);\n}",node_float_to_rgb_ar_frag:"void node_float_to_rgb(\nfloat r, float g, float b,\nout vec3 outValue)\n{\noutValue = vec3(r, g, b);\n}",node_fraction_ar_frag:"void node_fraction(\nvec3 inputValue,\nout vec3 outColor)\n{\noutColor = fract(inputValue);\n}",node_is_finite_ar_frag:"void node_is_finite(\nvec3 inputValue,\nout bool outValue)\n{\noutValue = !any(isinf(inputValue));\n}",node_image_ar_frag:"float check(bool value) {\nif (value == true) return -1.0;\nreturn 1.0;\n}\nvoid node_image(sampler2D ima, const int encoding, \nvec3 multiply, vec3 offset, vec2 uvcoords, float soffset, float toffset, float sscale, float tscale, bool sflip, bool tflip, bool swapSt,\nout vec3 outColor, out float outAlpha, out vec3 outTransparency) {\n\nvec2 uv = vec2(uvcoords.x, uvcoords.y);\nif (swapSt == false) {\nif (sflip) uv.x = 1.0 - uv.x;\nif (tflip) uv.y = 1.0 - uv.y;\nuv = vec2(sscale, tscale) * (uv + vec2(soffset * check(sflip), toffset * check(tflip)));\n} else {\nif (sflip) uv.y = 1.0 - uv.y;\nif (tflip) uv.x = 1.0 - uv.x;\nuv = vec2(sscale, tscale) * (uv.yx + vec2(toffset * check(sflip), soffset * check(tflip)));\n}\nuv.y = 1.0 - uv.y;\nvec4 tex = texture2D(ima, uv);\noutColor = nodeTexelToLinear(tex, encoding).rgb * multiply + offset;\noutAlpha = tex.a;\noutTransparency = outColor.rgb;\n}\nvoid node_image(sampler2D ima, const int encoding, \nvec4 multiply, vec4 offset, vec2 uvcoords, float soffset, float toffset, float sscale, float tscale, bool sflip, bool tflip, bool swapSt,\nout vec4 outColor) {\nvec2 uv = vec2(uvcoords.x, uvcoords.y);\nif (swapSt == false) {\nif (sflip) uv.x = 1.0 - uv.x;\nif (tflip) uv.y = 1.0 - uv.y;\nuv = vec2(sscale, tscale) * (uv + vec2(soffset * check(sflip), toffset * check(tflip)));\n} else {\nif (sflip) uv.y = 1.0 - uv.y;\nif (tflip) uv.x = 1.0 - uv.x;\nuv = vec2(sscale, tscale) * (uv.yx + vec2(toffset * check(sflip), soffset * check(tflip)));\n}\nuv.y = 1.0 - uv.y;\nvec4 tex = texture2D(ima, uv);\noutColor = nodeTexelToLinear(tex, encoding).rgba * multiply + offset;\n}",node_lambert_ar_frag:"void node_lambert(\nvec3 geometryNormal,\nfloat Kd, vec3 KdColor, vec3 normalCamera, vec3 opacity,\nout vec4 outColor, out float outAlpha, out vec3 outTransparency)\n{\nNodeMaterial material;\nmaterial.diffuseColor = Kd * KdColor;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\nvec3 normal = normalCamera;\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_DirectDiffuse\n#undef RE_IndirectDiffuse\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\noutAlpha = average(opacity);\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse, outAlpha);\noutTransparency = vec3(1.0) - opacity;\n}",node_length_ar_frag:"void node_length(\nint mode,\nvec3 inputVec,\nout float outValue)\n{\nif (mode == 0)\noutValue = length(inputVec);\nelse if (mode == 1)\noutValue = dot(inputVec, inputVec);\nelse\noutValue = abs(inputVec.x) + abs(inputVec.y) + abs(inputVec.z);\n}",node_log_ar_frag:"void node_log(\nvec3 inputVec, vec3 base,\nout vec3 outColor)\n{\noutColor = log(inputVec) / log(base);\n}",node_map_to_mtl_ar_frag:"\nvoid node_map_to_mtl(bool opaqueEnabled, vec4 color, out vec4 outColor)\n{\noutColor = vec4(color.rgb, opaqueEnabled ? color.a : 1.0);\n}",node_max_ar_frag:"void node_max(\nvec3 input1, vec3 input2,\nout vec3 outColor)\n{\noutColor = max(input1, input2);\n}",node_min_ar_frag:"void node_min(\nvec3 input1, vec3 input2,\nout vec3 outColor)\n{\noutColor = min(input1, input2);\n}",node_mix_shader_ar_frag:"void node_mix_shader(const int mode,\nconst float mixAmt, vec4 shader1, vec4 shader2,\nout vec4 color)\n{\nshader1.rgb *= shader1.a;\nshader2.rgb *= shader2.a;\nif (mode == 0)\ncolor = mix(shader1, shader2, clamp(mixAmt, 0.0, 1.0));\nelse\ncolor = vec4(shader1.rgb + shader2.rgb, min(shader1.a, shader2.a));\ncolor.rgb /= color.a;\n}",node_modulo_ar_frag:"void node_modulo(\nvec3 inputVec, vec3 divisor,\nout vec3 outColor)\n{\noutColor = mod(inputVec, divisor);\n}",node_multiply_ar_frag:"void node_multiply(\nvec3 input1, vec3 input2,\nout vec3 outColor)\n{\noutColor = input1 * input2;\n}",node_negate_ar_frag:"void node_negate(\nvec3 inputVec,\nout vec3 outColor)\n{\noutColor = -inputVec;\n}",node_normalize_ar_frag:"void node_normalize(\nvec3 inputVec,\nout vec3 outValue)\n{\noutValue = normalize(inputVec);\n}",node_normal_map_ar_frag:"void node_normal_map(\nvec4 tangentParam,\nvec3 inputVal, vec3 normal, float strength, vec3 tangent,\nout vec3 outValue) {\n#ifdef DOUBLE_SIDED\nnormal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\nvec3 normalTex = inputVal.xyz * 2.0 - 1.0;\nvec3 bitangent = tangentParam.w * cross(normal, tangent);\noutValue = normalize(normalTex.x * tangent + normalTex.y * bitangent + normalTex.z * normal);\n}",node_pow_ar_frag:"void node_pow(\nvec3 base, vec3 exponent,\nout vec3 outColor)\n{\noutColor = pow(base, exponent);\n}",node_random_ar_frag:"void node_abs(\nvec3 inputColor,\nout vec3 outColor)\n{\noutColor = inputColor;\n}",node_range_ar_frag:"void node_range(\nvec3 inputValue, float inputMin, float inputMax, \nfloat outputMin, float outputMax, bool smoothstep1, \nfloat contrast, float contrastPivot, float bias, float gain,\nout vec3 outColor, out vec3 outTransparency)\n{\n\noutColor = min(max(inputValue, vec3(inputMin)), vec3(inputMax));\noutColor = (outColor - contrastPivot) * contrast + contrastPivot;\nif (smoothstep1 == true) {\nfor (int i = 0; i < 3; i++)\noutColor[i] = smoothstep(outputMin, outputMax, outColor[i]);\n} else\noutColor = min(max(outColor, vec3(outputMin)), vec3(outputMax));\noutTransparency = outColor;\n}",node_ray_switch_ar_frag:"void node_ray_switch(vec3 camera, vec3 diffuseReflection, vec3 diffuseTransmission,\nvec3 shadow, vec3 specularReflection, vec3 specularTransmission,\nout vec3 outColor, out float outAlpha)\n{\n#if LIGHT_PATH_IS_CAM_RAY\noutColor = camera;\n#else\noutColor = diffuseReflection;\n#endif\noutAlpha = 1.0;\n}",node_reciprocal_ar_frag:"void node_reciprocal(\nvec3 inputVec,\nout vec3 outColor)\n{\noutColor = 1.0 / inputVec;\n}",node_rgba_to_float_ar_frag:"void node_rgba_to_float(\nconst int mode,\nvec3 inputValue, float inputA,\nout float outValue, out vec3 outTransparency)\n{\noutTransparency = inputValue + vec3(inputA / 4.0);\nif (mode == 0)\noutValue = min(min(min(inputValue.r, inputValue.g), inputValue.b), inputA);\nelse if (mode == 1)\noutValue = max(max(max(inputValue.r, inputValue.g), inputValue.b), inputA);\nelse if (mode == 2)\noutValue = (inputValue.r + inputValue.g + inputValue.b + inputA) / 4.0;\nelse if (mode == 3)\noutValue = inputValue.r + inputValue.g + inputValue.b + inputA;\nelse if (mode == 4) {\noutValue = dot(inputValue, LUM_WEIGHTS);\n}\nelse if (mode == 5)\noutValue = inputValue.r;\nelse if (mode == 6)\noutValue = inputValue.g;\nelse if (mode == 7)\noutValue = inputValue.b;\n}",node_rgb_to_float_ar_frag:"void node_rgb_to_float(\nconst int mode,\nvec3 inputValue,\nout float outValue)\n{\nif (mode == 0)\noutValue = min(min(inputValue.r, inputValue.g), inputValue.b);\nelse if (mode == 1)\noutValue = max(max(inputValue.r, inputValue.g), inputValue.b);\nelse if (mode == 2)\noutValue = (inputValue.r + inputValue.g + inputValue.b) / 3.0;\nelse if (mode == 3)\noutValue = inputValue.r + inputValue.g + inputValue.b;\nelse if (mode == 4) {\noutValue = dot(inputValue, LUM_WEIGHTS);\n}\nelse if (mode == 5)\noutValue = inputValue.r;\nelse if (mode == 6)\noutValue = inputValue.g;\nelse if (mode == 7)\noutValue = inputValue.b;\n}",node_rgb_to_vector_ar_frag:"void node_rgb_to_vector(\nconst int mode, \nvec3 inputValue,\nout vec3 outValue)\n{\n\noutValue = inputValue;\n}",node_shadow_matte_ar_frag:"#include <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;\noutColor.r = choose[channelR];\noutColor.g = choose[channelG];\noutColor.b = choose[channelB];\noutAlpha = choose[channelA];\nif (negateR)\noutColor.r = -outColor.r;\nif (negateG)\noutColor.g = -outColor.g;\nif (negateB)\noutColor.b = -outColor.b;\nif (negateA)\noutAlpha = -outAlpha;\n}\nvoid node_shuffle(const int channelR, const int channelG, const int channelB, const int channelA,\nvec4 color, float alpha, bool negateR, bool negateG, bool negateB, bool negateA,\nout vec4 outColor)\n{\noutColor = vec4(0.0);\nvec4 choose = vec4(color.rgb, alpha);\noutColor.r = choose[channelR];\noutColor.g = choose[channelG];\noutColor.b = choose[channelB];\noutColor.a = choose[channelA];\nif (negateR)\noutColor.r = -outColor.r;\nif (negateG)\noutColor.g = -outColor.g;\nif (negateB)\noutColor.b = -outColor.b;\nif (negateA)\noutColor.a = -outColor.a;\n}",node_sign_ar_frag:"void node_sign(\nvec3 inputVec,\nout vec3 outColor)\n{\noutColor = sign(inputVec);\n}",node_skydome_light_ar_frag:"void node_skydome_light(vec3 color, float intensity,\nout vec4 outgoingLight)\n{\noutgoingLight = vec4(color * intensity, 1.0);\n}\nvoid node_skydome_light(sampler2D envMap, int encoding, vec3 normal,\nfloat intensity,\nout vec4 outgoingLight)\n{\nvec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nvec3 reflectVec = normalize(cameraToVertex);\nmat3 uvTransform = mat3(1.0);\nvec4 color = sampleEquirectangular(envMap, reflectVec, uvTransform, encoding);\n#if LIGHT_PATH_IS_CAM_RAY\nintensity = 1.0;\n#endif\noutgoingLight = color * intensity;\n}",node_sqrt_ar_frag:"void node_sqrt(\nvec3 inputVec,\nout vec3 outColor)\n{\noutColor = sqrt(inputVec);\n}",node_standard_surface_ar_frag:"#define DEFAULT_REFLECTION_EDGE 1.0\n#define DEFAULT_REFLECTION_SLOPE 5.0\nvoid node_standard_surface(\nvec3 geometryNormal, const bool thinWalled,\nconst float base, const vec3 baseColor, const float diffuseRoughness,\nconst float metalness, const float specular, const vec3 specularColor,\nconst float specularRoughness, const float trans, const vec3 transColor,\nconst float transDepth, const vec3 transScatter, const float transExtraRoughness,\nconst float subsurface, const vec3 subsurfaceColor, const vec3 subsurfaceRadius,\nconst float coat, const vec3 coatColor, const float coatRoughness,\nconst float sheen, const vec3 sheenColor, const float sheenRoughness,\nconst float emission, const vec3 emissionColor, const vec3 opacity,\nconst vec3 normal, const vec3 clearcoatNormal, const float specularIOR,\nout vec4 outColor, out vec3 outTransparency)\n{\nNodeMaterial material;\nvec3 baseColorWeighted = base * baseColor.rgb;\nmaterial.diffuseColor = baseColorWeighted * (1.0 - metalness) * (1.0 - trans);\n#ifdef CLEARCOAT\nmaterial.clearcoat = saturate(coat);\nmaterial.clearcoatRoughness = clamp(coatRoughness, 0.0, 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.specularRoughness = max(specularRoughness, 0.0525);\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min(material.specularRoughness, 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.specularRoughness;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 refractedLight = vec3(0.0);\n#ifdef USE_GTAO\nvec4 gtaoVisibilityBentNormal = texture2D(gtaoMap,\ngl_FragCoord.xy / currResolution);\nvec3 bentNormal = normalize(unpackRGBToNormal(gtaoVisibilityBentNormal.gba));\n#define PROBE_NORMAL bentNormal\n#endif\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#define RE_Refraction RE_Refraction_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#undef RE_Refraction\n#ifdef PROBE_NORMAL\n#undef PROBE_NORMAL\n#endif\n#ifdef USE_GTAO\nreflectedLight.indirectDiffuse *= gtaoVisibilityBentNormal.r;\nfloat gtaoVisibility = gtaoVisibilityBentNormal.r;\nvec3 gtaoBentNormal = bentNormal;\nvec3 gtaoViewDir = geometry.viewDir;\nvec3 gtaoNormal = normal;\nfloat gtaoRoughness = material.specularRoughness;\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;\nfloat alpha = 1.0;\nif (thinWalled) {\nalpha = average(opacity) * (1.0 - saturate(trans) + maxFromRGB(outSpecular) * saturate(trans));\n} else {\noutColor3 += refractedLight;\n}\noutColor = vec4(outColor3, saturate(alpha));\noutTransparency = outColor3;\n}\nvoid node_standard_surface(\nvec3 geometryNormal, const bool thinWalled,\nconst float base, const vec3 baseColor, const float diffuseRoughness,\nconst float metalness, const float specular, const vec3 specularColor,\nconst float specularRoughness, const float trans, const vec3 transColor,\nconst float transDepth, const vec3 transScatter, const float transExtraRoughness,\nconst float subsurface, const vec3 subsurfaceColor, const vec3 subsurfaceRadius,\nconst float coat, const vec3 coatColor, const float coatRoughness,\nconst float sheen, const vec3 sheenColor, const float sheenRoughness,\nconst float emission, const vec3 emissionColor, const vec3 opacity,\nconst vec3 normal, const vec3 clearcoatNormal,\nout vec4 outColor, out vec3 outTransparency)\n{\nnode_standard_surface(\ngeometryNormal, thinWalled,\nbase, baseColor, diffuseRoughness,\nmetalness, specular, specularColor,\nspecularRoughness, trans, transColor,\ntransDepth, transScatter, transExtraRoughness,\nsubsurface, subsurfaceColor, subsurfaceRadius,\ncoat, coatColor, coatRoughness,\nsheen, sheenColor, sheenRoughness,\nemission, emissionColor, opacity,\nnormal, clearcoatNormal, 1.5,\noutColor, outTransparency);\n}",node_subtract_ar_frag:"void node_subtract(\nvec3 input1, vec3 input2,\nout vec3 outColor)\n{\noutColor = input1 - input2;\n}",node_trigo_ar_frag:"void node_trigo(\nconst int function, const int units,\nvec3 inputVec, float frequency, float phase,\nout vec3 outColor)\n{\nif (units == 1 && function >= 0 && function <=2)\ninputVec = radians(inputVec);\nif (function == 0)\noutColor = cos(inputVec * frequency + phase);\nelse if (function == 1)\noutColor = sin(inputVec * frequency + phase);\nelse if (function == 2)\noutColor = tan(inputVec * frequency + phase);\nelse if (function == 3)\noutColor = acos(inputVec * frequency + phase);\nelse if (function == 4)\noutColor = asin(inputVec * frequency + phase);\nelse if (function == 5)\noutColor = atan(inputVec * frequency + phase);\nelse if (function == 6)\noutColor = cosh(inputVec * frequency + phase);\nelse if (function == 7)\noutColor = sinh(inputVec * frequency + phase);\nelse\noutColor = tanh(inputVec * frequency + phase);\nif (units == 1 && function >= 3 && function <=5)\noutColor = degrees(outColor);\n}",node_two_sided_ar_frag:"void node_two_sided(\nbool frontFacing, \nvec3 front, vec3 back,\nout vec3 outColor)\n{\noutColor = frontFacing ? front : back;\n}",node_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 = sRGBToLinear(vec4(colorTempToRGB(temp), 1.0));\n}",node_brightcontrast_bl_frag:"\nvoid node_brightcontrast(vec4 color, float bright, float contrast, out vec4 outColor)\n{\nfloat bminc = bright - contrast * 0.5;\noutColor.r = max((1.0 + contrast) * color.r + bminc, 0.0);\noutColor.g = max((1.0 + contrast) * color.g + bminc, 0.0);\noutColor.b = max((1.0 + contrast) * color.b + bminc, 0.0);\noutColor.a = color.a;\n}",node_bsdf_anisotropic_bl_frag:"void node_bsdf_anisotropic(\nvec4 color, float roughness, float anisotropy, float rotation, vec3 normal, vec3 tangent,\nout vec4 outColor)\n{\noutColor = color;\n}",node_bsdf_diffuse_bl_frag:"\nvoid node_bsdf_diffuse(\nvec3 geometryNormal,\nvec4 color, float roughness, vec3 normal,\nout vec4 outColor) {\nnormal = vec3(normal[0], normal[2], -normal[1]);\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmaterial.diffuseColor = color.rgb;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#ifdef USE_GTAO\nvec4 gtaoVisibilityBentNormal = texture2D(gtaoMap,\ngl_FragCoord.xy / currResolution);\nvec3 bentNormal = normalize(unpackRGBToNormal(gtaoVisibilityBentNormal.gba));\n#define PROBE_NORMAL bentNormal\n#endif\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_DirectDiffuse\n#undef RE_IndirectDiffuse\n#ifdef PROBE_NORMAL\n#undef PROBE_NORMAL\n#endif\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define 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.specularRoughness = 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.specularRoughness = calcCubeUVAdjustedRoughness(\nmaterial.specularRoughness, 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 CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#ifdef USE_GTAO\nvec4 gtaoVisibilityBentNormal = texture2D(gtaoMap,\ngl_FragCoord.xy / currResolution);\nvec3 bentNormal = normalize(unpackRGBToNormal(gtaoVisibilityBentNormal.gba));\n#define PROBE_NORMAL bentNormal\n#endif\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#define RE_Refraction RE_Refraction_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_DirectSpecular\n#undef RE_IndirectSpecular\n#undef RE_Refraction\n#ifdef PROBE_NORMAL\n#undef PROBE_NORMAL\n#endif\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\n#ifdef USE_GTAO\nfloat gtaoVisibility = gtaoVisibilityBentNormal.r;\nvec3 gtaoBentNormal = bentNormal;\nvec3 gtaoViewDir = geometry.viewDir;\nvec3 gtaoNormal = normal;\nfloat gtaoRoughness = material.specularRoughness;\n#endif\n#include <lights_fragment_gtso>\nvec3 viewWorld;\nif (isPerspective(projectionMatrix))\nviewWorld = (invViewMatrix * vec4(-vViewPosition, 0.0)).xyz;\nelse\nviewWorld = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\nviewWorld = normalize(viewWorld);\nfloat fresnel = fresnelReflection(viewWorld, normalWorld, ior);\noutColor = vec4(color.rgb * mix(refractedLight, reflectedLight.directSpecular\n+ reflectedLight.indirectSpecular, fresnel), 1.0);\n}",node_bsdf_glossy_bl_frag:"\nvoid node_bsdf_glossy(\nvec3 geometryNormal,\nvec4 color, float roughness, vec3 normal,\nout vec4 outColor) {\nnormal = vec3(normal[0], normal[2], -normal[1]);\nnormal = normalize((viewMatrix * vec4(normal.xyz, 0.0)).xyz);\nNodeMaterial material;\nmaterial.specularColor = vec3(1.0);\nmaterial.fresnelRefl90 = vec3(1.0);\nmaterial.specularRoughness = clamp(roughness, 0.0, 1.0);\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.specularRoughness = calcCubeUVAdjustedRoughness(\nmaterial.specularRoughness, geomRoughness);\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#ifdef USE_GTAO\nvec4 gtaoVisibilityBentNormal = texture2D(gtaoMap,\ngl_FragCoord.xy / currResolution);\nvec3 bentNormal = normalize(unpackRGBToNormal(gtaoVisibilityBentNormal.gba));\n#define PROBE_NORMAL bentNormal\n#endif\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_DirectSpecular\n#undef RE_IndirectSpecular\n#ifdef PROBE_NORMAL\n#undef PROBE_NORMAL\n#endif\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\n#ifdef USE_GTAO\nfloat gtaoVisibility = gtaoVisibilityBentNormal.r;\nvec3 gtaoBentNormal = bentNormal;\nvec3 gtaoViewDir = geometry.viewDir;\nvec3 gtaoNormal = normal;\nfloat gtaoRoughness = material.specularRoughness;\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:"\nvec3 tintFromColor(vec3 color) {\nfloat lum = dot(color, vec3(0.3, 0.6, 0.1));\nreturn lum > 0.0 ? color / lum : vec3(1.0);\n}\nvec3 fresnelBlend(float ior, float fresnel, vec3 fresnelColor) {\nfloat fresnelFac = fresnelReflection(vec3(1.0, 0.0, 0.0), vec3(1.0, 0.0, 0.0), ior);\nfloat mixFac = saturate((fresnel - fresnelFac) / max(1e-8, 1.0 - fresnelFac));\nreturn mix(fresnelColor, vec3(1.0), mixFac);\n}\nvoid node_bsdf_principled(\nvec3 geometryNormal,\nvec4 baseColor, float subsurface, vec3 subsurfaceRadius, vec4 subsurfaceColor,\nfloat subsurfaceIOR, float subsurfaceAnisotropy,\nfloat metallic, float specular, float specularTint, float roughness,\nfloat anisotropic, float anisotropicRotation, float sheen, float sheenTint,\nfloat clearcoat, float clearcoatRoughness, float ior,\nfloat transmission, float transmissionRoughness, vec4 emission,\nfloat emissionStrength, float alpha, vec3 normal, vec3 clearcoatNormal,\nvec3 tangent,\nout vec4 outColor) {\nnormal = vec3(normal[0], normal[2], -normal[1]);\nvec3 normalWorld = normal;\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmetallic = clamp(metallic, 0.0, 1.0);\nfloat dielectric = 1.0 - metallic;\ntransmission *= dielectric;\nmaterial.diffuseColor = baseColor.rgb * dielectric;\n#ifndef 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);\n#endif\n#ifdef USE_SHEEN\nmaterial.sheenColor = sheen * mix(vec3(0.1), baseColor.rgb, sheenTint);\nmaterial.sheenRoughness = 0.1;\n#endif\nvec3 dielRefl = dielReflCoeff * specular\n* mix(vec3(1.0), tintFromColor(baseColor.rgb), specularTint);\nmaterial.specularColor = mix(dielRefl, baseColor.rgb, metallic);\nmaterial.specularRoughness = clamp(roughness, 0.0, 1.0);\nvec3 viewWorld;\nif (isPerspective(projectionMatrix))\nviewWorld = (invViewMatrix * vec4(-vViewPosition, 0.0)).xyz;\nelse\nviewWorld = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\nviewWorld = normalize(viewWorld);\nfloat fresnel = fresnelReflection(viewWorld, normalWorld, ior);\nvec3 fresnelColor = mix(vec3(1.0), baseColor.rgb, specularTint);\nmaterial.specularColor = mix(material.specularColor,\nfresnelBlend(ior, fresnel, fresnelColor) * fresnel, transmission);\nfloat isStrictDielectric = step(0.0, -length(vec4(subsurface, clearcoat,\ntransmission, float(metallic == 1.0))));\nmaterial.fresnelRefl90 = mix(vec3(1.0), material.specularColor,\n(1.0 - specular) * metallic * (1.0 - isStrictDielectric));\nmaterial.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.specularRoughness = calcCubeUVAdjustedRoughness(\nmaterial.specularRoughness, geomRoughness);\nmaterial.refractionRoughness = calcCubeUVAdjustedRoughness(\nmaterial.refractionRoughness, geomRoughness);\n#ifdef CLEARCOAT\nmaterial.clearcoatRoughness = calcCubeUVAdjustedRoughness(\nmaterial.clearcoatRoughness, geomRoughness);\nclearcoatNormal = normalize(vec3(clearcoatNormal[0], clearcoatNormal[2], -clearcoatNormal[1]));\nclearcoatNormal = (viewMatrix * vec4(clearcoatNormal.xyz, 0.0)).xyz;\n#endif\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 refractedLight = vec3(0.0);\n#ifdef USE_GTAO\nvec4 gtaoVisibilityBentNormal = texture2D(gtaoMap,\ngl_FragCoord.xy / currResolution);\nvec3 bentNormal = normalize(unpackRGBToNormal(gtaoVisibilityBentNormal.gba));\n#define PROBE_NORMAL bentNormal\n#endif\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#define RE_Refraction RE_Refraction_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#undef RE_Refraction\n#ifdef PROBE_NORMAL\n#undef PROBE_NORMAL\n#endif\n#ifdef USE_GTAO\nreflectedLight.indirectDiffuse *= gtaoVisibilityBentNormal.r;\nfloat gtaoVisibility = gtaoVisibilityBentNormal.r;\nvec3 gtaoBentNormal = bentNormal;\nvec3 gtaoViewDir = geometry.viewDir;\nvec3 gtaoNormal = normal;\nfloat gtaoRoughness = material.specularRoughness;\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;\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 CLEARCOAT\n#undef 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 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 CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#define RE_DirectDiffuse RE_DirectDiffuse_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_DirectDiffuse\n#undef RE_IndirectDiffuse\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse, 1.0);\n}",node_bsdf_transparent_bl_frag:"\nvoid node_bsdf_transparent(vec4 color, out vec4 outColor)\n{\nfloat alpha = saturate(1.0 - dot(color.rgb, vec3(0.333333)));\noutColor = vec4(0.0, 0.0, 0.0, alpha);\n}",node_bsdf_velvet_bl_frag:"void node_bsdf_velvet(vec4 color, float sigma, vec3 normal, out vec4 outColor)\n{\noutColor = color;\n}",node_bump_bl_frag:"\nvoid node_bump(\nconst bool invert,\nfloat strength, float bumpDist, float height, float height_dx,\nfloat height_dy, 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(\nconst bool invert,\nfloat strength, float bumpDist, float height, vec3 normal,\nout vec3 outNormal) {\nnode_bump(invert, strength, bumpDist, height, 0.0, 0.0, normal, outNormal);\n}",node_camera_bl_frag:"\nvoid node_camera(\nvec3 viewPos, const bool invCamZ,\nout vec3 outViewVector, out float outViewZDepth, out float outViewDistance)\n{\nviewPos = -viewPos;\nif (invCamZ)\nviewPos.z = -viewPos.z;\noutViewVector = normalize(viewPos);\noutViewZDepth = abs(viewPos.z);\noutViewDistance = length(viewPos);\n}",node_clamp_bl_frag:"void node_clamp(float value, float minVal, float maxVal, out float result) {\nresult = max(min(value, maxVal), minVal);\n}",node_combhsv_bl_frag:"\nvoid node_combhsv(float h, float s, float v, out vec4 col)\n{\nhsvToRGB(vec4(h, s, v, 1.0), col);\n}",node_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_rgb_bl_frag:"\nvoid node_curve_rgb(sampler2D curveData, float fac, vec4 col, out vec4 outCol)\n{\noutCol.r = texture2D(curveData, vec2(texture2D(curveData, vec2(col.r, 0.0)).a, 0.0)).r;\noutCol.g = texture2D(curveData, vec2(texture2D(curveData, vec2(col.g, 0.0)).a, 0.0)).g;\noutCol.b = texture2D(curveData, vec2(texture2D(curveData, vec2(col.b, 0.0)).a, 0.0)).b;\noutCol = mix(col, outCol, fac);\noutCol.a = col.a;\n}",node_curve_vec_bl_frag:"\nvoid node_curve_vec(sampler2D curveData, float fac, vec3 vec, out vec3 outVec)\n{\noutVec.x = texture2D(curveData, vec2((vec.x + 1.0) * 0.5, 0.0)).x;\noutVec.y = texture2D(curveData, vec2((vec.y + 1.0) * 0.5, 0.0)).y;\noutVec.z = texture2D(curveData, vec2((vec.z + 1.0) * 0.5, 0.0)).z;\noutVec = mix(vec, outVec * 2.0 - vec3(1.0), fac);\n}",node_displacement_bl_frag:"void node_displacement(float height, float midlevel, float scale, vec3 normal, out vec3 outDisplacement) {\noutDisplacement = vec3(0.0);\n}",node_eevee_specular_bl_frag:"void node_eevee_specular(\nvec3 geometryNormal,\nvec4 baseColor, vec4 specular, float roughness, vec4 emissiveColor,\nfloat transparency, vec3 normal, float clearcoat, float clearcoatRoughness,\nvec3 clearcoatNormal, float ambientOcclusion,\nout vec4 outColor) {\nnormal = vec3(normal[0], normal[2], -normal[1]);\nvec3 normalWorld = normal;\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmaterial.diffuseColor = baseColor.rgb;\nmaterial.specularColor = specular.rgb;\nmaterial.specularRoughness = clamp(roughness, 0.0, 1.0);\n#ifdef 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.specularRoughness = calcCubeUVAdjustedRoughness(\nmaterial.specularRoughness, geomRoughness);\n#ifdef CLEARCOAT\nmaterial.clearcoatRoughness = calcCubeUVAdjustedRoughness(\nmaterial.clearcoatRoughness, geomRoughness);\nclearcoatNormal = normalize(vec3(clearcoatNormal[0], clearcoatNormal[2], -clearcoatNormal[1]));\nclearcoatNormal = (viewMatrix * vec4(clearcoatNormal.xyz, 0.0)).xyz;\n#endif\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef USE_GTAO\nvec4 gtaoVisibilityBentNormal = texture2D(gtaoMap,\ngl_FragCoord.xy / currResolution);\nvec3 bentNormal = normalize(unpackRGBToNormal(gtaoVisibilityBentNormal.gba));\n#define PROBE_NORMAL bentNormal\n#endif\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#ifdef PROBE_NORMAL\n#undef PROBE_NORMAL\n#endif\n#ifdef USE_GTAO\nreflectedLight.indirectDiffuse *= gtaoVisibilityBentNormal.r;\nfloat gtaoVisibility = gtaoVisibilityBentNormal.r;\nvec3 gtaoBentNormal = bentNormal;\nvec3 gtaoViewDir = geometry.viewDir;\nvec3 gtaoNormal = normal;\nfloat gtaoRoughness = material.specularRoughness;\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:"\nvoid node_emission(vec4 color, float strength, out vec4 outColor)\n{\noutColor = vec4(strength * color.rgb, 1.0);\n}",node_fresnel_bl_frag:"void node_fresnel(vec3 viewPos, float IOR, vec3 normal, out float fac)\n{\nvec3 worldDir;\nif (isPerspective(projectionMatrix))\nworldDir = (invViewMatrix * vec4(-viewPos, 0.0)).xyz;\nelse\nworldDir = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\n\nworldDir = normalize(swizzleUpZ(worldDir));\nfloat eta = max(IOR, 0.00001);\nfac = fresnelReflection(worldDir, normal, (gl_FrontFacing) ? eta : 1.0 / eta);\n}",node_gamma_bl_frag:"\nvoid node_gamma(vec4 col, float gamma, out vec4 outCol)\n{\noutCol = col;\nif (col.r > 0.0)\noutCol.r = powCompat(col.r, gamma);\nif (col.g > 0.0)\noutCol.g = powCompat(col.g, gamma);\nif (col.b > 0.0)\noutCol.b = powCompat(col.b, gamma);\n}",node_hair_info_bl_frag:"void node_hair_info(out float isStrand, out float intercept, out float thickness,\nout vec3 tangentNormal, out float random) {\nisStrand = 0.0;\nintercept = 0.0;\nthickness = 0.0;\ntangentNormal = vec3(0.0);\nrandom = 0.0;\n}",node_holdout_bl_frag:"void node_holdout(out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_hue_sat_bl_frag:"\nvoid node_hue_sat(float hue, float sat, float value, float fac, vec4 col, out vec4 outCol)\n{\nvec4 hsv;\nrgbToHSV(col, hsv);\nhsv[0] += (fract(hue) - 0.5);\nif (hsv[0] > 1.0) hsv[0] -= 1.0; else if (hsv[0] < 0.0) hsv[0] += 1.0;\nhsv[1] *= sat;\nif (hsv[1] > 1.0) hsv[1] = 1.0; else if (hsv[1] < 0.0) hsv[1] = 0.0;\nhsv[2] *= value;\nhsvToRGB(hsv, outCol);\noutCol = mix(col, outCol, fac);\n}",node_invert_bl_frag:"\nvoid node_invert(float fac, vec4 col, out vec4 outCol)\n{\noutCol.xyz = mix(col.xyz, vec3(1.0, 1.0, 1.0) - col.xyz, fac);\noutCol.w = col.w;\n}",node_layer_weight_bl_frag:"\nvoid node_layer_weight(vec3 viewPos, float blend, vec3 normal, out float fresnel, out float facing)\n{\nvec3 worldDir;\nif (isPerspective(projectionMatrix))\nworldDir = (invViewMatrix * vec4(-viewPos, 0.0)).xyz;\nelse\nworldDir = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\n\nworldDir = normalize(swizzleUpZ(worldDir));\nfloat eta = max(1.0 - blend, EPSILON);\nfresnel = fresnelReflection(worldDir, normal, (gl_FrontFacing) ? 1.0 / eta : eta);\nfacing = abs(dot(worldDir, normal));\nif (blend != 0.5) {\nblend = clamp(blend, 0.0, 1.0 - EPSILON);\nblend = (blend < 0.5) ? blend * 2.0 : 0.5 / (1.0 - blend);\nfacing = pow(facing, blend);\n}\nfacing = 1.0 - facing;\n}",node_light_falloff_bl_frag:"void node_light_falloff(\nfloat strength, float inSmooth,\nout float quadratic, out float linear, out float constant)\n{\nquadratic = 1.0;\nlinear = 1.0;\nconstant = 1.0;\n}",node_light_path_bl_frag:"void node_light_path(\nout float isCameraRay, out float isShadowRay, out float isDiffuseRay, \nout float isGlossyRay, out float isSingularRay, out float isReflectionRay,\nout float isTransmissionRay, out float rayLength, out float rayDepth, \nout float diffuseDepth, out float glossyDepth, out float transparentDepth, \nout float transmissionDepth)\n{\n#if LIGHT_PATH_IS_CAM_RAY\nisCameraRay = 1.0;\n#else\nisCameraRay = 0.0;\n#endif\nisShadowRay = 0.0;\nisDiffuseRay = 0.0;\nisGlossyRay = 0.0;\nisSingularRay = 0.0;\nisReflectionRay = 0.0;\nisTransmissionRay = 0.0;\nrayLength = 1.0;\nrayDepth = 1.0;\ndiffuseDepth = 1.0;\nglossyDepth = 1.0;\ntransparentDepth = 1.0; \ntransmissionDepth = 1.0;\n}",node_mapping_bl_frag:"\nvoid node_mapping(mat4 mat, vec3 minVec, vec3 maxVec, bool useMin, bool useMax, vec3 vec, out vec3 outVec)\n{\noutVec = (mat * vec4(vec, 1.0)).xyz;\nif (useMin)\noutVec = max(outVec, minVec);\nif (useMax)\noutVec = min(outVec, maxVec);\n}\nmat3 rotationMatrix(float angleX, float angleY, float angleZ) {\nfloat cx = cos(angleX);\nfloat sx = sin(angleX);\nfloat cy = cos(angleY);\nfloat sy = sin(angleY);\nfloat cz = cos(angleZ);\nfloat sz = sin(angleZ);\nmat3 mat;\nmat[0][0] = cy * cz;\nmat[0][1] = cy * sz;\nmat[0][2] = -sy;\nmat[1][0] = sy * sx * cz - cx * sz;\nmat[1][1] = sy * sx * sz + cx * cz;\nmat[1][2] = cy * sx;\nmat[2][0] = sy * cx * cz + sx * sz;\nmat[2][1] = sy * cx * sz - sx * cz;\nmat[2][2] = cy * cx;\nreturn mat;\n}\n#define NODE_MAPPING_POINT 1\n#define NODE_MAPPING_TEXTURE 2\n#define NODE_MAPPING_VECTOR 3\n#define NODE_MAPPING_NORMAL 4\nvoid node_mapping(int type, vec3 vec, vec3 loc, vec3 rot, vec3 scale, out vec3 outVec)\n{\nif (type == NODE_MAPPING_POINT)\noutVec = rotationMatrix(rot.x, rot.y, rot.z) * (vec * scale) + loc;\nelse if (type == NODE_MAPPING_TEXTURE)\noutVec = transposeMat3(rotationMatrix(rot.x, rot.y, rot.z)) * (vec - loc) / scale;\nelse if (type == NODE_MAPPING_VECTOR)\noutVec = rotationMatrix(rot.x, rot.y, rot.z) * (vec * scale);\nelse {\nmat3 rot = rotationMatrix(rot.x, rot.y, rot.z) * mat3(\nscale[0], 0.0, 0.0,\n0.0, scale[1], 0.0,\n0.0, 0.0, scale[2]\n);\noutVec = normalize(mat3GetInverseTransposed(rot) * vec);\n}\n}",node_map_range_bl_frag:"#define NODE_MAP_RANGE_INTERP_LINEAR 0\n#define NODE_MAP_RANGE_INTERP_STEPPED 1\n#define NODE_MAP_RANGE_INTERP_SMOOTHSTEP 2\n#define NODE_MAP_RANGE_INTERP_SMOOTHERSTEP 3\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 interpolation, bool inClamp, float value,\nfloat fromMin, float fromMax, float toMin, float toMax, out float result) {\nnode_map_range(NODE_MAP_RANGE_INTERP_LINEAR, inClamp, value, fromMin,\nfromMax, toMin, toMax, 0.0, result);\n}",node_math_bl_frag:"\nvoid node_math_add(float val1, float val2, float val3, out float outVal)\n{\noutVal = val1 + val2;\n}\nvoid node_math_subtract(float val1, float val2, float val3, out float outVal)\n{\noutVal = val1 - val2;\n}\nvoid node_math_multiply(float val1, float val2, float val3, out float outVal)\n{\noutVal = val1 * val2;\n}\nvoid node_math_divide(float val1, float val2, float val3, out float outVal)\n{\nif (val2 == 0.0)\noutVal = 0.0;\nelse\noutVal = val1 / val2;\n}\nvoid node_math_sine(float val, float val2, float val3, out float outVal)\n{\noutVal = sin(val);\n}\nvoid node_math_cosine(float val, float val2, float val3, out float outVal)\n{\noutVal = cos(val);\n}\nvoid node_math_tangent(float val, float val2, float val3, out float outVal)\n{\noutVal = tan(val);\n}\nvoid node_math_arcsine(float val, float val2, float val3, out float outVal)\n{\nif (val <= 1.0 && val >= -1.0)\noutVal = asin(val);\nelse\noutVal = 0.0;\n}\nvoid node_math_arccosine(float val, float val2, float val3, out float outVal)\n{\nif (val <= 1.0 && val >= -1.0)\noutVal = acos(val);\nelse\noutVal = 0.0;\n}\nvoid node_math_arctangent(float val, float val2, float val3, out float outVal)\n{\noutVal = atan(val);\n}\nvoid node_math_arctan2(float val, float val2, float val3, out float outVal)\n{\noutVal = atan(val, val2);\n}\nvoid node_math_power(float val1, float val2, float val3, out float outVal)\n{\nif (val1 >= 0.0)\noutVal = powCompat(val1, val2);\nelse {\nfloat val2_mod_1 = mod(abs(val2), 1.0);\nif (val2_mod_1 > 0.999 || val2_mod_1 < 0.001)\noutVal = powCompat(val1, floor(val2 + 0.5));\nelse\noutVal = 0.0;\n}\n}\nvoid node_math_logarithm(float val1, float val2, float val3, out float outVal)\n{\nif (val1 > 0.0 && val2 > 0.0)\noutVal = log2(val1) / log2(val2);\nelse\noutVal = 0.0;\n}\nvoid node_math_sqrt(float val1, float val2, float val3, out float outVal)\n{\noutVal = sqrt(val1);\n}\nvoid node_math_maximum(float val1, float val2, float val3, out float outVal)\n{\noutVal = max(val1, val2);\n}\nvoid node_math_minimum(float val1, float val2, float val3, out float outVal)\n{\noutVal = min(val1, val2);\n}\nvoid node_math_round(float val1, float val2, float val3, out float outVal)\n{\noutVal = floor(val1 + 0.5);\n}\nvoid node_math_floor(float val1, float val2, float val3, out float outVal)\n{\noutVal = floor(val1);\n}\nvoid node_math_ceil(float val1, float val2, float val3, out float outVal)\n{\noutVal = ceil(val1);\n}\nvoid node_math_fract(float val1, float val2, float val3, out float outVal)\n{\noutVal = fract(val1);\n}\nvoid node_math_less_than(float val1, float val2, float val3, out float outVal)\n{\nif (val1 < val2)\noutVal = 1.0;\nelse\noutVal = 0.0;\n}\nvoid node_math_greater_than(float val1, float val2, float val3, out float outVal)\n{\nif (val1 > val2)\noutVal = 1.0;\nelse\noutVal = 0.0;\n}\nvoid node_math_modulo(float val1, float val2, float val3, out float outVal)\n{\nif (val2 == 0.0)\noutVal = 0.0;\nelse\noutVal = mod(val1, val2);\noutVal = (val1 > 0.0) ? outVal : outVal - val2;\n}\nvoid node_math_absolute(float val1, float val2, float val3, out float outVal)\n{\noutVal = abs(val1);\n}\nvoid node_math_compare(float val1, float val2, float val3, out float outVal) {\noutVal = step(abs(val1 - val2), val3);\n}\nvoid node_math_cosh(float val1, float val2, float val3, out float outVal) {\noutVal = cosh(val1);\n}\nvoid node_math_degrees(float val1, float val2, float val3, out float outVal) {\noutVal = val1 / PI * 180.0;\n}\nvoid node_math_exponent(float val1, float val2, float val3, out float outVal) {\noutVal = exp(val1);\n}\nvoid node_math_inverse_sqrt(float val1, float val2, float val3, out float outVal) {\nif (val1 >= 0.0) {\noutVal = 1.0 / sqrt(val1);\n} else {\noutVal = 0.0;\n}\n}\nvoid node_math_multiply_add(float val1, float val2, float val3, out float outVal) {\noutVal = val1 * val2 + val3;\n}\nvoid node_math_pingpong(float val1, float val2, float val3, out float outVal) {\nif (val2 == 0.0) {\noutVal = 0.0;\n} else {\nfloat absVal2 = abs(val2);\nfloat rem = mod(val1, absVal2);\noutVal = mix(rem, absVal2 - rem, mod(floor(val1 / absVal2), 2.0));\n}\n}\nvoid node_math_radians(float val1, float val2, float val3, out float outVal) {\noutVal = val1 / 180.0 * PI;\n}\nvoid node_math_sign(float val1, float val2, float val3, out float outVal) {\noutVal = sign(val1);\n}\nvoid node_math_sinh(float val1, float val2, float val3, out float outVal) {\noutVal = sinh(val1);\n}\nvoid node_math_smooth_max(float val1, float val2, float val3, out float outVal) {\noutVal = smoothMax(val1, val2, val3);\n}\nvoid node_math_smooth_min(float val1, float val2, float val3, out float outVal) {\noutVal = smoothMin(val1, val2, val3);\n}\nvoid node_math_snap(float val1, float val2, float val3, out float outVal) {\nval1 += 1e-5 * sign(val2);\nfloat quot = val1 / val2;\noutVal = floor(quot) * val2;\n}\nvoid node_math_tanh(float val1, float val2, float val3, out float outVal) {\noutVal = tanh(val1);\n}\nvoid node_math_trunc(float val1, float val2, float val3, out float outVal) {\nval1 += 1e-5;\noutVal = trunc(val1);\n}\nvoid node_math_wrap(float val1, float val2, float val3, out float outVal) {\nval1 += 1e-5;\noutVal = mod(val1 - val3, val2 - val3) + val3;\n}\nvoid node_math_add(float val1, float val2, out float outVal) {\nnode_math_add(val1, val2, 0.0, outVal);\n}\nvoid node_math_subtract(float val1, float val2, out float outVal) {\nnode_math_subtract(val1, val2, 0.0, outVal);\n}\nvoid node_math_multiply(float val1, float val2, out float outVal) {\nnode_math_multiply(val1, val2, 0.0, outVal);\n}\nvoid node_math_divide(float val1, float val2, out float outVal) {\nnode_math_divide(val1, val2, 0.0, outVal);\n}\nvoid node_math_sine(float val1, float val2, out float outVal) {\nnode_math_sine(val1, val2, 0.0, outVal);\n}\nvoid node_math_cosine(float val1, float val2, out float outVal) {\nnode_math_cosine(val1, val2, 0.0, outVal);\n}\nvoid node_math_tangent(float val1, float val2, out float outVal) {\nnode_math_tangent(val1, val2, 0.0, outVal);\n}\nvoid node_math_arcsine(float val1, float val2, out float outVal) {\nnode_math_arcsine(val1, val2, 0.0, outVal);\n}\nvoid node_math_arccosine(float val1, float val2, out float outVal) {\nnode_math_arccosine(val1, val2, 0.0, outVal);\n}\nvoid node_math_arctangent(float val1, float val2, out float outVal) {\nnode_math_arctangent(val1, val2, 0.0, outVal);\n}\nvoid node_math_arctan2(float val1, float val2, out float outVal) {\nnode_math_arctan2(val1, val2, 0.0, outVal);\n}\nvoid node_math_power(float val1, float val2, out float outVal) {\nnode_math_power(val1, val2, 0.0, outVal);\n}\nvoid node_math_logarithm(float val1, float val2, out float outVal) {\nnode_math_logarithm(val1, val2, 0.0, outVal);\n}\nvoid node_math_sqrt(float val1, float val2, out float outVal) {\nnode_math_sqrt(val1, val2, 0.0, outVal);\n}\nvoid node_math_maximum(float val1, float val2, out float outVal) {\nnode_math_maximum(val1, val2, 0.0, outVal);\n}\nvoid node_math_minimum(float val1, float val2, out float outVal) {\nnode_math_minimum(val1, val2, 0.0, outVal);\n}\nvoid node_math_round(float val1, float val2, out float outVal) {\nnode_math_round(val1, val2, 0.0, outVal);\n}\nvoid node_math_floor(float val1, float val2, out float outVal) {\nnode_math_floor(val1, val2, 0.0, outVal);\n}\nvoid node_math_ceil(float val1, float val2, out float outVal) {\nnode_math_ceil(val1, val2, 0.0, outVal);\n}\nvoid node_math_fract(float val1, float val2, out float outVal) {\nnode_math_fract(val1, val2, 0.0, outVal);\n}\nvoid node_math_less_than(float val1, float val2, out float outVal) {\nnode_math_less_than(val1, val2, 0.0, outVal);\n}\nvoid node_math_greater_than(float val1, float val2, out float outVal) {\nnode_math_greater_than(val1, val2, 0.0, outVal);\n}\nvoid node_math_modulo(float val1, float val2, out float outVal) {\nnode_math_modulo(val1, val2, 0.0, outVal);\n}\nvoid node_math_absolute(float val1, float val2, out float outVal) {\nnode_math_absolute(val1, val2, 0.0, outVal);\n}",node_mix_rgb_bl_frag:"\nvoid node_mix_rgb_mix(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_add(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col1 + col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_multiply(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col1 * col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_screen(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = vec4(1.0) - (vec4(facm) + fac * (vec4(1.0) - col2)) * (vec4(1.0) - col1);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_overlay(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nif (outCol.r < 0.5)\noutCol.r *= facm + 2.0 * fac * col2.r;\nelse\noutCol.r = 1.0 - (facm + 2.0 * fac * (1.0 - col2.r)) * (1.0 - outCol.r);\nif (outCol.g < 0.5)\noutCol.g *= facm + 2.0 * fac * col2.g;\nelse\noutCol.g = 1.0 - (facm + 2.0 * fac * (1.0 - col2.g)) * (1.0 - outCol.g);\nif (outCol.b < 0.5)\noutCol.b *= facm + 2.0 * fac * col2.b;\nelse\noutCol.b = 1.0 - (facm + 2.0 * fac * (1.0 - col2.b)) * (1.0 - outCol.b);\n}\nvoid node_mix_rgb_subtract(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col1 - col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_divide(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nif (col2.r != 0.0) outCol.r = facm * outCol.r + fac * outCol.r / col2.r;\nif (col2.g != 0.0) outCol.g = facm * outCol.g + fac * outCol.g / col2.g;\nif (col2.b != 0.0) outCol.b = facm * outCol.b + fac * outCol.b / col2.b;\n}\nvoid node_mix_rgb_difference(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, abs(col1 - col2), fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_darken(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol.rgb = min(col1.rgb, col2.rgb * fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_lighten(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol.rgb = max(col1.rgb, col2.rgb * fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_dodge(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = col1;\nif (outCol.r != 0.0) {\nfloat tmp = 1.0 - fac * col2.r;\nif (tmp <= 0.0)\noutCol.r = 1.0;\nelse if ((tmp = outCol.r / tmp) > 1.0)\noutCol.r = 1.0;\nelse\noutCol.r = tmp;\n}\nif (outCol.g != 0.0) {\nfloat tmp = 1.0 - fac * col2.g;\nif (tmp <= 0.0)\noutCol.g = 1.0;\nelse if ((tmp = outCol.g / tmp) > 1.0)\noutCol.g = 1.0;\nelse\noutCol.g = tmp;\n}\nif (outCol.b != 0.0) {\nfloat tmp = 1.0 - fac * col2.b;\nif (tmp <= 0.0)\noutCol.b = 1.0;\nelse if ((tmp = outCol.b / tmp) > 1.0)\noutCol.b = 1.0;\nelse\noutCol.b = tmp;\n}\n}\nvoid node_mix_rgb_burn(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat tmp, facm = 1.0 - fac;\noutCol = col1;\ntmp = facm + fac * col2.r;\nif (tmp <= 0.0)\noutCol.r = 0.0;\nelse if ((tmp = (1.0 - (1.0 - outCol.r) / tmp)) < 0.0)\noutCol.r = 0.0;\nelse if (tmp > 1.0)\noutCol.r = 1.0;\nelse\noutCol.r = tmp;\ntmp = facm + fac * col2.g;\nif (tmp <= 0.0)\noutCol.g = 0.0;\nelse if ((tmp = (1.0 - (1.0 - outCol.g) / tmp)) < 0.0)\noutCol.g = 0.0;\nelse if (tmp > 1.0)\noutCol.g = 1.0;\nelse\noutCol.g = tmp;\ntmp = facm + fac * col2.b;\nif (tmp <= 0.0)\noutCol.b = 0.0;\nelse if ((tmp = (1.0 - (1.0 - outCol.b) / tmp)) < 0.0)\noutCol.b = 0.0;\nelse if (tmp > 1.0)\noutCol.b = 1.0;\nelse\noutCol.b = tmp;\n}\n#ifdef HSV_NODES\nvoid node_mix_rgb_hue(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nvec4 hsv, hsv2, tmp;\nrgbToHSV(col2, hsv2);\nif (hsv2.y != 0.0) {\nrgbToHSV(outCol, hsv);\nhsv.x = hsv2.x;\nhsvToRGB(hsv, tmp);\noutCol = mix(outCol, tmp, fac);\noutCol.a = col1.a;\n}\n}\nvoid node_mix_rgb_saturation(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nvec4 hsv, hsv2;\nrgbToHSV(outCol, hsv);\nif (hsv.y != 0.0) {\nrgbToHSV(col2, hsv2);\nhsv.y = facm * hsv.y + fac * hsv2.y;\nhsvToRGB(hsv, outCol);\n}\n}\nvoid node_mix_rgb_value(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\nvec4 hsv, hsv2;\nrgbToHSV(col1, hsv);\nrgbToHSV(col2, hsv2);\nhsv.z = facm * hsv.z + fac * hsv2.z;\nhsvToRGB(hsv, outCol);\n}\nvoid node_mix_rgb_color(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nvec4 hsv, hsv2, tmp;\nrgbToHSV(col2, hsv2);\nif (hsv2.y != 0.0) {\nrgbToHSV(outCol, hsv);\nhsv.x = hsv2.x;\nhsv.y = hsv2.y;\nhsvToRGB(hsv, tmp);\noutCol = mix(outCol, tmp, fac);\noutCol.a = col1.a;\n}\n}\n#endif\nvoid node_mix_rgb_soft_light(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\nvec4 one = vec4(1.0);\nvec4 scr = one - (one - col2) * (one - col1);\noutCol = facm * col1 + fac * ((one - col1) * col2 * col1 + col1 * scr);\n}\nvoid node_mix_rgb_linear_light(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = col1 + fac * (2.0 * (col2 - vec4(0.5)));\n}",node_mix_shader_bl_frag:"\nvoid node_mix_shader(int transpShaderNum,\nfloat fac, vec4 color1, vec4 color2, out vec4 outColor)\n{\nif (transpShaderNum == 0)\ncolor1.rgb = color2.rgb;\nelse if (transpShaderNum == 1)\ncolor2.rgb = color1.rgb;\noutColor = mix(color1, color2, fac);\n}",node_new_geometry_bl_frag:"void node_new_geometry(\nbool frontFacing, vec3 viewPos, vec3 viewNorm,\nout vec3 position, out vec3 normal, out vec3 tangent,\nout vec3 trueNormal, out vec3 incoming, out vec3 parametric,\nout float backfacing, out float pointiness, out float randomPerIsland)\n{\nvec4 posWorld = invViewMatrix * vec4(-viewPos, 1.0);\nposition = swizzleUpZ(posWorld.xyz);\nvec4 viewDir = isOrtho(projectionMatrix) ? vec4(0.0, 0.0, -1.0, 0.0) : vec4(normalize(-viewPos), 0.0);\nviewDir = invViewMatrix * viewDir;\nvec3 incomingVec = -swizzleUpZ(viewDir.xyz);\n#if WORLD_NODES == 1\nnormal = incomingVec;\ntangent = vec3(0.0);\n#else\nvec3 norWorld = normalize(invViewMatrix * vec4(viewNorm, 0.0)).xyz;\nnormal = swizzleUpZ(norWorld);\nvec4 posLocal = invModelMatrix * posWorld;\nvec3 posLocalDelta = posLocal.xyz - boundingBoxMin;\nvec3 bbDelta = boundingBoxMax - boundingBoxMin;\nvec3 posOrco = vec3(\nbbDelta.x < 1e-5 ? -sign(posLocal.y) : posLocalDelta.x / bbDelta.x,\n0.0,\nbbDelta.z < 1e-5 ? sign(posLocal.y) : posLocalDelta.z / bbDelta.z\n);\nposOrco -= 0.5;\nvec3 tangWorld = (modelMatrix * vec4(posOrco.z, 0.0, -posOrco.x, 0.0)).xyz;\ntangWorld = cross(norWorld, normalize(cross(tangWorld, norWorld)));\ntangent = swizzleUpZ(tangWorld);\n#endif\ntrueNormal = normal;\nincoming = incomingVec;\nparametric = vec3(0.0);\nbackfacing = (frontFacing) ? 0.0 : 1.0;\n#if WORLD_NODES == 1\npointiness = 0.0;\n#else\npointiness = 0.5;\n#endif\nrandomPerIsland = 0.0;\n}\nvoid node_new_geometry(\nbool frontFacing, vec3 viewPos, vec3 viewNorm,\nout vec3 position, out vec3 normal, out vec3 tangent,\nout vec3 trueNormal, out vec3 incoming, out vec3 parametric,\nout float backfacing, out float pointiness) {\nfloat randomPerIsland;\nnode_new_geometry(frontFacing, viewPos, viewNorm, position, normal, tangent,\ntrueNormal, incoming, parametric, backfacing, pointiness, randomPerIsland);\n}",node_normal_bl_frag:"\nvoid node_normal(vec3 norParam, vec3 norIn, out vec3 norOut, out float dotOut)\n{\nnorOut = norParam;\ndotOut = dot(normalize(norIn), norParam);\n}",node_normal_map_bl_frag:"\nvoid node_normal_map(vec4 tangent, vec3 normal, float strength, vec4 normalColor, out vec3 normalOut)\n{\n#ifdef DOUBLE_SIDED\nnormal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\nvec3 normalTex = (normalColor.xyz * 2.0 - 1.0);\nvec4 viewTangent = vec4(normalize((modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz), tangent.w);\nvec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\nnormalOut = normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n+ normalTex.z * normal);\nnormalOut = mix(normal, normalOut, strength);\nnormalOut = normalize((invViewMatrix * vec4(normalOut, 0.0)).xyz);\nnormalOut = swizzleUpZ(normalOut);\n}",node_object_info_bl_frag:"uniform int objectIndex;\nuniform vec3 objectColor;\nuniform int materialIndex;\nuniform float objectRandom;\nvoid node_object_info(out vec3 location, out vec4 color, out float objIndex,\nout float matIndex, out float random) {\n#if WORLD_NODES == 1\nlocation = vec3(0.0);\ncolor = vec4(1.0);\nobjIndex = 0.0;\nmatIndex = 0.0;\nrandom = 0.0;\n#else\nlocation = swizzleUpZ(modelMatrix[3].xyz);\ncolor = vec4(objectColor, 1.0);\nobjIndex = float(objectIndex);\nmatIndex = float(materialIndex);\nrandom = float(objectRandom);\n#endif\n}\nvoid node_object_info(out vec3 location, out float objIndex, out float matIndex, out float random) {\n#if WORLD_NODES == 1\nlocation = vec3(0.0);\nobjIndex = 0.0;\nmatIndex = 0.0;\nrandom = 0.0;\n#else\nlocation = vec3(0.0);\nobjIndex = 0.0;\nmatIndex = 0.0;\nrandom = 0.5;\n#endif\n}",node_output_lamp_bl_frag:"void node_output_lamp(out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_output_material_bl_frag:"\nvoid node_output_material(vec4 surface, vec4 volume, float displacement, out vec4 outgoingLight) {\noutgoingLight = surface + volume;\n}\nvoid node_output_material(vec4 surface, vec4 volume, vec3 displacement, out vec4 outgoingLight) {\noutgoingLight = surface + volume;\n}",node_output_world_bl_frag:"void node_output_world(vec4 surface, vec4 volume, out vec4 outgoingLight)\n{\noutgoingLight = surface;\n}",node_particle_info_bl_frag:"\nvoid node_particle_info(out float index, out float random, out float age,\nout float lifeTime, out vec3 location, out float size, out vec3 velocity,\nout vec3 angularVelocity) {\n#if WORLD_NODES == 1\nindex = 0.0;\nrandom = 0.0;\nage = 0.0;\nlifeTime = 0.0;\nlocation = vec3(0.0);\nsize = 0.0;\nvelocity = vec3(0.0);\nangularVelocity = vec3(0.0);\n#else\nindex = 0.0;\nrandom = 0.0;\nage = 0.0;\nlifeTime = 0.0;\nlocation = vec3(0.0);\nsize = 0.0;\nvelocity = vec3(0.0);\nangularVelocity = vec3(0.0);\n#endif\n}",node_principled_volume_bl_frag:"void node_principled_volume(vec4 color, float colorAttribute, float density,\nfloat densityAttribute, float anisotropy, vec4 absorptionColor,\nfloat emissionStrength, vec4 emissionColor, float blackbodyIntensity,\nvec4 blackbodyTint, float temperature, float temperatureAttribute,\nout vec4 volume) {\nvolume = vec4(0.0);\n}",node_rgb_bl_frag:"\nuniform vec4 nodeRGB[NODE_RGB_NUM];\nvoid node_rgb(vec4 color, out vec4 outColor)\n{\noutColor = color;\n}",node_rgbtobw_bl_frag:"\nvoid node_rgbtobw(vec4 color, out float outVal) {\noutVal = linearToRelativeLuminance(color.rgb);\n}",node_script_bl_frag:"void node_script(out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_sephsv_bl_frag:"\nvoid node_sephsv(vec4 col, out float h, out float s, out float v)\n{\nvec4 hsv;\nrgbToHSV(col, hsv);\nh = hsv[0];\ns = hsv[1];\nv = hsv[2];\n}",node_seprgb_bl_frag:"\nvoid node_seprgb(vec4 col, out float r, out float g, out float b)\n{\nr = col.r;\ng = col.g;\nb = col.b;\n}",node_sepxyz_bl_frag:"void node_sepxyz(vec3 vector, out float x, out float y, out float z)\n{\nx = vector.x;\ny = vector.y;\nz = vector.z;\n}",node_shadertorgb_bl_frag:"void node_shadertorgb(vec4 shader, out vec4 color, out float alpha) {\ncolor = vec4(shader.rgb, 1.0);\nalpha = shader.a;\n}",node_squeeze_bl_frag:"\nvoid node_squeeze(float val, float width, float center, out float outVal)\n{\noutVal = 1.0 / (1.0 + pow(2.71828183, -((val - center) * width)));\n}",node_subsurface_scattering_bl_frag:"void node_subsurface_scattering(\nvec4 color, float scale, vec3 radius, float sharpen, float textureBlur, vec3 normal,\nout vec4 outColor)\n{\noutColor = color;\n}",node_tangent_bl_frag:"#define TANGENT_AXIS_X 0\n#define TANGENT_AXIS_Y 1\n#define TANGENT_AXIS_Z 2\nvoid node_tangent(int axis, vec3 viewPos, vec3 viewNorm, out vec3 outTangent) {\noutTangent = vec3(0.0);\n#if WORLD_NODES == 0\nvec4 posWorld = invViewMatrix * vec4(-viewPos, 1.0);\nvec3 norWorld = normalize(invViewMatrix * vec4(viewNorm, 0.0)).xyz;\nvec3 posLocal = (invModelMatrix * posWorld).xyz;\nvec3 posOrco = (posLocal - boundingBoxMin)\n/ (boundingBoxMax - boundingBoxMin) - 0.5;\nvec4 posOrcoPermuted;\nif (axis == TANGENT_AXIS_X) {\nposOrcoPermuted = vec4(0.0, -posOrco.z, posOrco.y, 0.0);\n} else if (axis == TANGENT_AXIS_Y) {\nposOrcoPermuted = vec4(-posOrco.y, posOrco.x, 0.0, 0.0);\n} else if (axis == TANGENT_AXIS_Z) {\nposOrcoPermuted = vec4(posOrco.z, 0.0, -posOrco.x, 0.0);\n}\nvec3 tangWorld = (modelMatrix * posOrcoPermuted).xyz;\ntangWorld = cross(norWorld, normalize(cross(tangWorld, norWorld)));\noutTangent = swizzleUpZ(tangWorld);\n#endif\n}\nvoid node_tangent(vec4 tangent, out vec3 outTangent) {\n#if WORLD_NODES == 0\noutTangent = normalize((modelMatrix * vec4(tangent.xyz, 0.0)).xyz);\noutTangent = swizzleUpZ(outTangent);\n#endif\n}",node_tex_brick_bl_frag:"float integer_noise(int rowCount, int brickCount)\n{\n#if __VERSION__ == 300\nint n = (rowCount << 16) + (brickCount & 0xFFFF);\nn = (n + 1013) & 0x7fffffff;\nn = (n >> 13) ^ n;\nint nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;\nreturn 0.5 * (float(nn) / 1073741824.0);\n#else\nconst int RAND_MAX = 32767;\nint next = ((123456 * rowCount) + brickCount) * 1103515245 + 12345;\nreturn (mod(float(next/65536), float(RAND_MAX + 1))) / float(RAND_MAX);\n#endif\n}\nvoid node_tex_brick(\nfloat offset, int offsetFrequency, float squash, int squashFrequency, \nvec3 vector, vec4 color1, vec4 color2, vec4 mortar, float scale,\nfloat mortarSize, float mortarSmooth, float bias, float brickWidth,\nfloat rowHeight,\nout vec4 outColor, out float outFac)\n{\nfloat x, y;\nvec3 p = vector * scale;\nfloat rowCount = floor(p.y / rowHeight);\nif (offsetFrequency != 0 && squashFrequency != 0) {\nbrickWidth *= mod(rowCount, float(squashFrequency)) > 0.5 ? 1.0 : squash;\noffset = mod(rowCount, float(offsetFrequency)) > 0.5 ? 0.0 : (brickWidth * offset);\n} \nint brickCount = int((p.x + offset) / brickWidth); \nfloat tint = clamp((integer_noise(int(rowCount), brickCount) + bias), 0.0, 1.0);\n\nx = (p.x + offset) - brickWidth * float(brickCount);\ny = p.y - rowHeight * rowCount;\nfloat min_dist = min(min(x, y), min(brickWidth - x, rowHeight - y));\n\nfloat f = step(min_dist, mortarSize);\nif (mortarSmooth > 0.0) {\nmin_dist = 1.0 - min_dist / mortarSize;\nf *= smoothstep(0.0, mortarSmooth, min_dist);\n}\noutColor = mix(mix(color1, color2, tint), mortar, f);\noutFac = f;\n}",node_tex_checker_bl_frag:"void node_tex_checker(vec3 vector, vec4 color1, vec4 color2, float scale, \nout vec4 outColor, out float outFac)\n{\nvec3 p = vector * scale;\np = (p + 0.00001) * 0.99999;\nfloat cx = floor(p.x);\nfloat cy = floor(p.y);\nfloat cz = floor(p.z);\nfloat result = sign(mod(cx + cy + cz, 2.0));\noutFac = max(result, 0.0);\noutColor = mix(color2, color1, outFac);\n}",node_tex_coord_bl_frag:"uniform mat4 nodeTexCoordObjectMatrices[NODE_TEX_COORD_NUM];\nvoid node_tex_coord(\nmat4 objectMat, vec3 viewPos, vec3 viewNorm, vec2 uv,\nout vec3 outGenerated, out vec3 outNormal, out vec3 outUV, out vec3 outObject,\nout vec3 outCamera, out vec3 outWindow, out vec3 outReflection)\n{\nvec4 view = vec4(-viewPos, 1.0);\nvec4 posWorld = invViewMatrix * view;\nvec3 loc = swizzleUpZ((invModelMatrix * posWorld).xyz);\n#if WORLD_NODES == 1\nloc = normalize(loc);\n#endif\n#if WORLD_NODES == 1\noutGenerated = loc;\n#else\nvec3 boxMin = vec3(boundingBoxMin.x, -boundingBoxMax.z, boundingBoxMin.y);\nvec3 boxMax = vec3(boundingBoxMax.x, -boundingBoxMin.z, boundingBoxMax.y);\nvec3 boxSize = boxMax - boxMin;\nif (abs(boxSize.x) < 0.001) {\noutGenerated.x = 0.5;\n} else {\noutGenerated.x = (loc.x - boxMin.x) / boxSize.x;\n}\nif (abs(boxSize.y) < 0.001) {\noutGenerated.y = 0.5;\n} else {\noutGenerated.y = (loc.y - boxMin.y) / boxSize.y;\n}\nif (abs(boxSize.z) < 0.001) {\noutGenerated.z = 0.5;\n} else {\noutGenerated.z = (loc.z - boxMin.z) / boxSize.z;\n}\n#endif\n#if WORLD_NODES == 1\noutNormal = -loc;\n#else\noutNormal = normalize(invModelMatrix * invViewMatrix * vec4(viewNorm, 0.0)).rgb;\noutNormal = swizzleUpZ(outNormal);\n#endif\n#if WORLD_NODES == 1\noutUV = vec3(0.0);\n#else\nuv.y = 1.0 - uv.y;\noutUV = vec3(uv, 0.0);\n#endif\n#if WORLD_NODES == 1\noutObject = loc;\n#else\noutObject = swizzleUpZ((objectMat * posWorld).xyz);\n#endif\noutCamera = vec3(view.xy, -view.z);\n#if WORLD_NODES == 1\noutWindow = vec3(0.0);\n#else\noutWindow = vec3(gl_FragCoord.xy / viewWidthHeight, 0.0);\n#endif\n#if WORLD_NODES == 1\noutReflection = -loc;\n#else\nvec4 reflection = (invViewMatrix * vec4(reflect(view.xyz, normalize(viewNorm)), 0.0));\noutReflection = normalize(swizzleUpZ(reflection.xyz));\n#endif\n}",node_tex_environment_bl_frag:"#define TEX_PROJ_EQUIRECTANGULAR 0\n#define TEX_PROJ_MIRROR_BALL 1\nvoid node_tex_environment(sampler2D tex, const int encoding, const int projection, vec3 vector, out vec4 outColor) {\nvec2 uv;\nfloat bias;\nif (projection == TEX_PROJ_EQUIRECTANGULAR) {\nvec3 direction = swizzleUpY(vector);\nif (length(direction) == 0.0) {\ndirection = vec3(0.0, 1.0, 0.0);\n} else {\ndirection = normalize(direction);\n}\nuv.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nuv.x = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;\n#if WORLD_NODES == 1\nbias = -16.0;\n#else\nconst float seamWidth = 0.15;\nconst float seamBiasFactor = -10.0;\nfloat seam = max(0.0, 1.0 - abs (direction.z) / seamWidth) *\nclamp (1.0 - direction.x / seamWidth, 0.0, 1.0);\nbias = seamBiasFactor * seam;\n#endif\n} else {\nvec3 normal = normalize(vector);\nnormal.y -= 1.0;\nnormal /= (2.0 * sqrt(max(-0.5 * normal.y, 0.0)));\nuv = clamp(0.5 * normal.xz + 0.5, 0.0, 1.0);\nbias = 0.0;\n}\nuv.y = 1.0 - uv.y;\noutColor = texture2D(tex, uv, bias);\noutColor = nodeTexelToLinear(outColor, encoding);\n}",node_tex_environment_none_bl_frag:"void node_tex_environment_none(vec3 vector, out vec4 outColor) {\noutColor = vec4(1.0, 0.0, 1.0, 1.0);\n}",node_tex_gradient_bl_frag:"#define TEX_GRAD_LINEAR 0\n#define TEX_GRAD_QUADRATIC 1\n#define TEX_GRAD_EASING 2\n#define TEX_GRAD_DIAGONAL 3\n#define TEX_GRAD_SPHERICAL 4\n#define TEX_GRAD_QUADRATIC_SPHERE 5\n#define TEX_GRAD_RADIAL 6\nvoid node_tex_gradient(const int type, vec3 vector, out vec4 outColor, out float outFac)\n{\nfloat x, y, z, r;\nx = vector.x;\ny = vector.y;\nz = vector.z;\nif (type == TEX_GRAD_LINEAR) {\noutFac = x;\n} else if (type == TEX_GRAD_QUADRATIC) {\nr = max(x, 0.0);\noutFac = pow2(r);\n} else if (type == TEX_GRAD_EASING) {\nr = min(max(x, 0.0), 1.0);\noutFac = (3.0 * pow2(r) - 2.0 * pow3(r));\n} else if (type == TEX_GRAD_DIAGONAL) {\noutFac = (x + y) * 0.5;\n} else if (type == TEX_GRAD_RADIAL) {\noutFac = atan(y, x) / PI2 + 0.5;\n} else {\nr = max(0.99999 - sqrt(x * x + y * y + z * z), 0.0);\nif (type == TEX_GRAD_QUADRATIC_SPHERE) {\noutFac = pow2(r);\n} else if (type == TEX_GRAD_SPHERICAL) {\noutFac = r;\n}\n}\noutFac = clamp(outFac, 0.0, 1.0);\noutColor = vec4(outFac, outFac, outFac, 1.0);\n}",node_tex_ies_bl_frag:"void node_tex_ies(vec3 vector, float strength, out float fac) {\nfac = 0.0;\n}",node_tex_image_bl_frag:"#define TEX_PROJ_FLAT 0\n#define TEX_PROJ_BOX 1\n#define TEX_PROJ_SPHERE 2\n#define TEX_PROJ_TUBE 3\nvoid node_tex_image(sampler2D ima, const int encoding, vec3 viewNorm,\nconst int projection, const float projectionBlend, const bool clampToEdgeNoExtend,\nvec3 vector,\nout vec4 outColor, out float outAlpha) {\nif (projection == TEX_PROJ_FLAT) {\nvec2 uv = vector.xy;\nuv.y = 1.0 - uv.y;\nif (clampToEdgeNoExtend && (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0)) {\noutColor = vec4(0.0);\noutAlpha = 0.0;\n} else {\noutColor = texture2D(ima, uv);\noutAlpha = outColor.a;\n}\noutColor = nodeTexelToLinear(outColor, encoding);\n} else if (projection == TEX_PROJ_BOX) {\nvec3 norm = normalize(viewNorm * normalMatrix);\nvector = swizzleUpY(vector);\nvec2 uvX = vec2(-sign(norm.x) * vector.z, -vector.y);\nvec2 uvY = vec2(sign(norm.y) * vector.z, -vector.x);\nvec2 uvZ = vec2(sign(norm.z) * vector.x, -vector.y);\nvec4 colX = nodeTexelToLinear(texture2D(ima, uvX), encoding);\nvec4 colY = nodeTexelToLinear(texture2D(ima, uvY), encoding);\nvec4 colZ = nodeTexelToLinear(texture2D(ima, uvZ), encoding);\nvec3 barycentric = abs(norm);\nbarycentric /= barycentric.x + barycentric.y + barycentric.z;\nvec3 edgeShape = min(min(barycentric.yzx, barycentric.zxy),\n(projectionBlend - 1.0) / (projectionBlend - 3.0));\nvec3 edgeValue = (1.0 - projectionBlend) * (1.0 - edgeShape) / 2.0;\nvec3 weight = max((barycentric - edgeValue) / (1.0 - edgeValue), EPSILON);\nweight /= (weight.x + weight.y + weight.z);\noutColor = weight.x * colX + weight.y * colY + weight.z * colZ;\noutAlpha = outColor.a;\n} else if (projection == TEX_PROJ_SPHERE) {\nvector = normalize(vector * 2.0 - 1.0);\nvector = swizzleUpY(vector);\nvec2 uv = vec2(atan(vector.x, vector.z) / PI2, acos(vector.y) / PI);\nuv.x = mod(uv.x, 1.0);\noutColor = texture2D(ima, uv);\noutAlpha = outColor.a;\noutColor = nodeTexelToLinear(outColor, encoding);\n} else if (projection == TEX_PROJ_TUBE) {\nvector = vector * 2.0 - 1.0;\nvector = swizzleUpY(vector);\nvec2 uv = vec2(atan(vector.x, vector.z) / PI2, (1.0 - vector.y) / 2.0);\nuv.x = mod(uv.x, 1.0);\noutColor = texture2D(ima, uv);\noutAlpha = outColor.a;\noutColor = nodeTexelToLinear(outColor, encoding);\n}\n}",node_tex_image_none_bl_frag:"void node_tex_image_none(vec3 vector, out vec4 color, out float alpha)\n{\ncolor = vec4(1.0, 0.0, 1.0, 1.0);\nalpha = 1.0;\n}",node_tex_magic_bl_frag:"void node_tex_magic(vec3 vector, float scale, float distortion,\nout vec4 outColor, out float outFac)\n{\noutColor = vec4(0.0);\noutFac = 0.0;\n}",node_tex_musgrave_bl_frag:"void node_tex_musgrave(vec3 vector, float w, float scale, float detail,\nfloat dimension, float lacunarity, float offset, float gain,\nout float outFac) {\noutFac = 0.0;\n}\nvoid node_tex_musgrave(\nvec3 vector, float scale, float detail, float dimension, float lacunarity,\nfloat offset, float gain,\nout vec4 outColor, out float outFac)\n{\noutColor = vec4(0.0);\noutFac = 0.0;\n}",node_tex_noise_bl_frag:"\nvoid node_tex_noise(\nfloat falloffFactor, float dispersionFactor,\nvec3 vector, float w, float scale, float detail, float roughness,\nfloat distortion, out float outFac, out vec4 outColor) {\nvec3 p = vector * scale;\nvec3 dx = dFdx(p);\nvec3 dy = dFdy(p);\nfloat octaveLenPerPixel = (length(dx) + length(dy)) / 4.0;\nif (distortion != 0.0) {\nvec3 r, offset = vec3(13.5, 13.5, 13.5);\nr.x = noiseSmooth(p + offset, octaveLenPerPixel, falloffFactor,\ndispersionFactor) * distortion;\nr.y = noiseSmooth(p, octaveLenPerPixel, falloffFactor,\ndispersionFactor) * distortion;\nr.z = noiseSmooth(p - offset, octaveLenPerPixel, falloffFactor,\ndispersionFactor) * distortion;\np += r;\n}\noutFac = noiseTurbulence(p, detail, octaveLenPerPixel, falloffFactor,\ndispersionFactor);\nvec3 color = vec3(outFac,\nnoiseTurbulence(vec3(p.y, p.x, p.z), detail, octaveLenPerPixel,\nfalloffFactor, dispersionFactor),\nnoiseTurbulence(vec3(p.y, p.z, p.x), detail, octaveLenPerPixel,\nfalloffFactor, dispersionFactor)\n);\noutColor = vec4(color, 1.0);\n}\nvoid node_tex_noise(\nfloat falloffFactor, float dispersionFactor,\nvec3 vector, float w, float scale, float detail, float distortion,\nout float outFac, out vec4 outColor) {\nnode_tex_noise(falloffFactor, dispersionFactor, vector, w, scale, detail,\n0.5, distortion, outFac, outColor);\n}\nvoid node_tex_noise(\nfloat falloffFactor, float dispersionFactor,\nvec3 vector, float scale, float detail, float distortion,\nout vec4 outColor, out float outFac) {\nnode_tex_noise(falloffFactor, dispersionFactor, vector, 0.0, scale, detail,\ndistortion, outFac, outColor);\n}",node_tex_pointdensity_bl_frag:"void node_tex_pointdensity(\nvec3 vector,\nout vec4 outColor, out float outDensity)\n{\noutColor = vec4(0.0);\noutDensity = 0.0;\n}",node_tex_sky_bl_frag:"\n#define TEX_SKY_PREETHAM 0\n#define TEX_SKY_HOSEK_WILKIE 1\n#define TEX_SKY_NISHITA 2\n#define Km 683.0\nvoid node_tex_sky(const int skyType, vec3 param0, vec3 param1, vec3 param2,\nvec3 param3, vec3 param4, vec3 param5, vec3 param6, vec3 param7,\nvec3 param8, vec3 radiance, vec3 sunDirection, vec3 vectorIn,\nout vec4 outColor) {\nif (length(vectorIn) == 0.0) {\nvectorIn = vec3(0.0, 1.0, 0.0);\n} else {\nvectorIn = normalize(vectorIn);\n}\nvectorIn = swizzleUpY(vectorIn);\nsunDirection = swizzleUpY(sunDirection);\nfloat cosGamma = clamp(dot(vectorIn, sunDirection), -1.0, 1.0);\nfloat cosTheta = clamp(vectorIn.y, 0.0, 1.0);\nif (skyType == TEX_SKY_PREETHAM) {\nvec3 radInternal = (1.0 + param0 * exp(param1 / cosTheta)) * (\n1.0 + param2 * exp(param3 * acos(cosGamma))\n+ param4 * pow(cosGamma, 2.0)\n);\nvec3 XYZ = xyY_to_XYZ(radInternal.y * radiance.y,\nradInternal.z * radiance.z, radInternal.x * radiance.x);\noutColor = vec4(max(xyz_to_sRGB(XYZ), 0.0), 1.0);\n} else if (skyType == TEX_SKY_HOSEK_WILKIE) {\nfloat cosGammaSq = pow(cosGamma, 2.0);\nvec3 chi = (1.0 + cosGammaSq) / pow(1.0 + pow(param8, vec3(2.0))\n- 2.0 * param8 * cosGamma, vec3(1.5));\nvec3 radInternal = (1.0 + param0 * exp(param1 / (cosTheta + 0.01))) * (\nparam2 + param3 * exp(param4 * acos(cosGamma))\n+ param5 * cosGammaSq + param6 * chi + param7 * sqrt(cosTheta)\n);\noutColor = vec4(max(xyz_to_sRGB(radInternal * radiance), 0.0) * PI2/Km, 1.0);\n} else {\noutColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n}",node_tex_voronoi_bl_frag:"#define DISTANCE_EUCLIDEAN 0\n#define DISTANCE_MANHATTAN 1\n#define DISTANCE_CHEBYCHEV 2\n#define DISTANCE_MINKOWSKI 3\n#define FEATURE_F1 0\n#define FEATURE_F2 1\n#define FEATURE_SMOOTH_F1 2\n#define FEATURE_DISTANCE_TO_EDGE 3\n#define FEATURE_N_SPHERE_RADIUS 4\nstruct VoronoiGridData {\nvec3 point;\nvec3 randVec;\nvec3 toClosest;\nfloat dist;\n};\nfloat worleyLength(vec3 vec, int distance, float exponent) {\nif (distance == DISTANCE_EUCLIDEAN) {\nreturn length(vec);\n} else if (distance == DISTANCE_MANHATTAN) {\nreturn abs(vec.x) + abs(vec.y) + abs(vec.z);\n} else if (distance == DISTANCE_CHEBYCHEV) {\nreturn max(max(abs(vec.x), abs(vec.y)), abs(vec.z));\n} else if (distance == DISTANCE_MINKOWSKI) {\nreturn pow(pow(abs(vec.x), exponent)\n+ pow(abs(vec.y), exponent)\n+ pow(abs(vec.z), exponent), 1.0 / exponent);\n}\nreturn 0.0;\n}\nvoid worleyNoise(vec3 pos, int distance, float exponent, int feature,\nfloat smoothness, float randomness, out float outDist, out vec4 outColor,\nout vec3 outPosition, out float outW, out float outRadius) {\nconst highp float RAND_FIX_ZERO = 0.125;\nvec3 posI = floor(pos);\nvec3 posF = fract(pos);\nVoronoiGridData vgd[27];\n#pragma unroll_loop_start\nfor (int i = 0; i <= 2; i++) {\n#pragma unroll_loop_start\nfor (int j = 0; j <= 2; j++) {\n#pragma unroll_loop_start\nfor (int k = 0; k <= 2; k++) {\nvec3 point = vec3((i), (j), (k)) - 1.0;\nvec3 randVec = rand3(posI + point + RAND_FIX_ZERO);\nvec3 toClosest = point + randomness * randVec - posF;\nconst int counter = (i) + (j) * 3 + (k) * 9;\nvgd[counter].point = point;\nvgd[counter].randVec = randVec;\nvgd[counter].toClosest = toClosest;\nvgd[counter].dist = worleyLength(toClosest, distance, exponent);\n}\n#pragma unroll_loop_end\n}\n#pragma unroll_loop_end\n}\n#pragma unroll_loop_end\nfloat f1 = 1e10;\nfloat f2 = 1e10;\nvec3 edgeToClosest = vec3(0.0);\nfloat distToEdge = 1e10;\nvec3 randColF1 = vec3(0.0);\nvec3 randColF2 = vec3(0.0);\nvec3 toClosestF1 = vec3(0.0);\nvec3 toClosestF2 = vec3(0.0);\nvec3 radPoint = vec3(0.0);\nvec3 radToClosest = vec3(0.0);\n#pragma unroll_loop_start\nfor (int i = 0; i < 27; i++) {\nif (feature == FEATURE_F1) {\nif (vgd[i].dist < f1) {\nf1 = vgd[i].dist;\nrandColF1 = vgd[i].randVec;\ntoClosestF1 = vgd[i].toClosest;\n}\n} else if (feature == FEATURE_F2) {\nif (vgd[i].dist < f1) {\nf2 = f1;\nf1 = vgd[i].dist;\nrandColF2 = randColF1;\nrandColF1 = vgd[i].randVec;\ntoClosestF2 = toClosestF1;\ntoClosestF1 = vgd[i].toClosest;\n} else if (vgd[i].dist < f2) {\nf2 = vgd[i].dist;\nrandColF2 = vgd[i].randVec;\ntoClosestF2 = vgd[i].toClosest;\n}\n} else if (feature == FEATURE_SMOOTH_F1) {\nf1 = smoothMin(f1, vgd[i].dist, smoothness);\n} else if (feature == FEATURE_DISTANCE_TO_EDGE) {\nfloat dist = worleyLength(vgd[i].toClosest, DISTANCE_EUCLIDEAN, exponent);\nif (dist < f1) {\nf1 = dist;\nedgeToClosest = vgd[i].toClosest;\n}\n} else if (feature == FEATURE_N_SPHERE_RADIUS) {\nfloat dist = worleyLength(vgd[i].toClosest, DISTANCE_EUCLIDEAN, exponent);\nif (dist < f1) {\nf1 = dist;\nradPoint = vgd[i].point;\nradToClosest = vgd[i].toClosest;\n}\n}\n}\n#pragma unroll_loop_end\nif (feature == FEATURE_F1) {\noutDist = f1;\noutColor = vec4(randColF1, 1.0);\noutPosition = pos + toClosestF1;\n} else if (feature == FEATURE_F2) {\noutDist = f2;\noutColor = vec4(randColF2, 1.0);\noutPosition = pos + toClosestF2;\n} else if (feature == FEATURE_SMOOTH_F1) {\noutDist = f1;\nvec3 avgCol = vec3(0.0);\nvec3 avgOff = vec3(0.0);\nfloat sumWeightsCol = 0.0;\nfloat sumWeightsOff = 0.0;\n#pragma unroll_loop_start\nfor (int i = 0; i < 27; i++) {\nfloat smoothFac = getSmoothFactor(f1, vgd[i].dist, smoothness);\nfloat weightOff = smoothFac * smoothFac * smoothFac;\nfloat weightCol = weightOff * smoothFac;\navgCol += vgd[i].randVec * weightCol;\navgOff += vgd[i].toClosest * weightOff;\nsumWeightsCol += weightCol;\nsumWeightsOff += weightOff;\n}\n#pragma unroll_loop_end\noutColor = vec4(avgCol / sumWeightsCol, 1.0);\noutPosition = pos + avgOff / sumWeightsOff;\n} else if (feature == FEATURE_DISTANCE_TO_EDGE) {\n#pragma unroll_loop_start\nfor (int i = 0; i < 27; i++) {\nif (vgd[i].toClosest != edgeToClosest) {\nfloat dist = dot(0.5 * (edgeToClosest + vgd[i].toClosest),\nnormalize(vgd[i].toClosest - edgeToClosest));\ndistToEdge = min(distToEdge, dist);\n}\n}\n#pragma unroll_loop_end\noutDist = distToEdge;\n} else if (feature == FEATURE_N_SPHERE_RADIUS) {\nfloat diam = 1e10;\n#pragma unroll_loop_start\nfor (int i = 0; i <= 2; i++) {\n#pragma unroll_loop_start\nfor (int j = 0; j <= 2; j++) {\n#pragma unroll_loop_start\nfor (int k = 0; k <= 2; k++) {\nvec3 localPoint = vec3((i), (j), (k)) - 1.0;\nif (length(localPoint) > 0.0) {\nvec3 point = localPoint + radPoint;\nvec3 randVec = rand3(posI + point + RAND_FIX_ZERO);\nvec3 toClosest = point + randomness * randVec - posF;\ndiam = min(diam, length(toClosest - radToClosest));\n}\n}\n#pragma unroll_loop_end\n}\n#pragma unroll_loop_end\n}\n#pragma unroll_loop_end\noutRadius = diam / 2.0;\n}\n}\n#define VORONOI_SMOOTH_COEFF 0.74\nvoid node_tex_voronoi(\nint distance, int feature,\nvec3 vector, float w, float scale, float smoothness, float exponent,\nfloat randomness,\nout float outDistance, out vec4 outColor, out vec3 outPosition,\nout float outW, out float outRadius) {\nvector = scale * (vector - 0.0001);\nsmoothness = clamp(smoothness, 1e-3, 1.0);\nsmoothness *= VORONOI_SMOOTH_COEFF;\nworleyNoise(vector, distance, exponent, feature, smoothness, randomness,\noutDistance, outColor, outPosition, outW, outRadius);\noutPosition /= scale;\n}\n#define DISTANCE_DISTANCE DISTANCE_EUCLIDEAN\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}\nvoid node_tex_wave(int waveType, int waveProfile, int bandsDirection,\nint ringsDirection, vec3 vector, float scale, float distortion,\nfloat detail, float detailScale, out vec4 outColor, out float outFac) {\nfloat legacyOffset = 0.0;\nif (waveProfile == TEX_WAVE_PROFILE_SIN) {\nlegacyOffset = PI_HALF;\n}\nnode_tex_wave(waveType, waveProfile, bandsDirection, ringsDirection, vector,\nscale, distortion, detail, detailScale, 0.5, legacyOffset, outColor,\noutFac);\n}",node_tex_white_noise_bl_frag:"void node_tex_white_noise(vec3 vector, float w, out float outValue,\nout vec4 outColor) {\noutValue = 0.0;\noutColor = vec4(0.0);\n}\nvoid node_tex_white_noise(vec3 vector, float w, out float outValue) {\noutValue = 0.0;\n}",node_uvmap_bl_frag:"void node_uvmap(vec2 uv, out vec3 outUV) {\n#if WORLD_NODES == 1\noutUV = vec3(0.0);\n#else\nuv.y = 1.0 - uv.y;\noutUV = vec3(uv, 0.0);\n#endif\n}",node_valtorgb_bl_frag:"\nvoid node_valtorgb(sampler2D colormap, float fac, out vec4 colOut, out float alphaOut)\n{\ncolOut = texture2D(colormap, vec2(fac, 0.0));\nalphaOut = colOut.a;\n}",node_value_bl_frag:"\nuniform float nodeValue[NODE_VALUE_NUM];\nvoid node_value(float val, out float outVal)\n{\noutVal = val;\n}",node_vect_math_bl_frag:"void node_vect_math_add(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = v1 + v2;\n}\nvoid node_vect_math_subtract(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = v1 - v2;\n}\nvoid node_vect_math_multiply(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = v1 * v2;\n}\nvoid node_vect_math_divide(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec.x = v2.x == 0.0 ? 0.0 : v1.x / v2.x;\noutVec.y = v2.y == 0.0 ? 0.0 : v1.y / v2.y;\noutVec.z = v2.z == 0.0 ? 0.0 : v1.z / v2.z;\n}\nvoid node_vect_math_cross_product(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = cross(v1, v2);\n}\nvoid node_vect_math_project(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nfloat d = dot(v2, v2);\noutVec = (d != 0.0) ? (dot(v1, v2) / d) * v2 : vec3(0.0);\n}\nvoid node_vect_math_reflect(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nif (v2 != vec3(0.0)) {\nv2 = normalize(v2);\n}\noutVec = reflect(v1, v2);\n}\nvoid node_vect_math_dot_product(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVal = dot(v1, v2);\n}\nvoid node_vect_math_distance(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVal = distance(v1, v2);\n}\nvoid node_vect_math_length(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVal = length(v1);\n}\nvoid node_vect_math_scale(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = v1 * val;\n}\nvoid node_vect_math_normalize(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\nif (v1 != vec3(0.0)) {\nv1 = normalize(v1);\n}\noutVec = v1;\n}\nvoid node_vect_math_snap(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec.x = v2.x == 0.0 ? 0.0 : floor(v1.x / v2.x) * v2.x;\noutVec.y = v2.y == 0.0 ? 0.0 : floor(v1.y / v2.y) * v2.y;\noutVec.z = v2.z == 0.0 ? 0.0 : floor(v1.z / v2.z) * v2.z;\n}\nvoid node_vect_math_floor(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = floor(v1);\n}\nvoid node_vect_math_ceil(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = ceil(v1);\n}\nvoid node_vect_math_modulo(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nvec3 signProduct = sign(v1) * sign(v2);\nv1 += 1e-5 * signProduct;\noutVec.x = signProduct.x > 0.0 ? mod(v1.x, abs(v2.x)) : 0.0;\noutVec.y = signProduct.y > 0.0 ? mod(v1.y, abs(v2.y)) : 0.0;\noutVec.z = signProduct.z > 0.0 ? mod(v1.z, abs(v2.z)) : 0.0;\n}\nvoid node_vect_math_fraction(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = fract(v1);\n}\nvoid node_vect_math_absolute(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = abs(v1);\n}\nvoid node_vect_math_minimum(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = min(v1, v2);\n}\nvoid node_vect_math_maximum(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = max(v1, v2);\n}\nvoid node_vect_math_cosine(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = cos(v1);\n}\nvoid node_vect_math_sine(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = sin(v1);\n}\nvoid node_vect_math_tangent(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = tan(v1);\n}\nvoid node_vect_math_wrap(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nv1 += 1e-5;\noutVec.x = v2.x == v3.x ? v2.x : mod(v1.x - v3.x, v2.x - v3.x) + v3.x;\noutVec.y = v2.y == v3.y ? v2.y : mod(v1.y - v3.y, v2.y - v3.y) + v3.y;\noutVec.z = v2.z == v3.z ? v2.z : mod(v1.z - v3.z, v2.z - v3.z) + v3.z;\n}\nvoid node_vect_math_absolute(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_absolute(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_add(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_add(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_ceil(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_ceil(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_cross_product(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_cross_product(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_distance(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_distance(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_divide(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_divide(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_dot_product(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_dot_product(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_floor(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_floor(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_fraction(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_fraction(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_maximum(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_maximum(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_length(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_length(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_minimum(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_minimum(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_modulo(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_modulo(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_project(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_project(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_normalize(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_normalize(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_multiply(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_multiply(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_scale(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_scale(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_reflect(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_reflect(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_subtract(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_subtract(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_snap(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_snap(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_add(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVec = v1 + v2;\noutVal = (abs(outVec[0]) + abs(outVec[1]) + abs(outVec[2])) * RECIPROCAL_3;\n}\nvoid node_vect_math_subtract(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVec = v1 - v2;\noutVal = (abs(outVec[0]) + abs(outVec[1]) + abs(outVec[2])) * RECIPROCAL_3;\n}\nvoid node_vect_math_average(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVec = v1 + v2;\noutVal = length(outVec);\noutVec = normalize(outVec);\n}\nvoid node_vect_math_dot_product(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVec = vec3(0, 0, 0);\noutVal = dot(v1, v2);\n}\nvoid node_vect_math_cross_product(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVec = cross(v1, v2);\noutVal = length(outVec);\noutVec /= outVal;\n}\nvoid node_vect_math_normalize(vec3 v, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVal = length(v);\noutVec = normalize(v);\n}",node_vect_transform_bl_frag:"\n#define VEC_TRANS_NONE 0\n#define VEC_TRANS_W_O 1\n#define VEC_TRANS_W_C 2\n#define VEC_TRANS_O_W 3\n#define VEC_TRANS_O_C 4\n#define VEC_TRANS_C_W 5\n#define VEC_TRANS_C_O 6\n#define VEC_TRANS_W_O_DIR 7\n#define VEC_TRANS_W_C_DIR 8\n#define VEC_TRANS_O_W_DIR 9\n#define VEC_TRANS_O_C_DIR 10\n#define VEC_TRANS_C_W_DIR 11\n#define VEC_TRANS_C_O_DIR 12\nvoid node_vect_transform(const int vecTransType, const bool invCamZ, vec3 vIn, out vec3 vOut)\n{\nif (vecTransType == VEC_TRANS_NONE)\nvOut = vIn;\nelse {\nvec4 vec;\nif (vecTransType < VEC_TRANS_W_O_DIR)\nvec = vec4(vIn.xyz, 1.0);\nelse\nvec = vec4(vIn.xyz, 0.0);\nif (vecTransType == VEC_TRANS_W_O || vecTransType == VEC_TRANS_W_O_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = invModelMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n} else if (vecTransType == VEC_TRANS_W_C || vecTransType == VEC_TRANS_W_C_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = viewMatrix * vec;\nif (invCamZ)\nvec[2] = -vec[2];\n} else if (vecTransType == VEC_TRANS_O_W || vecTransType == VEC_TRANS_O_W_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = modelMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n} else if (vecTransType == VEC_TRANS_O_C || vecTransType == VEC_TRANS_O_C_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = modelViewMatrix * vec;\nif (invCamZ)\nvec[2] = -vec[2];\n} else if (vecTransType == VEC_TRANS_C_W || vecTransType == VEC_TRANS_C_W_DIR) {\nif (invCamZ)\nvec[2] = -vec[2];\nvec = invViewMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n} else if (vecTransType == VEC_TRANS_C_O || vecTransType == VEC_TRANS_C_O_DIR) {\nif (invCamZ)\nvec[2] = -vec[2];\nvec = invModelMatrix * invViewMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n}\nvOut = vec.xyz;\n}\n}",node_vector_displacement_bl_frag:"void node_vector_displacement(vec4 vector, float midLevel, float scale,\nout vec3 displacement) {\ndisplacement = vec3(0.0);\n}",node_vector_rotate_bl_frag:"void node_vector_rotate_axis_angle(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nif (length(axis) > 0.0) {\nvector -= center;\noutVector = vec3RotateAxisAngle(vector, axis, invert * angle);\noutVector += center;\n} else {\noutVector = vector;\n}\n}\nvoid node_vector_rotate_euler_xyz(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvec4 axisAngle = eulerToAxisAngle(rotation);\nvector -= center;\noutVector = vec3RotateAxisAngle(vector, axisAngle.xyz, invert * axisAngle.w);\noutVector += center;\n}\nvoid node_vector_rotate_x_axis(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvector -= center;\noutVector = vec3RotateXAngle(vector, invert * angle);\noutVector += center;\n}\nvoid node_vector_rotate_y_axis(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvector -= center;\noutVector = vec3RotateYAngle(vector, invert * angle);\noutVector += center;\n}\nvoid node_vector_rotate_z_axis(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvector -= center;\noutVector = vec3RotateZAngle(vector, invert * angle);\noutVector += center;\n}",node_vertex_color_bl_frag:"void node_vertex_color(vec4 color, out vec4 outColor, out float outAlpha) {\noutColor = color;\noutAlpha = color.a;\n}",node_volume_absorption_bl_frag:"void node_volume_absorption(vec4 color, float density, out vec4 outColor)\n{\noutColor = color;\n}",node_volume_info_bl_frag:"void node_volume_info(out vec4 color, out float density, out float flame,\nout float temperature) {\ncolor = vec4(vec3(0.0), 1.0);\ndensity = 0.0;\nflame = 0.0;\ntemperature = 0.0;\n}",node_volume_scatter_bl_frag:"void node_volume_scatter(vec4 color, float density, float anisotropy, out vec4 outColor)\n{\noutColor = vec4(color);\n}",node_wavelength_bl_frag:"void node_wavelength(float wavelength, out vec4 outColor)\n{\noutColor = vec4(0.0, 0.0, 0.0, 1.0);\n#if __VERSION__ == 300\nvec3 xyz = vec3(0.0);\nfloat ii = (wavelength - 380.0) / 5.0;\nint i = int(ii);\nif (i < 0 || i >= 80) {\nreturn;\n}\nii -= float(i);\nvec3 c1 = cieColorMatch[i];\nvec3 c2 = cieColorMatch[i+1];\nxyz = mix(c1, c2, ii);\noutColor = vec4(xyz_to_sRGB(xyz), 1.0);\n#endif\n}",node_wireframe_bl_frag:"void node_wireframe(float size, out float outFac)\n{\noutFac = 0.0;\n}",node_bitmap_none_mx_frag:"void node_bitmap_none(out vec4 color)\n{\ncolor = vec4(1.0);\n}",node_bitmap_env_mx_frag:"void node_bitmap_env(sampler2D envMap, int reflectMode, float IOR,\nconst int encoding, const bool alphaAsMono, const bool alphaAsRGB,\nfloat uOffset, float vOffset, float uTiling, float vTiling, float wAngle, vec3 normal,\nout vec4 color, out float value)\n{\nvec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nvec3 reflectVec;\n#if WORLD_NODES\nreflectVec = normalize(cameraToVertex);\n#else\nif (reflectMode == MAX_ENV_COORDS_REFLECT)\nreflectVec = reflect(cameraToVertex, worldNormal);\nelse {\nfloat refrRatio = 1.0 / IOR;\nreflectVec = refract(cameraToVertex, worldNormal, refrRatio);\n}\n#endif\nmat3 uvTransform = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle);\ncolor = sampleEquirectangular(envMap, reflectVec, uvTransform, encoding);\nif (alphaAsMono)\nvalue = color.a;\nelse\nvalue = average(color.rgb);\nif (alphaAsRGB)\ncolor = vec4(color.a);\n}",node_bitmap_mx_frag:"void node_bitmap(sampler2D map, const vec2 uvIn, const int mapping, const int axis,\nconst ivec2 clampToEdgeNoExtend,\nconst int encoding, const bool alphaAsMono, const bool alphaAsRGB,\nfloat uOffset, float vOffset, float uTiling, float vTiling, float wAngle,\nout vec4 color, out float value)\n{\nvec3 coordsIn;\nif (mapping == MAPPING_EXPLICIT_MAP_CHANNEL) {\ncoordsIn = vec3(uvIn.x, 1.0 - uvIn.y, 0.0);\n} else if (mapping == MAPPING_VERTEX_COLOR_CHANNEL) {\ncoordsIn = vec3(0.0);\n} else if (mapping == MAPPING_PLANAR_OBJECT_XYZ) {\ncoordsIn = swizzleUpZ((invModelMatrix * invViewMatrix * vec4(-vViewPosition, 1.0)).xyz);\n} else {\ncoordsIn = swizzleUpZ((invViewMatrix * vec4(-vViewPosition, 1.0)).xyz);\n}\nif (axis == AXIS_XY)\ncoordsIn = vec3(coordsIn.x, coordsIn.y, 1.0);\nelse if (axis == AXIS_YZ)\ncoordsIn = vec3(coordsIn.y, coordsIn.z, 1.0);\nelse if (axis == AXIS_ZX)\ncoordsIn = vec3(coordsIn.z, coordsIn.x, 1.0);\nvec3 coordsOut = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle) * coordsIn;\nvec2 uv = vec2(coordsOut.x, 1.0 - coordsOut.y);\nif ((clampToEdgeNoExtend[0] == 1 && (uvIn.x < 0.0 || uvIn.x > 1.0)) ||\n(clampToEdgeNoExtend[1] == 1 && (uvIn.y < 0.0 || uvIn.y > 1.0))) {\ncolor = vec4(0.0, 0.0, 0.0, 1.0);\n} else {\ncolor = texture2D(map, uv);\ncolor = nodeTexelToLinear(color, encoding);\n}\nif (alphaAsMono)\nvalue = color.a;\nelse\nvalue = average(color.rgb);\nif (alphaAsRGB)\ncolor = vec4(color.a);\n}",node_bump_mx_frag:"void node_bump(sampler2D bumpMap, const vec3 eyePos, const vec3 normal, const vec2 uvIn,\nfloat uOffset, float vOffset, float uTiling, float vTiling, float wAngle,\nout vec3 normalOut)\n{\nvec3 coordsIn;\ncoordsIn = vec3(uvIn.x, 1.0 - uvIn.y, 1.0);\nvec3 coordsOut = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle) * coordsIn;\nvec2 uv = vec2(coordsOut.x, 1.0 - coordsOut.y);\nvec2 dSTdx = dFdx(uv);\nvec2 dSTdy = dFdy(uv);\nif (any(equal(dSTdx, vec2(0.0))) || any(equal(dSTdy, vec2(0.0)))) {\nnormalOut = normal;\n} else {\nconst float bumpScale = 1.0;\nvec3 vSigmaX = vec3(dFdx(eyePos.x), dFdx(eyePos.y), dFdx(eyePos.z));\nvec3 vSigmaY = vec3(dFdy(eyePos.x), dFdy(eyePos.y), dFdy(eyePos.z));\nvec3 vN = normal;\nvec3 R1 = cross(vSigmaY, vN);\nvec3 R2 = cross(vN, vSigmaX);\nfloat fDet = dot(vSigmaX, R1);\nfloat Hll = bumpScale * texture2D(bumpMap, uv).x;\nfloat dBx = bumpScale * texture2D(bumpMap, uv + dSTdx).x - Hll;\nfloat dBy = bumpScale * texture2D(bumpMap, uv + dSTdy).x - Hll;\nvec2 dHdxy = vec2(dBx, dBy);\nvec3 vGrad = sign(fDet) * (dHdxy.x * R1 + dHdxy.y * R2);\nnormalOut = normalize(abs(fDet) * normal - vGrad);\n}\n}",node_blend_mx_frag:"void node_blend(\nconst bool useCurve, const float curveLower, const float curveUpper,\nconst vec4 color1, const vec4 color2, float mask,\nout vec4 color)\n{\nif (useCurve)\nmask = smoothstep(curveLower, curveUpper, mask);\nelse\nmask = clamp(mask, 0.0, 1.0);\ncolor = mix(color1, color2, mask);\n}",node_color_correction_mx_frag:"#define REWIRE_RED 0\n#define REWIRE_GREEN 1\n#define REWIRE_BLUE 2\n#define REWIRE_ALPHA 3\n#define REWIRE_RED_INV 4\n#define REWIRE_GREEN_INV 5\n#define REWIRE_BLUE_INV 6\n#define REWIRE_ALPHA_INV 7\n#define REWIRE_MONOCHROME 8\n#define REWIRE_ONE 9\n#define REWIRE_ZERO 10\nfloat rewireChannel(int type, vec4 color)\n{\nif (type == REWIRE_RED)\nreturn color.r;\nelse if (type == REWIRE_GREEN)\nreturn color.g;\nelse if (type == REWIRE_BLUE)\nreturn color.b;\nelse if (type == REWIRE_ALPHA)\nreturn color.a;\nelse if (type == REWIRE_RED_INV)\nreturn 1.0-color.r;\nelse if (type == REWIRE_GREEN_INV)\nreturn 1.0-color.g;\nelse if (type == REWIRE_BLUE_INV)\nreturn 1.0-color.b;\nelse if (type == REWIRE_ALPHA_INV)\nreturn 1.0-color.a;\nelse if (type == REWIRE_MONOCHROME)\nreturn average(color.rgb);\nelse if (type == REWIRE_ONE)\nreturn 1.0;\nelse\nreturn 0.0;\n}\nvoid node_color_correction(const ivec4 rewire,\nconst vec4 color, const float hueShift, const float saturation,\nconst vec4 tint, const float tintStrength,\nconst float brightness, const float contrast,\nout vec4 outColor)\n{\nif (all(equal(rewire, ivec4(REWIRE_RED, REWIRE_GREEN, REWIRE_BLUE, REWIRE_ALPHA)))) {\noutColor = color;\n} else {\noutColor.r = rewireChannel(rewire.x, color);\noutColor.g = rewireChannel(rewire.y, color);\noutColor.b = rewireChannel(rewire.z, color);\noutColor.a = rewireChannel(rewire.w, color);\n}\nvec4 hsv;\nrgbToHSV(outColor, hsv);\nhsv[0] += hueShift / 360.0;\nif (hsv[0] > 1.0)\nhsv[0] -= 1.0;\nelse if (hsv[0] < 0.0)\nhsv[0] += 1.0;\nhsv[1] *= (saturation / 100.0 + 1.0);\nhsv[1] = saturate(hsv[1]);\nif (tintStrength > 0.0) {\nvec4 hsvTint;\nrgbToHSV(tint, hsvTint);\nhsv[0] = hsv[0] + (hsvTint[0] - hsv[0]) * tintStrength / 100.0;\n}\nhsvToRGB(hsv, outColor);\noutColor = (outColor - 0.5) * (contrast / 100.0 + 1.0) + 0.5 + brightness / 100.0;\noutColor = max(outColor, 0.0);\n}",node_color_map_mx_frag:"void node_color_map(const bool reverseGamma,\nconst vec4 color, const float gamma, const float gain,\nout vec4 outColor)\n{\nfloat p = reverseGamma ? gamma : 1.0 / gamma;\nfloat g = reverseGamma ? (gain > EPSILON ? 1.0 / gain : 1.0) : gain;\noutColor = vec4(g * pow(abs(color.rgb), vec3(p)), color.a);\n}",node_composite_layer_mx_frag:"#define COMP_BLEND_NORMAL 0\n#define COMP_BLEND_AVERAGE 1\n#define COMP_BLEND_ADD 2\n#define COMP_BLEND_SUBTRACT 3\n#define COMP_BLEND_DARKEN 4\n#define COMP_BLEND_MULTIPLY 5\n#define COMP_BLEND_COLORBURN 6\n#define COMP_BLEND_LINEARBURN 7\n#define COMP_BLEND_LIGHTEN 8\n#define COMP_BLEND_SCREEN 9\n#define COMP_BLEND_COLORDODGE 10\n#define COMP_BLEND_LINEARDODGE 11\n#define COMP_BLEND_SPOT 12\n#define COMP_BLEND_SPOTBLEND 13\n#define COMP_BLEND_OVERLAY 14\n#define COMP_BLEND_SOFTLIGHT 15\n#define COMP_BLEND_HARDLIGHT 16\n#define COMP_BLEND_PINLIGHT 17\n#define COMP_BLEND_HARDMIX 18\n#define COMP_BLEND_DIFFERENCE 19\n#define COMP_BLEND_EXCLUSION 20\n#define COMP_BLEND_HUE 21\n#define COMP_BLEND_SATURATION 22\n#define COMP_BLEND_COLOR 23\n#define COMP_BLEND_VALUE 24\nvec4 calcBlending(const vec4 colorBG, const vec4 colorFG, const int blendMode) {\nif (blendMode == COMP_BLEND_NORMAL)\nreturn colorFG;\nelse if (blendMode == COMP_BLEND_AVERAGE)\nreturn (colorFG + colorBG) / 2.0;\nelse if (blendMode == COMP_BLEND_ADD)\nreturn colorBG + colorFG;\nelse if (blendMode == COMP_BLEND_SUBTRACT)\nreturn colorBG - colorFG;\nelse if (blendMode == COMP_BLEND_DARKEN)\nreturn min(colorFG, colorBG);\nelse if (blendMode == COMP_BLEND_MULTIPLY)\nreturn colorBG * colorFG;\nelse if (blendMode == COMP_BLEND_COLORBURN) {\nif (colorFG.r == 0.0 && colorFG.g == 0.0 && colorFG.b == 0.0)\nreturn vec4(0.0, 0.0, 0.0, 1.0);\nelse\nreturn max(1.0 - (1.0 - colorBG) / colorFG, 0.0);\n} else if (blendMode == COMP_BLEND_LINEARBURN)\nreturn max(colorFG + colorBG - 1.0, 0.0);\nelse if (blendMode == COMP_BLEND_LIGHTEN)\nreturn max(colorFG, colorBG);\nelse if (blendMode == COMP_BLEND_SCREEN)\nreturn colorFG + colorBG - colorFG * colorBG;\nelse if (blendMode == COMP_BLEND_COLORDODGE) {\nif (colorFG.r == 1.0 && colorFG.g == 1.0 && colorFG.b == 1.0)\nreturn vec4(1.0);\nelse\nreturn min(colorBG / (1.0 - colorFG), 1.0);\n} else if (blendMode == COMP_BLEND_LINEARDODGE)\nreturn min(colorFG + colorBG, 1.0);\nelse if (blendMode == COMP_BLEND_SPOT)\nreturn min(2.0 * colorFG * colorBG, 1.0);\nelse if (blendMode == COMP_BLEND_SPOTBLEND)\nreturn min(colorFG * colorBG + colorBG, 1.0);\nelse if (blendMode == COMP_BLEND_OVERLAY) {\nif (colorBG.r <= 0.5 && colorBG.g <= 0.5 && colorBG.b <= 0.5)\nreturn saturate(2.0 * colorFG * colorBG);\nelse\nreturn saturate(1.0 - 2.0 * (1.0-colorFG) * (1.0-colorBG));\n} else if (blendMode == COMP_BLEND_SOFTLIGHT) {\nif (colorFG.r <= 0.5 && colorFG.g <= 0.5 && colorFG.b <= 0.5)\nreturn saturate(colorBG * (colorBG + 2.0 * colorFG * (1.0 - colorBG)));\nelse\nreturn saturate(colorBG + (2.0 * colorFG - 1.0) * (sqrt(colorBG) - colorBG));\n} else if (blendMode == COMP_BLEND_HARDLIGHT) {\nif (colorFG.r <= 0.5 && colorFG.g <= 0.5 && colorFG.b <= 0.5)\nreturn saturate(2.0 * colorFG * colorBG);\nelse\nreturn saturate(1.0 - 2.0*(1.0 - colorFG)*(1.0 - colorBG));\n} else if (blendMode == COMP_BLEND_PINLIGHT) {\nif (((colorFG.r > 0.5 && colorFG.g > 0.5 && colorFG.b > 0.5) && all(greaterThan(colorFG, colorBG))) ||\n((colorFG.r <= 0.5 && colorFG.g <= 0.5 && colorFG.b <= 0.5) && all(lessThan(colorFG, colorBG))))\nreturn colorFG;\nelse\nreturn colorBG;\n} else if (blendMode == COMP_BLEND_HARDMIX) {\nif (colorFG.r + colorBG.r <= 1.0 && colorFG.g + colorBG.g <= 1.0 && colorFG.b + colorBG.b <= 1.0)\nreturn vec4(0.0, 0.0, 0.0, 1.0);\nelse\nreturn vec4(1.0);\n} else if (blendMode == COMP_BLEND_DIFFERENCE)\nreturn abs(colorFG - colorBG);\nelse if (blendMode == COMP_BLEND_EXCLUSION)\nreturn colorFG + colorBG - 2.0 * colorFG * colorBG;\n}\nvec4 calcBlendingHSV(const vec4 colorBG, const vec4 colorFG, const int blendMode)\n{\nvec4 hsvBG, hsvFG;\nvec4 outColor;\nif (blendMode == COMP_BLEND_HUE) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvFG[0], hsvBG[1], hsvBG[2], 1.0), outColor);\n} else if (blendMode == COMP_BLEND_SATURATION) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvBG[0], hsvFG[1], hsvBG[2], 1.0), outColor);\n} else if (blendMode == COMP_BLEND_COLOR) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvFG[0], hsvFG[1], hsvBG[2], 1.0), outColor);\n} else if (blendMode == COMP_BLEND_VALUE) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvBG[0], hsvBG[1], hsvFG[2], 1.0), outColor);\n}\nreturn outColor;\n}\nvoid node_composite_layer(const int blendMode, const float opacity, \nconst vec4 colorBG, const vec4 colorFG, const vec4 mask,\nout vec4 outColor)\n{\nfloat fac = saturate(opacity * average(mask.rgb));\nif (blendMode < COMP_BLEND_HUE)\noutColor = calcBlending(colorBG, colorFG, blendMode);\nelse\noutColor = calcBlendingHSV(colorBG, colorFG, blendMode);\noutColor = mix(colorBG, outColor, fac);\n}",node_falloff_mx_frag:"void node_falloff(vec3 viewPos, float IOR,\nconst vec4 color1, const vec4 color2, vec3 normal, out vec4 color)\n{\nfloat fac;\n\nvec3 dir = normalize(viewPos);\nfloat eta = max(IOR, 0.00001);\nfac = fresnelReflection(dir, normal, (gl_FrontFacing) ? eta : 1.0 / eta);\ncolor = mix(color1, color2, fac);\n}",node_gradient_ramp_mx_frag:"#define GRAD_TYPE_4_CORNER 0\n#define GRAD_TYPE_BOX 1\n#define GRAD_TYPE_DIAGONAL 2\n#define GRAD_TYPE_LIGHTING 3\n#define GRAD_TYPE_LINEAR 4\n#define GRAD_TYPE_MAPPED 5\n#define GRAD_TYPE_NORMAL 6\n#define GRAD_TYPE_PONG 7\n#define GRAD_TYPE_RADIAL 8\n#define GRAD_TYPE_SPIRAL 9\n#define GRAD_TYPE_SWEEP 10\n#define GRAD_TYPE_TARTAN 11\nvoid node_gradient_ramp(\nsampler2D gradientData, int gradientType, vec2 uvIn, vec3 geometryNormal,\nvec3 viewPos, int mapping, int axis, ivec2 clampToEdgeNoExtend,\nvec4 sourceMap, float uOffset, float vOffset, float uTiling, float vTiling, float wAngle,\nout vec4 outCol)\n{\nvec3 coordsIn;\nif (mapping == MAPPING_EXPLICIT_MAP_CHANNEL) {\ncoordsIn = vec3(uvIn.x, 1.0 - uvIn.y, 0.0);\n} else if (mapping == MAPPING_VERTEX_COLOR_CHANNEL) {\ncoordsIn = vec3(0.0);\n} else if (mapping == MAPPING_PLANAR_OBJECT_XYZ) {\ncoordsIn = swizzleUpZ((invModelMatrix * invViewMatrix * vec4(-viewPos, 1.0)).xyz);\n} else {\ncoordsIn = swizzleUpZ((invViewMatrix * vec4(-vViewPosition, 1.0)).xyz);\n}\nif (axis == AXIS_XY)\ncoordsIn = vec3(coordsIn.x, coordsIn.y, 1.0);\nelse if (axis == AXIS_YZ)\ncoordsIn = vec3(coordsIn.y, coordsIn.z, 1.0);\nelse if (axis == AXIS_ZX)\ncoordsIn = vec3(coordsIn.z, coordsIn.x, 1.0);\nvec3 coordsOut = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle) * coordsIn;\nfloat coord = uvIn.x;\nuvIn = coordsOut.xy;\nif ((clampToEdgeNoExtend[0] == 1 && (uvIn.x < 0.0 || uvIn.x > 1.0)) ||\n(clampToEdgeNoExtend[1] == 1 && (uvIn.y < 0.0 || uvIn.y > 1.0))) {\noutCol = vec4(0.0, 0.0, 0.0, 1.0);\nreturn;\n}\nuvIn = fract(uvIn);\nif (gradientType == GRAD_TYPE_4_CORNER) {\ncoord = pow(uvIn.x, 2.0);\n} else if (gradientType == GRAD_TYPE_BOX) {\nvec2 boxUv = abs(uvIn - vec2(0.5)) * 2.0;\ncoord = max(boxUv.x, boxUv.y);\n} else if (gradientType == GRAD_TYPE_DIAGONAL) {\ncoord = abs(uvIn.x - uvIn.y) * sqrt(2.0);\n} else if (gradientType == GRAD_TYPE_LIGHTING) {\nIncidentLight directLight;\nGeometricContext geometry;\ngeometry.position = -viewPos;\nvec3 irr = vec3(0.0);\n#if (NUM_POINT_LIGHTS > 0)\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\ngetPointDirectLightIrradiance(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++) {\ngetSpotDirectLightIrradiance(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++) {\ngetDirectionalDirectLightIrradiance(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:"\nvoid 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;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specularColor.rgb;\nmaterial.diffuseIntensity = 1.0;\nmaterial.specularHardness = 4.0 * exp2(glossiness * 10.0);\nmaterial.specularIntensity = specularLevel;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\ndiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\nif (selfIllumColorOn) {\ndiffuse += selfIllum.rgb;\n} else {\ndiffuse = mix(diffuse, material.diffuseColor, selfIllum[0]);\n}\nspecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\nfloat specularStrength = maxFromRGB(specular);\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;\nfor (l = levels; l >= 1.0; l-=1.0) { \nn += snoise(vec4(vec * f, phase)) / f;\nf *= 2.0;\n}\nif (l > 0.0) \nn += l * snoise(vec4(vec * f, phase)) / f; \nn = 0.5 * (n + 1.0);\n} else {\nfloat l, f = 1.0;\nfloat ml = levels;\nfor (l = levels; l >= 1.0; l-=1.0, ml-=1.0) {\nn += abs(snoise(vec4(vec * f, phase))) / f;\nf *= 2.0f;\n}\nif (l > 0.0)\nn += l * abs(snoise(vec4(vec * f, phase))) / f;\n}\nreturn clamp(smoothstep(thresholdLow, thresholdHigh, n), 0.0, 1.0);\n}\nvoid node_noise(const vec2 uv, const int noiseType, const int coordType, \nconst vec3 color1, const vec3 color2, const float size,\nconst float thresholdLow, const float thresholdHigh, const float levels,\nconst float phase, const vec3 offset, const vec3 tiling, const vec3 angle,\nout vec4 color) {\nvec3 vec = (calcXYZTransform(offset, tiling, angle) * vec4(uv.x, 1.0 - uv.y, 1.0, 1.0)).xyz;\ncolor = vec4(mix(color1, color2, noise(vec, noiseType, size, thresholdLow, thresholdHigh, levels, phase)), 1.0);\n}\nvoid node_noise(const vec3 viewPos, const int noiseType, const int coordType,\nconst vec3 color1, const vec3 color2, const float size,\nconst float thresholdLow, const float thresholdHigh, const float levels,\nconst float phase, const vec3 offset, const vec3 tiling, const vec3 angle,\nout vec4 color) {\nvec4 posWorld = invViewMatrix * vec4(-viewPos, 1.0);\nvec3 vec;\nif (coordType == 0)\nvec = (invModelMatrix * posWorld).xyz;\nelse\nvec = posWorld.xyz;\nvec = (calcXYZTransform(offset, tiling, angle) * vec4(swizzleUpZ(vec), 1.0)).xyz;\ncolor = vec4(mix(color1, color2, noise(vec, noiseType, size, thresholdLow, thresholdHigh, levels, phase)), 1.0);\n}",node_normal_bump_mx_frag:"void node_normal_bump(const vec4 tangent, const vec3 normal, ivec2 flip,\nvec4 normalColor, vec3 additionalBump, float normalMult, float addBumpMult,\nout vec3 normalOut)\n{\nif (flip[0] == 1)\nnormalColor.x = 1.0 - normalColor.x;\nif (flip[1] == 0)\nnormalColor.y = 1.0 - normalColor.y;\nvec3 normalTex = (normalColor.xyz * 2.0 - 1.0);\nvec4 viewTangent = vec4(normalize(modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz, tangent.w);\nvec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\nnormalOut = normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n+ normalTex.z * normal);\nnormalOut = mix(normal, normalOut, normalMult);\nadditionalBump = mix(normal, additionalBump, addBumpMult);\nnormalOut = normalize(normalOut + additionalBump);\n}",node_output_map_mx_frag:"vec4 processOutputColor(vec4 color, const bool invert, const bool clampColor, const bool alphaFromRGB,\nconst float rgbLevel, const float rgbOffset, const float outputAmount)\n{\nvec3 color3 = color.rgb;\ncolor3 = clampColor ? saturate(color3) : color3;\ncolor3 = color3 * rgbLevel + vec3(rgbOffset);\ncolor3 = invert ? (vec3(1.0) - color3) : color3;\ncolor = outputAmount * vec4(color3, color.a);\ncolor.a = alphaFromRGB ? average(color.rgb) : color.a;\nreturn color;\n}\nvoid node_output_map(\nconst bool invert, const bool clampColor, const bool alphaFromRGB,\nconst vec4 color, const float rgbLevel, const float rgbOffset,\nconst float outputAmount, const float bumpAmount,\nout vec4 outColor)\n{\noutColor = processOutputColor(color, invert, clampColor, alphaFromRGB, rgbLevel, rgbOffset, outputAmount);\n}\nvoid node_output_map(\nconst bool invert, const bool clampColor, const bool alphaFromRGB, sampler2D colormap,\nvec4 color, const float rgbLevel, const float rgbOffset,\nconst float outputAmount, const float bumpAmount,\nout vec4 outColor)\n{\nfloat r = texture2D(colormap, vec2(color.r, 0.0)).r;\nfloat g = texture2D(colormap, vec2(color.g, 0.0)).g;\nfloat b = texture2D(colormap, vec2(color.b, 0.0)).b;\noutColor = processOutputColor(vec4(r, g, b, color.a),\ninvert, clampColor, alphaFromRGB, rgbLevel, rgbOffset, outputAmount);\n}",node_output_mx_frag:"void node_output(vec4 color, out vec4 outgoingLight)\n{\noutgoingLight = color;\n}",node_physical_mx_frag:"#define DEFAULT_REFLECTION_EDGE 1.0\n#define DEFAULT_REFLECTION_SLOPE 5.0\nvoid node_physical(\nvec3 geometryNormal, const float emitLuminance, const bool useCustomReflCurve,\nconst float reflFacing, const float reflEdge, const float reflSlope,\nconst bool roughnessInv, const bool transRoughnessLock, const bool transRoughnessInv,\nconst bool thinWalled,\nconst float baseWeight, const vec4 baseColor, const float reflectivity,\nconst vec4 reflColor, const float roughness, const float metalness,\nconst float diffRoughness, const float anisotropy, const float anisoangle,\nconst float transparency, const vec4 transColor, const float transRoughness,\nconst float ior, const float scattering, const vec4 sssColor,\nconst float sssScale, const float emission, const vec4 emitColor,\nconst float coating, const vec4 coatColor, const float coatRoughness,\nconst vec3 normal, const vec3 clearcoatNormal, const float displacement,\nconst float cutout,\nout vec4 outColor)\n{\nNodeMaterial material;\nvec3 baseColorWeighted = baseWeight * baseColor.rgb;\nmaterial.diffuseColor = baseColorWeighted * (1.0 - transparency);\n#ifdef CLEARCOAT\nmaterial.clearcoat = saturate(coating);\nmaterial.clearcoatRoughness = clamp(coatRoughness, 0.0, 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.specularRoughness = 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.specularRoughness = calcCubeUVAdjustedRoughness(\nmaterial.specularRoughness, geomRoughness);\nmaterial.refractionRoughness = calcCubeUVAdjustedRoughness(\nmaterial.refractionRoughness, geomRoughness);\n#ifdef CLEARCOAT\nmaterial.clearcoatRoughness = calcCubeUVAdjustedRoughness(\nmaterial.clearcoatRoughness, geomRoughness);\n#endif\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 refractedLight = vec3(0.0);\n#ifdef USE_GTAO\nvec4 gtaoVisibilityBentNormal = texture2D(gtaoMap,\ngl_FragCoord.xy / currResolution);\nvec3 bentNormal = normalize(unpackRGBToNormal(gtaoVisibilityBentNormal.gba));\n#define PROBE_NORMAL bentNormal\n#endif\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#define RE_Refraction RE_Refraction_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#undef RE_Refraction\n#ifdef PROBE_NORMAL\n#undef PROBE_NORMAL\n#endif\n#ifdef USE_GTAO\nreflectedLight.indirectDiffuse *= gtaoVisibilityBentNormal.r;\nfloat gtaoVisibility = gtaoVisibilityBentNormal.r;\nvec3 gtaoBentNormal = bentNormal;\nvec3 gtaoViewDir = geometry.viewDir;\nvec3 gtaoNormal = normal;\nfloat gtaoRoughness = material.specularRoughness;\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;\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));\n}",node_phy_sun_sky_env_mx_frag:"vec3 perezSky(vec3 paramA, vec3 paramB, vec3 paramC, vec3 paramD, vec3 paramE,\nvec3 radiance, vec3 sunDirection, vec3 direction)\n{\nfloat cosGamma = clamp(dot(direction, sunDirection), -1.0, 1.0);\nfloat cosTheta = clamp(direction.y, 0.0, 1.0);\nvec3 radInternal = (1.0 + paramA * exp(paramB / cosTheta)) * (\n1.0 + paramC * exp(paramD * acos(cosGamma))\n+ paramE * pow(cosGamma, 2.0)\n);\nfloat ciex = radInternal.y * radiance.y;\nfloat ciey = radInternal.z * radiance.z;\nfloat cieY = clamp(radInternal.x * radiance.x, 0.0, 1000000.0);\nvec3 XYZ = xyY_to_XYZ(ciex, ciey, cieY);\nreturn max(xyz_to_sRGB(XYZ), 0.0);\n}\n#define GROUND_SKY_SAMPLES 16\nvec3 groundSky(vec3 paramA, vec3 paramB, vec3 paramC, vec3 paramD, vec3 paramE, vec3 radiance, vec3 sunDirection, vec3 sunIlluminance)\n{\nconst int horizSamples = GROUND_SKY_SAMPLES;\nconst int vertSamples = GROUND_SKY_SAMPLES / 2;\nvec3 result = vec3(0.0);\nfor (int horizSampleIdx = 0; horizSampleIdx < horizSamples; horizSampleIdx++) {\nfloat horizSample = float(horizSampleIdx) / float(horizSamples);\nfloat horizAngle = PI2 * horizSample;\nfor (int vertSampleIdx = 0; vertSampleIdx < vertSamples; vertSampleIdx++) {\nfloat vertSample = float(vertSampleIdx) / float(vertSamples);\nfloat y = 1.0 - vertSample;\nfloat x = sqrt(1.0 - y*y) * cos(horizAngle);\nfloat z = -sqrt(1.0 - y*y) * sin(horizAngle);\nvec3 direction = vec3(x, y, z);\nvec3 sampleColor = perezSky(paramA, paramB, paramC, paramD, paramE,\nradiance, sunDirection, direction);\n\nresult += direction.y * sampleColor;\n}\n}\nresult /= float(horizSamples * vertSamples);\nresult += (sunIlluminance * sunDirection.y) / PI;\nreturn result;\n}\nvoid node_phy_sun_sky_env(vec3 paramA, vec3 paramB, vec3 paramC, vec3 paramD, vec3 paramE,\nvec3 radiance, vec3 sunDirection, vec3 sunIlluminance, vec3 sunLuminance, \nfloat globalIntensity, vec4 groundColor,\nout vec4 outColor) \n{\nvec3 dir = vWorldPosition;\nif (length(dir) == 0.0) {\ndir = vec3(0.0, 0.0, -1.0);\n} else {\ndir = normalize(dir);\n}\nif (dir.y < 0.0) {\noutColor = groundColor * vec4(groundSky(paramA, paramB, paramC, paramD, paramE, radiance, sunDirection, sunIlluminance), 1.0);\n} else {\noutColor = vec4(perezSky(paramA, paramB, paramC, paramD, paramE,\nradiance, sunDirection, dir), 1.0);\n}\noutColor = globalIntensity * outColor;\n}",node_reflect_refract_mx_frag:"void node_reflect_refract(sampler2D envMap,\nint reflectMode, const float IOR, const int encoding,\nvec3 normal, out vec4 color)\n{\nvec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nvec3 reflectVec;\nif (reflectMode == MAX_ENV_COORDS_REFLECT)\nreflectVec = reflect(cameraToVertex, worldNormal);\nelse {\nfloat refrRatio = 1.0 / IOR;\nreflectVec = refract(cameraToVertex, worldNormal, refrRatio);\n}\nreflectVec = normalize(reflectVec);\ncolor = sampleEquirectangular(envMap, reflectVec, mat3(1.0), encoding);\n}",node_reflect_refract_color_mx_frag:"void node_reflect_refract_color(const vec4 colorIn, out vec4 color)\n{\ncolor = vec4(colorIn);\n}",node_rgb_multiply_mx_frag:"void node_rgb_multiply(const vec4 color1, const vec4 color2, out vec4 color)\n{\ncolor = color1 * color2;\n}",node_rgb_tint_mx_frag:"void node_rgb_tint(const vec4 color, const vec4 red, const vec4 green, const vec4 blue,\nout vec4 outColor)\n{\nmat3 tintMatrix = mat3(red.rgb, green.rgb, blue.rgb);\noutColor = vec4(tintMatrix * color.rgb, color.a);\n}",node_rgb_mx_frag:"uniform vec4 nodeRGB[NODE_RGB_NUM];\nvoid node_rgb(vec4 color, out vec4 outColor)\n{\noutColor = color;\n}",node_shellac_mx_frag:"void node_shellac(const vec4 color1, const vec4 color2, const float amount,\nout vec4 color)\n{\ncolor = mix(color1, color2, clamp(amount, 0.0, 1.0));\n}",node_tex_environment_mx_frag:"\nvoid node_tex_environment(sampler2D tex, const int encoding, vec3 vector, out vec4 outColor) {\n\nvec3 direction = swizzleUpY(vector);\nif (length(direction) == 0.0) {\ndirection = vec3(0.0, 1.0, 0.0);\n} else {\ndirection = normalize(direction);\n}\nvec2 uv;\nuv.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nuv.x = atan(direction.x, direction.z) * RECIPROCAL_PI2 + 0.5;\nuv.y *= -1.0;\nconst float seamWidth = 0.15;\nconst float seamBiasFactor = -10.0;\nfloat seam = max(0.0, 1.0 - abs (direction.x) / seamWidth) *\nclamp (1.0 - direction.z / seamWidth, 0.0, 1.0);\noutColor = texture2D(tex, uv, seamBiasFactor * seam);\noutColor = nodeTexelToLinear(outColor, encoding);\n}",node_value_mx_frag:"uniform float nodeValue[NODE_VALUE_NUM];\nvoid node_value(float val, out float outVal)\n{\noutVal = val;\n}",node_vertex_color_mx_frag:"void node_vertex_color(vec3 color, out vec4 outColor)\n{\noutColor = vec4(color, 1.0);\n}",node_add_double_linear_my_frag:"void node_add_double_linear(\nfloat input1, float input2,\nout float outValue) {\noutValue = input1 + input2;\n}",node_add_matrix_my_frag:"void node_add_matrix(\nmat4 matrixIn1,\nout mat4 matrixSum)\n{\nmatrixSum = matrixIn1;\n}\nvoid node_add_matrix(\nmat4 matrixIn1, mat4 matrixIn2,\nout mat4 matrixSum)\n{\nmatrixSum = matrixIn1 + matrixIn2;\n}\nvoid node_add_matrix(\nmat4 matrixIn1, mat4 matrixIn2, mat4 matrixIn3,\nout mat4 matrixSum)\n{\nmatrixSum = matrixIn1 + matrixIn2 + matrixIn3;\n}",node_anim_curve_ta_my_frag:"uniform float nodeValue[NODE_VALUE_NUM];\nvoid node_anim_curve_ta(float val, out float outVal)\n{\noutVal = val;\n}",node_anim_curve_tu_my_frag:"uniform float nodeValue[NODE_VALUE_NUM];\nvoid node_anim_curve_tu(float val, out float outVal)\n{\noutVal = val;\n}",node_blend_colors_my_frag:"void node_blend_colors(float blender, vec3 color1, vec3 color2, out vec3 outColor)\n{\nblender = clamp(blender, 0.0, 1.0);\noutColor = mix(color1, color2, 1.0 - blender);\n}\nvoid node_blend_colors(float blender, vec4 color1, vec4 color2, out vec4 outColor)\n{\nblender = clamp(blender, 0.0, 1.0);\noutColor = mix(color1, color2, 1.0 - blender);\n}",node_bulge_my_frag:"void node_bulge(\nfloat uWidth, float vWidth, vec2 uvCoord,\nout float outAlpha, out vec3 outColor) {\nuvCoord = 2.0 * fract(uvCoord); \nfloat bulge = 0.0;\nif (uvCoord.x > uWidth && uvCoord.x < 2.0 - uWidth &&\nuvCoord.y > vWidth && uvCoord.y < 2.0 - vWidth) {\nuvCoord.x = (uvCoord.x - uWidth) / (1.0 - uWidth);\nuvCoord.y = (uvCoord.y - vWidth) / (1.0 - vWidth);\nbulge = uvCoord.x * (2.0 - uvCoord.x) * uvCoord.y * (2.0 - uvCoord.y);\n}\noutAlpha = bulge; \noutColor = vec3(bulge, bulge, bulge); \n}",node_blinn_my_frag:"void node_blinn(\nvec3 geometryNormal,\nvec3 color, vec3 ambientColor, vec3 incandescence, float matteOpacity,\nfloat diffuse, vec3 normal, float reflectivity, vec3 reflectedColor,\nfloat eccentricity, vec3 specularColor, float specularRollOff, float translucence,\nvec3 transparency,\nout vec4 outColor) {\nNodeMaterial material;\nmaterial.diffuseColor = diffuse * color;\n#ifdef CLEARCOAT\n#undef 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.specularRoughness = max(eccentricity, 0.0525);\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min(material.specularRoughness, 1.0);\nmaterial.specularColor = specularColor;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\nfloat alpha = 1.0 - average(transparency);\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\nreflectedLight.directSpecular + reflectedLight.indirectSpecular + incandescence, alpha);\n}",node_bump_2d_my_frag:"void node_bump_2d(\nvec3 normal,\nfloat bumpDepth, float bumpValue,\nout vec3 outNormal) {\nvec3 position = vViewPosition;\nvec3 dPdx = dFdx(position);\nvec3 dPdy = dFdy(position);\nfloat dHdx = dFdx(bumpValue);\nfloat dHdy = dFdy(bumpValue);\nvec3 tanX = cross(dPdy, normal);\nvec3 tanY = cross(normal, dPdx);\nvec3 surfaceGrad = dHdx * tanX + dHdy * tanY;\nfloat dotPosTanX = dot(dPdx, tanX);\noutNormal = normalize(normal * abs(dotPosTanX) - surfaceGrad * sign(dotPosTanX));\noutNormal = normalize(mix(normal, outNormal, max(0.0, bumpDepth)));\n}\nvoid node_bump_2d(\nvec3 normal, vec4 tangent,\nfloat bumpDepth, vec3 bumpValue,\nout vec3 outNormal) {\n#ifdef DOUBLE_SIDED\nnormal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\nvec3 normalTex = (bumpValue.xyz * 2.0 - 1.0);\nvec4 viewTangent = vec4(normalize((modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz), tangent.w);\nvec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\noutNormal = normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n+ normalTex.z * normal);\noutNormal = mix(normal, outNormal, bumpDepth);\n}",node_channels_my_frag:"void node_channels(\nint channelR, int channelG, int channelB, int channelA,\nfloat inAlpha, vec3 inColor,\nout float outAlpha, out vec3 outColor) {\noutAlpha = 1.0;\noutColor = vec3(1.0);\nif (channelR == 0)\noutColor.r = inColor.r;\nelse if (channelR == 1)\noutColor.r = inColor.g;\nelse if (channelR == 2)\noutColor.r = inColor.b;\nelse\noutColor.r = inAlpha;\nif (channelG == 0)\noutColor.g = inColor.r;\nelse if (channelG == 1)\noutColor.g = inColor.g;\nelse if (channelG == 2)\noutColor.g = inColor.b;\nelse\noutColor.g = inAlpha;\nif (channelB == 0)\noutColor.b = inColor.r;\nelse if (channelB == 1)\noutColor.b = inColor.g;\nelse if (channelB == 2)\noutColor.b = inColor.b;\nelse\noutColor.b = inAlpha;\nif (channelA == 0)\noutAlpha = inColor.r;\nelse if (channelA == 1)\noutAlpha = inColor.g;\nelse if (channelA == 2)\noutAlpha = inColor.b;\nelse\noutAlpha = inAlpha;\n}",node_checker_my_frag:"void node_checker(\nvec3 color1, vec3 color2, float contrast, vec2 uvCoord,\nout float outAlpha, out vec3 outColor) {\nuvCoord -= floor(uvCoord); \nvec3 deltaColor = color2 - color1;\ncolor1 += (1.0 - contrast) * 0.5 * deltaColor;\ncolor2 -= (1.0 - contrast) * 0.5 * deltaColor;\nif ((uvCoord.x < 0.5 && uvCoord.y >= 0.5) || (uvCoord.x >= 0.5 && uvCoord.y < 0.5)) { \noutColor = color2; \noutAlpha = 1.0; \n} else {\noutColor = color1; \noutAlpha = 0.0; \n}\n}",node_clamp_my_frag:"void node_clamp(\nvec3 inputValue, vec3 maxValue, vec3 minValue,\nout vec3 outputValue) {\noutputValue = clamp(inputValue, minValue, maxValue);\n}",node_cloth_my_frag:"void node_cloth(\nfloat brightSpread, vec3 gapColor, float randomness, vec3 uColor, float uWave, float uWidth,\nvec3 vColor, float vWave, float vWidth, float widthSpread, vec2 uvCoord,\nout float outAlpha, out vec3 outColor) {\nif (abs(uWave) > -EPSILON || abs(vWave) > -EPSILON) {\nuvCoord.x += - uWave * sin(PI2 * uvCoord.y);\nuvCoord.y += vWave * sin(PI2 * uvCoord.x);\n}\nuvCoord = fract(uvCoord);\nint thread = 0;\nif ((uvCoord.x >= 0.5 && uvCoord.y < 0.5) || (uvCoord.x < 0.5 && uvCoord.y >= 0.5)) {\nfloat flippedCoord;\nflippedCoord = uvCoord.x;\nuvCoord.x = uvCoord.y;\nuvCoord.y = flippedCoord;\nflippedCoord = uWidth;\nuWidth = vWidth;\nvWidth = flippedCoord;\nthread = 1;\n}\nuvCoord = fract(2.0 * uvCoord);\nfloat cloth = 1.0;\nif (uvCoord.y <= vWidth) {\nfloat clothU = uvCoord.x - 0.5 * uWidth;\nfloat clothV = 2.0 * uvCoord.y / vWidth - 1.0;\ncloth = 0.75 * (clothU * clothU + clothV * clothV);\n} else if (uvCoord.x <= uWidth) {\nfloat clothU = 2.0 * uvCoord.x / uWidth - 1.0;\nfloat clothV = uvCoord.y - 0.5 * vWidth - 1.0;\ncloth = 0.75 * (clothU * clothU + clothV * clothV);\nthread = 1 - thread;\n}\noutColor = gapColor;\nif (cloth < 1.0) {\ncloth = 1.0 - cloth;\ncloth = min(cloth, 1.0);\noutColor *= (1.0 - cloth);\nvec3 threadColor = uColor;\nif (thread == 0)\nthreadColor = vColor;\noutColor += threadColor * cloth;\n}\noutAlpha = dot(outColor, LUM_WEIGHTS_MAYA);\n}",node_color_condition_my_frag:"void node_color_condition(\nfloat alphaA, float alphaB, vec3 colorA, vec3 colorB, bool condition,\nout float outAlpha, out vec3 outColor) {\noutAlpha = condition ? alphaA : alphaB;\noutColor = condition ? colorA : colorB;\n}",node_color_composite_my_frag:"void node_color_composite(int operation,\nvec3 colorA, float alphaA, vec3 colorB, float alphaB, float factor,\nout vec3 outColor, out float outAlpha)\n{\nif (factor <= 0.0) {\noutColor = colorA;\noutAlpha = alphaA;\nreturn;\n}\nif (operation == 0) {\noutColor[0] = colorA[0] + (colorB[0] * factor);\noutColor[1] = colorA[1] + (colorB[1] * factor);\noutColor[2] = colorA[2] + (colorB[2] * factor);\noutAlpha = alphaA + (alphaB * factor);\n} else if (operation == 1) {\noutColor[0] = colorA[0] + ((colorB[0] - 1.0) * factor);\noutColor[1] = colorA[1] + ((colorB[1] - 1.0) * factor);\noutColor[2] = colorA[2] + ((colorB[2] - 1.0) * factor);\noutAlpha = alphaA + ((alphaB - 1.0) * factor);\n} else if (operation == 2) {\nif (factor >= 1.0) {\noutColor = colorB;\noutAlpha = alphaB;\nreturn;\n}\noutColor[0] = mix(colorA[0], colorB[0], factor);\noutColor[1] = mix(colorA[1], colorB[1], factor);\noutColor[2] = mix(colorA[2], colorB[2], factor);\noutAlpha = mix(alphaA, alphaB, factor);\n} else if (operation == 3) {\noutColor[0] = colorA[0] * (colorB[0] * factor + (1.0 - factor));\noutColor[1] = colorA[1] * (colorB[1] * factor + (1.0 - factor));\noutColor[2] = colorA[2] * (colorB[2] * factor + (1.0 - factor));\noutAlpha = alphaA * (alphaB * factor + (1.0 - factor));\n} else if (operation == 4) {\noutColor[0] = 1.0 - ((1.0 - colorA[0]) * (1.0 - colorB[0] * factor));\noutColor[1] = 1.0 - ((1.0 - colorA[1]) * (1.0 - colorB[1] * factor));\noutColor[2] = 1.0 - ((1.0 - colorA[2]) * (1.0 - colorB[2] * factor));\noutAlpha = 1.0 - ((1.0 - alphaA) * (1.0 - alphaB * factor));\n} else if (operation == 5) {\noutColor[0] = colorB[0] > 0.5 ? (2.0 * colorA[0] * colorB[0] * factor) + colorA[0] * (1.0 - factor) :\n1.0 - ((1.0 - colorA[0]) * (1.0 - colorB[0] * factor)) * (2.0 - (1.0 - factor));\noutColor[1] = colorB[1] > 0.5 ? (2.0 * colorA[1] * colorB[1] * factor) + colorA[1] * (1.0 - factor) :\n1.0 - ((1.0 - colorA[1]) * (1.0 - colorB[1] * factor)) * (2.0 - (1.0 - factor));\noutColor[2] = colorB[2] > 0.5 ? (2.0 * colorA[2] * colorB[2] * factor) + colorA[2] * (1.0 - factor) :\n1.0 - ((1.0 - colorA[2]) * (1.0 - colorB[2] * factor)) * (2.0 - (1.0 - factor));\noutAlpha = alphaB > 0.5 ? (2.0 * alphaA * alphaB * factor) + alphaA * (1.0 - factor) :\n1.0 - ((1.0 - alphaA) * (1.0 - alphaB * factor)) * (2.0 - (1.0 - factor));\n} else if (operation == 6) {\noutColor[0] = abs(colorA[0] - (colorB[0] * factor));\noutColor[1] = abs(colorA[1] - (colorB[1] * factor));\noutColor[2] = abs(colorA[2] - (colorB[2] * factor));\noutAlpha = abs(alphaA - (alphaB * factor));\n} else if (operation == 7) {\noutColor[0] = clamp(mix(colorA[0], colorA[0] / max(1.0 - colorB[0], 0.00001), factor), colorA[0], colorB[0]);\noutColor[1] = clamp(mix(colorA[1], colorA[1] / max(1.0 - colorB[1], 0.00001), factor), colorA[1], colorB[1]);\noutColor[2] = clamp(mix(colorA[2], colorA[2] / max(1.0 - colorB[2], 0.00001), factor), colorA[2], colorB[2]);\noutAlpha = clamp(mix(alphaA, alphaA / max(1.0 - alphaB, 0.00001), factor), alphaA, alphaB);\n} else if (operation == 8) {\noutColor[0] = clamp(mix(colorA[0], 1.0 - (colorA[0] / max(1.0 - colorB[0], 0.00001)), factor), colorA[0], colorB[0]);\noutColor[1] = clamp(mix(colorA[1], 1.0 - (colorA[1] / max(1.0 - colorB[1], 0.00001)), factor), colorA[1], colorB[1]);\noutColor[2] = clamp(mix(colorA[2], 1.0 - (colorA[2] / max(1.0 - colorB[2], 0.00001)), factor), colorA[2], colorB[2]);\noutAlpha = clamp(mix(alphaA, 1.0 - (alphaA / max(1.0 - alphaB, 0.00001)), factor), alphaA, alphaB);\n}\n}",node_color_constant_my_frag:"void node_color_constant(vec3 inColor, float inAlpha, out vec3 outColor, out float outAlpha)\n{\noutColor = inColor;\noutAlpha = inAlpha;\n}",node_color_correct_my_frag:"void node_color_correct(\nbool colClamp, vec3 colClampMin, vec3 colClampMax,\nbool alphaClamp, float alphaClampMin, float alphaClampMax,\nbool unpremultInput, bool premultResult,\nfloat alphaGain, float alphaGamma, float alphaOffset,\nvec3 colGain, vec3 colGamma, vec3 colOffset, float hueShift,\nfloat inAlpha, vec3 inColor, float satGain, float valGain,\nout float outAlpha, out vec3 outColor)\n{\noutColor = unpremultInput ? inColor/inAlpha : inColor;\nif (hueShift != 0.0 || satGain != 1.0 || valGain != 1.0) {\nvec4 color = vec4(outColor, 1.0);\nrgbToHSV(vec4(inColor, 1.0), color);\ncolor.r += hueShift / 360.0;\nif (color.r > 1.0)\ncolor.r -= 1.0;\nelse if (color.r < 0.0)\ncolor.r += 1.0;\ncolor.g *= satGain;\ncolor.b *= valGain;\nhsvToRGB(color, color);\noutColor = color.rgb;\n}\noutColor *= colGain;\noutColor += colOffset;\nif (any(notEqual(colGamma, vec3(1.0))))\noutColor = pow(outColor, 1.0 / colGamma);\nif (colClamp)\noutColor = clamp(outColor, colClampMin, colClampMax);\noutAlpha = inAlpha * alphaGain;\noutAlpha += alphaOffset;\nif (alphaGamma != 1.0)\noutAlpha = pow(outAlpha, 1.0 / alphaGamma);\nif (alphaClamp)\noutAlpha = clamp(outAlpha, alphaClampMin, alphaClampMax);\nif (premultResult)\noutColor *= outAlpha;\n}",node_color_logic_my_frag:"void node_color_logic(\nint operation,\nvec3 colorA, vec3 colorB,\nout bool outBool) {\nif (operation == 0) {\noutBool = all(equal(colorA, colorB));\n} else if (operation == 1) {\noutBool = any(notEqual(colorA, colorB));\n} else if (operation == 2) {\noutBool = ((colorA.x + colorA.y + colorA.z) < (colorB.x + colorB.y + colorB.z));\n} else if (operation == 3) {\noutBool = ((colorA.x + colorA.y + colorA.z) > (colorB.x + colorB.y + colorB.z));\n} else if (operation == 4) {\noutBool = ((colorA.x + colorA.y + colorA.z) <= (colorB.x + colorB.y + colorB.z));\n} else {\noutBool = ((colorA.x + colorA.y + colorA.z) >= (colorB.x + colorB.y + colorB.z));\n}\n}",node_color_mask_my_frag:"void node_color_mask(\nbool maskAlphaIsLuminance,\nfloat inAlpha, vec3 inColor, vec3 mask, float maskAlpha,\nout float outAlpha, out vec3 outColor) {\nif (maskAlphaIsLuminance)\nmaskAlpha = 1.0 - dot(mask, LUM_WEIGHTS_MAYA);\noutColor = inColor * (1.0 - maskAlpha);\n}",node_color_math_my_frag:"void node_color_math(\nint operation,\nfloat alphaA, float alphaB, vec3 colorA, vec3 colorB,\nout float outAlpha, out vec3 outColor) {\nif (operation == 0) {\noutColor = colorA + colorB;\noutAlpha = alphaA + alphaB;\n} else if (operation == 1) {\noutColor = colorA - colorB;\noutAlpha = alphaA - alphaB;\n} else if (operation == 2) {\noutColor = colorA * colorB;\noutAlpha = alphaA * alphaB;\n} else if (operation == 3) {\noutColor = colorA / colorB;\noutAlpha = alphaA / alphaB;\n} else if (operation == 4) {\noutColor = min(colorA, colorB);\noutAlpha = min(alphaA, alphaB);\n} else {\noutColor = max(colorA, colorB);\noutAlpha = max(alphaA, alphaB);\n}\n}",node_compose_matrix_my_frag:"mat3 quatToMat3(vec4 quat) {\nfloat x = quat.x,\ny = quat.y,\nz = quat.z,\nw = quat.w;\nfloat x2 = x + x;\nfloat y2 = y + y;\nfloat z2 = z + z;\n\nfloat xx = x * x2;\nfloat yx = y * x2;\nfloat yy = y * y2;\nfloat zx = z * x2;\nfloat zy = z * y2;\nfloat zz = z * z2;\nfloat wx = w * x2;\nfloat wy = w * y2;\nfloat wz = w * z2;\n\nmat3 mat;\n\nmat[0][0] = 1.0 - yy - zz;\nmat[1][0] = yx - wz;\nmat[2][0] = zx + wy;\n\nmat[0][1] = yx + wz;\nmat[1][1] = 1.0 - xx - zz;\nmat[2][1] = zy - wx;\n\nmat[0][2] = zx - wy;\nmat[1][2] = zy + wx;\nmat[2][2] = 1.0 - xx - yy;\nreturn mat;\n}\nvoid node_compose_matrix(\nbool useEulerRotation, int inputRotateOrder,\nvec4 inputQuat, vec3 inputRotate, vec3 inputScale, vec3 inputShear, vec3 inputTranslate,\nout mat4 outputMatrix)\n{\nmat4 rotateMatrix;\ninputRotate = radians(inputRotate);\nif (useEulerRotation)\nrotateMatrix = toMat4(mat3RotateX(inputRotate.x) * mat3RotateY(inputRotate.y) * mat3RotateZ(inputRotate.z));\nelse\nrotateMatrix = toMat4(quatToMat3(normalize(inputQuat)));\nmat4 scaleMatrix = mat4(inputScale.x, 0.0, 0.0, 0.0,\n0.0, inputScale.y, 0.0, 0.0,\n0.0, 0.0, inputScale.z, 0.0,\n0.0, 0.0, 0.0, 1.0);\nmat4 shearMatrix = mat4(1.0, 0.0, 0.0, 0.0,\ninputShear.x, 1.0, 0.0, 0.0,\ninputShear.y, inputShear.z, 1.0, 0.0,\n0.0, 0.0, 0.0, 1.0);\nmat4 transMatrix = mat4(1.0, 0.0, 0.0, 0.0,\n0.0, 1.0, 0.0, 0.0,\n0.0, 0.0, 1.0, 0.0,\ninputTranslate.x, inputTranslate.y, inputTranslate.z, 1.0);\noutputMatrix = scaleMatrix * shearMatrix * rotateMatrix * transMatrix;\n}",node_condition_my_frag:"void node_condition(\nint operation,\nvec3 colorIfFalse, vec3 colorIfTrue, float firstTerm, float secondTerm,\nout vec3 outColor) {\nif (operation == 0) {\nif (firstTerm == secondTerm)\noutColor = colorIfTrue;\nelse\noutColor = colorIfFalse;\n} else if (operation == 1) {\nif (firstTerm != secondTerm)\noutColor = colorIfTrue;\nelse\noutColor = colorIfFalse;\n} else if (operation == 2) {\nif (firstTerm > secondTerm)\noutColor = colorIfTrue;\nelse\noutColor = colorIfFalse;\n} else if (operation == 3) {\nif (firstTerm >= secondTerm)\noutColor = colorIfTrue;\nelse\noutColor = colorIfFalse;\n} else if (operation == 4) {\nif (firstTerm < secondTerm)\noutColor = colorIfTrue;\nelse\noutColor = colorIfFalse;\n} else if (operation == 5) {\nif (firstTerm <= secondTerm)\noutColor = colorIfTrue;\nelse\noutColor = colorIfFalse;\n}\n}",node_decompose_matrix_my_frag:"vec4 mat3ToQuat(mat3 m) {\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 q = vec4(0.0, 0.0, 0.0, 0.0);\nif (trace > 0.0) {\nfloat s = sqrt(trace + 1.0) * 2.0;\nq.w = 0.25 * s;\nq.x = (m[2][1] - m[1][2]) / s;\nq.y = (m[0][2] - m[2][0]) / s;\nq.z = (m[1][0] - m[0][1]) / s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]) * 2.0;\nq.w = (m[2][1] - m[1][2]) / s;\nq.x = 0.25 * s;\nq.y = (m[0][1] + m[1][0]) / s;\nq.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]) * 2.0;\nq.w = (m[0][2] - m[2][0]) / s;\nq.x = (m[0][1] + m[1][0]) / s;\nq.y = 0.25 * s;\nq.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]) * 2.0;\nq.w = (m[1][0] - m[0][1]) / s;\nq.x = (m[0][2] + m[2][0]) / s;\nq.y = (m[1][2] + m[2][1]) / s;\nq.z = 0.25 * s;\n}\nreturn q;\n}\nvec3 mat3ToEuler(mat3 m) {\nfloat m11 = m[0][0], m12 = m[1][0], m13 = m[2][0];\nfloat m21 = m[0][1], m22 = m[1][1], m23 = m[2][1];\nfloat m31 = m[0][2], m32 = m[1][2], m33 = m[2][2];\nvec3 euler;\neuler.y = asin(clamp(m13, -1.0, 1.0));\nif (abs(m13) < 0.9999999) {\neuler.x = atan(-m23, m33);\neuler.z = atan(-m12, m11);\n} else {\neuler.x = atan(m32, m22);\neuler.z = 0.0;\n}\nreturn euler;\n}\nvoid decomposeMat4(mat4 m, out vec3 position, out vec4 quat, out vec3 euler, out vec3 scale) {\nfloat sx = length(vec3(m[0][0], m[0][1], m[0][2]));\nfloat sy = length(vec3(m[1][0], m[1][1], m[1][2]));\nfloat sz = length(vec3(m[2][0], m[2][1], m[2][2]));\nfloat det = mat3GetDeterminant(toMat3(m));\nif (det < 0.0)\nsx = -sx;\nposition.x = m[3][0];\nposition.y = m[3][1];\nposition.z = m[3][2];\nfloat invSX = 1.0 / sx;\nfloat invSY = 1.0 / sy;\nfloat invSZ = 1.0 / sz;\nm[0][0] *= invSX;\nm[0][1] *= invSX;\nm[0][2] *= invSX;\nm[1][0] *= invSY;\nm[1][1] *= invSY;\nm[1][2] *= invSY;\nm[2][0] *= invSZ;\nm[2][1] *= invSZ;\nm[2][2] *= invSZ;\nquat = mat3ToQuat(toMat3(m));\neuler = mat3ToEuler(toMat3(m));\nscale.x = sx;\nscale.y = sy;\nscale.z = sz;\n}\nvoid node_decompose_matrix(\nmat4 inputMatrix,\nout vec4 outputQuat, out vec3 outputRotate, out vec3 outputScale, out vec3 outputShear, out vec3 outputTranslate)\n{\ndecomposeMat4(inputMatrix, outputTranslate, outputQuat, outputRotate, outputScale);\noutputShear = vec3(0.0, 0.0, 0.0);\n}",node_env_sphere_my_frag:"void node_env_sphere(sampler2D envMap, int encoding, vec3 normal,\nmat4 placementMatrix,\nout float outAlpha, out vec3 outColor)\n{\nvec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\nvec3 reflectVec;\n#if WORLD_NODES\nreflectVec = normalize(cameraToVertex);\n#else\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nreflectVec = reflect(cameraToVertex, worldNormal);\n#endif\nmat3 uvTransform = mat3(1.0);\nreflectVec = toMat3(placementMatrix) * reflectVec;\nvec4 tex = sampleEquirectangular(envMap, reflectVec, uvTransform, encoding);\noutAlpha = tex.a;\noutColor = tex.rgb;\n}",node_file_my_frag:"void node_file(sampler2D ima, const int encoding, const bool rgbToAlpha,\nvec2 uvCoord,\nout float outAlpha, out vec3 outColor, out vec2 outSize, out vec3 outTransparency) {\nvec2 uv = vec2(uvCoord.x, 1.0 - uvCoord.y);\nvec4 tex = texture2D(ima, uv);\noutColor = nodeTexelToLinear(tex, encoding).rgb;\nif (rgbToAlpha)\noutAlpha = dot(tex.rgb, LUM_WEIGHTS_MAYA);\nelse\noutAlpha = tex.a;\noutSize = vec2(0.0);\noutTransparency = vec3(1.0 - outAlpha, 1.0 - outAlpha, 1.0 - outAlpha);\n}",node_float_condition_my_frag:"void node_float_condition(\nbool condition, float floatA, float floatB, \nout float outFloat) {\noutFloat = condition ? floatA : floatB;\n}",node_float_composite_my_frag:"void node_float_composite(int operation,\nfloat floatA, float floatB, float factor,\nout float outFloat)\n{\nif (factor <= 0.0) {\noutFloat = floatA;\nreturn;\n}\nif (operation == 0) {\noutFloat = floatA + (floatB * factor);\n} else if (operation == 1) {\noutFloat = floatA + ((floatB - 1.0) * factor);\n} else if (operation == 2) {\nif (factor >= 1.0) {\noutFloat = floatB;\nreturn;\n}\noutFloat = mix(floatA, floatB, factor);\n} else if (operation == 3) {\noutFloat = floatA * (floatB * factor + (1.0 - factor));\n} else if (operation == 4) {\noutFloat = 1.0 - ((1.0 - floatA) * (1.0 - floatB * factor));\n} else if (operation == 5) {\noutFloat = floatB > 0.5 ? (2.0 * floatA * floatB * factor) + floatA * (1.0 - factor) :\n1.0 - ((1.0 - floatA) * (1.0 - floatB * factor)) * (2.0 - (1.0 - factor));\n} else if (operation == 6) {\noutFloat = abs(floatA - (floatB * factor));\n} else if (operation == 7) {\noutFloat = clamp(mix(floatA, floatA / max(1.0 - floatB, 0.00001), factor), floatA, floatB);\n} else if (operation == 8) {\noutFloat = clamp(mix(floatA, 1.0 - (floatA / max(1.0 - floatB, 0.00001)), factor), floatA, floatB);\n}\n}",node_float_constant_my_frag:"void node_float_constant(float inFloat, out float outFloat)\n{\noutFloat = inFloat;\n}",node_float_logic_my_frag:"void node_float_logic(\nint operation,\nfloat floatA, float floatB,\nout bool outBool) {\nif (operation == 0) {\noutBool = (floatA == floatB);\n} else if (operation == 1) {\noutBool = (floatA != floatB);\n} else if (operation == 2) {\noutBool = (floatA < floatB);\n} else if (operation == 3) {\noutBool = (floatA > floatB);\n} else if (operation == 4) {\noutBool = (floatA <= floatB);\n} else {\noutBool = (floatA >= floatB);\n}\n}",node_float_mask_my_frag:"void node_float_mask(\nfloat inFloat, float mask,\nout float outFloat) {\noutFloat = inFloat - mask;\n}",node_float_math_my_frag:"void node_float_math(\nint operation,\nfloat floatA, float floatB,\nout float outFloat) {\nif (operation == 0) {\noutFloat = floatA + floatB;\n} else if (operation == 1) {\noutFloat = floatA - floatB;\n} else if (operation == 2) {\noutFloat = floatA * floatB;\n} else if (operation == 3) {\noutFloat = floatA / floatB;\n} else if (operation == 4) {\noutFloat = min(floatA, floatB);\n} else if (operation == 5) {\noutFloat = max(floatA, floatB);\n} else {\noutFloat = pow(floatA, floatB);\n}\n}",node_four_by_four_matrix_my_frag:"void node_four_by_four_matrix(\nfloat in00, float in01, float in02, float in03,\nfloat in10, float in11, float in12, float in13,\nfloat in20, float in21, float in22, float in23,\nfloat in30, float in31, float in32, float in33,\nout mat4 outMatrix)\n{\noutMatrix = mat4(in00, in01, in02, in03,\nin10, in11, in12, in13,\nin20, in21, in22, in23,\nin30, in31, in32, in33);\n}",node_gamma_correct_my_frag:"void node_gamma_correct(\nvec3 gamma, vec3 value,\nout vec3 outValue) {\noutValue = pow(value, 1.0 / gamma);\n}",node_grid_my_frag:"void node_grid(\nfloat contrast, vec3 fillerColor, vec3 lineColor, float uWidth, float vWidth, vec2 uvCoord,\nout float outAlpha, out vec3 outColor) {\nuvCoord = fract(uvCoord); \nfloat v0 = max(uvCoord.y, 0.5 * vWidth);\nfloat v1 = min(uvCoord.y, 1.0 - 0.5 * vWidth);\nfloat u0 = max(uvCoord.x, 0.5 * uWidth);\nfloat u1 = min(uvCoord.x, 1.0 - 0.5 * uWidth);\nfloat gridFactor = (v0 <= v1 && u0 <= u1) ? 1.0 : 0.0;\ngridFactor = 0.5 - contrast * (gridFactor - 0.5);\ngridFactor = max(gridFactor, 0.0);\nvec3 gridColor = mix(fillerColor, lineColor, gridFactor); \ngridColor.r = max(gridColor.r, 0.0);\ngridColor.g = max(gridColor.g, 0.0);\ngridColor.b = max(gridColor.b, 0.0);\noutAlpha = saturate(gridFactor); \noutColor = gridColor; \n}",node_inverse_matrix_my_frag:"\nmat4 inverseMat4(mat4 m) {\nfloat a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\na10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\na20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\na30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3];\nfloat b00 = a00 * a11 - a01 * a10,\nb01 = a00 * a12 - a02 * a10,\nb02 = a00 * a13 - a03 * a10,\nb03 = a01 * a12 - a02 * a11,\nb04 = a01 * a13 - a03 * a11,\nb05 = a02 * a13 - a03 * a12,\nb06 = a20 * a31 - a21 * a30,\nb07 = a20 * a32 - a22 * a30,\nb08 = a20 * a33 - a23 * a30,\nb09 = a21 * a32 - a22 * a31,\nb10 = a21 * a33 - a23 * a31,\nb11 = a22 * a33 - a23 * a32;\nfloat det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\nreturn mat4(a11 * b11 - a12 * b10 + a13 * b09,\na02 * b10 - a01 * b11 - a03 * b09,\na31 * b05 - a32 * b04 + a33 * b03,\na22 * b04 - a21 * b05 - a23 * b03,\na12 * b08 - a10 * b11 - a13 * b07,\na00 * b11 - a02 * b08 + a03 * b07,\na32 * b02 - a30 * b05 - a33 * b01,\na20 * b05 - a22 * b02 + a23 * b01,\na10 * b10 - a11 * b08 + a13 * b06,\na01 * b08 - a00 * b10 - a03 * b06,\na30 * b04 - a31 * b02 + a33 * b00,\na21 * b02 - a20 * b04 - a23 * b00,\na11 * b07 - a10 * b09 - a12 * b06,\na00 * b09 - a01 * b07 + a02 * b06,\na31 * b01 - a30 * b03 - a32 * b00,\na20 * b03 - a21 * b01 + a22 * b00) / det;\n}\nvoid node_inverse_matrix(\nmat4 inputMatrix,\nout mat4 outputMatrix)\n{\noutputMatrix = inverseMat4(inputMatrix);\n}",node_lambert_my_frag:"\nvoid node_lambert(\nvec3 geometryNormal,\nvec3 color, vec3 ambientColor, vec3 incandescence, float matteOpacity,\nfloat diffuse, vec3 normal, float translucence, vec3 transparency,\nout vec4 outColor) {\nNodeMaterial material;\nmaterial.diffuseColor = diffuse * color.rgb;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#define RE_DirectDiffuse RE_DirectDiffuse_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_DirectDiffuse\n#undef RE_IndirectDiffuse\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\nfloat alpha = 1.0 - average(transparency);\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + incandescence, alpha);\n}",node_layered_texture_layer_my_frag:"#define LAYER_BLEND_MODE_NONE 0.0\n#define LAYER_BLEND_MODE_OVER 1.0\n#define LAYER_BLEND_MODE_IN 2.0\n#define LAYER_BLEND_MODE_OUT 3.0\n#define LAYER_BLEND_MODE_ADD 4.0\n#define LAYER_BLEND_MODE_SUBTRACT 5.0\n#define LAYER_BLEND_MODE_MULTIPLY 6.0\n#define LAYER_BLEND_MODE_DIFFERENCE 7.0\n#define LAYER_BLEND_MODE_LIGHTEN 8.0\n#define LAYER_BLEND_MODE_DARKEN 9.0\n#define LAYER_BLEND_MODE_SATURATE 10.0\n#define LAYER_BLEND_MODE_DESATURATE 11.0\n#define LAYER_BLEND_MODE_ILLUMINATE 12.0\nvoid node_layered_texture_layer(\nconst float alphaBG, const vec3 colorBG, \nconst vec3 color, const float alpha, const float blendMode, const bool isVisible,\nout float outAlpha, out vec3 outColor)\n{\noutAlpha = alphaBG;\noutColor = colorBG;\nif (!isVisible)\nreturn;\nif (blendMode == LAYER_BLEND_MODE_NONE) {\noutColor = color;\n} else if (blendMode == LAYER_BLEND_MODE_OVER) {\noutColor = mix(colorBG, color, alpha);\n} else if (blendMode == LAYER_BLEND_MODE_IN) {\noutColor = alpha * colorBG;\n} else if (blendMode == LAYER_BLEND_MODE_OUT) {\noutColor = (1.0 - alpha) * colorBG;\n} else if (blendMode == LAYER_BLEND_MODE_ADD) {\noutColor = mix(colorBG, colorBG + color, alpha);\n} else if (blendMode == LAYER_BLEND_MODE_SUBTRACT) {\noutColor = mix(colorBG, colorBG - color, alpha);\n} else if (blendMode == LAYER_BLEND_MODE_MULTIPLY) {\noutColor = mix(colorBG, colorBG * color, alpha);\n} else {\noutColor = mix(colorBG, color, alpha);\n}\n}",node_light_path_my_frag:"void node_light_path(out float isCameraRay)\n{\n#if LIGHT_PATH_IS_CAM_RAY\nisCameraRay = 1.0;\n#else\nisCameraRay = 0.0;\n#endif\n}",node_luminance_my_frag:"void node_luminance(\nvec3 value,\nout float outValue) {\noutValue = dot(value, LUM_WEIGHTS_MAYA);\n}",node_multiply_divide_my_frag:"void node_multiply_divide(\nint operation,\nvec3 input1, vec3 input2,\nout vec3 outValue) {\nif (operation == 0) {\noutValue = input1;\n} else if (operation == 1) {\noutValue = input1 * input2;\n} else if (operation == 2) {\n\noutValue = input1 / input2;\n} else {\noutValue = pow(input1, input2);\n}\n}",node_mult_double_linear_my_frag:"void node_mult_double_linear(\nfloat input1, float input2,\nout float outValue) {\noutValue = input1 * input2;\n}",node_mult_matrix_my_frag:"\nvoid node_mult_matrix(\nmat4 matrixIn1,\nout mat4 matrixSum)\n{\nmatrixSum = matrixIn1;\n}\nvoid node_mult_matrix(\nmat4 matrixIn1, mat4 matrixIn2,\nout mat4 matrixSum)\n{\nmatrixSum = matrixIn2 * matrixIn1;\n}\nvoid node_mult_matrix(\nmat4 matrixIn1, mat4 matrixIn2, mat4 matrixIn3,\nout mat4 matrixSum)\n{\nmatrixSum = matrixIn3 * matrixIn2 * matrixIn1;\n}",node_noise_my_frag:"vec2 calcNoiseImplode(float implode, vec2 implodeCenter, vec2 uv) {\nif (abs(implode) >= EPSILON) {\nuv -= implodeCenter;\nfloat len = length(uv);\nif (len > EPSILON) {\nfloat factor = pow(len, 1.0-implode) / len;\nuv *= factor;\n}\nuv += implodeCenter;\n}\nreturn uv;\n}\nvoid node_noise(\nfloat amplitude, int depthMax, float frequency, float frequencyRatio, float implode,\nvec2 implodeCenter, bool inflection, float ratio, float threshold, float time, vec2 uvCoord,\nout float outAlpha, out vec3 outColor) {\nuvCoord = calcNoiseImplode(implode, implodeCenter, uvCoord);\nfrequency *= 0.6;\namplitude *= 0.9;\nuvCoord *= frequency;\nfloat noiseAccum = 0.0;\nvec2 freqOffset = vec2(0.02, 0.3);\nint depthId = 0;\nwhile (depthId < depthMax) {\nint stepVal = depthId;\nfloat noise = noisePerlin(vec3(uvCoord + freqOffset, time + 0.5 * float(stepVal)));\nif (inflection)\nnoise = abs(noise);\nnoiseAccum += amplitude * noise;\nuvCoord *= frequencyRatio;\ntime *= sqrt(frequencyRatio);\namplitude *= ratio;\nfreqOffset += vec2(0.02, 0.3);\ndepthId++;\n}\nif (!inflection)\nnoiseAccum = 0.5 * noiseAccum + 0.5;\nnoiseAccum += threshold;\noutAlpha = min(1.0, noiseAccum);\noutColor = vec3(outAlpha, outAlpha, outAlpha);\n}",node_output_my_frag:"void node_output(vec4 rgb, out vec4 outgoingLight)\n{\noutgoingLight = rgb;\n}",node_place_2d_texture_my_frag:"void node_place_2d_texture(const vec2 inUv,\nvec2 offset, vec2 repeatUv, float rotateUv,\nout vec2 outUv)\n{\noutUv = (calcUvTransform(offset.x, offset.y, repeatUv.x, repeatUv.y, rotateUv) * vec3(inUv, 1.0)).xy;\noutUv.y = 1.0 - outUv.y;\n}",node_phong_my_frag:"void node_phong(\nvec3 geometryNormal,\nvec3 color, vec3 ambientColor, vec3 incandescence, float matteOpacity,\nfloat diffuse, vec3 normal, float reflectivity, vec3 reflectedColor,\nfloat cosinePower, vec3 specularColor, float translucence, vec3 transparency,\nout vec4 outColor) {\nNodeMaterial material;\nmaterial.diffuseColor = diffuse * color;\n#ifdef CLEARCOAT\n#undef 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.specularRoughness = max(roughness, 0.0525);\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min(material.specularRoughness, 1.0);\nmaterial.specularColor = specularColor;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define 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 CLEARCOAT\n#undef 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.specularRoughness = max(roughness, 0.0525);\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min(material.specularRoughness, 1.0);\nmaterial.specularColor = specularColor;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\nfloat alpha = 1.0 - average(transparency);\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\nreflectedLight.directSpecular + reflectedLight.indirectSpecular + incandescence, alpha);\n}",node_premultiply_my_frag:"void node_premultiply(\nfloat inAlpha, vec3 inColor,\nout float outAlpha, out vec3 outColor) {\noutColor = inColor * inAlpha;\noutAlpha = inAlpha;\n}",node_ramp_my_frag:"void node_ramp(\nsampler2D rampData, int rampType,\nvec2 uvCoord,\nout float outAlpha, out vec3 outColor)\n{\nfloat coord;\nif (rampType == 0) {\ncoord = uvCoord.y;\n} else if (rampType == 1) {\ncoord = uvCoord.x;\n} else if (rampType == 2) {\ncoord = abs(uvCoord.x + uvCoord.y) / 2.0;\n} else if (rampType == 3) {\nvec2 uvSpiral = mat2(0.0, 1.0, 1.0, 0.0) * (uvCoord - vec2(0.5));\ncoord = atan(uvSpiral.y, uvSpiral.x) / PI2 + 0.5;\n} else if (rampType == 4) {\ncoord = length(uvCoord - vec2(0.5)) * sqrt(2.0);\n} else if (rampType == 5) {\nvec2 boxUv = abs(uvCoord - vec2(0.5)) * 2.0;\ncoord = max(boxUv.x, boxUv.y);\n} else if (rampType == 6) {\nuvCoord = abs((uvCoord - vec2(0.5)) * 2.0);\ncoord = uvCoord.y;\n} else if (rampType == 7) {\ncoord = uvCoord.y;\n} else {\ncoord = uvCoord.y;\n}\nvec4 tex = texture2D(rampData, vec2(coord, 0.0));\noutAlpha = average(tex.xyz);\noutColor = tex.xyz;\n}",node_remap_hsv_my_frag:"void node_remap_hsv(vec3 color, out vec3 outColor)\n{\noutColor = color;\n}",node_reverse_my_frag:"void node_reverse(\nvec3 inValue,\nout vec3 outValue) {\noutValue = 1.0 - inValue;\n}",node_sampler_info_my_frag:"void node_sampler_info(\nbool frontFacing, vec4 tangent, vec2 uv,\nvec3 viewNorm,\nout float facingRatio, out bool flippedNormal, out mat4 matrixEyeToWorld,\nout vec3 normalCamera, out vec2 pixelCenter, out vec3 pointCamera,\nout vec3 pointObj, out vec3 pointWorld,\nout vec3 tangentUCamera, out vec3 tangentVCamera, out vec2 uvCoord)\n{\nvec4 worldPos = invViewMatrix * vec4(-vViewPosition, 1.0);\nfacingRatio = dot(normalize(viewNorm), normalize(vViewPosition));\nflippedNormal = frontFacing;\nmatrixEyeToWorld = invViewMatrix;\nnormalCamera = viewNorm;\npixelCenter = vec2(1.0);\npointCamera = -vViewPosition;\npointObj = (invModelMatrix * worldPos).xyz;\npointWorld = worldPos.xyz;\ntangentUCamera = normalize((modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz);\ntangentVCamera = tangent.w * cross(viewNorm, tangentUCamera);\nuvCoord = vec2(uv.x, 1.0-uv.y);\n}",node_set_range_my_frag:"void node_set_range(\nvec3 maxValue, vec3 minValue, vec3 oldMax, vec3 oldMin, vec3 value,\nout vec3 outValue) {\noutValue = minValue + (((value - oldMin) / (oldMax - oldMin)) * (maxValue - minValue));\n}",node_shading_engine_my_frag:"void node_shading_engine(vec4 surface, vec4 volume, vec3 displacement, out vec4 outgoingLight) {\noutgoingLight = surface + volume;\n}",node_surface_shader_my_frag:"void node_surface_shader(\nvec3 color, vec3 glowColor, vec3 matteOpacity, vec3 transparency,\nout vec3 outColor, out vec3 outGlowColor, out vec3 outMatteOpacity, out vec3 outTransparency)\n{\noutColor = color;\noutGlowColor = glowColor;\noutMatteOpacity = matteOpacity;\noutTransparency = transparency;\n}",node_transform_my_frag:"void node_transform(\nout vec3 center, out mat4 inverseMatrix, out mat4 matrix,\nout mat4 parentInverseMatrix, out mat4 parentMatrix, out mat4 worldInverseMatrix,\nout mat4 worldMatrix, out mat4 xformMatrix)\n{\ncenter = modelMatrix[3].xyz;\ninverseMatrix = invModelMatrix;\nmatrix = modelMatrix;\nparentInverseMatrix = mat4(1.0);\nparentMatrix = mat4(1.0);\nworldInverseMatrix = invModelMatrix;\nworldMatrix = modelMatrix;\nxformMatrix = matrix;\n}",node_transpose_matrix_my_frag:"mat4 transposeMat4(mat4 m) {\nreturn mat4(vec4(m[0].x, m[1].x, m[2].x, m[3].x),\nvec4(m[0].y, m[1].y, m[2].y, m[3].y),\nvec4(m[0].z, m[1].z, m[2].z, m[3].z),\nvec4(m[0].w, m[1].w, m[2].w, m[3].w));\n}\nvoid node_transpose_matrix(\nmat4 inputMatrix,\nout mat4 outputMatrix)\n{\noutputMatrix = transposeMat4(inputMatrix);\n}",node_unit_conversion_my_frag:"void node_unit_conversion(float conversionFactor, float inInput, out float outOutput)\n{\noutOutput = conversionFactor * inInput;\n}\nvoid node_unit_conversion(float conversionFactor, vec3 inInput, out vec3 outOutput)\n{\noutOutput = conversionFactor * inInput;\n}",node_unpremultiply_my_frag:"void node_unpremultiply(\nfloat inAlpha, vec3 inColor,\nout float outAlpha, out vec3 outColor) {\noutColor = inColor / inAlpha;\noutAlpha = inAlpha;\n}",node_vector_product_my_frag:"void node_vector_product(\nconst int operation, const bool normalizeOutput,\nvec3 input1, vec3 input2, mat4 matrix,\nout vec3 outVector) {\nif (operation == 0) {\noutVector = input1;\n} else if (operation == 1) {\nif (normalizeOutput) {\ninput1 = normalize(input1);\ninput2 = normalize(input2);\n}\noutVector = vec3(dot(input1, input2));\n} else if (operation == 2) {\noutVector = cross(input1, input2);\n} else if (operation == 3) {\noutVector = (matrix * vec4(input1, 0.0)).xyz;\n} else {\noutVector = (matrix * vec4(input1, 1.0)).xyz;\n}\n\nif (operation > 1 && normalizeOutput)\noutVector = normalize(outVector);\n}",node_wt_add_matrix_my_frag:"void node_wt_add_matrix(\nmat4 matrixIn1, float weightIn1,\nout mat4 matrixSum)\n{\nmatrixSum = weightIn1 * matrixIn1;\n}\nvoid node_wt_add_matrix(\nmat4 matrixIn1, float weightIn1, mat4 matrixIn2, float weightIn2,\nout mat4 matrixSum)\n{\nmatrixSum = weightIn1 * matrixIn1 + weightIn2 * matrixIn2;\n}\nvoid node_wt_add_matrix(\nmat4 matrixIn1, float weightIn1, mat4 matrixIn2, float weightIn2, mat4 matrixIn3, float weightIn3,\nout mat4 matrixSum)\n{\nmatrixSum = weightIn1 * matrixIn1 + weightIn2 * matrixIn2 + weightIn3 * matrixIn3;\n}",pp_plane_vert:"varying vec2 vUv;\nvoid main() {\nvUv = uv;\ngl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",pp_afterimage_frag:"uniform float damp;\nuniform sampler2D tOld;\nuniform sampler2D tNew;\nvarying vec2 vUv;\nvec4 when_gt(vec4 x, float y) {\nreturn max(sign(x - y), 0.0);\n}\nvoid main() {\nvec4 texelOld = texture2D(tOld, vUv);\nvec4 texelNew = texture2D(tNew, vUv);\n\ntexelOld *= damp * when_gt(texelOld, 0.1);\ngl_FragColor = max(texelNew, texelOld);\n}",pp_bloom_composite_frag:"varying vec2 vUv;\nuniform sampler2D blurTexture1;\nuniform sampler2D blurTexture2;\nuniform sampler2D blurTexture3;\nuniform sampler2D blurTexture4;\nuniform sampler2D blurTexture5;\nuniform sampler2D dirtTexture;\nuniform float bloomStrength;\nuniform float bloomRadius;\nuniform float bloomFactors[NUM_MIPS];\nuniform vec3 bloomTintColors[NUM_MIPS];\nfloat lerpBloomFactor(const in float factor) {\nfloat mirrorFactor = 1.2 - factor;\nreturn mix(factor, mirrorFactor, bloomRadius);\n}\nvoid main() {\ngl_FragColor = bloomStrength * (\nlerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +\nlerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +\nlerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +\nlerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +\nlerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv)\n);\n}",pp_bloom_lum_high_pass_frag:"uniform sampler2D tDiffuse;\nuniform vec3 defaultColor;\nuniform float defaultOpacity;\nuniform float luminosityThreshold;\nuniform float smoothWidth;\nvarying vec2 vUv;\nvoid main() {\nvec4 texel = texture2D(tDiffuse, vUv);\nvec3 luma = vec3(0.299, 0.587, 0.114);\nfloat v = dot(texel.xyz, luma);\nvec4 outputColor = vec4(defaultColor.rgb, defaultOpacity);\nfloat alpha = smoothstep(luminosityThreshold, luminosityThreshold + smoothWidth, v);\ngl_FragColor = mix(outputColor, texel, alpha);\ngl_FragColor = clamp(gl_FragColor, 0.0, 10.0);\n}",pp_bloom_separable_blur_frag:"#include <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));\n#if MAP_TEXELS == 1\ntexel = mapTexelToLinear(texel);\n#endif\ngl_FragColor = opacity * texel;\n#if MAP_TEXELS == 1\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#endif\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 = 64.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) {\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) / 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;\nfloat randAngle = texture2D(tNoise, vUv * noiseScale).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);\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}",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}",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}"},O={common:{diffuse:{value:new _t(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Un},uv2Transform:{value:new Un},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},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 Be(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 _t(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},maxDistance:{},shadowCameraNear:{},expBias:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadow:{},shadowCameraNear:{},shadowCameraFar:{},expBias:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{},expBias:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},rectAreaLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{},expBias:{}}},rectAreaShadowMap:{value:[]},rectAreaShadowMatrix:{value:[]},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new _t(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Un}},sprite:{diffuse:{value:new _t(16777215)},opacity:{value:1},center:{value:new Be(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Un}},mask:{depthTexture:{value:null},cameraNearFar:{value:new Be(.5,.5)},textureMatrix:{value:new gt}},node:{nodeRGB:{value:[]},nodeValue:{value:[]},flipCubeMap:{value:-1},materialIndex:{value:0}},nodeGTAO:{gtaoMap:{value:null}},ssr:{invProjectionMatrix:{value:new gt},ssrSourceBuffer:{value:null},ssrDepthBuffer:{value:null},ssrBackfaceDepthBuffer:{value:null},ssrStride:{value:20},ssrResolution:{value:new Be},ssrThickness:{value:.01},ssrJitter:{value:1},ssrMaxDistance:{value:100}},planeReflectionProbe:{planeReflTexture:{value:null},planeReflTextureMatrix:{value:new gt},planeReflDir:{value:new vt},planeReflBoundingBoxMin:{value:new vt},planeReflBoundingBoxMax:{value:new vt},planeReflInvModelMatrix:{value:new gt},planeReflFalloff:{value:0}}},E={basic:{uniforms:la([O.common,O.specularmap,O.envmap,O.aomap,O.lightmap,O.fog]),vertexShader:yt.meshbasic_vert,fragmentShader:yt.meshbasic_frag},lambert:{uniforms:la([O.common,O.specularmap,O.envmap,O.aomap,O.lightmap,O.emissivemap,O.fog,O.lights,{emissive:{value:new _t(0)}}]),vertexShader:yt.meshlambert_vert,fragmentShader:yt.meshlambert_frag},phong:{uniforms:la([O.common,O.specularmap,O.envmap,O.aomap,O.lightmap,O.emissivemap,O.bumpmap,O.normalmap,O.displacementmap,O.fog,O.lights,{emissive:{value:new _t(0)},specular:{value:new _t(1118481)},shininess:{value:30}}]),vertexShader:yt.meshphong_vert,fragmentShader:yt.meshphong_frag},standard:{uniforms:la([O.common,O.envmap,O.aomap,O.lightmap,O.emissivemap,O.bumpmap,O.normalmap,O.displacementmap,O.roughnessmap,O.metalnessmap,O.fog,O.lights,O.planeReflectionProbe,{emissive:{value:new _t(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1},envMapParallaxType:{value:0},envMapParallaxMatrix:{value:new gt},envMapParallaxMatrixInv:{value:new gt}}]),vertexShader:yt.meshphysical_vert,fragmentShader:yt.meshphysical_frag},toon:{uniforms:la([O.common,O.aomap,O.lightmap,O.emissivemap,O.bumpmap,O.normalmap,O.displacementmap,O.gradientmap,O.fog,O.lights,{emissive:{value:new _t(0)}}]),vertexShader:yt.meshtoon_vert,fragmentShader:yt.meshtoon_frag},matcap:{uniforms:la([O.common,O.bumpmap,O.normalmap,O.displacementmap,O.fog,{matcap:{value:null}}]),vertexShader:yt.meshmatcap_vert,fragmentShader:yt.meshmatcap_frag},points:{uniforms:la([O.points,O.fog]),vertexShader:yt.points_vert,fragmentShader:yt.points_frag},dashed:{uniforms:la([O.common,O.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:yt.linedashed_vert,fragmentShader:yt.linedashed_frag},depth:{uniforms:la([O.common,O.displacementmap,{slopeScaledBias:{value:0}}]),vertexShader:yt.depth_vert,fragmentShader:yt.depth_frag},normal:{uniforms:la([O.common,O.bumpmap,O.normalmap,O.displacementmap,{opacity:{value:1}}]),vertexShader:yt.normal_vert,fragmentShader:yt.normal_frag},sprite:{uniforms:la([O.sprite,O.fog]),vertexShader:yt.sprite_vert,fragmentShader:yt.sprite_frag},background:{uniforms:{uvTransform:{value:new Un},t2D:{value:null}},vertexShader:yt.background_vert,fragmentShader:yt.background_frag},cube:{uniforms:la([O.envmap,{opacity:{value:1}}]),vertexShader:yt.cube_vert,fragmentShader:yt.cube_frag},equirect:{uniforms:{tEquirect:{value:null},invertU:{value:!1},offsetU:{value:0}},vertexShader:yt.equirect_vert,fragmentShader:yt.equirect_frag},distanceRGBA:{uniforms:la([O.common,O.displacementmap,{referencePosition:{value:new vt},nearDistance:{value:1},farDistance:{value:1e3},slopeScaledBias:{value:0}}]),vertexShader:yt.distanceRGBA_vert,fragmentShader:yt.distanceRGBA_frag},shadow:{uniforms:la([O.lights,O.fog,{color:{value:new _t(0)},opacity:{value:1}}]),vertexShader:yt.shadow_vert,fragmentShader:yt.shadow_frag},mask:{uniforms:la([O.common,O.displacementmap,O.mask]),vertexShader:yt.mask_vert,fragmentShader:yt.mask_frag},equicube:{uniforms:{tEquirect:{value:null},faceIndex:{value:0},invertU:{value:!1},offsetU:{value:0}},vertexShader:yt.equicube_vert,fragmentShader:yt.equicube_frag},node:{uniforms:la([O.common,O.displacementmap,O.envmap,O.fog,O.lights,O.ssr,O.planeReflectionProbe,O.node,O.nodeGTAO,{envMapIntensity:{value:1},envMapParallaxType:{value:0},envMapParallaxMatrix:{value:new gt},envMapParallaxMatrixInv:{value:new gt}}]),vertexShader:yt.meshnode_vert,fragmentShader:yt.meshnode_frag},cubeOctahedral:{uniforms:{tCube:{value:null},texelSize:{value:new Be(.5,.5)}},vertexShader:yt.pp_plane_vert,fragmentShader:yt.pp_cube_octahedral_proj_frag}};function Ta(s,l,n,c,r){const u=new _t(0);let d=0,h,p,f=null,m=0,v=null;function g(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,r)}return{getClearColor:function(){return u},setClearColor:function(e,t=1){u.set(e),d=t,g(u,d)},getClearAlpha:function(){return d},setClearAlpha:function(e){d=e,g(u,d)},dispose:function(){h&&(h.geometry.dispose(),h.material.dispose()),h=void 0,p&&(p.geometry.dispose(),p.material.dispose()),p=void 0},render:function(e,t){let n=!1;var r=t.background&&t.background.isSceneBackground;let i=r?t.background.data:t.background;i&&i.isTexture&&(i=l.get(i));const a=s.xr;var o=a.getSession&&a.getSession(),o=(null===(i=o&&"additive"===o.environmentBlendMode?null:i)?g(u,d):i&&i.isColor&&(g(i,1),n=!0),(s.autoClear||n)&&s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil),!!r&&t.background.useHDR);i&&(i.isCubeTexture||i.isWebGLCubeRenderTarget||i.mapping===N)?(void 0===p&&((p=new ee(new oa(1,1,1),new T({name:"BackgroundCubeMaterial",uniforms:sa(E.cube.uniforms),vertexShader:E.cube.vertexShader,fragmentShader:E.cube.fragmentShader,side:Fe,depthTest:!1,depthWrite:!1,fog:!1,useHDR:o}))).geometry.deleteAttribute("normal"),p.geometry.deleteAttribute("uv"),p.onBeforeRender=function(e,t,n){var r=n.far;this.matrixWorld.makeScale(r,r,r),this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(p.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),c.update(p)),i.isWebGLCubeRenderTarget&&(i=i.texture),p.material.uniforms.envMap.value=i,p.material.uniforms.flipEnvMap.value=i.isCubeTexture&&i._needsFlipEnvMap?-1:1,f===i&&m===i.version&&v===s.toneMapping||(p.material.needsUpdate=!0,f=i,m=i.version,v=s.toneMapping),e.unshift(p,p.geometry,p.material,0,0,null)):i&&i.isTexture&&(void 0===h&&((h=new ee(new Sa(2,2),new T({name:"BackgroundMaterial",uniforms:sa(E.background.uniforms),vertexShader:E.background.vertexShader,fragmentShader:E.background.fragmentShader,side:Ve,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),c.update(h)),!0===(h.material.uniforms.t2D.value=i).matrixAutoUpdate&&i.updateMatrix(),h.material.uniforms.uvTransform.value.copy(i.matrix),f===i&&m===i.version&&v===s.toneMapping||(h.material.needsUpdate=!0,f=i,m=i.version,v=s.toneMapping),e.unshift(h,h.geometry,h.material,0,0,null))}}}function Ca(x,y,b,M){const i=x.getParameter(34921),h=M.isWebGL2?null:y.get("OES_vertex_array_object"),p=M.isWebGL2||null!==h,f={},e=g(null);let m=e;function v(e){if(M.isWebGL2)return x.bindVertexArray(e);h.bindVertexArrayOES(e)}function a(e){if(M.isWebGL2)return x.deleteVertexArray(e);h.deleteVertexArrayOES(e)}function g(e){const t=[],n=[],r=[];for(let e=0;e<i;e++)t[e]=0,n[e]=0,r[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:n,attributeDivisors:r,object:e,attributes:{},index:null}}function A(){const n=m.newAttributes;for(let e=0,t=n.length;e<t;e++)n[e]=0}function w(e){S(e,0)}function S(e,t){const n=m.newAttributes,r=m.enabledAttributes,i=m.attributeDivisors;if(n[e]=1,0===r[e]&&(x.enableVertexAttribArray(e),r[e]=1),i[e]!==t){const a=M.isWebGL2?x:y.get("ANGLE_instanced_arrays");a[M.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](e,t),i[e]=t}}function T(){var n=m.newAttributes;const r=m.enabledAttributes;for(let e=0,t=r.length;e<t;e++)r[e]!==n[e]&&(x.disableVertexAttribArray(e),r[e]=0)}function C(e,t,n,r,i,a){!0!==M.isWebGL2||5124!==n&&5125!==n?x.vertexAttribPointer(e,t,n,r,i,a):x.vertexAttribIPointer(e,t,n,i,a)}function o(){t(),m!==e&&v((m=e).object)}function t(){e.geometry=null,e.program=null,e.wireframe=!1}return{setup:function(e,t,n,r,i){let a=!1;if(p){var o=function(e,t,n){n=!0===n.wireframe;let r=f[e.id];void 0===r&&(r={},f[e.id]=r);let i=r[t.id];void 0===i&&(i={},r[t.id]=i);let a=i[n];void 0===a&&(a=g(M.isWebGL2?x.createVertexArray():h.createVertexArrayOES()),i[n]=a);return a}(r,n,t);if(m!==o&&v((m=o).object),a=function(e,t){var n=m.attributes,r=e.attributes;let i=0;for(const s in r){var a=n[s],o=r[s];if(void 0===a)return!0;if(a.attribute!==o)return!0;if(a.data!==o.data)return!0;i++}return m.attributesNum!==i||m.index!==t}(r,i)){o=i;const l={},c=r.attributes;let e=0;for(const u in c){var s=c[u];const d={};(d.attribute=s).data&&(d.data=s.data),l[u]=d,e++}m.attributes=l,m.attributesNum=e,m.index=o}}else{o=!0===t.wireframe;m.geometry===r.id&&m.program===n.id&&m.wireframe===o||(m.geometry=r.id,m.program=n.id,m.wireframe=o,a=!0)}!0===e.isInstancedMesh&&(a=!0),null!==i&&b.update(i,34963),a&&(function(e,t,n,r){if(!1===M.isWebGL2&&(e.isInstancedMesh||r.isInstancedBufferGeometry)&&null===y.get("ANGLE_instanced_arrays"))return;A();var i=r.attributes,a=n.getAttributes(),o=t.defaultAttributeValues;for(const _ in a){var s=a[_];if(0<=s){var l=i[_];if(void 0!==l){var c,u=l.normalized,d=l.itemSize,h=b.get(l);void 0!==h&&(v=h.buffer,c=h.type,h=h.bytesPerElement,l.isInterleavedBufferAttribute?(m=l.data,p=m.stride,f=l.offset,m&&m.isInstancedInterleavedBuffer?(S(s,m.meshPerAttribute),void 0===r._maxInstanceCount&&(r._maxInstanceCount=m.meshPerAttribute*m.count)):w(s),x.bindBuffer(34962,v),C(s,d,c,u,p*h,f*h)):(l.isInstancedBufferAttribute?(S(s,l.meshPerAttribute),void 0===r._maxInstanceCount&&(r._maxInstanceCount=l.meshPerAttribute*l.count)):w(s),x.bindBuffer(34962,v),C(s,d,c,u,0,0)))}else if("instanceMatrix"===_){var p,f,m=b.get(e.instanceMatrix);void 0!==m&&(p=m.buffer,f=m.type,S(s+0,1),S(s+1,1),S(s+2,1),S(s+3,1),x.bindBuffer(34962,p),x.vertexAttribPointer(s+0,4,f,!1,64,0),x.vertexAttribPointer(s+1,4,f,!1,64,16),x.vertexAttribPointer(s+2,4,f,!1,64,32),x.vertexAttribPointer(s+3,4,f,!1,64,48))}else if("instanceColor"===_){var v,h=b.get(e.instanceColor);void 0!==h&&(l=h.buffer,v=h.type,S(s,1),x.bindBuffer(34962,l),x.vertexAttribPointer(s,3,v,!1,12,0))}else if(void 0!==o){var g=o[_];if(void 0!==g)switch(g.length){case 2:x.vertexAttrib2fv(s,g);break;case 3:x.vertexAttrib3fv(s,g);break;case 4:x.vertexAttrib4fv(s,g);break;default:x.vertexAttrib1fv(s,g)}}}}T()}(e,t,n,r),null!==i&&x.bindBuffer(34963,b.get(i).buffer))},reset:o,resetDefaultState:t,dispose:function(){o();for(const e in f){const t=f[e];for(const n in t){const r=t[n];for(const i in r)a(r[i].object),delete r[i];delete t[n]}delete f[e]}},releaseStatesOfGeometry:function(e){if(void 0!==f[e.id]){const t=f[e.id];for(const n in t){const r=t[n];for(const i in r)a(r[i].object),delete r[i];delete t[n]}delete f[e.id]}},releaseStatesOfProgram:function(e){for(const t in f){const n=f[t];if(void 0!==n[e.id]){const r=n[e.id];for(const i in r)a(r[i].object),delete r[i];delete n[e.id]}}},initAttributes:A,enableAttribute:w,disableUnusedAttributes:T}}function Ea(a,o,s,e){const l=e.isWebGL2;let c;this.setMode=function(e){c=e},this.render=function(e,t){a.drawArrays(c,e,t),s.update(t,c,1)},this.renderInstances=function(n,r,i){if(0!==i){let e,t;if(l)e=a,t="drawArraysInstanced";else if(e=o.get("ANGLE_instanced_arrays"),t="drawArraysInstancedANGLE",null===e)return void console.error("v3d.WebGLBufferRenderer: using v3d.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");e[t](c,n,r,i),s.update(r,c,i)}}}function La(t,n,e){let r;function i(e){if("highp"===e){if(0<t.getShaderPrecisionFormat(35633,36338).precision&&0<t.getShaderPrecisionFormat(35632,36338).precision)return"highp";e="mediump"}return"mediump"===e&&0<t.getShaderPrecisionFormat(35633,36337).precision&&0<t.getShaderPrecisionFormat(35632,36337).precision?"mediump":"lowp"}var a="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext;let o=void 0!==e.precision?e.precision:"highp";var s=i(o),s=(s!==o&&(console.warn("v3d.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s),a||n.has("WEBGL_draw_buffers")),e=!0===e.logarithmicDepthBuffer,l=t.getParameter(34930),c=t.getParameter(35660),u=t.getParameter(3379),d=t.getParameter(34076),h=t.getParameter(34921),p=t.getParameter(36347),f=t.getParameter(36348),m=t.getParameter(36349),v=0<c,g=a||n.has("OES_texture_float"),_=v&&g,x=a?t.getParameter(36183):0;return{isWebGL2:a,drawBuffers:s,getMaxAnisotropy:function(){return void 0!==r?r:r=!0===n.has("EXT_texture_filter_anisotropic")?(e=n.get("EXT_texture_filter_anisotropic"),t.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY_EXT)):0;var e},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:e,maxTextures:l,maxVertexTextures:c,maxTextureSize:u,maxCubemapSize:d,maxAttributes:h,maxVertexUniforms:p,maxVaryings:f,maxFragmentUniforms:m,vertexTextures:v,floatFragmentTextures:g,floatVertexTextures:_,maxSamples:x}}function Ra(l){const s=this;let c=null,u=0,d=!1,h=!1;const p=new xa,f=new Un,m={value:null,needsUpdate:!1};function v(){m.value!==c&&(m.value=c,m.needsUpdate=0<u),s.numPlanes=u,s.numIntersection=0}function g(n,e,r,t){var i=null!==n?n.length:0;let a=null;if(0!==i){if(a=m.value,!0!==t||null===a){var t=r+4*i,o=e.matrixWorldInverse;f.getNormalMatrix(o),(null===a||a.length<t)&&(a=new Float32Array(t));for(let e=0,t=r;e!==i;++e,t+=4)p.copy(n[e]).applyMatrix4(o,f),p.normal.toArray(a,t),a[t+3]=p.constant}m.value=a,m.needsUpdate=!0}return s.numPlanes=i,s.numIntersection=0,a}this.uniform=m,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t,n){var r=0!==e.length||t||0!==u||d;return d=t,c=g(e,n,0),u=e.length,r},this.beginShadows=function(){h=!0,g(null)},this.endShadows=function(){h=!1,v()},this.setState=function(e,n,r){var i=e.clippingPlanes,a=e.clipIntersection,t=e.clipShadows;const o=l.get(e);if(!d||null===i||0===i.length||h&&!t)h?g(null):v();else{var e=h?0:u,s=4*e;let t=o.clippingState||null;m.value=t,t=g(i,n,s,r);for(let e=0;e!==s;++e)t[e]=c[e];o.clippingState=t,this.numIntersection=a?this.numPlanes:0,this.numPlanes+=e}}}function Pa(i){let a=new WeakMap;function o(e,t){return t===P?e.mapping=L:t===I&&(e.mapping=R),e}function s(e){const t=e.target,n=(t.removeEventListener("dispose",s),a.get(t));void 0!==n&&(a.delete(t),n.dispose())}return{get:function(e){if(e&&e.isTexture){var t=e.mapping;if(t===P||t===I){if(a.has(e))return o(a.get(e).texture,e.mapping);t=e.image;if(t&&0<t.height){var n=i.getRenderTarget();const r=new fa(t.height/2);return r.fromEquirectangularTexture(i,e),a.set(e,r),i.setRenderTarget(n),e.addEventListener("dispose",s),o(r.texture,e.mapping)}return null}}return e},dispose:function(){a=new WeakMap}}}function Ia(n){const r={};function i(e){if(void 0!==r[e])return r[e];let t;switch(e){case"WEBGL_depth_texture":t=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":t=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":t=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":t=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:t=n.getExtension(e)}return r[e]=t}return{has:function(e){return null!==i(e)},init:function(e){e.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float")},get:function(e){var t=i(e);return null===t&&console.warn("v3d.WebGLRenderer: "+e+" extension not supported."),t}}}function Na(e,p,r,i){const a={},f=new WeakMap;function o(e){const t=e.target;null!==t.index&&p.remove(t.index);for(const n in t.attributes)p.remove(t.attributes[n]);t.removeEventListener("dispose",o),delete a[t.id];e=f.get(t);e&&(p.remove(e),f.delete(t)),i.releaseStatesOfGeometry(t),!0===t.isInstancedBufferGeometry&&delete t._maxInstanceCount,r.memory.geometries--}function s(e){const n=[];var r=e.index,t=e.attributes.position;let i=0;if(null!==r){var a=r.array;i=r.version;for(let e=0,t=a.length;e<t;e+=3){var o=a[e+0],s=a[e+1],l=a[e+2];n.push(o,s,s,l,l,o)}}else{r=t.array;i=t.version;for(let e=0,t=r.length/3-1;e<t;e+=3){var c=e+0,u=e+1,d=e+2;n.push(c,u,u,d,d,c)}}const h=new(65535<Si(n)?Mi:yi)(n,1);h.version=i;t=f.get(e);t&&p.remove(t),f.set(e,h)}return{get:function(e,t){return!0===a[t.id]||(t.addEventListener("dispose",o),a[t.id]=!0,r.memory.geometries++),t},update:function(e){var t=e.attributes;for(const i in t)p.update(t[i],34962);var n=e.morphAttributes;for(const a in n){var r=n[a];for(let e=0,t=r.length;e<t;e++)p.update(r[e],34962)}},getWireframeAttribute:function(e){var t,n=f.get(e);return(!n||null!==(t=e.index)&&n.version<t.version)&&s(e),f.get(e)}}}function Da(a,o,s,e){const l=e.isWebGL2;let c;let u,d;this.setMode=function(e){c=e},this.setIndex=function(e){u=e.type,d=e.bytesPerElement},this.render=function(e,t){a.drawElements(c,t,u,e*d),s.update(t,c,1)},this.renderInstances=function(n,r,i){if(0!==i){let e,t;if(l)e=a,t="drawElementsInstanced";else if(e=o.get("ANGLE_instanced_arrays"),t="drawElementsInstancedANGLE",null===e)return void console.error("v3d.WebGLIndexedBufferRenderer: using v3d.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");e[t](c,r,u,n*d,i),s.update(r,c,i)}}}function Oa(e){const a={geometries:0,textures:0,textureSpecs:new Map},r={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:a,render:r,programs:null,autoReset:!0,reset:function(){r.frame++,r.calls=0,r.triangles=0,r.points=0,r.lines=0},update:function(e,t,n){switch(r.calls++,t){case 4:r.triangles+=n*(e/3);break;case 1:r.lines+=n*(e/2);break;case 3:r.lines+=n*(e-1);break;case 2:r.lines+=n*e;break;case 0:r.points+=n*e;break;default:console.error("v3d.WebGLInfo: Unknown draw mode:",t)}},addTextureSpec:function(e){let t,n,r,i;i=e.isWebGLRenderTarget?(t=e.texture.name,n="WebGLRenderTarget",r=e.width,e.height):(t=e.name,n="Texture",r=e.image.width,e.image.height),a.textureSpecs.set(e,{name:t,type:n,width:r,height:i})},removeTextureSpec:function(e){a.textureSpecs.delete(e)}}}function Fa(e,t){return Math.abs(t[1])-Math.abs(e[1])}function Ba(p){const f={},m=new Float32Array(12);return{update:function(e,t,n,r){var i=e.morphTargetInfluences,a=void 0===i?0:i.length;let o=f[t.id];if(void 0===o){o=[];for(let e=0;e<a;e++)o[e]=[e,0];f[t.id]=o}var s=n.morphTargets&&t.morphAttributes.position,l=n.morphNormals&&t.morphAttributes.normal;for(let e=0;e<a;e++)0!==o[e][1]&&(s&&t.deleteAttribute("morphTarget"+e),l&&t.deleteAttribute("morphNormal"+e));for(let e=0;e<a;e++){const h=o[e];h[0]=e,h[1]=i[e]}o.sort(Fa);let c=0;for(let e=0;e<m.length;e++){var u=o[e];if(u){var d=u[0],u=u[1];if(u){s&&t.setAttribute("morphTarget"+e,s[d]),l&&t.setAttribute("morphNormal"+e,l[d]),m[e]=u,c+=u;continue}}m[e]=0}e=t.morphTargetsRelative?1:1-c,r.getUniforms().setValue(p,"morphTargetBaseInfluence",e),r.getUniforms().setValue(p,"morphTargetInfluences",m)}}}function za(e,r,i,a){let o=new WeakMap;function s(e){const t=e.target;t.removeEventListener("dispose",s),i.remove(t.instanceMatrix),null!==t.instanceColor&&i.remove(t.instanceColor)}return{update:function(e){var t=a.render.frame,n=e.geometry,n=r.get(e,n);return o.get(n)!==t&&(r.update(n),o.set(n,t)),e.isInstancedMesh&&(!1===e.hasEventListener("dispose",s)&&e.addEventListener("dispose",s),i.update(e.instanceMatrix,34962),null!==e.instanceColor&&i.update(e.instanceColor,34962)),n},dispose:function(){o=new WeakMap}}}E.physical={uniforms:la([E.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new Be(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new _t(0)},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new Be},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new _t(0)}}]),vertexShader:yt.meshphysical_vert,fragmentShader:yt.meshphysical_frag},E.copy={defines:{MAP_TEXELS:0},uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:yt.pp_plane_vert,fragmentShader:yt.pp_copy_frag},E.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:yt.pp_plane_vert,fragmentShader:yt.pp_bokeh_frag},E.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 Be(1/1024,1/512)}},vertexShader:yt.pp_plane_vert,fragmentShader:yt.pp_fxaa_frag},E.grayscale={uniforms:{tDiffuse:{value:null}},vertexShader:yt.pp_plane_vert,fragmentShader:yt.pp_grayscale_frag},E.brightness_contrast={uniforms:{tDiffuse:{value:null},brightness:{value:0},contrast:{value:0}},vertexShader:yt.pp_plane_vert,fragmentShader:yt.pp_brightness_contrast_frag},E.bloomLumHighPass={uniforms:{tDiffuse:{type:"t",value:null},luminosityThreshold:{type:"f",value:1},smoothWidth:{type:"f",value:1},defaultColor:{type:"c",value:new _t(0)},defaultOpacity:{type:"f",value:0}},vertexShader:yt.pp_plane_vert,fragmentShader:yt.pp_bloom_lum_high_pass_frag},E.blur={defines:{LOG_SPACE:0,OCTAHEDRAL_MAP:0},uniforms:{colorTexture:{value:null},texSize:{value:new Be(.5,.5)},direction:{value:new Be(.5,.5)},kernelRadius:{value:1}},customPrepTokens:{MAX_SAMPLE_RADIUS:4},vertexShader:yt.pp_plane_vert,fragmentShader:yt.pp_blur_frag},E.tonemap={defines:{ALPHA_AS_LUMA:0},uniforms:{tDiffuse:{value:null}},vertexShader:yt.pp_plane_vert,fragmentShader:yt.pp_tonemap_frag},E.afterimage={uniforms:{damp:{value:.96},tOld:{value:null},tNew:{value:null}},vertexShader:yt.pp_plane_vert,fragmentShader:yt.pp_afterimage_frag};class Va extends Hn{constructor(e=null,t=1,n=1,r=1){super(null),this.image={data:e,width:t,height:n,depth:r},this.magFilter=dt,this.minFilter=dt,this.wrapR=ut,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}Va.prototype.isDataTexture2DArray=!0;class Ua extends Hn{constructor(e=null,t=1,n=1,r=1){super(null),this.image={data:e,width:t,height:n,depth:r},this.magFilter=dt,this.minFilter=dt,this.wrapR=ut,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}Ua.prototype.isDataTexture3D=!0;const Ga=new Hn,ka=new Va,Wa=new Ua,Ha=new pa,Xa=[],ja=[],Ya=new Float32Array(16),Za=new Float32Array(9),qa=new Float32Array(4);function Qa(n,r,i){const e=n[0];if(e<=0||0<e)return n;var t=r*i;let a=Xa[t];if(void 0===a&&(a=new Float32Array(t),Xa[t]=a),0!==r){e.toArray(a,0);for(let e=1,t=0;e!==r;++e)t+=i,n[e].toArray(a,t)}return a}function Ka(n,r){if(n.length===r.length){for(let e=0,t=n.length;e<t;e++)if(n[e]!==r[e])return;return 1}}function Ja(n,r){for(let e=0,t=r.length;e<t;e++)n[e]=r[e]}function $a(t,n){let r=ja[n];void 0===r&&(r=new Int32Array(n),ja[n]=r);for(let e=0;e!==n;++e)r[e]=t.allocateTextureUnit();return r}function eo(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function to(e,t){const n=this.cache;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):Ka(n,t)||(e.uniform2fv(this.addr,t),Ja(n,t))}function no(e,t){const n=this.cache;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):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):Ka(n,t)||(e.uniform3fv(this.addr,t),Ja(n,t))}function ro(e,t){const n=this.cache;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):Ka(n,t)||(e.uniform4fv(this.addr,t),Ja(n,t))}function io(e,t){var n=this.cache,r=t.elements;void 0===r?Ka(n,t)||(e.uniformMatrix2fv(this.addr,!1,t),Ja(n,t)):Ka(n,r)||(qa.set(r),e.uniformMatrix2fv(this.addr,!1,qa),Ja(n,r))}function ao(e,t){var n=this.cache,r=t.elements;void 0===r?Ka(n,t)||(e.uniformMatrix3fv(this.addr,!1,t),Ja(n,t)):Ka(n,r)||(Za.set(r),e.uniformMatrix3fv(this.addr,!1,Za),Ja(n,r))}function oo(e,t){var n=this.cache,r=t.elements;void 0===r?Ka(n,t)||(e.uniformMatrix4fv(this.addr,!1,t),Ja(n,t)):Ka(n,r)||(Ya.set(r),e.uniformMatrix4fv(this.addr,!1,Ya),Ja(n,r))}function so(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function lo(e,t){var n=this.cache;Ka(n,t)||(e.uniform2iv(this.addr,t),Ja(n,t))}function co(e,t){var n=this.cache;Ka(n,t)||(e.uniform3iv(this.addr,t),Ja(n,t))}function uo(e,t){var n=this.cache;Ka(n,t)||(e.uniform4iv(this.addr,t),Ja(n,t))}function ho(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function po(e,t){var n=this.cache;Ka(n,t)||(e.uniform2uiv(this.addr,t),Ja(n,t))}function fo(e,t){var n=this.cache;Ka(n,t)||(e.uniform3uiv(this.addr,t),Ja(n,t))}function mo(e,t){var n=this.cache;Ka(n,t)||(e.uniform4uiv(this.addr,t),Ja(n,t))}function vo(e,t,n){const r=this.cache;var i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.safeSetTexture2D(t||Ga,i)}function go(e,t,n){const r=this.cache;var i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(t||Wa,i)}function _o(e,t,n){const r=this.cache;var i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.safeSetTextureCube(t||Ha,i)}function xo(e,t,n){const r=this.cache;var i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(t||ka,i)}function yo(e,t){e.uniform1fv(this.addr,t)}function bo(e,t){t=Qa(t,this.size,2);e.uniform2fv(this.addr,t)}function Mo(e,t){t=Qa(t,this.size,3);e.uniform3fv(this.addr,t)}function Ao(e,t){t=Qa(t,this.size,4);e.uniform4fv(this.addr,t)}function wo(e,t){t=Qa(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,t)}function So(e,t){t=Qa(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,t)}function To(e,t){t=Qa(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,t)}function Co(e,t){e.uniform1iv(this.addr,t)}function Eo(e,t){e.uniform2iv(this.addr,t)}function Lo(e,t){e.uniform3iv(this.addr,t)}function Ro(e,t){e.uniform4iv(this.addr,t)}function Po(e,t){e.uniform1uiv(this.addr,t)}function Io(e,t){e.uniform2uiv(this.addr,t)}function No(e,t){e.uniform3uiv(this.addr,t)}function Do(e,t){e.uniform4uiv(this.addr,t)}function Oo(e,t,n){var r=t.length,i=$a(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.safeSetTexture2D(t[e]||Ga,i[e])}function Fo(e,t,n){var r=t.length,i=$a(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.safeSetTextureCube(t[e]||Ha,i[e])}function Bo(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=function(e){switch(e){case 5126:return eo;case 35664:return to;case 35665:return no;case 35666:return ro;case 35674:return io;case 35675:return ao;case 35676:return oo;case 5124:case 35670:return so;case 35667:case 35671:return lo;case 35668:case 35672:return co;case 35669:case 35673:return uo;case 5125:return ho;case 36294:return po;case 36295:return fo;case 36296:return mo;case 35678:case 36198:case 36298:case 36306:case 35682:return vo;case 35679:case 36299:case 36307:return go;case 35680:case 36300:case 36308:case 36293:return _o;case 36289:case 36303:case 36311:case 36292:return xo}}(t.type)}function zo(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=function(e){switch(e){case 5126:return yo;case 35664:return bo;case 35665:return Mo;case 35666:return Ao;case 35674:return wo;case 35675:return So;case 35676:return To;case 5124:case 35670:return Co;case 35667:case 35671:return Eo;case 35668:case 35672:return Lo;case 35669:case 35673:return Ro;case 5125:return Po;case 36294:return Io;case 36295:return No;case 36296:return Do;case 35678:case 36198:case 36298:case 36306:case 35682:return Oo;case 35680:case 36300:case 36308:case 36293:return Fo}}(t.type)}function Vo(e){this.id=e,this.seq=[],this.map={}}zo.prototype.updateCache=function(e){var t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),Ja(t,e)},Vo.prototype.setValue=function(n,r,i){var a=this.seq;for(let e=0,t=a.length;e!==t;++e){const o=a[e];o.setValue(n,r[o.id],i)}};const Uo=/(\w+)(\])?(\[|\.)?/g;function Go(e,t){e.seq.push(t),e.map[t.id]=t}function ko(t,n){this.seq=[],this.map={};var r=t.getProgramParameter(n,35718);for(let e=0;e<r;++e){var i=t.getActiveUniform(n,e),a=t.getUniformLocation(n,i.name),o=(d=p=h=d=u=c=l=s=o=void 0,i),s=a,l=this,c=o.name,u=c.length;for(Uo.lastIndex=0;;){var d=Uo.exec(c),h=Uo.lastIndex;let t=d[1];var p="]"===d[2],d=d[3];if(p&&(t|=0),void 0===d||"["===d&&h+2===u){Go(l,new(void 0===d?Bo:zo)(t,o,s));break}{let e=l.map[t];void 0===e&&Go(l,e=new Vo(t)),l=e}}}}function Wo(e,t,n){t=e.createShader(t);return e.shaderSource(t,n),e.compileShader(t),t}ko.prototype.setValue=function(e,t,n,r){const i=this.map[t];void 0!==i&&i.setValue(e,n,r)},ko.prototype.setOptional=function(e,t,n){t=t[n];void 0!==t&&this.setValue(e,n,t)},ko.upload=function(n,r,i,a){for(let e=0,t=r.length;e!==t;++e){const o=r[e],s=i[o.id];!1!==s.needsUpdate&&o.setValue(n,s.value,a)}},ko.seqWithValue=function(n,r){const i=[];for(let e=0,t=n.length;e!==t;++e){var a=n[e];a.id in r&&i.push(a)}return i};let Ho=0;function Xo(e){switch(e){case an:return["Linear","(value)"];case on:return["sRGB","(value)"];case sn:return["RGBE","(value)"];case 3004:return["RGBM","(value, 7.0)"];case 3005:return["RGBM","(value, 16.0)"];case 3006:return["RGBD","(value, 256.0)"];case 3007:return["Gamma","(value, float(GAMMA_FACTOR))"];case 3003:return["LogLuv","(value)"];default:return console.warn("v3d.WebGLProgram: Unsupported encoding:",e),["Linear","(value)"]}}function jo(e,t,n){var r=e.getShaderParameter(t,35713),i=e.getShaderInfoLog(t).trim();return r&&""===i?"":"v3d.WebGLShader: gl.getShaderInfoLog() "+n+"\n"+i+function(e){const t=e.split("\n");for(let e=0;e<t.length;e++)t[e]=e+1+": "+t[e];return t.join("\n")}(e.getShaderSource(t))}function Yo(e,t){t=Xo(t);return"vec4 "+e+"(vec4 value) { return "+t[0]+"ToLinear"+t[1]+"; }"}function Zo(e){return""!==e}function qo(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).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/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows).replace(/NUM_RECT_AREA_LIGHT_SHADOWS/g,t.numRectAreaLightShadows)}function Qo(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}function Ko(e,t){const n=Object.keys(t);var r;return n.length?(r=new RegExp(n.join("|"),"g"),e.replace(r,function(e){return t[e]})):e}function Jo(e,t){for(const n in t)e=e.replace("#include <"+n+">",t[n]);return e}const $o=/^[ \t]*#include +<([\w\d./]+)>/gm;function es(e){return e.replace($o,ts)}function ts(e,t){var n=yt[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return es(n)}function ns(i){var a;const e=new RegExp("#pragma unroll_loop_start[\\s]+?for \\(int (\\w+) \\= (\\d+)\\; (\\w+) <(=?) (\\w+)\\; (\\w+)\\+\\+\\) \\{"),o=new RegExp("\\{|\\}","g");for(;a=e.exec(i);){let e,n;e=n=o.lastIndex=a.index+a[0].length;let t,r=1;for(;(t=o.exec(i))&&("{"==t[0]?r++:"}"==t[0]&&r--,n=t.index),t&&0<r;);if(0==r){var s=i.substring(a.index,o.lastIndex);const h=i.substring(e,n);var l=new RegExp(`\\[${a[1]}\\]`,"g"),c=new RegExp(`\\(${a[1]}\\)`,"g");let t="";var u=parseInt(a[2]),d=parseInt(a[5])+("="===a[4]?1:0);for(let e=u;e<d;e++)t+="{"+h.replace(l,`[${e}]`).replace(c,`(${e})`)+"}";i=i.replace(s,t)}}return i=i.replace("#pragma unroll_loop_end","")}function rs(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 is(e,t,n,r){const s=e.getContext();var i=n.defines;let a=n.vertexShader,o=n.fragmentShader;var l=function(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===ne?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===ie?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===ae?t="SHADOWMAP_TYPE_VSM":e.shadowMapType===oe?t="SHADOWMAP_TYPE_ESM":e.shadowMapType===se?t="SHADOWMAP_TYPE_PCF_POISSON_DISK":e.shadowMapType===le&&(t="SHADOWMAP_TYPE_BILINEAR"),t}(n),c=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case L:case R:t="ENVMAP_TYPE_CUBE";break;case N:case D:t="ENVMAP_TYPE_CUBE_UV";break;case P:case I:t="ENVMAP_TYPE_EQUIREC"}return t}(n),u=function(e){let t="ENVMAP_MODE_REFLECTION";if(e.envMap)switch(e.envMapMode){case R:case I:t="ENVMAP_MODE_REFRACTION"}return t}(n),d=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case 0:t="ENVMAP_BLENDING_MULTIPLY";break;case 1:t="ENVMAP_BLENDING_MIX";break;case 2:t="ENVMAP_BLENDING_ADD"}return t}(n),h=0<e.gammaFactor?e.gammaFactor:1,p=n.unitsScaleFactor%1?String(n.unitsScaleFactor):String(n.unitsScaleFactor)+".0";const f=n.isWebGL2?"":function(e){const t=[e.extensionDerivatives||e.envMapCubeUV||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||0<e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""];return t.filter(Zo).join("\n")}(n),m=function(e){const t=[];for(const r in e){var n=e[r];!1!==n&&t.push("#define "+r+" "+n)}return t.join("\n")}(i),v=s.createProgram(),g=this;let _,x,y=n.glslVersion?"#version "+n.glslVersion+"\n":"",b=(n.isRawShaderMaterial?(0<(_=[m].filter(Zo).join("\n")).length&&(_+="\n"),0<(x=[f,m].filter(Zo).join("\n")).length&&(x+="\n")):(_=[rs(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":"",m,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+h,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.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.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"","#define NUM_MORPH_TARGETS "+n.numMorphTargets,n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",n.planeReflProbe?"#define USE_PLANE_REFLECTION":"",`
|
|
uniform mat4 modelMatrix;
|
|
uniform mat4 modelViewMatrix;
|
|
uniform mat4 projectionMatrix;
|
|
uniform mat4 viewMatrix;
|
|
uniform mat3 normalMatrix;
|
|
uniform vec3 cameraPosition;
|
|
uniform bool isOrthographic;
|
|
|
|
#ifdef USE_INSTANCING
|
|
attribute mat4 instanceMatrix;
|
|
#endif
|
|
|
|
#ifdef USE_INSTANCING_COLOR
|
|
attribute vec3 instanceColor;
|
|
#endif
|
|
|
|
attribute vec3 position;
|
|
attribute vec3 normal;
|
|
attribute vec2 uv;
|
|
|
|
#ifdef USE_TANGENT
|
|
attribute vec4 tangent;
|
|
#endif
|
|
|
|
#if defined(USE_COLOR_ALPHA)
|
|
attribute vec4 color;
|
|
#elif defined(USE_COLOR)
|
|
attribute vec3 color;
|
|
#endif
|
|
|
|
#ifdef USE_MORPHTARGETS
|
|
#if NUM_MORPH_TARGETS > 0
|
|
attribute vec3 morphTarget0;
|
|
#endif
|
|
#if NUM_MORPH_TARGETS > 1
|
|
attribute vec3 morphTarget1;
|
|
#endif
|
|
#if NUM_MORPH_TARGETS > 2
|
|
attribute vec3 morphTarget2;
|
|
#endif
|
|
#if NUM_MORPH_TARGETS > 3
|
|
attribute vec3 morphTarget3;
|
|
#endif
|
|
#if NUM_MORPH_TARGETS > 4
|
|
attribute vec3 morphTarget4;
|
|
#endif
|
|
#if NUM_MORPH_TARGETS > 5
|
|
attribute vec3 morphTarget5;
|
|
#endif
|
|
|
|
#ifdef USE_MORPHNORMALS
|
|
#if NUM_MORPH_TARGETS > 0
|
|
attribute vec3 morphNormal0;
|
|
#endif
|
|
#if NUM_MORPH_TARGETS > 1
|
|
attribute vec3 morphNormal1;
|
|
#endif
|
|
#if NUM_MORPH_TARGETS > 2
|
|
attribute vec3 morphNormal2;
|
|
#endif
|
|
#if NUM_MORPH_TARGETS > 3
|
|
attribute vec3 morphNormal3;
|
|
#endif
|
|
#if NUM_MORPH_TARGETS > 4
|
|
attribute vec3 morphNormal4;
|
|
#endif
|
|
#if NUM_MORPH_TARGETS > 5
|
|
attribute vec3 morphNormal5;
|
|
#endif
|
|
#else
|
|
#if NUM_MORPH_TARGETS > 6
|
|
attribute vec3 morphTarget6;
|
|
#endif
|
|
#if NUM_MORPH_TARGETS > 7
|
|
attribute vec3 morphTarget7;
|
|
#endif
|
|
#if NUM_MORPH_TARGETS > 8
|
|
attribute vec3 morphTarget8;
|
|
#endif
|
|
#if NUM_MORPH_TARGETS > 9
|
|
attribute vec3 morphTarget9;
|
|
#endif
|
|
#if NUM_MORPH_TARGETS > 10
|
|
attribute vec3 morphTarget10;
|
|
#endif
|
|
#if NUM_MORPH_TARGETS > 11
|
|
attribute vec3 morphTarget11;
|
|
#endif
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef USE_SKINNING
|
|
attribute vec4 skinIndex;
|
|
attribute vec4 skinWeight;
|
|
#endif
|
|
`].filter(Zo).join("\n"),x=[f,rs(n),"#define SHADER_NAME "+n.shaderName,m,function(e){switch(e){case"blender":return"#define MT_BLENDER";case"max":return"#define MT_MAX";case"maya":return"#define MT_MAYA";default:return""}}(n.materialProfile),e.compatSettings.saturateSpecEnvBlenderApprox?"#define COMPAT_SATURATE_SPEC_ENV_BLENDER_APPROX":"",e.compatSettings.useSpecEnvBlenderApprox?"#define COMPAT_USE_SPEC_ENV_BLENDER_APPROX":"",e.compatSettings.simplifiedSRGB?"#define COMPAT_SIMPLIFIED_SRGB":"",n.alphaTest?"#define ALPHATEST "+n.alphaTest+(n.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+h,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 "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",0!==n.envMapCubeUVTileSize?"#define cubeUV_maxTileSize "+Ri(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.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.sheen?"#define USE_SHEEN":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"",n.physicallyCorrectLights?"#define UNITS_SCALE_FACTOR "+p:"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping===ke||n.useHDR?"":"#define TONE_MAPPING",n.toneMapping===ke||n.useHDR?"":yt.tonemapping_pars_fragment,n.toneMapping===ke||n.useHDR?"":function(e,t){let n;switch(t){case 1:n="Linear";break;case 2:n="Reinhard";break;case 3:n="OptimizedCineon";break;case 4:n="ACESFilmic";break;case 6:n="LogarithmicMax";break;case 7:n="PhysicalMax";break;case 8:n="FilmicBlender";break;default:console.warn("v3d.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"(vec3 color) { return "+n+"ToneMapping(color); }"}("toneMapping",n.toneMapping),n.dithering?"#define DITHERING":"",yt.encodings_pars_fragment,n.map?Yo("mapTexelToLinear",n.mapEncoding):"",n.matcap?Yo("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?Yo("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?Yo("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.lightMap?Yo("lightMapTexelToLinear",n.lightMapEncoding):"",(i="linearToOutputTexel",h=Xo(h=n.outputEncoding),"vec4 "+i+"(vec4 value) { return LinearTo"+h[0]+h[1]+"; }"),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",n.distancePacking?"#define DISTANCE_PACKING "+n.distancePacking:"",n.useSlopeScaledBias?"#define USE_SLOPE_SCALED_BIAS":"","#define ESM_DISTANCE_SCALE "+Ri(n.esmDistanceScale),n.planeReflProbe?"#define USE_PLANE_REFLECTION":"",n.planeReflProbe?Yo("planeReflProbeTexelToLinear",n.planeReflProbeEncoding):"",n.useGTAO?"#define USE_GTAO":"",e.compatSettings.gtaoDisableBkgFix?"#define GTAO_DISABLE_BKG_FIX":"","\n"].filter(Zo).join("\n")),n.isMeshNodeMaterial&&(a=Jo(a,n.nodeChunks),o=Jo(o,n.nodeChunks)),a=Qo(a=qo(a=es(a),n),n),n.customPrepTokens&&(a=Ko(a,n.customPrepTokens)),o=Qo(o=qo(o=es(o),n),n),n.customPrepTokens&&(o=Ko(o,n.customPrepTokens)),a=ns(a),o=ns(o),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",_=["#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+_,x=["#define varying in",n.glslVersion===gn?"":"out highp vec4 pc_fragColor;",n.glslVersion===gn?"":"#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"+x),y+_+a),M=y+x+o;e.debug.disableCompiledShaderCache&&(b+="\nconst float ANTI_CACHE = "+Math.random()+";",M+="\nconst float ANTI_CACHE = "+Math.random()+";");const A=Wo(s,35633,b),w=Wo(s,35632,M);s.attachShader(v,A),s.attachShader(v,w),void 0!==n.index0AttributeName?s.bindAttribLocation(v,0,n.index0AttributeName):!0===n.morphTargets&&s.bindAttribLocation(v,0,"position"),s.linkProgram(v);let S=!0;function T(){if(S=!1,e.debug.checkShaderErrors){var n,r,i=s.getProgramInfoLog(v).trim(),a=s.getShaderInfoLog(A).trim(),o=s.getShaderInfoLog(w).trim();let e=!0,t=!0;!1===s.getProgramParameter(v,35714)?(e=!1,n=jo(s,A,"vertex"),r=jo(s,w,"fragment"),console.error("v3d.WebGLProgram: shader error: ",s.getError(),"35715",s.getProgramParameter(v,35715),"gl.getProgramInfoLog",i,n,r)):""!==i?console.warn("v3d.WebGLProgram: gl.getProgramInfoLog()",i):""!==a&&""!==o||(t=!1),t&&(g.diagnostics={runnable:e,programLog:i,vertexShader:{log:a,prefix:_},fragmentShader:{log:o,prefix:x}})}s.deleteShader(A),s.deleteShader(w)}let C;this.getUniforms=function(){return void 0===C&&(S&&T(),C=new ko(s,v)),C};let E;return this.getAttributes=function(){return void 0===E&&(S&&T(),E=function(t,n){const r={};var i=t.getProgramParameter(n,35721);for(let e=0;e<i;e++){var a=t.getActiveAttrib(n,e).name;r[a]=t.getAttribLocation(n,a)}return r}(s,v)),E},this.destroy=function(){r.releaseStatesOfProgram(this),s.deleteProgram(v),this.program=void 0},this.name=n.shaderName,this.id=Ho++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=A,this.fragmentShader=w,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(t,n){if(this.profile.calcRenderTime){const r=t.getExtension(n?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query");if(r){let e;n?(e=t.createQuery(),t.beginQuery(r.TIME_ELAPSED_EXT,e)):(e=r.createQueryEXT(),r.beginQueryEXT(r.TIME_ELAPSED_EXT,e)),this.profile.timerQueries.push(e)}}},this.endTimerQuery=function(t,n){if(this.profile.calcRenderTime){const o=t.getExtension(n?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query");if(o){n?t.endQuery(o.TIME_ELAPSED_EXT):o.endQueryEXT(o.TIME_ELAPSED_EXT);const s=this.profile.timerQueries;for(let e=s.length-1;0<=e;e--){var r=s[e],i=n?t.getQueryParameter(r,34919):o.getQueryObjectEXT(r,o.QUERY_RESULT_AVAILABLE_EXT),a=t.getParameter(o.GPU_DISJOINT_EXT);i&&!a&&(i=n?t.getQueryParameter(r,34918):o.getQueryObjectEXT(r,o.QUERY_RESULT_EXT),this.profile.renderTime+=i/1e6,s.splice(e,1))}}}},this}function as(m,v,g,_,a,x){const o=[],y=_.isWebGL2,b=_.logarithmicDepthBuffer,M=_.floatVertexTextures,A=_.maxVertexUniforms,w=_.vertexTextures;let S=_.precision;const T={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"},i=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexAlphas","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen","transmission","transmissionMap","thicknessMap","useGTAO","maxMorphTargets","maxMorphNormals","distancePacking","useSlopeScaledBias","numMorphTargets","unitsScaleFactor","useHDR","esmDistanceScale","numRectAreaLightShadows","planeReflProbe","planeReflProbeEncoding"];function C(e){let t;return t=e&&e.isTexture?e.encoding:e&&e.isWebGLRenderTarget?(console.warn("v3d.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),e.texture.encoding):an}return{getParameters:function(e,t,n,r,i,a){var o,s=r.fog,r=e.isMeshStandardMaterial?r.environment:null,r=v.get(e.envMap||r),l=T[e.type],c=i.isSkinnedMesh?(c=(c=i).skeleton.bones,M?1024:(o=A,o=Math.floor((o-20)/4),(o=Math.min(o,c.length))<c.length?(console.warn("v3d.WebGLRenderer: Skeleton has "+c.length+" bones. This GPU supports "+o+"."),0):o)):0;null!==e.precision&&(S=_.getMaxPrecision(e.precision))!==e.precision&&console.warn("v3d.WebGLProgram.getParameters:",e.precision,"not supported, using",S,"instead.");let u,d;d=l?(o=E[l],u=o.vertexShader,o.fragmentShader):(u=e.vertexShader,e.fragmentShader);var h=m.getRenderTarget();const p=i.geometry;var f=!!r&&(r.mapping===N||r.mapping===D);return{isWebGL2:y,shaderID:l,shaderName:e.type,vertexShader:u,fragmentShader:d,defines:e.defines,isRawShaderMaterial:!0===e.isRawShaderMaterial,glslVersion:e.glslVersion,precision:S,instancing:!0===i.isInstancedMesh,instancingColor:!0===i.isInstancedMesh&&null!==i.instanceColor,supportsVertexTextures:w,outputEncoding:null!==h?C(h.texture):m.outputEncoding,map:!!e.map,mapEncoding:C(e.map),matcap:!!e.matcap,matcapEncoding:C(e.matcap),envMap:!!r,envMapMode:r&&r.mapping,envMapEncoding:C(r),envMapCubeUV:f,envMapCubeUVTileSize:f&&void 0!==r.image?r.image.width/3:0,lightMap:!!e.lightMap,lightMapEncoding:C(e.lightMap),aoMap:!!e.aoMap,emissiveMap:!!e.emissiveMap,emissiveMapEncoding:C(e.emissiveMap),bumpMap:!!e.bumpMap,normalMap:!!e.normalMap,objectSpaceNormalMap:e.normalMapType===hn,tangentSpaceNormalMap:e.normalMapType===dn,clearcoatMap:!!e.clearcoatMap,clearcoatRoughnessMap:!!e.clearcoatRoughnessMap,clearcoatNormalMap:!!e.clearcoatNormalMap,displacementMap:!!e.displacementMap,roughnessMap:!!e.roughnessMap,metalnessMap:!!e.metalnessMap,specularMap:!!e.specularMap,alphaMap:!!e.alphaMap,gradientMap:!!e.gradientMap,sheen:!!e.sheen,transmission:!!e.transmission,transmissionMap:!!e.transmissionMap,thicknessMap:!!e.thicknessMap,combine:e.combine,vertexTangents:e.normalMap&&(e.vertexTangents||p&&p.isBufferGeometry&&p.getAttribute("tangent")),vertexColors:e.vertexColors,vertexAlphas:!0===e.vertexColors&&i.geometry&&i.geometry.attributes.color&&4===i.geometry.attributes.color.itemSize,vertexUvs:!!(e.map||e.bumpMap||e.normalMap||e.specularMap||e.alphaMap||e.emissiveMap||e.roughnessMap||e.metalnessMap||e.clearcoatMap||e.clearcoatRoughnessMap||e.clearcoatNormalMap||e.displacementMap||e.transmissionMap||e.thicknessMap),uvsVertexOnly:!(e.map||e.bumpMap||e.normalMap||e.specularMap||e.alphaMap||e.emissiveMap||e.roughnessMap||e.metalnessMap||e.clearcoatNormalMap||e.transmission||e.transmissionMap||e.thicknessMap||!e.displacementMap),fog:!!s,useFog:e.fog,fogExp2:s&&s.isFogExp2,flatShading:!!e.flatShading,sizeAttenuation:e.sizeAttenuation,logarithmicDepthBuffer:b,skinning:!0===i.isSkinnedMesh&&0<c,maxBones:c,useVertexTexture:M,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:m.maxMorphTargets,maxMorphNormals:m.maxMorphNormals,numDirLights:t.directional.length,numPointLights:t.point.length,numSpotLights:t.spot.length,numRectAreaLights:t.rectArea.length,numHemiLights:t.hemi.length,numDirLightShadows:t.directionalShadowMap.length,numPointLightShadows:t.pointShadowMap.length,numSpotLightShadows:t.spotShadowMap.length,numClippingPlanes:x.numPlanes,numClipIntersection:x.numIntersection,dithering:e.dithering,shadowMapEnabled:m.shadowMap.enabled&&0<n.length,shadowMapType:m.shadowMap.type,toneMapping:e.toneMapped?m.toneMapping:ke,physicallyCorrectLights:m.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===Ue,flipSided:e.side===Fe,depthPacking:void 0!==e.depthPacking&&e.depthPacking,numMorphTargets:Math.min((i.morphTargetInfluences||[]).length,m.maxMorphTargets),distancePacking:void 0!==e.distancePacking&&e.distancePacking,useSlopeScaledBias:void 0!==e.useSlopeScaledBias&&e.useSlopeScaledBias,esmDistanceScale:m.shadowMap.esmDistanceScale,numRectAreaLightShadows:t.rectAreaShadowMap.length,planeReflProbe:!!a,planeReflProbeEncoding:C(null==a||null==(l=a.renderTarget)?void 0:l.texture),materialName:e.name,materialProfile:e.profile,unitsScaleFactor:m.unitsScaleFactor,useHDR:!!e.useHDR,customPrepTokens:e.customPrepTokens,isMeshNodeMaterial:e.isMeshNodeMaterial,nodeChunks:e.nodeChunks,nodeChunksHash:e.nodeChunksHash,index0AttributeName:e.index0AttributeName,extensionDerivatives:e.extensions&&e.extensions.derivatives,extensionFragDepth:e.extensions&&e.extensions.fragDepth,extensionDrawBuffers:e.extensions&&e.extensions.drawBuffers,extensionShaderTextureLOD:e.extensions&&e.extensions.shaderTextureLOD,rendererExtensionFragDepth:y||g.has("EXT_frag_depth"),rendererExtensionDrawBuffers:y||g.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:y||g.has("EXT_shader_texture_lod"),customProgramCacheKey:e.customProgramCacheKey(),useGTAO:e.isMeshNodeMaterial&&e.canUseGTAO()&&m.gtaoMap}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.fragmentShader),n.push(t.vertexShader)),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 r in t.customPrepTokens)n.push(r),n.push(t.customPrepTokens[r]);if(!1===t.isRawShaderMaterial){for(let e=0;e<i.length;e++)n.push(t[i[e]]);n.push(m.outputEncoding),n.push(m.gammaFactor)}return n.push(t.customProgramCacheKey),void 0!==t.nodeChunksHash&&n.push(t.nodeChunksHash),n.join()},getUniforms:function(e){var t=T[e.type];let n;return n=t?(t=E[t],ca.clone(t.uniforms)):e.uniforms},acquireProgram:function(e,n){let r;for(let e=0,t=o.length;e<t;e++){var i=o[e];if(i.cacheKey===n){++(r=i).usedTimes;break}}void 0===r&&(r=new is(m,n,e,a),o.push(r));const t=r.profile.materials;return e.materialName&&t.indexOf(e.materialName)<0&&t.push(e.materialName),r},releaseProgram:function(e){var t;0==--e.usedTimes&&(t=o.indexOf(e),o[t]=o[o.length-1],o.pop(),e.destroy())},programs:this.programs=o}}function os(){let r=new WeakMap;return{get:function(e){let t=r.get(e);return void 0===t&&(t={},r.set(e,t)),t},remove:function(e){r.delete(e)},update:function(e,t,n){r.get(e)[t]=n},dispose:function(){r=new WeakMap}}}function ss(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program!==t.program?e.program.id-t.program.id: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 ls(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 cs(l){const c=[];let u=0;const o=[],s=[],d=[],h={id:-1};function p(e,t,n,r,i,a){let o=c[u];var s=l.get(n);return void 0===o?(o={id:e.id,object:e,geometry:t,material:n,program:s.program||h,groupOrder:r,renderOrder:e.renderOrder,z:i,group:a},c[u]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=n,o.program=s.program||h,o.groupOrder=r,o.renderOrder=e.renderOrder,o.z=i,o.group=a),u++,o}return{opaque:o,transmissive:s,transparent:d,init:function(){u=0,o.length=0,s.length=0,d.length=0},push:function(e,t,n,r,i,a){e=p(e,t,n,r,i,a),(0<n.transmission?s:!0===n.transparent?d:o).push(e)},unshift:function(e,t,n,r,i,a){e=p(e,t,n,r,i,a),(0<n.transmission?s:!0===n.transparent?d:o).unshift(e)},finish:function(){for(let e=u,t=c.length;e<t;e++){const n=c[e];if(null===n.id)break;n.id=null,n.object=null,n.geometry=null,n.material=null,n.program=null,n.group=null}},sort:function(e,t){1<o.length&&o.sort(e||ss),1<s.length&&s.sort(t||ls),1<d.length&&d.sort(t||ls)}}}function us(r){let i=new WeakMap;return{get:function(e,t){let n;return!1===i.has(e)?(n=new cs(r),i.set(e,[n])):t>=i.get(e).length?(n=new cs(r),i.get(e).push(n)):n=i.get(e)[t],n},dispose:function(){i=new WeakMap}}}function ds(){const n={};return{get:function(e){if(void 0!==n[e.id])return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new vt,color:new _t};break;case"SpotLight":t={position:new vt,direction:new vt,color:new _t,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new vt,color:new _t,distance:0,decay:0};break;case"HemisphereLight":t={direction:new vt,skyColor:new _t,groundColor:new _t};break;case"RectAreaLight":t={color:new _t,position:new vt,halfWidth:new vt,halfHeight:new vt}}return n[e.id]=t}}}let hs=0;function ps(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function fs(t,P){const I=new ds,N=function(){const n={};return{get:function(e){if(void 0!==n[e.id])return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be,position:new vt,shadowCameraNear:1,maxDistance:0,expBias:1};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be,shadow:0,shadowCameraNear:1,shadowCameraFar:1e3,expBias:1};break;case"PointLight":case"RectAreaLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be,shadowCameraNear:1,shadowCameraFar:1e3,expBias:1}}return n[e.id]=t}}}(),D={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numRectAreaShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],rectAreaShadow:[],rectAreaShadowMap:[],rectAreaShadowMatrix:[]};for(let e=0;e<9;e++)D.probe.push(new vt);const _=new vt,x=new gt,y=new gt;return{setup:function(n){let r=0,i=0,a=0;for(let e=0;e<9;e++)D.probe[e].set(0,0,0);let o=0,s=0,l=0,c=0,u=0,d=0,h=0,p=0,f=0;n.sort(ps);for(let e=0,t=n.length;e<t;e++){var m=n[e],v=m.color,g=m.intensity,_=m.distance,x=m.shadow&&m.shadow.map?m.shadow.map.texture:null;if(m.isAmbientLight)r+=v.r*g,i+=v.g*g,a+=v.b*g;else if(m.isLightProbe)for(let e=0;e<9;e++)D.probe[e].addScaledVector(m.sh.coefficients[e],g);else if(m.isDirectionalLight){const b=I.get(m);if(b.color.copy(m.color).multiplyScalar(m.intensity),m.castShadow){var y=m.shadow;const M=N.get(m);M.shadowBias=y.bias,M.shadowNormalBias=y.normalBias,M.shadowRadius=y.radius,M.shadowMapSize=y.mapSize,D.directionalShadow[o]=M,D.directionalShadowMap[o]=x,D.directionalShadowMatrix[o]=m.shadow.matrix,M.shadowCameraNear=y.camera.near,M.expBias=y.expBias,d++}D.directional[o]=b,o++}else if(m.isSpotLight){const A=I.get(m);if(A.position.setFromMatrixPosition(m.matrixWorld),A.color.copy(v).multiplyScalar(g),A.distance=_,A.coneCos=Math.cos(m.angle),A.penumbraCos=Math.cos(m.angle*(1-m.penumbra)),A.decay=m.decay,m.castShadow){const w=m.shadow,S=N.get(m);S.shadowBias=w.bias,S.shadowNormalBias=w.normalBias,S.shadowRadius=w.radius,S.shadowMapSize=w.mapSize,D.spotShadow[l]=S,D.spotShadowMap[l]=x,D.spotShadowMatrix[l]=m.shadow.matrix,S.shadow=m.castShadow?w.calcUseOmniMaps(m.angle)?2:1:0,S.shadowCameraNear=w.camera.near,S.shadowCameraFar=w.camera.far,S.expBias=w.expBias,p++}D.spot[l]=A,l++}else if(m.isRectAreaLight){const T=I.get(m);if(T.color.copy(v).multiplyScalar(g),T.halfWidth.set(.5*m.width,0,0),T.halfHeight.set(0,.5*m.height,0),m.castShadow){y=m.shadow;const C=N.get(m);C.shadowBias=y.bias,C.shadowNormalBias=y.normalBias,C.shadowRadius=y.radius,C.shadowMapSize=y.mapSize,C.shadowCameraNear=y.camera.near,C.shadowCameraFar=y.camera.far,C.expBias=y.expBias,D.rectAreaShadow[c]=C,D.rectAreaShadowMap[c]=x,D.rectAreaShadowMatrix[c]=m.shadow.matrix,f++}D.rectArea[c]=T,c++}else if(m.isPointLight){const E=I.get(m);if(E.color.copy(m.color).multiplyScalar(m.intensity),E.distance=m.distance,E.decay=m.decay,m.castShadow){_=m.shadow;const L=N.get(m);L.shadowBias=_.bias,L.shadowNormalBias=_.normalBias,L.shadowRadius=_.radius,L.shadowMapSize=_.mapSize,L.shadowCameraNear=_.camera.near,L.shadowCameraFar=_.camera.far,L.expBias=_.expBias,D.pointShadow[s]=L,D.pointShadowMap[s]=x,D.pointShadowMatrix[s]=m.shadow.matrix,h++}D.point[s]=E,s++}else if(m.isHemisphereLight){const R=I.get(m);R.skyColor.copy(m.color).multiplyScalar(g),R.groundColor.copy(m.groundColor).multiplyScalar(g),D.hemi[u]=R,u++}}0<c&&(P.isWebGL2||!0===t.has("OES_texture_float_linear")?(D.rectAreaLTC1=O.LTC_FLOAT_1,D.rectAreaLTC2=O.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(D.rectAreaLTC1=O.LTC_HALF_1,D.rectAreaLTC2=O.LTC_HALF_2):console.error("v3d.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),D.ambient[0]=r,D.ambient[1]=i,D.ambient[2]=a;const e=D.hash;e.directionalLength===o&&e.pointLength===s&&e.spotLength===l&&e.rectAreaLength===c&&e.hemiLength===u&&e.numDirectionalShadows===d&&e.numPointShadows===h&&e.numSpotShadows===p&&e.numRectAreaShadows===f||(D.directional.length=o,D.spot.length=l,D.rectArea.length=c,D.point.length=s,D.hemi.length=u,D.directionalShadow.length=d,D.directionalShadowMap.length=d,D.pointShadow.length=h,D.pointShadowMap.length=h,D.spotShadow.length=p,D.spotShadowMap.length=p,D.directionalShadowMatrix.length=d,D.pointShadowMatrix.length=h,D.spotShadowMatrix.length=p,e.directionalLength=o,e.pointLength=s,e.spotLength=l,e.rectAreaLength=c,e.hemiLength=u,e.numDirectionalShadows=d,e.numPointShadows=h,e.numSpotShadows=p,D.rectAreaShadow.length=f,D.rectAreaShadowMap.length=f,D.rectAreaShadowMatrix.length=f,e.numRectAreaShadows=f,D.version=hs++)},setupView:function(n,r){let i=0,a=0,o=0,s=0,l=0;var c=r.matrixWorldInverse;for(let e=0,t=n.length;e<t;e++){var u=n[e];if(u.isDirectionalLight){const h=D.directional[i];if(h.direction.setFromMatrixPosition(u.matrixWorld),_.setFromMatrixPosition(u.target.matrixWorld),h.direction.sub(_),h.direction.transformDirection(c),u.castShadow){var d=u.shadow;const p=N.get(u);p.position.setFromMatrixPosition(u.matrixWorld),p.position.applyMatrix4(c),p.maxDistance=d.isDirectionalLightShadowCSM?d.maxDistance:r.far}i++}else if(u.isSpotLight){const f=D.spot[o];f.position.setFromMatrixPosition(u.matrixWorld),f.position.applyMatrix4(c),f.direction.setFromMatrixPosition(u.matrixWorld),_.setFromMatrixPosition(u.target.matrixWorld),f.direction.sub(_),f.direction.transformDirection(c),o++}else if(u.isRectAreaLight){const m=D.rectArea[s];m.position.setFromMatrixPosition(u.matrixWorld),m.position.applyMatrix4(c),y.identity(),x.copy(u.matrixWorld),x.premultiply(c),y.extractRotation(x),m.halfWidth.set(.5*u.width,0,0),m.halfHeight.set(0,.5*u.height,0),m.halfWidth.applyMatrix4(y),m.halfHeight.applyMatrix4(y),s++}else if(u.isPointLight){const v=D.point[a];v.position.setFromMatrixPosition(u.matrixWorld),v.position.applyMatrix4(c),a++}else if(u.isHemisphereLight){const g=D.hemi[l];g.direction.setFromMatrixPosition(u.matrixWorld),g.direction.transformDirection(c),g.direction.normalize(),l++}}},state:D}}function ms(e,t){const n=new fs(e,t),r=[],i=[],a=[],o=[];return{init:function(){r.length=0,i.length=0,a.length=0,o.length=0},state:{lightsArray:r,shadowsArray:i,envMapProbeArray:a,planeReflProbeArray:o,lights:n},setupLights:function(){n.setup(r)},setupLightsView:function(e){n.setupView(r,e)},pushLight:function(e){r.push(e)},pushShadow:function(e){i.push(e)},pushEnvMapProbe:function(e){a.push(e)},sortEnvMapProbes:function(){a.sort((e,t)=>e.influenceDistance-t.influenceDistance)},pushPlaneReflProbe:function(e){o.push(e)}}}function vs(r,i){let a=new WeakMap;return{get:function(e,t=0){let n;return!1===a.has(e)?(n=new ms(r,i),a.set(e,[n])):t>=a.get(e).length?(n=new ms(r,i),a.get(e).push(n)):n=a.get(e)[t],n},dispose:function(){a=new WeakMap}}}class gs extends pi{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,this.useSlopeScaledBias=!1,this.slopeScaledBias=0,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.useSlopeScaledBias=e.useSlopeScaledBias,this.slopeScaledBias=e.slopeScaledBias,this.morphTargets=e.morphTargets,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}}gs.prototype.isMeshDepthMaterial=!0;class _s extends pi{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new vt,this.nearDistance=1,this.farDistance=1e3,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.defines={DISTANCE_SCALE:"1.0"},this.distancePacking=cn,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.morphTargets=e.morphTargets,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}}_s.prototype.isMeshDistanceMaterial=!0;var xs="uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\nfloat mean = 0.0;\nfloat squared_mean = 0.0;\nfloat depth = unpackRGBAToDepth(texture2D(shadow_pass, (gl_FragCoord.xy) / resolution));\nfor (float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n#ifdef HORIZONTAL_PASS\nvec2 distribution = unpackRGBATo2Half(texture2D(shadow_pass, (gl_FragCoord.xy + vec2(i, 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, i) * radius) / resolution));\nmean += depth;\nsquared_mean += depth * depth;\n#endif\n}\nmean = mean * HALF_SAMPLE_RATE;\nsquared_mean = squared_mean * HALF_SAMPLE_RATE;\nfloat std_dev = sqrt(squared_mean - mean * mean);\ngl_FragColor = pack2HalfToRGBA(vec2(mean, std_dev));\n}",ys="void main() {\ngl_Position = vec4(position, 1.0);\n}";const bs=new gt,Ms=new vt,As=new vt;class ws{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new Be(512,512),this.map=null,this.mapPass=null,this.matrix=new gt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ma,this._frameExtents=new Be(1,1),this._viewportCount=1,this._viewports=[new mt(0,0,1,1)],this.expBias=1,this.slopeScaledBias=0,this._additionalMap2D=null,this._additionalMapCube=null}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Ms.setFromMatrixPosition(e.matrixWorld),t.position.copy(Ms),As.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(As),t.updateMatrixWorld(),bs.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(bs),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose(),null!==this._additionalMap2D&&this._additionalMap2D.dispose(),null!==this._additionalMapCube&&this._additionalMapCube.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this.expBias=e.expBias,this.slopeScaledBias=e.slopeScaledBias,this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}ws.prototype.isLightShadow=!0;const Ss=Math.PI/4,Ts=new gt,Cs=new vt,Es=new vt;class Ls extends ws{constructor(){super(new da(50,1,.5,500)),this.focus=1,this.useOmniMaps=!1,this.useMinFov90=!1,this._frameExtentsOmni=new Be(4,2),this._viewportCountOmni=6,this._viewportsOmni=[new mt(2,1,1,1),new mt(0,1,1,1),new mt(3,1,1,1),new mt(1,1,1,1),new mt(3,0,1,1),new mt(1,0,1,1)],this._cubeDirections=[new vt(1,0,0),new vt(-1,0,0),new vt(0,0,1),new vt(0,0,-1),new vt(0,1,0),new vt(0,-1,0)],this._cubeUps=[new vt(0,1,0),new vt(0,1,0),new vt(0,1,0),new vt(0,1,0),new vt(0,0,1),new vt(0,0,-1)]}updateMatrices(e,t=0){if(this.useOmniMaps){const i=this.camera,a=this.matrix;Cs.setFromMatrixPosition(e.matrixWorld),i.position.copy(Cs),Es.copy(i.position),Es.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Es),i.updateMatrixWorld(),a.makeTranslation(-Cs.x,-Cs.y,-Cs.z),Ts.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ts)}else{const o=this.camera;var t=2*An*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=e.distance||o.far;t===o.fov&&n===o.aspect&&r===o.far||(o.fov=t,o.aspect=n,o.far=r,o.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 e>Ss?this.useOmniMaps=!0:this.useOmniMaps=!1,this.useOmniMaps}copy(e){return super.copy(e),this.focus=e.focus,this.useOmniMaps=e.useOmniMaps,this.useMinFov90=e.useMinFov90,this}}Ls.prototype.isSpotLightShadow=!0;class Rs extends ua{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,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,r,i,a){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=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){var e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let i=n-e,a=n+e,o=r+t,s=r-t;null!==this.view&&this.view.enabled&&(n=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom,i+=n*this.view.offsetX,a=i+n*this.view.width,o-=e*this.view.offsetY,s=o-e*this.view.height),this.projectionMatrix.makeOrthographic(i,a,o,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}}Rs.prototype.isOrthographicCamera=!0;const Ps=.8,Is=.2,Ns=.8,Ds=50;function Os(L,f,e){let R=new Ma;const P=new Be,h=new Be,p=new mt,r=[],i=[],m={},v=e.maxTextureSize,I=e.isWebGL2,b={0:Fe,1:Ve,2:Ue},g=new T({defines:{SAMPLE_RATE:.25,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new Be},radius:{value:4}},vertexShader:ys,fragmentShader:xs}),_=g.clone(),t=(_.defines.HORIZONTAL_PASS=1,new S),x=(t.setAttribute("position",new re(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3)),new ee(t,g)),N=new gt,c=new gt,D=new Be(v,v),O=new vt,F=new vt,B=new vt,Z=[new vt(1,0,0),new vt(-1,0,0),new vt(0,1,0),new vt(0,-1,0),new vt(0,0,1),new vt(0,0,-1)],q=[new vt(0,1,0),new vt(0,1,0),new vt(0,0,1),new vt(0,0,-1),new vt(0,1,0),new vt(0,1,0)],z=new fr,u=[new vt,new vt,new vt,new vt,new vt,new vt,new vt,new vt],d=new ee(new Sa(1,1,1,1)),V=(d.name="esmFarPlane",d.castShadow=!0,d.material.shadowSide=Ve,0),U=1,G=0,k=1,W=new Rs(-1,1,1,-1,0,10),H=new ee(new Sa(2,2)),Q=new T({type:"ShadowCubeOctahedral",defines:Object.assign({},E.cubeOctahedral.defines),uniforms:ca.clone(E.cubeOctahedral.uniforms),vertexShader:E.cubeOctahedral.vertexShader,fragmentShader:E.cubeOctahedral.fragmentShader}),l={},y={},X=this;function M(e){var t=e<<0;let n=r[t];return void 0===n&&(n=new gs({depthPacking:ln,morphTargets:e}),r[t]=n),n}function A(e){var t=e<<0;let n=i[t];return void 0===n&&(n=new _s({morphTargets:e}),i[t]=n),n}function w(n,r,i,e,t,a,o,s,l){let c=null,u=M,d=n.customDepthMaterial,h=(!s&&o!==oe||(u=A,d=n.customDistanceMaterial),!1);if(c=void 0===d?(!0===i.morphTargets&&(h=r.morphAttributes&&r.morphAttributes.position&&0<r.morphAttributes.position.length),u(h)):d,L.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length){n=c.uuid,r=i.uuid;let e=m[n],t=(void 0===e&&(e={},m[n]=e),e[r]);void 0===t&&(t=c.clone(),e[r]=t),c=t}else if(h){n=c.uuid,r=i.uuid;let e=m[n],t=(void 0===e&&(e={},m[n]=e),e[r]);void 0===t&&(t=c.clone(),e[r]=t),c=t}switch(c.visible=i.visible,c.wireframe=i.wireframe,o===ae?c.side=null!==i.shadowSide?i.shadowSide:i.side:c.side=null!==i.shadowSide?i.shadowSide:b[i.side],c.clipShadows=i.clipShadows,c.clippingPlanes=i.clippingPlanes,c.clipIntersection=i.clipIntersection,c.wireframeLinewidth=i.wireframeLinewidth,c.linewidth=i.linewidth,!s&&o!==oe||!0!==c.isMeshDistanceMaterial||(c.referencePosition.copy(l),c.nearDistance=t,c.farDistance=a,c.distancePacking=o===oe?un:cn),o===oe&&(c.defines.DISTANCE_SCALE=Ri(X.esmDistanceScale)),o){case te:case le:case ne:case ie:case se:c.useSlopeScaledBias=!0,c.slopeScaledBias=e.shadow.slopeScaledBias;break;case oe:c.useSlopeScaledBias=!0,c.slopeScaledBias=.5}return c}function j(n,r,i,a,o,s){if(!1!==n.visible){var e=r.ignoreShadowLayers||n.layers.test(r.layers);if(e&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===ae)&&(!n.frustumCulled||R.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,n.matrixWorld);var l=f.update(n),c=n.material;if(Array.isArray(c)){var u=l.groups;for(let e=0,t=u.length;e<t;e++){var d=u[e],h=c[d.materialIndex];h&&h.visible&&(h=w(n,l,h,a,i.near,i.far,o,s,F),L.renderBufferDirect(i,null,l,h,n,d))}}else c.visible&&(e=w(n,l,c,a,i.near,i.far,o,s,F),L.renderBufferDirect(i,null,l,e,n,null))}var p=n.children;for(let e=0,t=p.length;e<t;e++)j(p[e],r,i,a,o,s)}}function K(t,n,r,i){const a=r.shadow,e=a.camera;F.setFromMatrixPosition(r.matrixWorld),P.copy(a.mapSize);var o,s,l=a.getFrameExtents(),c=(P.multiply(l),h.copy(a.mapSize),(P.x>v||P.y>v)&&(P.x>v&&(h.x=Math.floor(v/l.x),P.x=h.x*l.x,a.mapSize.x=h.x),P.y>v&&(h.y=Math.floor(v/l.y),P.y=h.y*l.y,a.mapSize.y=h.y)),r.isSpotLight&&a.map&&a.map.width/a.map.height!=2&&(l=a.map,a.map=a._additionalMap2D,a._additionalMap2D=l),r.isPointLight||r.isRectAreaLight||r.isSpotLight&&a.useOmniMaps),u=(c?r.isSpotLight&&(e.fov=90,e.updateProjectionMatrix()):r.isDirectionalLight?(r.shadow.isDirectionalLightShadowCSM&&(l=J(n,a,P,z),e.left=l.center.x-l.radius,e.right=l.center.x+l.radius,e.top=l.center.y+l.radius,e.bottom=l.center.y-l.radius,e.near=-l.center.z-l.radius,e.far=-l.center.z+l.radius,e.updateProjectionMatrix()),l=r.getWorldDirection(B),F.addScaledVector(l,e.near)):r.isSpotLight&&a.useMinFov90&&(e.fov=90,e.updateProjectionMatrix()),null!==a.map||c||i!==ae||(l={minFilter:ht,magFilter:ht,format:pt},a.map=new ze(P.x,P.y,l),a.map.texture.name=r.name+".shadowMap",a.mapPass=new ze(P.x,P.y,l),e.updateProjectionMatrix()),null===a.map&&(l={minFilter:dt,magFilter:dt,format:pt},a.map=new ze(P.x,P.y,l),a.map.texture.name=r.name+".shadowMap",e.updateProjectionMatrix()),L.state.buffers.color.setClear(1,1,1,1),L.setRenderTarget(a.map),L.clear(),a.getViewportCount());for(let e=0;e<u;e++){var d=a.getViewport(e);p.set(h.x*d.x,h.y*d.y,h.x*d.z,h.y*d.w),L.state.viewport(p),a.updateMatrices(r,e),R=a.getFrustum(),j(t,n,a.camera,r,i,c)}c||i!==ae||(l=a,o=n,s=f.update(x),g.uniforms.shadow_pass.value=l.map.texture,g.uniforms.resolution.value=l.mapSize,g.uniforms.radius.value=l.radius,L.setRenderTarget(l.mapPass),L.clear(),L.renderBufferDirect(o,null,s,g,x,null),_.uniforms.shadow_pass.value=l.mapPass.texture,_.uniforms.resolution.value=l.mapSize,_.uniforms.radius.value=l.radius,L.setRenderTarget(l.map),L.clear(),L.renderBufferDirect(o,null,s,_,x,null))}function Y(e,t,n,r,i,a,o){const s=H.material=(o===G?function(e){if(!(e in l)){const t=l[e]=new T({type:"ShadowBlur",defines:Object.assign({},E.blur.defines,{LOG_SPACE:1,OCTAHEDRAL_MAP:1}),uniforms:ca.clone(E.blur.uniforms),customPrepTokens:Object.assign({},E.blur.customPrepTokens),vertexShader:E.blur.vertexShader,fragmentShader:E.blur.fragmentShader});t.customPrepTokens.MAX_SAMPLE_RADIUS=e}return l[e]}:function(e){if(!(e in y)){const t=y[e]=new T({type:"ShadowBlur",defines:Object.assign({},E.blur.defines,{LOG_SPACE:1}),uniforms:ca.clone(E.blur.uniforms),customPrepTokens:Object.assign({},E.blur.customPrepTokens),vertexShader:E.blur.vertexShader,fragmentShader:E.blur.fragmentShader});t.customPrepTokens.MAX_SAMPLE_RADIUS=e}return y[e]})(r);s.uniforms.direction.value.set(+(a===V),+(a===U)),s.uniforms.colorTexture.value=t.texture,s.uniforms.texSize.value.set(t.width,t.height),s.uniforms.kernelRadius.value=i,s.uniformsNeedUpdate=!0,e.setRenderTarget(n),e.clear(),e.updateGeometry(H),e.renderBufferDirect(W,!1,H.geometry,s,H,null)}function J(t,e,n,r){var i=ft(e.maxDistance,t.near,t.far)/t.far;for(let e=0;e<u.length;e++){const l=u[e];var a=1&e;l.set(e>>2&1,e>>1&1,a).multiplyScalar(2).subScalar(1).applyMatrix4(t.projectionMatrixInverse),1==a&&l.multiplyScalar(i)}r.setFromPoints(u),c.multiplyMatrices(e.camera.matrixWorldInverse,t.matrixWorld);const o=r.center.applyMatrix4(c);var e=r.radius*=c.getMaxScaleOnAxis(),s=n.x/2/e,n=n.y/2/e;return o.x=Math.round(o.x*s)/s,o.y=Math.round(o.y*n)/n,r}function $(e,t,n,r){let i,a,o,s,l,c;t.isPerspectiveCamera?(i=a=0,o=-.999*t.far,s=l=2*-o*Math.tan(En(t.fov)/2),c=1):t.isOrthographicCamera&&(i=(t.right+t.left)/2,a=(t.top+t.bottom)/2,o=-.999*t.far,s=t.right-t.left,l=t.top-t.bottom,c=1),t.add(d),d.scale.set(s,l,c),d.position.set(i,a,o),d.updateMatrixWorld(),j(d,e,t,n,r,!0)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ne,this.esmDistanceScale=1,this.render=function(n,r,i){if(!1!==X.enabled&&(!1!==X.autoUpdate||!1!==X.needsUpdate)&&0!==n.length){var e=L.getRenderTarget(),t=L.getActiveCubeFace(),a=L.getActiveMipmapLevel();const _=L.state;_.setBlending(ce),_.buffers.color.setClear(1,1,1,1),_.buffers.depth.setTest(!0),_.setScissorTest(!1);for(let e=0,t=n.length;e<t;e++){var o=n[e];const x=o.shadow;if(void 0===x)console.warn("v3d.WebGLShadowMap:",o,"has no shadow.");else if(!1!==x.autoUpdate||!1!==x.needsUpdate){if(o.isSpotLight&&x.calcUseOmniMaps(o.angle),o.isPointLight||o.isRectAreaLight||o.isSpotLight&&x.useOmniMaps)switch(X.type){case te:case le:case ne:case ie:case se:K(r,i,o,X.type);break;case oe:{s=void 0;l=void 0;c=void 0;u=void 0;d=void 0;h=void 0;var s=r;var l=i;var c=o;var u=X.type;const y=c.shadow,b=y.camera,M=y.matrix,A=c.isPointLight||c.isRectAreaLight?2:1,w=P.copy(y.mapSize).multiplyScalar(A).min(D).multiplyScalar(1/A);null===y._additionalMapCube&&(y._additionalMapCube=new fa(w.x,{minFilter:ht,magFilter:ht,format:I?Qe:pt,type:je}),y._additionalMapCube.texture.name=c.name+".shadowMap.tmpCube");null===y._additionalMap2D&&(y._additionalMap2D=new ze(w.x*A,w.y*A,{minFilter:ht,magFilter:ht,format:I?Qe:pt,type:je}),y._additionalMap2D.texture.name=c.name+".shadowMap.tmp2D");null===y.map&&(y.map=new ze(w.x*A,w.y*A,{minFilter:ht,magFilter:ht,format:I?Qe:pt,type:je}),y.map.texture.name=c.name+".shadowMap");F.setFromMatrixPosition(c.matrixWorld),b.position.copy(F),c.isSpotLight&&(b.fov=90,b.updateProjectionMatrix());M.makeTranslation(-F.x,-F.y,-F.z);for(let e=0;e<6;e++)O.copy(b.position),O.add(Z[e]),b.up.copy(q[e]),2!==e&&3!==e&&b.up.multiplyScalar(-1),b.lookAt(O),b.updateMatrixWorld(),N.multiplyMatrices(b.projectionMatrix,b.matrixWorldInverse),R.setFromProjectionMatrix(N),L.setRenderTarget(y._additionalMapCube,e),L.clearDepth(),$(l,b,c,u),j(s,l,b,c,u,!0);var d=Math.max(y.radius*A,.001),h=function(e){return Math.ceil(Is*e)}(d);(function(e,t,n){const r=H.material=Q;r.uniforms.tCube.value=t.texture,r.uniforms.texelSize.value.set(1/n.width,1/n.height),r.uniformsNeedUpdate=!0,e.setRenderTarget(n),e.clear(),e.updateGeometry(H),e.renderBufferDirect(W,!1,H.geometry,r,H,null)})(L,y._additionalMapCube,y.map),Y(L,y.map,y._additionalMap2D,h,d,U,G),Y(L,y._additionalMap2D,y.map,h,d,V,G)}break;default:continue}else{if(!o.isSpotLight&&!o.isDirectionalLight)continue;switch(X.type){case te:case le:case ne:case ie:case se:case ae:K(r,i,o,X.type);break;case oe:{p=void 0;f=void 0;m=void 0;v=void 0;g=void 0;g=void 0;g=void 0;var p=r;var f=i;var m=o;var v=X.type;const S=m.shadow,T=S.camera,C=S.matrix,E=P.copy(S.mapSize).min(D);null===S._additionalMap2D&&(S._additionalMap2D=new ze(E.x,E.y,{minFilter:ht,magFilter:ht,format:I?Qe:pt,type:je}),S._additionalMap2D.texture.name=m.name+".shadowMap.tmp2D");null===S.map&&(S.map=new ze(E.x,E.y,{minFilter:ht,magFilter:ht,format:I?Qe:pt,type:je}),S.map.texture.name=m.name+".shadowMap");F.setFromMatrixPosition(m.matrixWorld),T.position.copy(F),O.setFromMatrixPosition(m.target.matrixWorld),T.lookAt(O),T.updateMatrixWorld(),m.isDirectionalLight?(m.shadow.isDirectionalLightShadowCSM&&(g=J(f,S,E,z),T.left=g.center.x-g.radius,T.right=g.center.x+g.radius,T.top=g.center.y+g.radius,T.bottom=g.center.y-g.radius,T.near=-g.center.z-g.radius,T.far=-g.center.z+g.radius,T.updateProjectionMatrix()),g=m.getWorldDirection(B),F.addScaledVector(g,T.near)):m.isSpotLight&&S.useMinFov90&&(T.fov=90,T.updateProjectionMatrix());C.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),C.multiply(T.projectionMatrix),C.multiply(T.matrixWorldInverse),N.multiplyMatrices(T.projectionMatrix,T.matrixWorldInverse),R.setFromProjectionMatrix(N),L.setRenderTarget(S.map),L.clearDepth(),$(f,T,m,v),j(p,f,T,m,v,!1);let e;e=m.isDirectionalLight&&m.shadow.isDirectionalLightShadowCSM?function(e,t){return Ds*e/t}(S.radius,(T.right-T.left)/2):m.isSpotLight?S.radius*Ns:S.radius;var g=function(e){return Math.ceil(Ps*e)}(e=Math.max(e,.001));Y(L,S.map,S._additionalMap2D,g,e,V,k),Y(L,S._additionalMap2D,S.map,g,e,U,k)}break;default:continue}}x.needsUpdate=!1}}X.needsUpdate=!1,L.setRenderTarget(e,t,a)}}}function Fs(u,F,e){const n=e.isWebGL2;const r=new function(){let t=!1;const a=new mt;let n=null;const o=new mt(0,0,0,0);return{setMask:function(e){n===e||t||(u.colorMask(e,e,e,e),n=e)},setLocked:function(e){t=e},setClear:function(e,t,n,r,i){!0===i&&(e*=r,t*=r,n*=r),a.set(e,t,n,r),!1===o.equals(a)&&(u.clearColor(e,t,n,r),o.copy(a))},reset:function(){t=!1,n=null,o.set(-1,0,0,0)}}},i=new function(){let t=!1,n=null,r=null,i=null;return{setTest:function(e){(e?P:I)(2929)},setMask:function(e){n===e||t||(u.depthMask(e),n=e)},setFunc:function(e){if(r!==e){if(e)switch(e){case Le:u.depthFunc(512);break;case Re:u.depthFunc(519);break;case Pe:u.depthFunc(513);break;case Ie:u.depthFunc(515);break;case Ne:u.depthFunc(514);break;case De:u.depthFunc(518);break;case Oe:u.depthFunc(516);break;case Ge:u.depthFunc(517);break;default:u.depthFunc(515)}else u.depthFunc(515);r=e}},setLocked:function(e){t=e},setClear:function(e){i!==e&&(u.clearDepth(e),i=e)},reset:function(){t=!1,n=null,r=null,i=null}}},a=new function(){let t=!1,n=null,r=null,i=null,a=null,o=null,s=null,l=null,c=null;return{setTest:function(e){t||(e?P:I)(2960)},setMask:function(e){n===e||t||(u.stencilMask(e),n=e)},setFunc:function(e,t,n){r===e&&i===t&&a===n||(u.stencilFunc(e,t,n),r=e,i=t,a=n)},setOp:function(e,t,n){o===e&&s===t&&l===n||(u.stencilOp(e,t,n),o=e,s=t,l=n)},setLocked:function(e){t=e},setClear:function(e){c!==e&&(u.clearStencil(e),c=e)},reset:function(){t=!1,n=null,r=null,i=null,a=null,o=null,s=null,l=null,c=null}}};let t={},o=null,s={},l=null,c=!1,d=null,h=null,p=null,f=null,m=null,v=null,g=null,_=!1,x=null,y=null,b=null,M=null,A=null;const B=u.getParameter(35661);let w=!1,S=0;const T=u.getParameter(7938);-1!==T.indexOf("WebGL")?(S=parseFloat(/^WebGL (\d)/.exec(T)[1]),w=1<=S):-1!==T.indexOf("OpenGL ES")&&(S=parseFloat(/^OpenGL ES (\d)/.exec(T)[1]),w=2<=S);let C=null,E={};var e=u.getParameter(3088),z=u.getParameter(2978);const L=(new mt).fromArray(e),R=(new mt).fromArray(z);function V(e,t,n){var r=new Uint8Array(4),i=u.createTexture();u.bindTexture(e,i),u.texParameteri(e,10241,9728),u.texParameteri(e,10240,9728);for(let e=0;e<n;e++)u.texImage2D(t+e,0,6408,1,1,0,6408,5121,r);return i}const U={};function P(e){!0!==t[e]&&(u.enable(e),t[e]=!0)}function I(e){!1!==t[e]&&(u.disable(e),t[e]=!1)}U[3553]=V(3553,3553,1),U[34067]=V(34067,34069,6),r.setClear(0,0,0,1),i.setClear(1),a.setClear(0),P(2929),i.setFunc(Ie),G(!1),k(j),P(2884),O(ce);const N={[$]:32774,[ue]:32778,[me]:32779},D=(n?(N[ve]=32775,N[ge]=32776):null!==(e=F.get("EXT_blend_minmax"))&&(N[ve]=e.MIN_EXT,N[ge]=e.MAX_EXT),{[_e]:0,[xe]:1,[ye]:768,[Me]:770,[Ee]:776,[Te]:774,[we]:772,[be]:769,[Ae]:771,[Ce]:775,[Se]:773});function O(e,t,n,r,i,a,o,s){if(e===ce)!0===c&&(I(3042),c=!1);else if(!1===c&&(P(3042),c=!0),e!==J){if(e!==d||s!==_){if(h===$&&m===$||(u.blendEquation(32774),h=$,m=$),s)switch(e){case Z:u.blendFuncSeparate(1,771,1,771);break;case q:u.blendFunc(1,1);break;case Q:u.blendFuncSeparate(0,0,769,771);break;case K:u.blendFuncSeparate(0,768,0,770);break;default:console.error("v3d.WebGLState: Invalid blending: ",e)}else switch(e){case Z:u.blendFuncSeparate(770,771,1,771);break;case q:u.blendFunc(770,1);break;case Q:u.blendFunc(0,769);break;case K:u.blendFunc(0,768);break;default:console.error("v3d.WebGLState: Invalid blending: ",e)}p=null,f=null,v=null,g=null,d=e,_=s}}else i=i||t,a=a||n,o=o||r,t===h&&i===m||(u.blendEquationSeparate(N[t],N[i]),h=t,m=i),n===p&&r===f&&a===v&&o===g||(u.blendFuncSeparate(D[n],D[r],D[a],D[o]),p=n,f=r,v=a,g=o),d=e,_=null}function G(e){x!==e&&(e?u.frontFace(2304):u.frontFace(2305),x=e)}function k(e){e!==X?(P(2884),e!==y&&(e===j?u.cullFace(1029):e===Y?u.cullFace(1028):u.cullFace(1032))):I(2884),y=e}function W(e,t,n){e?(P(32823),M===t&&A===n||(u.polygonOffset(t,n),M=t,A=n)):I(32823)}function H(e){void 0===e&&(e=33984+B-1),C!==e&&(u.activeTexture(e),C=e)}return{buffers:{color:r,depth:i,stencil:a},enable:P,disable:I,bindFramebuffer:function(e,t){return null===t&&null!==o&&(t=o),s[e]!==t&&(u.bindFramebuffer(e,t),s[e]=t,n&&(36009===e&&(s[36160]=t),36160===e&&(s[36009]=t)),!0)},bindXRFramebuffer:function(e){e!==o&&(u.bindFramebuffer(36160,e),o=e)},useProgram:function(e){return l!==e&&(u.useProgram(e),l=e,!0)},setBlending:O,setMaterial:function(e,t){(e.side===Ue?I:P)(2884);let n=e.side===Fe;G(n=t?!n:n),e.blending===Z&&!1===e.transparent?O(ce):O(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),i.setFunc(e.depthFunc),i.setTest(e.depthTest),i.setMask(e.depthWrite),r.setMask(e.colorWrite),t=e.stencilWrite,a.setTest(t),t&&(a.setMask(e.stencilWriteMask),a.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),a.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),W(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),(!0===e.alphaToCoverage?P:I)(32926)},setFlipSided:G,setCullFace:k,setLineWidth:function(e){e!==b&&(w&&u.lineWidth(e),b=e)},setPolygonOffset:W,setScissorTest:function(e){(e?P:I)(3089)},activeTexture:H,bindTexture:function(e,t){null===C&&H();let n=E[C];void 0===n&&(n={type:void 0,texture:void 0},E[C]=n),n.type===e&&n.texture===t||(u.bindTexture(e,t||U[e]),n.type=e,n.texture=t)},unbindTexture:function(){const e=E[C];void 0!==e&&void 0!==e.type&&(u.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{u.compressedTexImage2D.apply(u,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},texImage2D:function(){try{u.texImage2D.apply(u,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},texImage3D:function(){try{u.texImage3D.apply(u,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},scissor:function(e){!1===L.equals(e)&&(u.scissor(e.x,e.y,e.z,e.w),L.copy(e))},viewport:function(e){!1===R.equals(e)&&(u.viewport(e.x,e.y,e.z,e.w),R.copy(e))},reset:function(){u.disable(3042),u.disable(2884),u.disable(2929),u.disable(32823),u.disable(3089),u.disable(2960),u.disable(32926),u.blendEquation(32774),u.blendFunc(1,0),u.blendFuncSeparate(1,0,1,0),u.colorMask(!0,!0,!0,!0),u.clearColor(0,0,0,0),u.depthMask(!0),u.depthFunc(513),u.clearDepth(1),u.stencilMask(4294967295),u.stencilFunc(519,0,4294967295),u.stencilOp(7680,7680,7680),u.clearStencil(0),u.cullFace(1029),u.frontFace(2305),u.polygonOffset(0,0),u.activeTexture(33984),u.bindFramebuffer(36160,null),!0===n&&(u.bindFramebuffer(36009,null),u.bindFramebuffer(36008,null)),u.useProgram(null),u.lineWidth(1),u.scissor(0,0,u.canvas.width,u.canvas.height),u.viewport(0,0,u.canvas.width,u.canvas.height),t={},C=null,E={},o=null,s={},l=null,c=!1,d=null,h=null,p=null,f=null,m=null,v=null,g=null,_=!1,x=null,y=null,b=null,M=null,A=null,L.set(0,0,u.canvas.width,u.canvas.height),R.set(0,0,u.canvas.width,u.canvas.height),r.reset(),i.reset(),a.reset()}}}function Bs(m,i,v,g,_,x,y){const b=_.isWebGL2,t=_.maxTextures,M=_.maxCubemapSize,u=_.maxTextureSize,B=_.maxSamples,a=new WeakMap;let l,n=!1;try{n="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function c(e,t){return n?new OffscreenCanvas(e,t):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function A(e,t,n,r){let i=1;if((i=e.width>r||e.height>r?r/Math.max(e.width,e.height):i)<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const a=t?In:Math.floor;r=a(i*e.width),t=a(i*e.height);void 0===l&&(l=c(r,t));const o=n?c(r,t):l,s=(o.width=r,o.height=t,o.getContext("2d"));return s.drawImage(e,0,0,r,t),console.warn("v3d.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+r+"x"+t+")."),o}return"data"in e&&console.warn("v3d.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function w(e){return Rn(e.width)&&Rn(e.height)}function S(e,t){return e.generateMipmaps&&t&&e.minFilter!==dt&&e.minFilter!==ht}function T(e,t,n,r){m.generateMipmap(e);const i=g.get(t);i.__maxMipLevel=Math.log(Math.max(n,r))*Math.LOG2E}function C(e,t,n){if(!1===b)return t;if(null!==e){if(void 0!==m[e])return m[e];console.warn("v3d.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let r=t;return 6403===t&&(5126===n&&(r=33326),5131===n&&(r=33325),5121===n&&(r=33321)),6407===t&&(5126===n&&(r=34837),5131===n&&(r=34843),5121===n&&(r=32849)),6408===t&&(5126===n&&(r=34836),5131===n&&(r=34842),5121===n&&(r=32856)),33325!==r&&33326!==r&&34842!==r&&34836!==r||i.get("EXT_color_buffer_float"),r}function r(e){return e===dt||e===W||e===H?9728:9729}function o(e){const t=e.target;var n;t.removeEventListener("dispose",o),e=t,void 0!==(n=g.get(e)).__webglInit&&(m.deleteTexture(n.__webglTexture),g.remove(e)),t.isVideoTexture&&a.delete(t),y.memory.textures--,y.removeTextureSpec(t)}function E(e){const t=e.target;t.removeEventListener("dispose",E);var e=t,n=e.texture,r=g.get(e),i=g.get(n);if(e){if(void 0!==i.__webglTexture&&(m.deleteTexture(i.__webglTexture),y.memory.textures--),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)m.deleteFramebuffer(r.__webglFramebuffer[e]),r.__webglDepthbuffer&&m.deleteRenderbuffer(r.__webglDepthbuffer[e]);else m.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&m.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&m.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer&&m.deleteRenderbuffer(r.__webglColorRenderbuffer),r.__webglDepthRenderbuffer&&m.deleteRenderbuffer(r.__webglDepthRenderbuffer);if(e.isWebGLMultipleRenderTargets)for(let e=0,t=n.length;e<t;e++){var a=g.get(n[e]);a.__webglTexture&&(m.deleteTexture(a.__webglTexture),y.memory.textures--),g.remove(n[e])}g.remove(n),g.remove(e)}y.removeTextureSpec(t)}let s=0;function d(e,t){var n,r=g.get(e);if(e.isVideoTexture&&(n=e,i=y.render.frame,a.get(n)!==i&&(a.set(n,i),n.update())),0<e.version&&r.__version!==e.version){var i=e.image;if(void 0===i)console.warn("v3d.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==i.complete)return void P(r,e,t);console.warn("v3d.WebGLRenderer: Texture marked for update but image is incomplete")}}v.activeTexture(33984+t),v.bindTexture(3553,r.__webglTexture)}function h(e,t){var n=g.get(e);if(0<e.version&&n.__version!==e.version){var r=n,i=e,e=t;if(6===i.image.length){R(r,i),v.activeTexture(33984+e),v.bindTexture(34067,r.__webglTexture),m.pixelStorei(37440,i.flipY),m.pixelStorei(37441,i.premultiplyAlpha),m.pixelStorei(3317,i.unpackAlignment),m.pixelStorei(37443,0);var a=i&&(i.isCompressedTexture||i.image[0].isCompressedTexture),o=i.image[0]&&i.image[0].isDataTexture;const f=[];for(let e=0;e<6;e++)f[e]=a||o?o?i.image[e].image:i.image[e]:A(i.image[e],!1,!0,M);var e=f[0],s=w(e)||b,l=x.convert(i.format),c=x.convert(i.type),u=C(i.internalFormat,l,c);L(34067,i,s);let n;if(a){for(let t=0;t<6;t++){n=f[t].mipmaps;for(let e=0;e<n.length;e++){var d=n[e];i.format!==pt&&i.format!==wt?null!==l?v.compressedTexImage2D(34069+t,e,u,d.width,d.height,0,d.data):console.warn("v3d.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):v.texImage2D(34069+t,e,u,d.width,d.height,0,l,c,d.data)}}r.__maxMipLevel=n.length-1}else{n=i.mipmaps;for(let t=0;t<6;t++)if(o){v.texImage2D(34069+t,0,u,f[t].width,f[t].height,0,l,c,f[t].data);for(let e=0;e<n.length;e++){var h=n[e].image[t].image;v.texImage2D(34069+t,e+1,u,h.width,h.height,0,l,c,h.data)}}else{v.texImage2D(34069+t,0,u,l,c,f[t]);for(let e=0;e<n.length;e++){var p=n[e];v.texImage2D(34069+t,e+1,u,l,c,p.image[t])}}r.__maxMipLevel=n.length}S(i,s)&&T(34067,i,e.width,e.height),r.__version=i.version,i.onUpdate&&i.onUpdate(i)}}else v.activeTexture(33984+t),v.bindTexture(34067,n.__webglTexture)}const p={[U]:10497,[ut]:33071,[G]:33648},f={[dt]:9728,[W]:9984,[H]:9986,[ht]:9729,[We]:9985,[He]:9987};function L(e,t,n){n?(m.texParameteri(e,10242,p[t.wrapS]),m.texParameteri(e,10243,p[t.wrapT]),32879!==e&&35866!==e||m.texParameteri(e,32882,p[t.wrapR]),m.texParameteri(e,10240,f[t.magFilter]),m.texParameteri(e,10241,f[t.minFilter])):(m.texParameteri(e,10242,33071),m.texParameteri(e,10243,33071),32879!==e&&35866!==e||m.texParameteri(e,32882,33071),t.wrapS===ut&&t.wrapT===ut||console.warn("v3d.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to v3d.ClampToEdgeWrapping."),m.texParameteri(e,10240,r(t.magFilter)),m.texParameteri(e,10241,r(t.minFilter)),t.minFilter!==dt&&t.minFilter!==ht&&console.warn("v3d.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to v3d.NearestFilter or v3d.LinearFilter.")),!0===i.has("EXT_texture_filter_anisotropic")&&(n=i.get("EXT_texture_filter_anisotropic"),t.type===At&&!1===i.has("OES_texture_float_linear")||!1===b&&t.type===je&&!1===i.has("OES_texture_half_float_linear")||(1<t.anisotropy||g.get(t).__currentAnisotropy)&&(m.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,_.getMaxAnisotropy())),g.get(t).__currentAnisotropy=t.anisotropy))}function R(e,t){void 0===e.__webglInit&&(e.__webglInit=!0,t.addEventListener("dispose",o),e.__webglTexture=m.createTexture(),y.memory.textures++,y.addTextureSpec(t))}function P(e,n,t){let r=3553;n.isDataTexture2DArray&&(r=35866),n.isDataTexture3D&&(r=32879),R(e,n),v.activeTexture(33984+t),v.bindTexture(r,e.__webglTexture),m.pixelStorei(37440,n.flipY),m.pixelStorei(37441,n.premultiplyAlpha),m.pixelStorei(3317,n.unpackAlignment),m.pixelStorei(37443,0);t=n;var t=!b&&(t.wrapS!==ut||t.wrapT!==ut||t.minFilter!==dt&&t.minFilter!==ht)&&!1===w(n.image),t=A(n.image,t,!1,u),i=w(t)||b,a=x.convert(n.format);let o=x.convert(n.type),s=C(n.internalFormat,a,o);L(r,n,i);let l;var c=n.mipmaps;if(n.isDepthTexture)s=6402,b?s=n.type===At?36012:n.type===Xe?33190:n.type===Ye?35056:33189:n.type===At&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),n.format===Ze&&6402===s&&n.type!==V&&n.type!==Xe&&(console.warn("v3d.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=V,o=x.convert(n.type)),n.format===qe&&6402===s&&(s=34041,n.type!==Ye&&(console.warn("v3d.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=Ye,o=x.convert(n.type))),v.texImage2D(3553,0,s,t.width,t.height,0,a,o,null);else if(n.isDataTexture)if(0<c.length&&i){for(let e=0,t=c.length;e<t;e++)l=c[e],v.texImage2D(3553,e,s,l.width,l.height,0,a,o,l.data);n.generateMipmaps=!1,e.__maxMipLevel=c.length-1}else v.texImage2D(3553,0,s,t.width,t.height,0,a,o,t.data),e.__maxMipLevel=0;else if(n.isCompressedTexture){for(let e=0,t=c.length;e<t;e++)l=c[e],n.format!==pt&&n.format!==wt?null!==a?v.compressedTexImage2D(3553,e,s,l.width,l.height,0,l.data):console.warn("v3d.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):v.texImage2D(3553,e,s,l.width,l.height,0,a,o,l.data);e.__maxMipLevel=c.length-1}else if(n.isDataTexture2DArray)v.texImage3D(35866,0,s,t.width,t.height,t.depth,0,a,o,t.data),e.__maxMipLevel=0;else if(n.isDataTexture3D)v.texImage3D(32879,0,s,t.width,t.height,t.depth,0,a,o,t.data),e.__maxMipLevel=0;else if(0<c.length&&i){for(let e=0,t=c.length;e<t;e++)l=c[e],v.texImage2D(3553,e,s,a,o,l);n.generateMipmaps=!1,e.__maxMipLevel=c.length-1}else v.texImage2D(3553,0,s,a,o,t),e.__maxMipLevel=0;S(n,i)&&T(r,n,t.width,t.height),e.__version=n.version,n.onUpdate&&n.onUpdate(n)}function I(e,t,n,r,i){var a=x.convert(n.format),o=x.convert(n.type),s=C(n.internalFormat,a,o);32879===i||35866===i?v.texImage3D(i,0,s,t.width,t.height,t.depth,0,a,o,null):v.texImage2D(i,0,s,t.width,t.height,0,a,o,null),v.bindFramebuffer(36160,e),m.framebufferTexture2D(36160,r,i,g.get(n).__webglTexture,0),v.bindFramebuffer(36160,null)}function N(t,n,r){if(m.bindRenderbuffer(36161,t),n.depthBuffer&&!n.stencilBuffer){let e=33189;r?((i=n.depthTexture)&&i.isDepthTexture&&(i.type===At?e=36012:i.type===Xe&&(e=33190)),i=D(n),m.renderbufferStorageMultisample(36161,i,e,n.width,n.height)):m.renderbufferStorage(36161,e,n.width,n.height),m.framebufferRenderbuffer(36160,36096,36161,t)}else{var e,i;n.depthBuffer&&n.stencilBuffer?(r?(i=D(n),m.renderbufferStorageMultisample(36161,i,35056,n.width,n.height)):m.renderbufferStorage(36161,34041,n.width,n.height),m.framebufferRenderbuffer(36160,33306,36161,t)):(i=!0===n.isWebGLMultipleRenderTargets?n.texture[0]:n.texture,t=x.convert(i.format),e=x.convert(i.type),i=C(i.internalFormat,t,e),r?(t=D(n),m.renderbufferStorageMultisample(36161,t,i,n.width,n.height)):m.renderbufferStorage(36161,i,n.width,n.height))}m.bindRenderbuffer(36161,null)}function z(t){const n=g.get(t);var e=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture){if(e)throw new Error("target.depthTexture not supported in Cube render targets");var r=n.__webglFramebuffer,i=t;if(i&&i.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(v.bindFramebuffer(36160,r),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of v3d.DepthTexture");if(g.get(i.depthTexture).__webglTexture&&i.depthTexture.image.width===i.width&&i.depthTexture.image.height===i.height||(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),d(i.depthTexture,0),r=g.get(i.depthTexture).__webglTexture,i.depthTexture.format===Ze)m.framebufferTexture2D(36160,36096,3553,r,0);else{if(i.depthTexture.format!==qe)throw new Error("Unknown depthTexture format");m.framebufferTexture2D(36160,33306,3553,r,0)}}else if(e){n.__webglDepthbuffer=[];for(let e=0;e<6;e++)v.bindFramebuffer(36160,n.__webglFramebuffer[e]),n.__webglDepthbuffer[e]=m.createRenderbuffer(),N(n.__webglDepthbuffer[e],t,!1)}else v.bindFramebuffer(36160,n.__webglFramebuffer),n.__webglDepthbuffer=m.createRenderbuffer(),N(n.__webglDepthbuffer,t,!1);v.bindFramebuffer(36160,null)}function D(e){return b&&e.isWebGLMultisampleRenderTarget?Math.min(B,e.samples):0}let O=!1,F=!1;this.allocateTextureUnit=function(){var e=s;return e>=t&&console.warn("v3d.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+t),s+=1,e},this.resetTextureUnits=function(){s=0},this.setTexture2D=d,this.setTexture2DArray=function(e,t){var n=g.get(e);0<e.version&&n.__version!==e.version?P(n,e,t):(v.activeTexture(33984+t),v.bindTexture(35866,n.__webglTexture))},this.setTexture3D=function(e,t){var n=g.get(e);0<e.version&&n.__version!==e.version?P(n,e,t):(v.activeTexture(33984+t),v.bindTexture(32879,n.__webglTexture))},this.setTextureCube=h,this.setupRenderTarget=function(n){const t=n.texture,r=g.get(n),i=g.get(t);n.addEventListener("dispose",E),!0!==n.isWebGLMultipleRenderTargets&&(i.__webglTexture=m.createTexture(),i.__version=t.version,y.memory.textures++),y.addTextureSpec(n);var a,e=!0===n.isWebGLCubeRenderTarget,o=!0===n.isWebGLMultipleRenderTargets,s=!0===n.isWebGLMultisampleRenderTarget,l=t.isDataTexture3D||t.isDataTexture2DArray,c=w(n)||b;if(!b||t.format!==wt||t.type!==At&&t.type!==je||(t.format=pt,console.warn("v3d.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),e){r.__webglFramebuffer=[];for(let e=0;e<6;e++)r.__webglFramebuffer[e]=m.createFramebuffer()}else if(r.__webglFramebuffer=m.createFramebuffer(),o)if(_.drawBuffers){var u=n.texture;for(let e=0,t=u.length;e<t;e++){const f=g.get(u[e]);void 0===f.__webglTexture&&(f.__webglTexture=m.createTexture(),y.memory.textures++)}}else console.warn("v3d.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");else s&&(b?(r.__webglMultisampledFramebuffer=m.createFramebuffer(),r.__webglColorRenderbuffer=m.createRenderbuffer(),m.bindRenderbuffer(36161,r.__webglColorRenderbuffer),s=x.convert(t.format),a=x.convert(t.type),s=C(t.internalFormat,s,a),a=D(n),m.renderbufferStorageMultisample(36161,a,s,n.width,n.height),v.bindFramebuffer(36160,r.__webglMultisampledFramebuffer),m.framebufferRenderbuffer(36160,36064,36161,r.__webglColorRenderbuffer),m.bindRenderbuffer(36161,null),n.depthBuffer&&(r.__webglDepthRenderbuffer=m.createRenderbuffer(),N(r.__webglDepthRenderbuffer,n,!0)),v.bindFramebuffer(36160,null)):console.warn("v3d.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2."));if(e){v.bindTexture(34067,i.__webglTexture),L(34067,t,c);for(let e=0;e<6;e++)I(r.__webglFramebuffer[e],n,t,36064,34069+e);S(t,c)&&T(34067,t,n.width,n.height),v.bindTexture(34067,null)}else if(o){var d=n.texture;for(let e=0,t=d.length;e<t;e++){var h=d[e],p=g.get(h);v.bindTexture(3553,p.__webglTexture),L(3553,h,c),I(r.__webglFramebuffer,n,h,36064+e,3553),S(h,c)&&T(3553,h,n.width,n.height)}v.bindTexture(3553,null)}else{let e=3553;l&&(b?(a=t.isDataTexture3D,e=a?32879:35866):console.warn("v3d.DataTexture3D and v3d.DataTexture2DArray only supported with WebGL2.")),v.bindTexture(e,i.__webglTexture),L(e,t,c),I(r.__webglFramebuffer,n,t,36064,e),S(t,c)&&T(3553,t,n.width,n.height),v.bindTexture(3553,null)}n.depthBuffer&&z(n)},this.updateRenderTargetMipmap=function(n){var r=w(n)||b,i=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let e=0,t=i.length;e<t;e++){var a,o,s=i[e];S(s,r)&&(a=n.isWebGLCubeRenderTarget?34067:3553,o=g.get(s).__webglTexture,v.bindTexture(a,o),T(a,s,n.width,n.height),v.bindTexture(a,null))}},this.updateMultisampleRenderTarget=function(t){if(t.isWebGLMultisampleRenderTarget)if(b){var n=t.width,r=t.height;let e=16384;t.depthBuffer&&(e|=256),t.stencilBuffer&&(e|=1024);t=g.get(t);v.bindFramebuffer(36008,t.__webglMultisampledFramebuffer),v.bindFramebuffer(36009,t.__webglFramebuffer),m.blitFramebuffer(0,0,n,r,0,0,n,r,e,9728),v.bindFramebuffer(36008,null),v.bindFramebuffer(36009,t.__webglMultisampledFramebuffer)}else console.warn("v3d.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(e,t){e&&e.isWebGLRenderTarget&&(!1===O&&(console.warn("v3d.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),O=!0),e=e.texture),d(e,t)},this.safeSetTextureCube=function(e,t){e&&e.isWebGLCubeRenderTarget&&(!1===F&&(console.warn("v3d.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),F=!0),e=e.texture),h(e,t)}}function zs(e,n,t){const r=t.isWebGL2;return{convert:function(e){let t;if(e===Mt)return 5121;if(e===d)return 32819;if(e===h)return 32820;if(e===p)return 33635;if(e===l)return 5120;if(e===c)return 5122;if(e===V)return 5123;if(e===u)return 5124;if(e===Xe)return 5125;if(e===At)return 5126;if(e===je)return r?5131:null!==(t=n.get("OES_texture_half_float"))?t.HALF_FLOAT_OES:null;if(e===f)return 6406;if(e===wt)return 6407;if(e===pt)return 6408;if(e===m)return 6409;if(e===v)return 6410;if(e===Ze)return 6402;if(e===qe)return 34041;if(e===Qe)return 6403;if(e===M)return 36244;if(e===A)return 33319;if(e===w)return 33320;if(e===B)return 36248;if(e===z)return 36249;if(e===Ke||e===Je||e===$e||e===et){if(null===(t=n.get("WEBGL_compressed_texture_s3tc")))return null;if(e===Ke)return t.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===Je)return t.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===$e)return t.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===et)return t.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(e===tt||e===nt||e===rt||e===it){if(null===(t=n.get("WEBGL_compressed_texture_pvrtc")))return null;if(e===tt)return t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===nt)return t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===rt)return t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===it)return t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(e===at)return null!==(t=n.get("WEBGL_compressed_texture_etc1"))?t.COMPRESSED_RGB_ETC1_WEBGL:null;if((e===ot||e===st)&&null!==(t=n.get("WEBGL_compressed_texture_etc"))){if(e===ot)return t.COMPRESSED_RGB8_ETC2;if(e===st)return t.COMPRESSED_RGBA8_ETC2_EAC}return e===lt||e===ct||e===St||e===Tt||e===Ct||e===Et||e===Lt||e===Rt||e===Pt||e===It||e===Nt||e===Dt||e===Ot||e===Ft||e===zt||e===Vt||e===Ut||e===Gt||e===kt||e===Wt||e===Ht||e===Xt||e===jt||e===Yt||e===Zt||e===qt||e===Qt||e===Kt?null!==(t=n.get("WEBGL_compressed_texture_astc"))?e:null:e===Bt?null!==(t=n.get("EXT_texture_compression_bptc"))?e:null:e===Ye?r?34042:null!==(t=n.get("WEBGL_depth_texture"))?t.UNSIGNED_INT_24_8_WEBGL:null:void 0}}}class Vs extends da{constructor(e=[]){super(),this.cameras=e}}Vs.prototype.isArrayCamera=!0;class Us extends he{constructor(){super(),this.type="Group"}getWorldDirection(e){this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}}Us.prototype.isGroup=!0;const Gs={type:"move"};class ks{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Us,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 Us,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new vt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new vt,this._targetRay.name="XR_CONTROLLER_"+String(e)),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Us,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new vt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new vt),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}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 r=null,i=null,a=null;const o=this._targetRay,s=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState)if(null!==o&&null!==(r=t.getPose(e.targetRaySpace,n))&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Gs)),l&&e.hand){a=!0;for(const h of e.hand.values()){var c=t.getJointPose(h,n);if(void 0===l.joints[h.jointName]){const f=new Us;f.matrixAutoUpdate=!1,f.visible=!1,l.joints[h.jointName]=f,l.add(f)}const p=l.joints[h.jointName];null!==c&&(p.matrix.fromArray(c.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.jointRadius=c.radius),p.visible=null!==c}const d=l.joints["index-finger-tip"];var u=l.joints["thumb-tip"],u=d.position.distanceTo(u.position);l.inputState.pinching&&.025<u?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&u<=.015&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==s&&e.gripSpace&&null!==(i=t.getPose(e.gripSpace,n))&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1);return null!==o&&(o.visible=null!==r),null!==s&&(s.visible=null!==i),null!==l&&(l.visible=null!==a),this}}class Ws{constructor(e,t,n=0,r=1/0){this.ray=new Mr(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new Nr,this.params={Mesh:{omitGeometry:!1},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{},checkVisibility:!0},this.layers.enable(3),this.layers.enable(4),this.layers.enable(5),this.layers.enable(6),this.layers.enable(7)}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t&&t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t&&t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("v3d.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!1,n=[]){return Xs(e,this,n,t,this.params.checkVisibility),n.sort(Hs),n}intersectObjects(n,r=!1,i=[]){for(let e=0,t=n.length;e<t;e++)Xs(n[e],this,i,r,this.params.checkVisibility);return i.sort(Hs),i}}function Hs(e,t){return e.distance-t.distance}function Xs(e,n,r,t,i){if(!(i&&(!1===e.visible||e.isMesh&&e.isMaterialGeneratedMesh&&e.parent&&!e.parent.visible)||(e.layers.test(n.layers)&&e.raycast(n,r),!0!==t))){var a=e.children;for(let e=0,t=a.length;e<t;e++)Xs(a[e],n,r,!0,i)}}class js extends n{constructor(e,p){super();const f=this,m=e.state;let v=null,r=1,i=null,a="local-floor",g=null,_=null,x=null,y=null,b=null,M=!1,A=null,o=null,s=null,w=null,S=null,T=null;const C=[],l=new Map,E=new da,L=(E.layers.enable(1),E.viewport=new mt,new da),R=(L.layers.enable(2),L.viewport=new mt,[E,L]),P=new Vs;P.layers.enable(1),P.layers.enable(2);let I=null,N=null,n=null,D=null,O=null,B=null;const t=new vt,h=new vt,c=new de;function u(e){const t=l.get(e.inputSource);t&&t.dispatchEvent({type:e.type,data:e.inputSource})}function z(){l.forEach(function(e,t){e.disconnect(t)}),l.clear(),I=null,N=null,m.bindXRFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),x&&p.deleteFramebuffer(x),A&&p.deleteFramebuffer(A),o&&p.deleteRenderbuffer(o),s&&p.deleteRenderbuffer(s),x=null,A=null,o=null,s=null,b=null,y=null,_=null,v=null,d.stop(),f.isPresenting=!1,f.dispatchEvent({type:"sessionend"})}function V(t){var n=v.inputSources;for(let e=0;e<C.length;e++)l.set(n[e],C[e]);for(let e=0;e<t.removed.length;e++){var r=t.removed[e];const a=l.get(r);a&&(a.dispatchEvent({type:"disconnected",data:r}),l.delete(r))}for(let e=0;e<t.added.length;e++){var i=t.added[e];const o=l.get(i);o&&o.dispatchEvent({type:"connected",data:i})}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=C[e];return void 0===t&&(t=new ks,C[e]=t),t.getTargetRaySpace(e)},this.getControllerGrip=function(e){let t=C[e];return void 0===t&&(t=new ks,C[e]=t),t.getGripSpace()},this.getHand=function(e){let t=C[e];return void 0===t&&(t=new ks,C[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===f.isPresenting&&console.warn("v3d.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){a=e,!0===f.isPresenting&&console.warn("v3d.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){var e;return n?(n.clone().invert().decompose(t,c,h),e=new XRRigidTransform({x:t.x,y:t.y,z:t.z},{x:c.x,y:c.y,z:c.z,w:c.w}),i.getOffsetReferenceSpace(e)):i},this.getBaseLayer=function(){return null!==y?y:b},this.getBinding=function(){return _},this.getFrame=function(){return w},this.getSession=function(){return v},this.setSession=async function(t){if(null!==(v=t)){v.addEventListener("select",u),v.addEventListener("selectstart",u),v.addEventListener("selectend",u),v.addEventListener("squeeze",u),v.addEventListener("squeezestart",u),v.addEventListener("squeezeend",u),v.addEventListener("end",z),v.addEventListener("inputsourceschange",V);t=p.getContextAttributes();if(!0!==t.xrCompatible&&await p.makeXRCompatible(),void 0===v.renderState.layers){var n={antialias:t.antialias,alpha:t.alpha,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:r};b=new XRWebGLLayer(v,p,n),v.updateRenderState({baseLayer:b})}else if(p instanceof WebGLRenderingContext){n={antialias:!0,alpha:t.alpha,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:r};b=new XRWebGLLayer(v,p,n),v.updateRenderState({layers:[b]})}else{M=t.antialias;let e=null;t.depth&&(T=256,t.stencil&&(T|=1024),S=t.stencil?33306:36096,e=t.stencil?35056:33190);n={colorFormat:t.alpha?32856:32849,depthFormat:e,scaleFactor:r};_=new XRWebGLBinding(v,p),y=_.createProjectionLayer(n),x=p.createFramebuffer(),v.updateRenderState({layers:[y]}),M&&(A=p.createFramebuffer(),o=p.createRenderbuffer(),p.bindRenderbuffer(36161,o),p.renderbufferStorageMultisample(36161,4,32856,y.textureWidth,y.textureHeight),m.bindFramebuffer(36160,A),p.framebufferRenderbuffer(36160,36064,36161,o),p.bindRenderbuffer(36161,null),null!==e&&(s=p.createRenderbuffer(),p.bindRenderbuffer(36161,s),p.renderbufferStorageMultisample(36161,4,e,y.textureWidth,y.textureHeight),p.framebufferRenderbuffer(36160,S,36161,s),p.bindRenderbuffer(36161,null)),m.bindFramebuffer(36160,null))}i=await v.requestReferenceSpace(a),d.setContext(v),d.start(),f.isPresenting=!0,f.dispatchEvent({type:"sessionstart"})}};const U=new vt,G=new vt;function k(e,t){n=null===t?(e.matrixWorld.copy(e.matrix),null):(e.matrixWorld.copy(e.matrix),t.matrixWorld),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null!==v){P.near=L.near=E.near=e.near,P.far=L.far=E.far=e.far,I===P.near&&N===P.far||(v.updateRenderState({depthNear:P.near,depthFar:P.far}),I=P.near,N=P.far);var t,n,r,i,a,o,s,l,c,u,d=e.parent,h=P.cameras;k(P,d);for(let e=0;e<h.length;e++)k(h[e],d);P.matrixWorld.decompose(P.position,P.quaternion,P.scale),e.matrixWorld.copy(P.matrixWorld),null===d?e.matrix.copy(e.matrixWorld):(e.matrix.copy(d.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale);const p=e.children;for(let e=0,t=p.length;e<t;e++)p[e].updateMatrixWorld(!0);2===h.length?(e=P,t=E,n=L,U.setFromMatrixPosition(t.matrixWorld),G.setFromMatrixPosition(n.matrixWorld),r=U.distanceTo(G),i=t.projectionMatrix.elements,n=n.projectionMatrix.elements,a=i[14]/(i[10]-1),o=i[14]/(i[10]+1),s=(i[9]+1)/i[5],l=(i[9]-1)/i[5],i=(i[8]-1)/i[0],n=(n[8]+1)/n[0],c=a*i,u=a*n,i=(n=r/(n-i))*-i,t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(i),e.translateZ(n),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),t=a+n,a=o+n,e.projectionMatrix.makePerspective(c-i,r-i+u,s*o/a*t,l*o/a*t,t,a)):P.projectionMatrix.copy(E.projectionMatrix),P.projectionMatrixInverse.copy(P.projectionMatrix).invert()}},this.getCamera=function(){return P},this.getFoveation=function(){return null!==y?y.fixedFoveation:null!==b?b.fixedFoveation:void 0},this.setFoveation=function(e){null!==y&&(y.fixedFoveation=e),null!==b&&void 0!==b.fixedFoveation&&(b.fixedFoveation=e)};let F=null;const d=new Aa;d.setAnimationLoop(function(e,t){var n=f.getReferenceSpace();if(g=t.getViewerPose(n),w=t,null!==g){var r=g.views;null!==b&&m.bindXRFramebuffer(b.framebuffer);let n=!1;r.length!==P.cameras.length&&(P.cameras.length=0,n=!0);for(let t=0;t<r.length;t++){var i,a=r[t];let e=null;e=null!==b?b.getViewport(a):(i=_.getViewSubImage(y,a),m.bindXRFramebuffer(x),void 0!==i.depthStencilTexture&&p.framebufferTexture2D(36160,S,3553,i.depthStencilTexture,0),p.framebufferTexture2D(36160,36064,3553,i.colorTexture,0),i.viewport);const c=R[t];c.matrix.fromArray(a.transform.matrix),c.projectionMatrix.fromArray(a.projectionMatrix),c.viewport.set(e.x,e.y,e.width,e.height),0===t&&P.matrix.copy(c.matrix),!0===n&&P.cameras.push(c)}M&&(m.bindXRFramebuffer(A),null!==T&&p.clear(T))}var o,s=v.inputSources;for(let e=0;e<C.length;e++){const u=C[e];var l=s[e],l=(u.update(l,t,n),l=l=l=void 0,t);if(D){const d=l.getHitTestResults(D);if(d.length){l=d[0].getPose(f.getReferenceSpace()),l=(new gt).fromArray(l.transform.matrix);const h=new vt;h.setFromMatrixPosition(l),O(h)}else B()}}F&&F(e,t),M&&(e=y.textureWidth,o=y.textureHeight,m.bindFramebuffer(36008,A),m.bindFramebuffer(36009,x),p.invalidateFramebuffer(36008,[S]),p.invalidateFramebuffer(36009,[S]),p.blitFramebuffer(0,0,e,o,0,0,e,o,16384,9728),p.invalidateFramebuffer(36008,[36064]),m.bindFramebuffer(36008,null),m.bindFramebuffer(36009,null),m.bindFramebuffer(36160,A)),w=null}),this.setAnimationLoop=function(e){F=e},this.dispose=function(){},this.arHitTest=function(e,t,n,r){v&&XRSession.prototype.requestHitTestSource&&(O=n||function(){},B=r||function(){},this.raycaster=this.raycaster||new Ws,this.raycaster.setFromCamera({x:e,y:t},R[0]),n=this.raycaster.ray,new XRRay(n.origin,n.direction),v.requestReferenceSpace("viewer").then(function(e){e={space:e};v.requestHitTestSource(e).then(function(e){D=e})}))}}}function Ys(p){function f(e,t){e.opacity.value=t.opacity,t.color&&e.diffuse.value.copy(t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap);var n=p.get(t).envMap;n&&(e.envMap.value=n,e.flipEnvMap.value=n.isCubeTexture&&n._needsFlipEnvMap?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio,void 0!==(n=p.get(n).__maxMipLevel)&&(e.maxMipLevel.value=n)),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity);let r;t.map?r=t.map:t.specularMap?r=t.specularMap:t.displacementMap?r=t.displacementMap:t.normalMap?r=t.normalMap:t.bumpMap?r=t.bumpMap:t.roughnessMap?r=t.roughnessMap:t.metalnessMap?r=t.metalnessMap:t.alphaMap?r=t.alphaMap:t.emissiveMap?r=t.emissiveMap:t.clearcoatMap?r=t.clearcoatMap:t.clearcoatNormalMap?r=t.clearcoatNormalMap:t.clearcoatRoughnessMap&&(r=t.clearcoatRoughnessMap),void 0!==r&&(!0===(r=r.isWebGLRenderTarget?r.texture:r).matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix));let i;t.aoMap?i=t.aoMap:t.lightMap&&(i=t.lightMap),void 0!==i&&(!0===(i=i.isWebGLRenderTarget?i.texture:i).matrixAutoUpdate&&i.updateMatrix(),e.uv2Transform.value.copy(i.matrix))}function m(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Fe&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Fe&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),p.get(t).envMap&&(e.envMapIntensity.value=t.envMapIntensity,e.envMapParallaxType.value=t.envMapParallaxType,e.envMapParallaxMatrix.value.copy(t.envMapParallaxMatrix),e.envMapParallaxMatrixInv.value.copy(t.envMapParallaxMatrixInv))}return{refreshFogUniforms:function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshGTAOUniforms:function(e,t){e.gtaoMap.value=t},refreshMaterialUniforms:function(t,n,r,i,a){var e,o;if(n.ssrParams&&(o=n,(e=t).invProjectionMatrix.value=o.ssrParams.invProjectionMatrix,e.ssrSourceBuffer.value=o.ssrParams.sourceBuffer.texture,e.ssrDepthBuffer.value=o.ssrParams.depthBuffer.texture,e.ssrBackfaceDepthBuffer.value=o.ssrParams.backfaceDepthBuffer.texture,e.ssrResolution.value.set(o.ssrParams.sourceBuffer.width,o.ssrParams.sourceBuffer.height),e.ssrStride.value=o.ssrParams.stride,e.ssrThickness.value=o.ssrParams.thickness,e.ssrMaxDistance.value=o.ssrParams.maxDistance,e.ssrJitter.value=o.ssrParams.jitter),n.isMeshBasicMaterial)f(t,n);else if(n.isMeshLambertMaterial)f(t,n),e=t,(o=n).emissiveMap&&(e.emissiveMap.value=o.emissiveMap);else if(n.isMeshToonMaterial){f(t,n);var s=t,l=n;l.gradientMap&&(s.gradientMap.value=l.gradientMap),l.emissiveMap&&(s.emissiveMap.value=l.emissiveMap),l.bumpMap&&(s.bumpMap.value=l.bumpMap,s.bumpScale.value=l.bumpScale,l.side===Fe&&(s.bumpScale.value*=-1)),l.normalMap&&(s.normalMap.value=l.normalMap,s.normalScale.value.copy(l.normalScale),l.side===Fe&&s.normalScale.value.negate()),l.displacementMap&&(s.displacementMap.value=l.displacementMap,s.displacementScale.value=l.displacementScale,s.displacementBias.value=l.displacementBias)}else if(n.isMeshPhongMaterial){f(t,n);s=t,l=n;s.specular.value.copy(l.specular),s.shininess.value=Math.max(l.shininess,1e-4),l.emissiveMap&&(s.emissiveMap.value=l.emissiveMap),l.bumpMap&&(s.bumpMap.value=l.bumpMap,s.bumpScale.value=l.bumpScale,l.side===Fe&&(s.bumpScale.value*=-1)),l.normalMap&&(s.normalMap.value=l.normalMap,s.normalScale.value.copy(l.normalScale),l.side===Fe&&s.normalScale.value.negate()),l.displacementMap&&(s.displacementMap.value=l.displacementMap,s.displacementScale.value=l.displacementScale,s.displacementBias.value=l.displacementBias)}else if(n.isMeshStandardMaterial)f(t,n),n.isMeshPhysicalMaterial?(a=a,m(c=t,u=n),c.reflectivity.value=u.reflectivity,c.clearcoat.value=u.clearcoat,c.clearcoatRoughness.value=u.clearcoatRoughness,u.sheen&&c.sheen.value.copy(u.sheen),u.clearcoatMap&&(c.clearcoatMap.value=u.clearcoatMap),u.clearcoatRoughnessMap&&(c.clearcoatRoughnessMap.value=u.clearcoatRoughnessMap),u.clearcoatNormalMap&&(c.clearcoatNormalScale.value.copy(u.clearcoatNormalScale),c.clearcoatNormalMap.value=u.clearcoatNormalMap,u.side===Fe&&c.clearcoatNormalScale.value.negate()),c.transmission.value=u.transmission,u.transmissionMap&&(c.transmissionMap.value=u.transmissionMap),0<u.transmission&&(c.transmissionSamplerMap.value=a.texture,c.transmissionSamplerSize.value.set(a.width,a.height)),c.thickness.value=u.thickness,u.thicknessMap&&(c.thicknessMap.value=u.thicknessMap),c.attenuationDistance.value=u.attenuationDistance,c.attenuationColor.value.copy(u.attenuationColor)):m(t,n);else if(n.isMeshMatcapMaterial){f(t,n);var a=t,c=n;c.matcap&&(a.matcap.value=c.matcap),c.bumpMap&&(a.bumpMap.value=c.bumpMap,a.bumpScale.value=c.bumpScale,c.side===Fe&&(a.bumpScale.value*=-1)),c.normalMap&&(a.normalMap.value=c.normalMap,a.normalScale.value.copy(c.normalScale),c.side===Fe&&a.normalScale.value.negate()),c.displacementMap&&(a.displacementMap.value=c.displacementMap,a.displacementScale.value=c.displacementScale,a.displacementBias.value=c.displacementBias)}else if(n.isMeshDepthMaterial){f(t,n);var u=t,a=n;a.displacementMap&&(u.displacementMap.value=a.displacementMap,u.displacementScale.value=a.displacementScale,u.displacementBias.value=a.displacementBias),u.slopeScaledBias.value=a.slopeScaledBias}else if(n.isMeshDistanceMaterial){f(t,n);var a=t,d=n;d.displacementMap&&(a.displacementMap.value=d.displacementMap,a.displacementScale.value=d.displacementScale,a.displacementBias.value=d.displacementBias),a.referencePosition.value.copy(d.referencePosition),a.nearDistance.value=d.nearDistance,a.farDistance.value=d.farDistance,a.slopeScaledBias.value=d.slopeScaledBias}else if(n.isMeshNormalMaterial){f(t,n);var a=t,d=n;d.bumpMap&&(a.bumpMap.value=d.bumpMap,a.bumpScale.value=d.bumpScale,d.side===Fe&&(a.bumpScale.value*=-1)),d.normalMap&&(a.normalMap.value=d.normalMap,a.normalScale.value.copy(d.normalScale),d.side===Fe&&a.normalScale.value.negate()),d.displacementMap&&(a.displacementMap.value=d.displacementMap,a.displacementScale.value=d.displacementScale,a.displacementBias.value=d.displacementBias)}else if(n.isLineBasicMaterial)a=n,(h=t).diffuse.value.copy(a.color),h.opacity.value=a.opacity,n.isLineDashedMaterial&&(h=n,(a=t).dashSize.value=h.dashSize,a.totalSize.value=h.dashSize+h.gapSize,a.scale.value=h.scale);else if(n.isPointsMaterial){a=t;var h=n;a.diffuse.value.copy(h.color),a.opacity.value=h.opacity,a.size.value=h.size*r,a.scale.value=.5*i,h.map&&(a.map.value=h.map);h.alphaMap&&(a.alphaMap.value=h.alphaMap);let e;h.map?e=h.map:h.alphaMap&&(e=h.alphaMap);void 0!==e&&(!0===e.matrixAutoUpdate&&e.updateMatrix(),a.uvTransform.value.copy(e.matrix))}else if(n.isSpriteMaterial){var r=t;var i=n;r.diffuse.value.copy(i.color),r.opacity.value=i.opacity,r.rotation.value=i.rotation,i.map&&(r.map.value=i.map);i.alphaMap&&(r.alphaMap.value=i.alphaMap);let e;i.map?e=i.map:i.alphaMap&&(e=i.alphaMap);void 0!==e&&(!0===e.matrixAutoUpdate&&e.updateMatrix(),r.uvTransform.value.copy(e.matrix))}else n.isShadowMaterial?(t.color.value.copy(n.color),t.opacity.value=n.opacity):n.isMeshMaskMaterial?(f(t,n),a=t,(i=n).displacementMap&&(a.displacementMap.value=i.displacementMap,a.displacementScale.value=i.displacementScale,a.displacementBias.value=i.displacementBias),i.cameraNearFar&&(a.cameraNearFar.value=i.cameraNearFar),a.depthTexture.value=i.depthTexture,i.textureMatrix&&(a.textureMatrix.value=i.textureMatrix)):n.isMeshNodeMaterial?(r=t,a=n,(i=p.get(a).envMap)&&(r.envMap.value=i,r.flipEnvMap.value=i.isCubeTexture&&i._needsFlipEnvMap?-1:1,r.reflectivity.value=a.reflectivity,r.refractionRatio.value=a.refractionRatio,void 0!==(i=p.get(i).__maxMipLevel)&&(r.maxMipLevel.value=i),r.envMapIntensity.value=a.envMapIntensity,r.envMapParallaxType.value=a.envMapParallaxType,r.envMapParallaxMatrix.value.copy(a.envMapParallaxMatrix),r.envMapParallaxMatrixInv.value.copy(a.envMapParallaxMatrixInv)),a.displacementMap&&(r.displacementMap.value=a.displacementMap,r.displacementScale.value=a.displacementScale,r.displacementBias.value=a.displacementBias),r.materialIndex.value=a.materialIndex):n.isMeshLineMaterial?(i=n,(r=t).lineWidth.value=i.lineWidth,r.sizeAttenuation.value=i.sizeAttenuation,r.color.value=i.color,r.opacity.value=i.opacity,r.useMap.value=i.useMap,i.map&&(r.map.value=i.map),r.useAlphaMap.value=i.useAlphaMap,i.alphaMap&&(r.alphaMap.value=i.alphaMap),r.visibility.value=i.visibility,r.alphaTest.value=i.alphaTest,r.repeat.value=i.repeat):n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)},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 Zs(){var l={};return{get:function(e,t,n,r){if(void 0!==l[r.id])var i=l[r.id];else{for(var i=[r],a=1;a<2;a++){var o=0!=(1&a),s=r.clone();s.morphTargets=o,i[a]=s}l[r.id]=i}o=!1,n.morphTargets&&(t&&t.isBufferGeometry?o=t.morphAttributes&&t.morphAttributes.position&&0<t.morphAttributes.position.length:t&&t.isGeometry&&(o=t.morphTargets&&0<t.morphTargets.length)),t=0,o&&(t|=1),t=i[t];return t.visible=n.visible,t.wireframe=n.wireframe,t.wireframeLinewidth=n.wireframeLinewidth,t.side=n.side,t.linewidth=n.linewidth,t.clipShadows=n.clipShadows,t.clippingPlanes=n.clippingPlanes,t.clipIntersection=n.clipIntersection,t.isMeshMaskMaterial&&(r.cameraNearFar&&t.cameraNearFar.copy(r.cameraNearFar),r.textureMatrix&&t.textureMatrix.copy(r.textureMatrix),r.depthTexture&&(t.depthTexture=r.depthTexture)),t},update:function(e){delete l[e.id]},dispose:function(){l={}}}}function i(e={}){const i=void 0!==e.canvas?e.canvas:function(){const e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.style.display="block",e}(),n=void 0!==e.context?e.context:null,r=void 0!==e.alpha&&e.alpha,a=void 0===e.depth||e.depth,o=void 0===e.stencil||e.stencil,A=void 0!==e.antialias&&e.antialias,c=void 0===e.premultipliedAlpha||e.premultipliedAlpha,w=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,S=void 0!==e.powerPreference?e.powerPreference:"default",H=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let m=null,T=null;const u=[],d=[],C=(this.domElement=i,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.gammaFactor=2,this.outputEncoding=an,this.physicallyCorrectLights=!1,this.unitsScaleFactor=1,this.toneMapping=1,this.toneMappingExposure=1,this.maxMorphTargets=12,this.maxMorphNormals=6,this.gtaoMap=null,this.compatSettings={useSpecEnvBlenderApprox:!0,saturateSpecEnvBlenderApprox:!1,simplifiedSRGB:!1,gtaoDisableBkgFix:!1},this);let X=!1,j=0,Y=0,E=null,L=-1,R=null;const P=new mt,Z=new mt;let q=null,I=i.width,N=i.height,D=1,Q=null,K=null;const s=new mt(0,0,I,N),J=new mt(0,0,I,N);let $=!1;const l=[],ee=new Ma;let te=!1,ne=!1,O=null;const re=new gt,F=new vt,ie={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},ae=new gt,oe=new gt,se=new Be,le=new gt;function ce(){return null===E?D:1}let B=n;function ue(t,n){for(let e=0;e<t.length;e++){var r=t[e],r=i.getContext(r,n);if(null!==r)return r}return null}try{var de={alpha:r,depth:a,stencil:o,antialias:A,premultipliedAlpha:c,preserveDrawingBuffer:w,powerPreference:S,xrCompatible:!ma.checkSafari(),failIfMajorPerformanceCaveat:H};if(i.addEventListener("webglcontextlost",Me,!1),i.addEventListener("webglcontextrestored",Ae,!1),null===B){const Oe=["webgl2","webgl","experimental-webgl"];if(!0===C.isWebGL1Renderer&&Oe.shift(),null===(B=ue(Oe,de)))throw ue(Oe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");var he="undefined"!=typeof WebGL2RenderingContext&&B instanceof WebGL2RenderingContext;console.log("Verge3D 3.9.1 "+Li()+" ("+(3483952072==Nn(xn)?"Trial":"License")+", "+(he?"WebGL 2.0":"WebGL 1.0")+")")}void 0===B.getShaderPrecisionFormat&&(B.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("v3d.WebGLRenderer: "+e.message),e}let h,z,V,v,U,G,k,p,pe,g,f,fe,me,ve,W,_,x,ge,_e,xe,y,b,ye;function be(){h=new Ia(B),z=new La(B,h,e),h.init(z),y=new zs(B,h,z),V=new Fs(B,h,z),l[0]=1029,v=new Oa(B),U=new os,G=new Bs(B,h,V,U,z,y,v),k=new Pa(C),p=new wa(B,z),b=new Ca(B,h,p,z),pe=new Na(B,p,v,b),g=new za(B,pe,p,v),ge=new Ba(B),W=new Ra(U),f=new as(C,k,h,z,b,W),fe=new Ys(U),me=new us(U),ve=new vs(h,z),x=new Ta(C,k,V,g,c),_=new Os(C,g,z),_e=new Ea(B,h,v,z),xe=new Da(B,h,v,z),v.programs=f.programs,C.capabilities=z,C.extensions=h,C.properties=U,C.renderLists=me,C.shadowMap=_,C.state=V,C.info=v,ye=new Zs}be();const M=new js(C,B);function Me(e){e.preventDefault(),console.log("v3d.WebGLRenderer: Context Lost."),X=!0}function Ae(){console.log("v3d.WebGLRenderer: Context Restored."),X=!1;var e=v.autoReset,t=_.enabled,n=_.autoUpdate,r=_.needsUpdate,i=_.type;be(),v.autoReset=e,_.enabled=t,_.autoUpdate=n,_.needsUpdate=r,_.type=i}function we(e){const t=e.target;t.removeEventListener("dispose",we),e=t;{var n=e;const r=U.get(n).programs;void 0!==r&&r.forEach(function(e){f.releaseProgram(e)})}U.remove(e)}this.xr=M,this.getContext=function(){return B},this.getContextAttributes=function(){return B.getContextAttributes()},this.forceContextLoss=function(){const e=h.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=h.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return D},this.setPixelRatio=function(e){void 0!==e&&(D=e,this.setSize(I,N,!1))},this.getSize=function(e){return e.set(I,N)},this.setSize=function(e,t,n){M.isPresenting?console.warn("v3d.WebGLRenderer: Can't change size while VR device is presenting."):(I=e,N=t,i.width=Math.floor(e*D),i.height=Math.floor(t*D),!1!==n&&(i.style.width=e+"px",i.style.height=t+"px"),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(e){return e.set(I*D,N*D).floor()},this.setDrawingBufferSize=function(e,t,n){I=e,N=t,D=n,i.width=Math.floor(e*n),i.height=Math.floor(t*n),this.setViewport(0,0,e,t)},this.getCurrentViewport=function(e){return e.copy(P)},this.getViewport=function(e){return e.copy(s)},this.setViewport=function(e,t,n,r){e.isVector4?s.set(e.x,e.y,e.z,e.w):s.set(e,t,n,r),V.viewport(P.copy(s).multiplyScalar(D).floor())},this.getScissor=function(e){return e.copy(J)},this.setScissor=function(e,t,n,r){e.isVector4?J.set(e.x,e.y,e.z,e.w):J.set(e,t,n,r),V.scissor(Z.copy(J).multiplyScalar(D).floor())},this.getScissorTest=function(){return $},this.setScissorTest=function(e){V.setScissorTest($=e)},this.setOpaqueSort=function(e){Q=e},this.setTransparentSort=function(e){K=e},this.getClearColor=function(e){return e.copy(x.getClearColor())},this.setClearColor=function(){x.setClearColor.apply(x,arguments)},this.getClearAlpha=function(){return x.getClearAlpha()},this.setClearAlpha=function(){x.setClearAlpha.apply(x,arguments)},this.clear=function(e,t,n){let r=0;void 0!==e&&!e||(r|=16384),void 0!==t&&!t||(r|=256),void 0!==n&&!n||(r|=1024),B.clear(r)},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(){i.removeEventListener("webglcontextlost",Me,!1),i.removeEventListener("webglcontextrestored",Ae,!1),this.disposeGTAO(),this.disposeInternalCaches(),M.dispose(),M.removeEventListener("sessionstart",Te),M.removeEventListener("sessionend",Ce),O&&(O.dispose(),O=null),t.stop()},this.disposeGTAO=function(){var e;null!=(e=this.gtaoMap)&&e.dispose(),this.gtaoMap=null},this.disposeInternalCaches=function(){me.dispose(),ve.dispose(),U.dispose(),k.dispose(),g.dispose(),b.dispose(),x.dispose(),p.dispose(),ye.dispose()},this.renderBufferImmediate=function(e,t){b.initAttributes();const n=U.get(e);e.hasPositions&&!n.position&&(n.position=B.createBuffer()),e.hasNormals&&!n.normal&&(n.normal=B.createBuffer()),e.hasUvs&&!n.uv&&(n.uv=B.createBuffer()),e.hasColors&&!n.color&&(n.color=B.createBuffer());t=t.getAttributes();e.hasPositions&&(B.bindBuffer(34962,n.position),B.bufferData(34962,e.positionArray,35048),b.enableAttribute(t.position),B.vertexAttribPointer(t.position,3,5126,!1,0,0)),e.hasNormals&&(B.bindBuffer(34962,n.normal),B.bufferData(34962,e.normalArray,35048),b.enableAttribute(t.normal),B.vertexAttribPointer(t.normal,3,5126,!1,0,0)),e.hasUvs&&(B.bindBuffer(34962,n.uv),B.bufferData(34962,e.uvArray,35048),b.enableAttribute(t.uv),B.vertexAttribPointer(t.uv,2,5126,!1,0,0)),e.hasColors&&(B.bindBuffer(34962,n.color),B.bufferData(34962,e.colorArray,35048),b.enableAttribute(t.color),B.vertexAttribPointer(t.color,3,5126,!1,0,0)),b.disableUnusedAttributes(),B.drawArrays(4,0,e.count),e.count=0},this.renderBufferDirect=function(e,t,n,r,i,a){null===t&&(t=ie);var o=i.isMesh&&i.matrixWorld.determinant()<0;const s=De(e,t,r,i);V.setMaterial(r,o);let l=n.index;e=n.attributes.position;if(null===l){if(void 0===e||0===e.count)return}else if(0===l.count)return;let c=1,u=(!0===r.wireframe&&(l=pe.getWireframeAttribute(n),c=2),(r.morphTargets||r.morphNormals)&&ge.update(i,n,r,s),b.setup(i,r,s,n,l),_e);null!==l&&(t=p.get(l),(u=xe).setIndex(t));var o=(null!==l?l:e).count,t=n.drawRange.start*c,e=n.drawRange.count*c,d=null!==a?a.start*c:0,a=null!==a?a.count*c:1/0,h=Math.max(t,d),o=Math.min(o,t+e,d+a)-1,t=Math.max(0,o-h+1);if(0!==t){if(i.isMesh)!0===r.wireframe?(V.setLineWidth(r.wireframeLinewidth*ce()),u.setMode(1)):u.setMode(4);else if(i.isLine){let e=r.linewidth;void 0===e&&(e=1),V.setLineWidth(e*ce()),i.isLineSegments?u.setMode(1):i.isLineLoop?u.setMode(2):u.setMode(3)}else i.isPoints?u.setMode(0):i.isSprite&&u.setMode(4);s.beginTimerQuery(B,z.isWebGL2),i.isInstancedMesh?u.renderInstances(h,t,i.count):n.isInstancedBufferGeometry?(e=Math.min(n.instanceCount,n._maxInstanceCount),u.renderInstances(h,t,e)):u.render(h,t),s.endTimerQuery(B,z.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(t),n.sortEnvMapProbes();let r=null;return null!==e.worldEnvMapProbe&&null!==e.worldEnvMapProbe.renderTarget&&(r=e.worldEnvMapProbe.renderTarget.texture),e.traverse(t=>{if(t.material){const e=Array.isArray(t.material)?t.material:[t.material];e.forEach(e=>{(e.isMeshStandardMaterial||e.isMeshPhysicalMaterial||e.isMeshNodeMaterial)&&(t.material.envMap=r,t.material.needsUpdate=!0)})}}),n},this.compile=function(i,e){const a=ve.get(i,d.length),o=(this._compilePrepareRenderState(i,e,a),{});i.traverse(function(t){var n=t.material;if(n)if(Array.isArray(n))for(let e=0;e<n.length;e++){var r=n[e];r.uuid in o==!1&&(Re(r,i,t,a),o[r.uuid]=!0)}else n.uuid in o==!1&&(Re(n,i,t,a),o[n.uuid]=!0)})},this.compileAsync=function(n,e,o){const s=new ms(h,z),r=(this._compilePrepareRenderState(n,e,s),[]);if(n.traverse(function(t){if(t.material){const e=Array.isArray(t.material)?t.material:[t.material];e.forEach(function(e){r.push({scene:n,obj:t,mat:e})})}}),0===r.length)o(1);else{const l=h.get("KHR_parallel_shader_compile"),c=(null===l?1:2)*r.length;let i=0,a=0;const u={};if(Di(r,function(e,t,n){var r,e=Re(e.mat,e.scene,e.obj,s);l&&((r=e.id)in u||(u[r]={program:e,weight:0}),u[r].weight++),o&&(i++,o((i+a)/c))},16),l){const d=setInterval(function(){let e=0;for(var t in u){t=u[t];(void 0===t.program.program||B.getProgramParameter(t.program.program,l.COMPLETION_STATUS_KHR))&&(e+=t.weight)}a=Math.max(a,e),o&&o((i+a)/c),a===r.length&&clearInterval(d)},16)}}};let Se=null;function Te(){t.stop()}function Ce(){t.start()}const t=new Aa;function Ee(n,r,i){var a=!0===r.isScene?r.overrideMaterial:null;for(let e=0,t=n.length;e<t;e++){var o=n[e];const h=o.object;var s=o.geometry,l=a?ye.get(h,s,o.material,a):o.material,c=o.group;if(i.isArrayCamera){var u=i.cameras;for(let e=0,t=u.length;e<t;e++){var d=u[e];h.layers.test(d.layers)&&(V.viewport(P.copy(d.viewport)),T.setupLightsView(d),Le(h,r,d,s,l,c))}}else Le(h,r,i,s,l,c)}}function Le(e,t,n,r,i,a){var o,s;e.onBeforeRender(C,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),e.isImmediateRenderObject?(o=De(n,t,i,e),V.setMaterial(i),b.reset(),s=o,e.render(function(e){C.renderBufferImmediate(e,s)})):!0===i.transparent&&i.side===Ue?(i.side=Fe,i.needsUpdate=!0,C.renderBufferDirect(n,t,r,i,e,a),i.side=Ve,i.needsUpdate=!0,C.renderBufferDirect(n,t,r,i,e,a),i.side=Ue):C.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(C,t,n,r,i,a)}function Re(t,e,n,r){!0!==e.isScene&&(e=ie);const i=U.get(t);var a=r.state.lights,o=r.state.shadowsArray,s=a.state.version,r=Ne(n,t,r);i.planeReflProbe=r;const l=f.getParameters(t,a.state,o,e,n,r);o=f.getProgramCacheKey(l);let c=i.programs,u=(i.environment=t.isMeshStandardMaterial?e.environment:null,i.fog=e.fog,i.envMap=k.get(t.envMap||i.environment),i.useGTAO=t.isMeshNodeMaterial&&t.canUseGTAO()&&C.gtaoMap,void 0===c&&(t.addEventListener("dispose",we),c=new Map,i.programs=c),c.get(o));if(void 0!==u){if(i.currentProgram===u&&i.lightsStateVersion===s)return Ie(t,l),u}else l.uniforms=f.getUniforms(t),t.onBuild(l,C),t.onBeforeCompile(l,C),u=f.acquireProgram(l,o),c.set(o,u),i.uniforms=l.uniforms;if(t.morphTargets||t.morphNormals){var d=u.getAttributes();if(t.morphTargets)for(let e=t.numSupportedMorphTargets=0;e<C.maxMorphTargets;e++)0<=d["morphTarget"+e]&&t.numSupportedMorphTargets++;if(t.morphNormals)for(let e=t.numSupportedMorphNormals=0;e<C.maxMorphNormals;e++)0<=d["morphNormal"+e]&&t.numSupportedMorphNormals++}const h=i.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||t.defines.WORLD_NODES||(h.clippingPlanes=W.uniform),Ie(t,l),i.needsLights=(n=t).isMeshLambertMaterial||n.isMeshToonMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.isShadowMaterial||n.isShaderMaterial&&!0===n.lights||n.isMeshNodeMaterial,i.lightsStateVersion=s,i.needsLights&&(h.ambientLightColor.value=a.state.ambient,h.lightProbe.value=a.state.probe,h.directionalLights.value=a.state.directional,h.directionalLightShadows.value=a.state.directionalShadow,h.spotLights.value=a.state.spot,h.spotLightShadows.value=a.state.spotShadow,h.rectAreaLights.value=a.state.rectArea,h.ltc_1.value=a.state.rectAreaLTC1,h.ltc_2.value=a.state.rectAreaLTC2,h.pointLights.value=a.state.point,h.pointLightShadows.value=a.state.pointShadow,h.hemisphereLights.value=a.state.hemi,h.directionalShadowMap.value=a.state.directionalShadowMap,h.directionalShadowMatrix.value=a.state.directionalShadowMatrix,h.spotShadowMap.value=a.state.spotShadowMap,h.spotShadowMatrix.value=a.state.spotShadowMatrix,h.pointShadowMap.value=a.state.pointShadowMap,h.pointShadowMatrix.value=a.state.pointShadowMatrix,h.rectAreaLightShadows.value=a.state.rectAreaShadow,h.rectAreaShadowMap.value=a.state.rectAreaShadowMap,h.rectAreaShadowMatrix.value=a.state.rectAreaShadowMatrix),t.nodeValue&&(h.nodeValue.value=t.nodeValue),t.nodeRGBArr&&(h.nodeRGB.value=t.nodeRGBArr),i.currentProgram=u,i.uniformsList=null,u}function Pe(e){var t;return null===e.uniformsList&&(t=e.currentProgram.getUniforms(),e.uniformsList=ko.seqWithValue(t.seq,e.uniforms)),e.uniformsList}function Ie(e,t){const n=U.get(e);n.outputEncoding=t.outputEncoding,n.instancing=t.instancing,n.skinning=t.skinning,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas}function Ne(t,e,n){return(e.isMeshStandardMaterial||e.isMeshPhysicalMaterial||e.isMeshNodeMaterial)&&n.state.planeReflProbeArray.find(e=>e.intersectsMesh(t))||null}function De(e,t,r,n){!0!==t.isScene&&(t=ie),G.resetTextureUnits();var i=t.fog,a=r.isMeshStandardMaterial?t.environment:null,o=null===E?C.outputEncoding:E.texture.encoding,s=(r.envMapAutoAssign&&(r.isMeshStandardMaterial||r.isMeshPhysicalMaterial||r.isMeshNodeMaterial)&&((l=T.state.envMapProbeArray.find(e=>{return null===e.influenceGroup?e.intersectsMesh(n):n.groupNames.includes(e.influenceGroup)^e.influenceGroupInv})||t.worldEnvMapProbe)&&(r.envMap=(null==(s=l.renderTarget)?void 0:s.texture)||null,s=l.parallaxDistance,r.envMapParallaxMatrix.copy(l.matrixWorldInverse).premultiply(le.makeScale(1/s,1/s,1/s)),r.envMapParallaxMatrixInv.copy(l.matrixWorld).multiply(le.makeScale(s,s,s)),r.envMapParallaxType=l.parallaxType)),k.get(r.envMap||a)),l=!0===r.vertexColors&&n.geometry&&n.geometry.attributes.color&&4===n.geometry.attributes.color.itemSize,a=r.side===Fe;const c=U.get(r);var u=T.state.lights,d=(!0!==te||!0!==ne&&e===R||(d=e===R&&r.id===L,W.setState(r,e,d)),Ne(n,r,T)),h=r.isMeshNodeMaterial&&r.canUseGTAO()&&C.gtaoMap;let p=!1,f=!1;if(r.version===c.__version)(!c.needsLights||c.lightsStateVersion===u.state.version)&&c.outputEncoding===o&&(!n.isInstancedMesh||!1!==c.instancing)&&(n.isInstancedMesh||!0!==c.instancing)&&(!n.isSkinnedMesh||!1!==c.skinning)&&(n.isSkinnedMesh||!0!==c.skinning)?c.envMap!==s?(p=!0,f=!0):(r.fog&&c.fog!==i||void 0!==c.numClippingPlanes&&(c.numClippingPlanes!==W.numPlanes||c.numIntersection!==W.numIntersection)||c.vertexAlphas!==l||c.planeReflProbe!==d||r.isMeshNormalMaterial&&c.flipSided!==a||c.useGTAO!==h)&&(p=!0):p=!0;else if(p=!0,c.__version=r.version,r.nodeRGBArr)for(let e=0;e<r.nodeRGB.length;e++){const b=r.nodeRGB[e];b.toArray(r.nodeRGBArr,4*e)}let m=c.currentProgram,v=!1,g=!1,_=!1;const x=(m=!0===p?Re(r,t,n,T):m).getUniforms(),y=c.uniforms;if(V.useProgram(m.program)&&(v=!0,g=!0,_=!0),r.id!==L&&(L=r.id,g=!0),f&&(g=!0),v||R!==e){if(x.setValue(B,"projectionMatrix",e.projectionMatrix),z.logarithmicDepthBuffer&&x.setValue(B,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),R!==e&&(R=e,g=!0,_=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshStandardMaterial||r.isMeshNodeMaterial||r.envMap){const M=x.map.cameraPosition;void 0!==M&&M.setValue(B,F.setFromMatrixPosition(e.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.isMeshNodeMaterial)&&x.setValue(B,"isOrthographic",!0===e.isOrthographicCamera),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.isMeshNodeMaterial||r.isShadowMaterial||n.isSkinnedMesh)&&x.setValue(B,"viewMatrix",e.matrixWorldInverse),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshNodeMaterial||r.isMeshStandardMaterial||r.isMeshPhysicalMaterial||r.isShadowMaterial)&&x.setValue(B,"invViewMatrix",e.matrixWorld)}if(n.isSkinnedMesh){x.setOptional(B,n,"bindMatrix"),x.setOptional(B,n,"bindMatrixInverse");const A=n.skeleton;A&&(z.floatVertexTextures?(null===A.boneTexture&&A.computeBoneTexture(),x.setValue(B,"boneTexture",A.boneTexture,G),x.setValue(B,"boneTextureSize",A.boneTextureSize)):x.setOptional(B,A,"boneMatrices"))}if(!g&&c.receiveShadow===n.receiveShadow||(c.receiveShadow=n.receiveShadow,x.setValue(B,"receiveShadow",n.receiveShadow)),r.needsBoundingBox){const w=n.geometry;w&&(null===w.boundingBox&&w.computeBoundingBox(),x.setValue(B,"boundingBoxMin",w.boundingBox.min),x.setValue(B,"boundingBoxMax",w.boundingBox.max))}if(g){if(x.setValue(B,"toneMappingExposure",C.toneMappingExposure),6==C.toneMapping?(x.setValue(B,"toneMappingBrightness",C.toneMappingBrightness),x.setValue(B,"toneMappingContrast",C.toneMappingContrast),x.setValue(B,"toneMappingMidTones",C.toneMappingMidTones),x.setValue(B,"toneMappingPhysicalScale",C.toneMappingPhysicalScale),x.setValue(B,"toneMappingChromaticAdaptation",C.toneMappingChromaticAdaptation),x.setValue(B,"toneMappingWhiteColor",C.toneMappingWhiteColor),x.setValue(B,"toneMappingColorDifferentiation",C.toneMappingColorDifferentiation),x.setValue(B,"toneMappingExteriorDaylight",C.toneMappingExteriorDaylight)):7==C.toneMapping&&(x.setValue(B,"toneMappingResolution",se.set(I,N)),x.setValue(B,"toneMappingWhiteBalance",C.toneMappingWhiteBalance),x.setValue(B,"toneMappingHighlights",C.toneMappingHighlights),x.setValue(B,"toneMappingMidTones",C.toneMappingMidTones),x.setValue(B,"toneMappingShadows",C.toneMappingShadows),x.setValue(B,"toneMappingSaturation",C.toneMappingSaturation),x.setValue(B,"toneMappingPhysicalScale",C.toneMappingPhysicalScale),x.setValue(B,"toneMappingAperture",C.toneMappingAperture),x.setValue(B,"toneMappingShutter",C.toneMappingShutter),x.setValue(B,"toneMappingISO",C.toneMappingISO),x.setValue(B,"toneMappingVignetting",C.toneMappingVignetting)),c.needsLights&&(u=y,o=_,u.ambientLightColor.needsUpdate=o,u.lightProbe.needsUpdate=o,u.directionalLights.needsUpdate=o,u.directionalLightShadows.needsUpdate=o,u.pointLights.needsUpdate=o,u.pointLightShadows.needsUpdate=o,u.spotLights.needsUpdate=o,u.spotLightShadows.needsUpdate=o,u.rectAreaLights.needsUpdate=o,u.hemisphereLights.needsUpdate=o,u.rectAreaLightShadows.needsUpdate=o),i&&r.fog&&fe.refreshFogUniforms(y,i),c.useGTAO&&(a=null!=(l=null==(s=E)?void 0:s.width)?l:I,e=null!=(t=null==(h=E)?void 0:h.height)?t:N,x.setValue(B,"currResolution",se.set(a,e)),fe.refreshGTAOUniforms(y,C.gtaoMap)),fe.refreshMaterialUniforms(y,r,D,N,O),d&&fe.refreshPlaneReflProbeUniforms(y,d),r.isMeshNodeMaterial)for(const S in r.nodeTextures)x.setValue(B,S,r.nodeTextures[S],G);r.isMeshLineMaterial&&x.setValue(B,"resolution",se.set(I,N)),ko.upload(B,Pe(c),y,G)}return r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(ko.upload(B,Pe(c),y,G),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&x.setValue(B,"center",n.center),r.isMeshNodeMaterial&&(ae.copy(n.matrixWorld).invert(),x.setValue(B,"invModelMatrix",ae),x.setValue(B,"viewWidthHeight",se.set(P.z-P.x,P.w-P.y)),r.nodeTexCoordObject.forEach(function(e,t){const n=null===e?ae:oe.copy(e.matrixWorld).invert();n.toArray(r.nodeTexCoordObjectArr,16*t)}),r.nodeTexCoordObjectArr&&x.setValue(B,"nodeTexCoordObjectMatrices",r.nodeTexCoordObjectArr),x.setValue(B,"objectIndex",n.objectIndex),x.setValue(B,"objectColor",n.objectColor),x.setValue(B,"objectRandom",Nn(n.uuid)/Math.pow(2,32))),x.setValue(B,"modelViewMatrix",n.modelViewMatrix),x.setValue(B,"normalMatrix",n.normalMatrix),x.setValue(B,"modelMatrix",n.matrixWorld),m}t.setAnimationLoop(function(e){Se&&Se(e)}),"undefined"!=typeof window&&t.setContext(window),this.setAnimationLoop=function(e){Se=e,M.setAnimationLoop(e),null===e?t.stop():t.start()},M.addEventListener("sessionstart",Te),M.addEventListener("sessionend",Ce),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)console.error("v3d.WebGLRenderer.render: camera is not an instance of v3d.Camera.");else if(!0!==X){b.resetDefaultState(),L=-1,!(R=null)===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),!0===M.enabled&&!0===M.isPresenting&&(!0===M.cameraAutoUpdate&&M.updateCamera(t),t=M.getCamera()),!0===e.isScene&&e.onBeforeRender(C,e,t,E),(T=ve.get(e,d.length)).init(),d.push(T),re.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),ee.setFromProjectionMatrix(re),ne=this.localClippingEnabled,te=W.init(this.clippingPlanes,ne,t),(m=me.get(e,u.length)).init(),u.push(m),!function n(r,i,a,o){r.isAnnotationControl&&r.update(i);let s=!1;if(r.visible&&(s=r.layers.test(i.layers)))if(r.isGroup)a=r.renderOrder;else if(r.isLOD)!0===r.autoUpdate&&r.update(i);else if(r.isLight)T.pushLight(r),r.castShadow&&T.pushShadow(r);else if(r.isCubeReflectionProbe)T.pushEnvMapProbe(r);else if(r.isPlaneReflectionProbe)T.pushPlaneReflProbe(r);else if(r.isSprite){if(!r.frustumCulled||ee.intersectsSprite(r)){o&&F.setFromMatrixPosition(r.matrixWorld).applyMatrix4(re);const e=g.update(r),t=r.material;m.push(r,e,t,a,F.z,null)}}else if(r.isImmediateRenderObject)o&&F.setFromMatrixPosition(r.matrixWorld).applyMatrix4(re),m.push(r,null,r.material,a,F.z,null);else if((r.isMesh||r.isLine||r.isPoints)&&(r.isSkinnedMesh&&r.skeleton.frame!==v.render.frame&&(r.skeleton.update(),r.skeleton.frame=v.render.frame),!r.frustumCulled||ee.intersectsObject(r))){o&&F.setFromMatrixPosition(r.matrixWorld).applyMatrix4(re);const c=g.update(r),u=r.material;if(Array.isArray(u)){const d=c.groups;for(let e=0,t=d.length;e<t;e++){const h=d[e],p=u[h.materialIndex];p&&p.visible&&m.push(r,c,p,a,F.z,h)}}else u.visible&&m.push(r,c,u,a,F.z,null)}if(r.disableChildRendering)return;const l=r.children;for(let e=0,t=l.length;e<t;e++){const f=l[e];!s&&f.isMesh&&f.isMaterialGeneratedMesh||n(f,i,a,o)}}(e,t,0,C.sortObjects),m.finish(),!0===C.sortObjects&&m.sort(Q,K),!0===te&&W.beginShadows();var n=T.state.shadowsArray,n=(_.render(n,e,t),T.setupLights(),T.setupLightsView(t),T.sortEnvMapProbes(),!0===te&&W.endShadows(),!0===this.info.autoReset&&this.info.reset(),x.render(m,e),m.opaque),r=m.transmissive,i=m.transparent;if(0<n.length&&Ee(n,e,t),0<r.length){var a=e,o=t;if(null===O){const c=!0===A&&!0===z.isWebGL2?Yn:ze;O=new c(1024,1024,{generateMipmaps:!0,type:null!==y.convert(je)?je:Mt,minFilter:He,magFilter:dt,wrapS:ut,wrapT:ut})}var s=C.getRenderTarget(),l=(C.setRenderTarget(O),C.clear(),C.toneMapping);C.toneMapping=ke,Ee(n,a,o),C.toneMapping=l,G.updateMultisampleRenderTarget(O),G.updateRenderTargetMipmap(O),C.setRenderTarget(s),Ee(r,a,o)}0<i.length&&Ee(i,e,t),null!==E&&(G.updateMultisampleRenderTarget(E),G.updateRenderTargetMipmap(E)),!0===e.isScene&&e.onAfterRender(C,e,t),V.buffers.depth.setTest(!0),V.buffers.depth.setMask(!0),V.buffers.color.setMask(!0),V.setPolygonOffset(!1),b.resetDefaultState(),L=-1,R=null,d.pop(),T=0<d.length?d[d.length-1]:null,u.pop(),m=0<u.length?u[u.length-1]:null}},this.getActiveCubeFace=function(){return j},this.getActiveMipmapLevel=function(){return Y},this.getRenderTarget=function(){return E},this.setRenderTarget=function(t,e=0,n=0){E=t,j=e,Y=n,t&&void 0===U.get(t).__webglFramebuffer&&G.setupRenderTarget(t);let r=null,i=!1,a=!1;q=t?(((o=t.texture).isDataTexture3D||o.isDataTexture2DArray)&&(a=!0),o=U.get(t).__webglFramebuffer,t.isWebGLCubeRenderTarget?(r=o[e],i=!0):r=t.isWebGLMultisampleRenderTarget?U.get(t).__webglMultisampledFramebuffer:o,P.copy(t.viewport),Z.copy(t.scissor),t.scissorTest):(P.copy(s).multiplyScalar(D).floor(),Z.copy(J).multiplyScalar(D).floor(),$);var o=V.bindFramebuffer(36160,r);if(o&&z.drawBuffers){let e=!1;if(t)if(t.isWebGLMultipleRenderTargets){const G=t.texture;if(l.length!==G.length||36064!==l[0]){for(let e=0,t=G.length;e<t;e++)l[e]=36064+e;l.length=G.length,e=!0}}else 1===l.length&&36064===l[0]||(l[0]=36064,l.length=1,e=!0);else 1===l.length&&1029===l[0]||(l[0]=1029,l.length=1,e=!0);e&&(z.isWebGL2?B.drawBuffers(l):h.get("WEBGL_draw_buffers").drawBuffersWEBGL(l))}V.viewport(P),V.scissor(Z),V.setScissorTest(q),i?(o=U.get(t.texture),B.framebufferTexture2D(36160,36064,34069+e,o.__webglTexture,n)):a&&(o=U.get(t.texture),t=e||0,B.framebufferTextureLayer(36160,36064,o.__webglTexture,n||0,t))},this.readRenderTargetPixels=function(t,n,r,i,a,o,s){if(t&&t.isWebGLRenderTarget){let e=U.get(t).__webglFramebuffer;if(e=t.isWebGLCubeRenderTarget&&void 0!==s?e[s]:e){V.bindFramebuffer(36160,e);try{var l=t.texture,c=l.format,u=l.type;if(c!==pt&&y.convert(c)!==B.getParameter(35739))return void console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");var d=u===je&&(h.has("EXT_color_buffer_half_float")||z.isWebGL2&&h.has("EXT_color_buffer_float"));if(!(u===Mt||y.convert(u)===B.getParameter(35738)||u===At&&(z.isWebGL2||h.has("OES_texture_float")||h.has("WEBGL_color_buffer_float"))||d))return void console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===B.checkFramebufferStatus(36160)?0<=n&&n<=t.width-i&&0<=r&&r<=t.height-a&&B.readPixels(n,r,i,a,y.convert(c),y.convert(u),o):console.error("v3d.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const e=null!==E?U.get(E).__webglFramebuffer:null;V.bindFramebuffer(36160,e)}}}else console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not v3d.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(e,t,n=0){var r=Math.pow(2,-n),i=Math.floor(t.image.width*r),r=Math.floor(t.image.height*r);let a=y.convert(t.format);z.isWebGL2&&6408===(a=6407===a?32849:a)&&(a=32856),G.setTexture2D(t,0),B.copyTexImage2D(3553,n,a,e.x,e.y,i,r,0),V.unbindTexture()},this.copyTextureToTexture=function(e,t,n,r=0){var i=t.image.width,a=t.image.height,o=y.convert(n.format),s=y.convert(n.type);G.setTexture2D(n,0),B.pixelStorei(37440,n.flipY),B.pixelStorei(37441,n.premultiplyAlpha),B.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?B.texSubImage2D(3553,r,e.x,e.y,i,a,o,s,t.image.data):t.isCompressedTexture?B.compressedTexSubImage2D(3553,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):B.texSubImage2D(3553,r,e.x,e.y,o,s,t.image),0===r&&n.generateMipmaps&&B.generateMipmap(3553),V.unbindTexture()},this.copyTextureToTexture3D=function(t,n,r,i,a=0){if(C.isWebGL1Renderer)console.warn("v3d.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");else{var o=t.max.x-t.min.x+1,s=t.max.y-t.min.y+1,l=t.max.z-t.min.z+1,c=y.convert(i.format),u=y.convert(i.type);let e;if(i.isDataTexture3D)G.setTexture3D(i,0),e=32879;else{if(!i.isDataTexture2DArray)return void console.warn("v3d.WebGLRenderer.copyTextureToTexture3D: only supports v3d.DataTexture3D and v3d.DataTexture2DArray.");G.setTexture2DArray(i,0),e=35866}B.pixelStorei(37440,i.flipY),B.pixelStorei(37441,i.premultiplyAlpha),B.pixelStorei(3317,i.unpackAlignment);var d=B.getParameter(3314),h=B.getParameter(32878),p=B.getParameter(3316),f=B.getParameter(3315),m=B.getParameter(32877),v=r.isCompressedTexture?r.mipmaps[0]:r.image;B.pixelStorei(3314,v.width),B.pixelStorei(32878,v.height),B.pixelStorei(3316,t.min.x),B.pixelStorei(3315,t.min.y),B.pixelStorei(32877,t.min.z),r.isDataTexture||r.isDataTexture3D?B.texSubImage3D(e,a,n.x,n.y,n.z,o,s,l,c,u,v.data):r.isCompressedTexture?(console.warn("v3d.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),B.compressedTexSubImage3D(e,a,n.x,n.y,n.z,o,s,l,c,v.data)):B.texSubImage3D(e,a,n.x,n.y,n.z,o,s,l,c,u,v),B.pixelStorei(3314,d),B.pixelStorei(32878,h),B.pixelStorei(3316,p),B.pixelStorei(3315,f),B.pixelStorei(32877,m),0===a&&i.generateMipmaps&&B.generateMipmap(e),V.unbindTexture()}},this.initTexture=function(e){G.setTexture2D(e,0),V.unbindTexture()},this.resetState=function(){j=0,Y=0,E=null,V.reset(),b.reset()},"undefined"!=typeof __V3D_DEVTOOLS__&&__V3D_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this})),this.updateGeometry=function(e){return g.update(e)}}class qs extends i{}class Qs{constructor(e,t=25e-5){this.name="",this.color=new _t(e),this.density=t}clone(){return new Qs(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}Qs.prototype.isFogExp2=qs.prototype.isWebGL1Renderer=!0;class Ks{constructor(e,t=1,n=1e3){this.name="",this.color=new _t(e),this.near=t,this.far=n}clone(){return new Ks(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}Ks.prototype.isFog=!0;class Js extends he{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,this.postprocessing=[],this.worldMaterial=null,this.worldEnvMapProbe=null,"undefined"!=typeof __V3D_DEVTOOLS__&&__V3D_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}dispose(){this.dispatchEvent({type:"dispose"})}}Js.prototype.isScene=!0;class $s{constructor(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=mn,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=wn()}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(n,r,i){n*=this.stride,i*=r.stride;for(let e=0,t=this.stride;e<t;e++)this.array[n+e]=r.array[i+e];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=wn()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);e=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]);const t=new this.constructor(e,this.stride);return t.setUsage(this.usage),t}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=wn()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}$s.prototype.isInterleavedBuffer=!0;const el=new vt;class tl{constructor(e,t,n,r=!1){this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=!0===r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(n){for(let e=0,t=this.data.count;e<t;e++)el.x=this.getX(e),el.y=this.getY(e),el.z=this.getZ(e),el.applyMatrix4(n),this.setXYZ(e,el.x,el.y,el.z);return this}applyNormalMatrix(n){for(let e=0,t=this.count;e<t;e++)el.x=this.getX(e),el.y=this.getY(e),el.z=this.getZ(e),el.applyNormalMatrix(n),this.setXYZ(e,el.x,el.y,el.z);return this}transformDirection(n){for(let e=0,t=this.count;e<t;e++)el.x=this.getX(e),el.y=this.getY(e),el.z=this.getZ(e),el.transformDirection(n),this.setXYZ(e,el.x,el.y,el.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(e){if(void 0!==e)return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new tl(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized);{console.log("v3d.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const n=[];for(let e=0;e<this.count;e++){var t=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)n.push(this.data.array[t+e])}return new re(new this.array.constructor(n),this.itemSize,this.normalized)}}toJSON(e){if(void 0!==e)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};{console.log("v3d.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const n=[];for(let e=0;e<this.count;e++){var t=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)n.push(this.data.array[t+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}}}tl.prototype.isInterleavedBufferAttribute=!0;class nl extends pi{constructor(e){super(),this.type="SpriteMaterial",this.color=new _t(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!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}}nl.prototype.isSpriteMaterial=!0;let rl;const il=new vt,al=new vt,ol=new vt,sl=new Be,ll=new Be,cl=new gt,ul=new vt,dl=new vt,hl=new vt,pl=new Be,fl=new Be,ml=new Be;class vl extends he{constructor(e){var t;super(),this.type="Sprite",void 0===rl&&(rl=new S,t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new $s(t,5),rl.setIndex([0,1,2,0,2,3]),rl.setAttribute("position",new tl(t,3,0,!1)),rl.setAttribute("uv",new tl(t,2,3,!1))),this.geometry=rl,this.material=void 0!==e?e:new nl,this.center=new Be(.5,.5)}raycast(e,t){null===e.camera&&console.error('v3d.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),al.setFromMatrixScale(this.matrixWorld),cl.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ol.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&al.multiplyScalar(-ol.z);var n=this.material.rotation;let r,i;0!==n&&(i=Math.cos(n),r=Math.sin(n));var n=this.center,a=(gl(ul.set(-.5,-.5,0),ol,n,al,r,i),gl(dl.set(.5,-.5,0),ol,n,al,r,i),gl(hl.set(.5,.5,0),ol,n,al,r,i),pl.set(0,0),fl.set(1,0),ml.set(1,1),e.ray.intersectTriangle(ul,dl,hl,!1,il));null===a&&(gl(dl.set(-.5,.5,0),ol,n,al,r,i),fl.set(0,1),null===(a=e.ray.intersectTriangle(ul,hl,dl,!1,il)))||((n=e.ray.origin.distanceTo(il))<e.near||n>e.far||t.push({distance:n,point:il.clone(),uv:ui.getUV(il,ul,dl,hl,pl,fl,ml,new Be),face:null,object:this}))}copy(e){return super.copy(e),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function gl(e,t,n,r,i,a){sl.subVectors(e,n).addScalar(.5).multiply(r),void 0!==i?(ll.x=a*sl.x-i*sl.y,ll.y=i*sl.x+a*sl.y):ll.copy(sl),e.copy(t),e.x+=ll.x,e.y+=ll.y,e.applyMatrix4(cl)}vl.prototype.isSprite=!0;const _l=new vt,xl=new vt;class yl extends he{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);var n=e.levels;for(let e=0,t=n.length;e<t;e++){const r=n[e];this.addLevel(r.object.clone(),r.distance)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0){t=Math.abs(t);const n=this.levels;let r;for(r=0;r<n.length&&!(t<n[r].distance);r++);return n.splice(r,0,{distance:t,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(n){var r=this.levels;if(0<r.length){let e,t;for(e=1,t=r.length;e<t&&!(n<r[e].distance);e++);return r[e-1].object}return null}raycast(e,t){var n;0<this.levels.length&&(_l.setFromMatrixPosition(this.matrixWorld),n=e.ray.origin.distanceTo(_l),this.getObjectForDistance(n).raycast(e,t))}update(n){const r=this.levels;if(1<r.length){_l.setFromMatrixPosition(n.matrixWorld),xl.setFromMatrixPosition(this.matrixWorld);var i=_l.distanceTo(xl)/n.zoom;r[0].object.visible=!0;let e,t;for(e=1,t=r.length;e<t&&i>=r[e].distance;e++)r[e-1].object.visible=!1,r[e].object.visible=!0;for(this._currentLevel=e-1;e<t;e++)r[e].object.visible=!1}}toJSON(e){const n=super.toJSON(e);!1===this.autoUpdate&&(n.object.autoUpdate=!1),n.object.levels=[];var r=this.levels;for(let e=0,t=r.length;e<t;e++){var i=r[e];n.object.levels.push({object:i.object.uuid,distance:i.distance})}return n}}const bl=new vt,Ml=new mt,Al=new mt,wl=new vt,Sl=new gt;class Tl extends ee{constructor(e,t){super(e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new gt,this.bindMatrixInverse=new gt,this.normalizeSkinWeights()}copy(e){return super.copy(e),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 n=new mt,r=this.geometry.attributes.skinWeight;for(let e=0,t=r.count;e<t;e++){n.x=r.getX(e),n.y=r.getY(e),n.z=r.getZ(e),n.w=r.getW(e);var i=1/n.manhattanLength();i!=1/0?n.multiplyScalar(i):n.set(1,0,0,0),r.setXYZW(e,n.x,n.y,n.z,n.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){var n=this.skeleton,r=this.geometry;Ml.fromBufferAttribute(r.attributes.skinIndex,e),Al.fromBufferAttribute(r.attributes.skinWeight,e),bl.fromBufferAttribute(r.attributes.position,e).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){var i,a=Al.getComponent(e);0!==a&&(i=Ml.getComponent(e),Sl.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(wl.copy(bl).applyMatrix4(Sl),a))}return t.applyMatrix4(this.bindMatrixInverse)}}Tl.prototype.isSkinnedMesh=!0;class Cl extends he{constructor(){super(),this.type="Bone"}}Cl.prototype.isBone=!0;class El extends Hn{constructor(e=null,t=1,n=1,r,i,a,o,s,l=dt,c=dt,u,d){super(null,a,o,s,l,c,r,i,u,d),this.image={data:e,width:t,height:n},this.magFilter=l,this.minFilter=c,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}El.prototype.isDataTexture=!0;const Ll=new gt,Rl=new gt;class Pl{constructor(e=[],t=[]){this.uuid=wn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){var 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 gt)}}calculateInverses(){for(let e=this.boneInverses.length=0,t=this.bones.length;e<t;e++){const n=new gt;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const r=this.bones[e];r&&(r.parent&&r.parent.isBone?(r.matrix.copy(r.parent.matrixWorld).invert(),r.matrix.multiply(r.matrixWorld)):r.matrix.copy(r.matrixWorld),r.matrix.decompose(r.position,r.quaternion,r.scale))}}update(){var n=this.bones,r=this.boneInverses,i=this.boneMatrices;const e=this.boneTexture;for(let e=0,t=n.length;e<t;e++){var a=n[e]?n[e].matrixWorld:Rl;Ll.multiplyMatrices(a,r[e]),Ll.toArray(i,16*e)}null!==e&&(e.needsUpdate=!0)}clone(){return new Pl(this.bones,this.boneInverses)}computeBoneTexture(){var e=Pn(Math.sqrt(4*this.bones.length));e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);var n=new El(t,e,e,pt,At);return this.boneMatrices=t,this.boneTexture=n,this.boneTextureSize=e,this}getBoneByName(n){for(let e=0,t=this.bones.length;e<t;e++){var r=this.bones[e];if(r.name===n)return r}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(n,r){this.uuid=n.uuid;for(let t=0,e=n.bones.length;t<e;t++){var i=n.bones[t];let e=r[i];void 0===e&&(console.warn("v3d.Skeleton: No bone found with UUID:",i),e=new Cl),this.bones.push(e),this.boneInverses.push((new gt).fromArray(n.boneInverses[t]))}return this.init(),this}toJSON(){const n={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};n.uuid=this.uuid;var r=this.bones,i=this.boneInverses;for(let e=0,t=r.length;e<t;e++){var a=r[e];n.bones.push(a.uuid);const o=i[e];n.boneInverses.push(o.toArray())}return n}}const Il=new gt,Nl=new gt,Dl=[],Ol=new ee;class Fl extends ee{constructor(e,t,n){super(e,t),this.instanceMatrix=new re(new Float32Array(16*n),16),this.instanceColor=null,this.count=n,this.frustumCulled=!1}copy(e){return super.copy(e),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,r){var t=this.matrixWorld,i=this.count;if(Ol.geometry=this.geometry,Ol.material=this.material,void 0!==Ol.material)for(let n=0;n<i;n++){this.getMatrixAt(n,Il),Nl.multiplyMatrices(t,Il),Ol.matrixWorld=Nl,Ol.raycast(e,Dl);for(let e=0,t=Dl.length;e<t;e++){const a=Dl[e];a.instanceId=n,a.object=this,r.push(a)}Dl.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new re(new Float32Array(3*this.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"})}}Fl.prototype.isInstancedMesh=!0;class Bl extends pi{constructor(e){super(),this.type="LineBasicMaterial",this.color=new _t(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,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.morphTargets=e.morphTargets,this}}Bl.prototype.isLineBasicMaterial=!0;const zl=new vt,Vl=new vt,Ul=new gt,Gl=new Mr,kl=new fr;class Wl extends he{constructor(e=new S,t=new Bl){super(),this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){var n=e.attributes.position;const r=[0];for(let e=1,t=n.count;e<t;e++)zl.fromBufferAttribute(n,e-1),Vl.fromBufferAttribute(n,e),r[e]=r[e-1],r[e]+=zl.distanceTo(Vl);e.setAttribute("lineDistance",new k(r,1))}else console.warn("v3d.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("v3d.Line.computeLineDistances() no longer supports v3d.Geometry. Use v3d.BufferGeometry instead.");return this}raycast(n,r){const e=this.geometry;var t=this.matrixWorld,i=n.params.Line.threshold,a=e.drawRange;if(null===e.boundingSphere&&e.computeBoundingSphere(),kl.copy(e.boundingSphere),kl.applyMatrix4(t),kl.radius+=i,!1!==n.ray.intersectsSphere(kl)){Ul.copy(t).invert(),Gl.copy(n.ray).applyMatrix4(Ul);var t=i/((this.scale.x+this.scale.y+this.scale.z)/3),o=t*t;const h=new vt,p=new vt,f=new vt,m=new vt;var s=this.isLineSegments?2:1;if(e.isBufferGeometry){const v=e.index;var l,c=e.attributes.position;if(null!==v)for(let e=Math.max(0,a.start),t=Math.min(v.count,a.start+a.count)-1;e<t;e+=s){var u=v.getX(e),d=v.getX(e+1),u=(h.fromBufferAttribute(c,u),p.fromBufferAttribute(c,d),Gl.distanceSqToSegment(h,p,m,f));o<u||(m.applyMatrix4(this.matrixWorld),(d=n.ray.origin.distanceTo(m))<n.near||d>n.far||r.push({distance:d,point:f.clone().applyMatrix4(this.matrixWorld),index:e,face:null,faceIndex:null,object:this}))}else for(let e=Math.max(0,a.start),t=Math.min(c.count,a.start+a.count)-1;e<t;e+=s)h.fromBufferAttribute(c,e),p.fromBufferAttribute(c,e+1),o<Gl.distanceSqToSegment(h,p,m,f)||(m.applyMatrix4(this.matrixWorld),(l=n.ray.origin.distanceTo(m))<n.near||l>n.far||r.push({distance:l,point:f.clone().applyMatrix4(this.matrixWorld),index:e,face:null,faceIndex:null,object:this}))}else e.isGeometry&&console.error("v3d.Line.raycast() no longer supports v3d.Geometry. Use v3d.BufferGeometry instead.")}}updateMorphTargets(){var e=this.geometry;if(e.isBufferGeometry){var t=e.morphAttributes,n=Object.keys(t);if(0<n.length){var r=t[n[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){var i=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{t=e.morphTargets;void 0!==t&&0<t.length&&console.error("v3d.Line.updateMorphTargets() does not support v3d.Geometry. Use v3d.BufferGeometry instead.")}}}Wl.prototype.isLine=!0;const Hl=new vt,Xl=new vt;class jl extends Wl{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){var n=e.attributes.position;const r=[];for(let e=0,t=n.count;e<t;e+=2)Hl.fromBufferAttribute(n,e),Xl.fromBufferAttribute(n,e+1),r[e]=0===e?0:r[e-1],r[e+1]=r[e]+Hl.distanceTo(Xl);e.setAttribute("lineDistance",new k(r,1))}else console.warn("v3d.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("v3d.LineSegments.computeLineDistances() no longer supports v3d.Geometry. Use v3d.BufferGeometry instead.");return this}}jl.prototype.isLineSegments=!0;class Yl extends Wl{constructor(e,t){super(e,t),this.type="LineLoop"}}Yl.prototype.isLineLoop=!0;class Zl extends pi{constructor(e){super(),this.type="PointsMaterial",this.color=new _t(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,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.morphTargets=e.morphTargets,this}}Zl.prototype.isPointsMaterial=!0;const ql=new gt,Ql=new Mr,Kl=new fr,Jl=new vt;class $l extends he{constructor(e=new S,t=new Zl){super(),this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(n,r){const e=this.geometry;var i=this.matrixWorld,t=n.params.Points.threshold,a=e.drawRange;if(null===e.boundingSphere&&e.computeBoundingSphere(),Kl.copy(e.boundingSphere),Kl.applyMatrix4(i),Kl.radius+=t,!1!==n.ray.intersectsSphere(Kl)){ql.copy(i).invert(),Ql.copy(n.ray).applyMatrix4(ql);var t=t/((this.scale.x+this.scale.y+this.scale.z)/3),o=t*t;if(e.isBufferGeometry){const c=e.index;var s=e.attributes.position;if(null!==c)for(let e=Math.max(0,a.start),t=Math.min(c.count,a.start+a.count);e<t;e++){var l=c.getX(e);Jl.fromBufferAttribute(s,l),ec(Jl,l,o,i,n,r,this)}else for(let e=Math.max(0,a.start),t=Math.min(s.count,a.start+a.count);e<t;e++)Jl.fromBufferAttribute(s,e),ec(Jl,e,o,i,n,r,this)}else console.error("v3d.Points.raycast() no longer supports v3d.Geometry. Use v3d.BufferGeometry instead.")}}updateMorphTargets(){var e=this.geometry;if(e.isBufferGeometry){var t=e.morphAttributes,n=Object.keys(t);if(0<n.length){var r=t[n[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){var i=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{t=e.morphTargets;void 0!==t&&0<t.length&&console.error("v3d.Points.updateMorphTargets() does not support v3d.Geometry. Use v3d.BufferGeometry instead.")}}}function ec(e,t,n,r,i,a,o){var s=Ql.distanceSqToPoint(e);if(s<n){const l=new vt;Ql.closestPointToPoint(e,l),l.applyMatrix4(r);n=i.ray.origin.distanceTo(l);n<i.near||n>i.far||a.push({distance:n,distanceToRay:Math.sqrt(s),point:l,index:t,face:null,object:o})}}$l.prototype.isPoints=!0;class tc extends Hn{constructor(t,e,n,r,i,a,o,s,l){super(t,e,n,r,i,a,o,s,l),this.format=void 0!==o?o:wt,this.minFilter=void 0!==a?a:ht,this.magFilter=void 0!==i?i:ht,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(function e(){c.needsUpdate=!0,t.requestVideoFrameCallback(e)})}clone(){return new this.constructor(this.image).copy(this)}update(){var e=this.image;!1=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}tc.prototype.isVideoTexture=!0;class nc extends Hn{constructor(e,t,n,r,i,a,o,s,l,c,u,d){super(null,a,o,s,l,c,r,i,u,d),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}nc.prototype.isCompressedTexture=!0;class rc extends Hn{constructor(e,t,n,r,i,a,o,s,l){super(e,t,n,r,i,a,o,s,l),this.needsUpdate=!0}}rc.prototype.isCanvasTexture=!0;class ic extends Hn{constructor(e,t,n,r,i,a,o,s,l,c){if((c=void 0!==c?c:Ze)!==Ze&&c!==qe)throw new Error("DepthTexture format must be either v3d.DepthFormat or v3d.DepthStencilFormat");super(null,r,i,a,o,s,c,n=void 0===(n=void 0===n&&c===Ze?V:n)&&c===qe?Ye:n,l),this.image={width:e,height:t},this.magFilter=void 0!==o?o:dt,this.minFilter=void 0!==s?s:dt,this.flipY=!1,this.generateMipmaps=!1}}ic.prototype.isDepthTexture=!0;class ac extends S{constructor(n=1,r=8,i=0,a=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:n,segments:r,thetaStart:i,thetaLength:a},r=Math.max(3,r);const t=[],o=[],s=[],l=[],c=new vt,u=new Be;o.push(0,0,0),s.push(0,0,1),l.push(.5,.5);for(let e=0,t=3;e<=r;e++,t+=3){var d=i+e/r*a;c.x=n*Math.cos(d),c.y=n*Math.sin(d),o.push(c.x,c.y,c.z),s.push(0,0,1),u.x=(o[t]/n+1)/2,u.y=(o[t+1]/n+1)/2,l.push(u.x,u.y)}for(let e=1;e<=r;e++)t.push(e,e+1,0);this.setIndex(t),this.setAttribute("position",new k(o,3)),this.setAttribute("normal",new k(s,3)),this.setAttribute("uv",new k(l,2))}static fromJSON(e){return new ac(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class oc extends S{constructor(p=1,f=1,t=1,m=8,r=1,e=!1,v=0,g=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:p,radiusBottom:f,height:t,radialSegments:m,heightSegments:r,openEnded:e,thetaStart:v,thetaLength:g};const _=this,x=(m=Math.floor(m),r=Math.floor(r),[]),y=[],b=[],M=[];let A=0;const i=[],w=t/2;let S=0;{const E=new vt,L=new vt;let n=0;var a=(f-p)/t;for(let e=0;e<=r;e++){const R=[];var o=e/r,s=o*(f-p)+p;for(let e=0;e<=m;e++){var l=e/m,c=l*g+v,u=Math.sin(c),c=Math.cos(c);L.x=s*u,L.y=-o*t+w,L.z=s*c,y.push(L.x,L.y,L.z),E.set(u,a,c).normalize(),b.push(E.x,E.y,E.z),M.push(l,1-o),R.push(A++)}i.push(R)}for(let t=0;t<m;t++)for(let e=0;e<r;e++){var d=i[e][t],h=i[e+1][t],T=i[e+1][t+1],C=i[e][t+1];x.push(d,h,C),x.push(h,T,C),n+=6}_.addGroup(S,n,0),S+=n}function n(t){var n=A;const r=new Be,i=new vt;let a=0;var o=!0===t?p:f,s=!0===t?1:-1;for(let e=1;e<=m;e++)y.push(0,w*s,0),b.push(0,s,0),M.push(.5,.5),A++;var l=A;for(let e=0;e<=m;e++){var c=e/m*g+v,u=Math.cos(c),c=Math.sin(c);i.x=o*c,i.y=w*s,i.z=o*u,y.push(i.x,i.y,i.z),b.push(0,s,0),r.x=.5*u+.5,r.y=.5*c*s+.5,M.push(r.x,r.y),A++}for(let e=0;e<m;e++){var d=n+e,h=l+e;!0===t?x.push(h,h+1,d):x.push(h+1,h,d),a+=3}_.addGroup(S,a,!0===t?1:2),S+=a}!1===e&&(0<p&&n(!0),0<f&&n(!1)),this.setIndex(x),this.setAttribute("position",new k(y,3)),this.setAttribute("normal",new k(b,3)),this.setAttribute("uv",new k(M,2))}static fromJSON(e){return new oc(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class sc extends oc{constructor(e=1,t=1,n=8,r=1,i=!1,a=0,o=2*Math.PI){super(0,e,t,n,r,i,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}static fromJSON(e){return new sc(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class lc extends S{constructor(n,t,e=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:n,indices:t,radius:e,detail:r};const i=[],a=[];var F=r,o=new vt,s=new vt,l=new vt;for(let e=0;e<t.length;e+=3){b(t[e+0],o),b(t[e+1],s),b(t[e+2],l);{c=void 0;u=void 0;d=void 0;h=void 0;p=void 0;f=void 0;m=void 0;var c=o;var u=s;var d=l;var h=F;const w=h+1,S=[];for(let t=0;t<=w;t++){S[t]=[];const T=c.clone().lerp(d,t/w);var p=u.clone().lerp(d,t/w),f=w-t;for(let e=0;e<=f;e++)0===e&&t===w?S[t][e]=T:S[t][e]=T.clone().lerp(p,e/f)}for(let t=0;t<w;t++)for(let e=0;e<2*(w-t)-1;e++){var m=Math.floor(e/2);e%2==0?(y(S[t][m+1]),y(S[t+1][m]),y(S[t][m])):(y(S[t][m+1]),y(S[t+1][m+1]),y(S[t+1][m]))}}}{var B=e;const C=new vt;for(let e=0;e<i.length;e+=3)C.x=i[e+0],C.y=i[e+1],C.z=i[e+2],C.normalize().multiplyScalar(B),i[e+0]=C.x,i[e+1]=C.y,i[e+2]=C.z}{const E=new vt;for(let e=0;e<i.length;e+=3){E.x=i[e+0],E.y=i[e+1],E.z=i[e+2];var z=A(E)/2/Math.PI+.5,V=function(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}(E)/Math.PI+.5;a.push(z,1-V)}{const L=new vt,R=new vt,P=new vt,I=new vt,N=new Be,D=new Be,O=new Be;for(let e=0,t=0;e<i.length;e+=9,t+=6){L.set(i[e+0],i[e+1],i[e+2]),R.set(i[e+3],i[e+4],i[e+5]),P.set(i[e+6],i[e+7],i[e+8]),N.set(a[t+0],a[t+1]),D.set(a[t+2],a[t+3]),O.set(a[t+4],a[t+5]),I.copy(L).add(R).add(P).divideScalar(3);var v=A(I);M(N,t+0,L,v),M(D,t+2,R,v),M(O,t+4,P,v)}}for(let e=0;e<a.length;e+=6){var g=a[e+0],_=a[e+2],x=a[e+4],U=Math.max(g,_,x),G=Math.min(g,_,x);.9<U&&G<.1&&(g<.2&&(a[e+0]+=1),_<.2&&(a[e+2]+=1),x<.2&&(a[e+4]+=1))}}function y(e){i.push(e.x,e.y,e.z)}function b(e,t){e*=3;t.x=n[0+e],t.y=n[1+e],t.z=n[2+e]}function M(e,t,n,r){r<0&&1===e.x&&(a[t]=e.x-1),0===n.x&&0===n.z&&(a[t]=r/2/Math.PI+.5)}function A(e){return Math.atan2(e.z,-e.x)}this.setAttribute("position",new k(i,3)),this.setAttribute("normal",new k(i.slice(),3)),this.setAttribute("uv",new k(a,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(e){return new lc(e.vertices,e.indices,e.radius,e.details)}}class cc extends lc{constructor(e=1,t=0){var n=(1+Math.sqrt(5))/2,r=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,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],[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 cc(e.radius,e.detail)}}const uc=new vt,dc=new vt,hc=new vt,pc=new ui;class fc extends S{constructor(e,t){if(super(),this.type="EdgesGeometry",this.parameters={thresholdAngle:t},t=void 0!==t?t:1,!0===e.isGeometry)console.error("v3d.EdgesGeometry no longer supports v3d.Geometry. Use v3d.BufferGeometry instead.");else{var n=Math.pow(10,4),r=Math.cos(Mn*t);const m=e.getIndex();var i=e.getAttribute("position"),a=(m||i).count;const v=[0,0,0];var o,s,l=["a","b","c"];const g=new Array(3),_={},x=[];for(let e=0;e<a;e+=3){m?(v[0]=m.getX(e),v[1]=m.getX(e+1),v[2]=m.getX(e+2)):(v[0]=e,v[1]=e+1,v[2]=e+2);const{a:y,b,c:M}=pc;if(y.fromBufferAttribute(i,v[0]),b.fromBufferAttribute(i,v[1]),M.fromBufferAttribute(i,v[2]),pc.getNormal(hc),g[0]=`${Math.round(y.x*n)},${Math.round(y.y*n)},`+Math.round(y.z*n),g[1]=`${Math.round(b.x*n)},${Math.round(b.y*n)},`+Math.round(b.z*n),g[2]=`${Math.round(M.x*n)},${Math.round(M.y*n)},`+Math.round(M.z*n),g[0]!==g[1]&&g[1]!==g[2]&&g[2]!==g[0])for(let e=0;e<3;e++){var c=(e+1)%3,u=g[e],d=g[c],h=pc[l[e]],p=pc[l[c]],f=u+"_"+d,d=d+"_"+u;d in _&&_[d]?(hc.dot(_[d].normal)<=r&&(x.push(h.x,h.y,h.z),x.push(p.x,p.y,p.z)),_[d]=null):f in _||(_[f]={index0:v[e],index1:v[c],normal:hc.clone()})}}for(const A in _)_[A]&&({index0:o,index1:s}=_[A],uc.fromBufferAttribute(i,o),dc.fromBufferAttribute(i,s),x.push(uc.x,uc.y,uc.z),x.push(dc.x,dc.y,dc.z));this.setAttribute("position",new k(x,3))}}}class mc{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("v3d.Curve: .getPoint() not implemented."),null}getPointAt(e,t){e=this.getUtoTmapping(e);return this.getPoint(e,t)}getPoints(t=5){const n=[];for(let e=0;e<=t;e++)n.push(this.getPoint(e/t));return n}getSpacedPoints(t=5){const n=[];for(let e=0;e<=t;e++)n.push(this.getPointAt(e/t));return n}getLength(){var e=this.getLengths();return e[e.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const n=[];let r,i=this.getPoint(0),a=0;n.push(0);for(let e=1;e<=t;e++)r=this.getPoint(e/t),a+=r.distanceTo(i),n.push(a),i=r;return this.cacheArcLengths=n}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){var n=this.getLengths();let r=0;var i=n.length;let a,o=(a=t||e*n[i-1],0),s=i-1,l;for(;o<=s;)if((l=n[r=Math.floor(o+(s-o)/2)]-a)<0)o=r+1;else{if(!(0<l)){s=r;break}s=r-1}if(n[r=s]===a)return r/(i-1);t=n[r],e=n[r+1],e=(a-t)/(e-t);return(r+e)/(i-1)}getTangent(e,t){let n=e-1e-4,r=e+1e-4;n<0&&(n=0),1<r&&(r=1);var e=this.getPoint(n),i=this.getPoint(r);const a=t||new(e.isVector2?Be:vt);return a.copy(i).sub(e).normalize(),a}getTangentAt(e,t){e=this.getUtoTmapping(e);return this.getTangent(e,t)}computeFrenetFrames(n,e){const t=new vt,r=[],i=[],a=[],o=new vt,s=new gt;for(let e=0;e<=n;e++){var l=e/n;r[e]=this.getTangentAt(l,new vt),r[e].normalize()}i[0]=new vt,a[0]=new vt;let c=Number.MAX_VALUE;var u,d=Math.abs(r[0].x),h=Math.abs(r[0].y),p=Math.abs(r[0].z);d<=c&&(c=d,t.set(1,0,0)),h<=c&&(c=h,t.set(0,1,0)),p<=c&&t.set(0,0,1),o.crossVectors(r[0],t).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let e=1;e<=n;e++)i[e]=i[e-1].clone(),a[e]=a[e-1].clone(),o.crossVectors(r[e-1],r[e]),o.length()>Number.EPSILON&&(o.normalize(),u=Math.acos(ft(r[e-1].dot(r[e]),-1,1)),i[e].applyMatrix4(s.makeRotationAxis(o,u))),a[e].crossVectors(r[e],i[e]);if(!0===e){let t=Math.acos(ft(i[0].dot(i[n]),-1,1));t/=n,0<r[0].dot(o.crossVectors(i[0],i[n]))&&(t=-t);for(let e=1;e<=n;e++)i[e].applyMatrix4(s.makeRotationAxis(r[e],t*e)),a[e].crossVectors(r[e],i[e])}return{tangents:r,normals:i,binormals:a}}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 vc extends mc{constructor(e=0,t=0,n=1,r=1,i=0,a=2*Math.PI,o=!1,s=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t){const n=t||new Be;var r=2*Math.PI;let i=this.aEndAngle-this.aStartAngle;for(t=Math.abs(i)<Number.EPSILON;i<0;)i+=r;for(;i>r;)i-=r;i<Number.EPSILON&&(i=t?0:r),!0!==this.aClockwise||t||(i===r?i=-r:i-=r);var a,o,t=this.aStartAngle+e*i;let s=this.aX+this.xRadius*Math.cos(t),l=this.aY+this.yRadius*Math.sin(t);return 0!==this.aRotation&&(e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),a=s-this.aX,o=l-this.aY,s=a*e-o*t+this.aX,l=a*t+o*e+this.aY),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}}vc.prototype.isEllipseCurve=!0;class gc extends vc{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.type="ArcCurve"}}function _c(){let i=0,a=0,o=0,s=0;function l(e,t,n,r){i=e,a=n,o=-3*e+3*t-2*n-r,s=2*e-2*t+n+r}return{initCatmullRom:function(e,t,n,r,i){l(t,n,i*(n-e),i*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,i,a,o){e=(t-e)/i-(n-e)/(i+a)+(n-t)/a,i=(n-t)/a-(r-t)/(a+o)+(r-n)/o;l(t,n,e*=a,i*=a)},calc:function(e){var t=e*e,n=t*e;return i+a*e+o*t+s*n}}}gc.prototype.isArcCurve=!0;const xc=new vt,yc=new _c,bc=new _c,Mc=new _c;class Ac extends mc{constructor(e=[],t=!1,n="centripetal",r=.5){super(),this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(r,e=new vt){const t=e;var e=this.points,n=e.length,r=(n-(this.closed?0:1))*r;let i=Math.floor(r),a=r-i;this.closed?i+=0<i?0:(Math.floor(Math.abs(i)/n)+1)*n:0===a&&i===n-1&&(i=n-2,a=1);let o,s;o=this.closed||0<i?e[(i-1)%n]:(xc.subVectors(e[0],e[1]).add(e[0]),xc);const l=e[i%n],c=e[(i+1)%n];if(s=this.closed||i+2<n?e[(i+2)%n]:(xc.subVectors(e[n-1],e[n-2]).add(e[n-1]),xc),"centripetal"===this.curveType||"chordal"===this.curveType){r="chordal"===this.curveType?.5:.25;let e=Math.pow(o.distanceToSquared(l),r),t=Math.pow(l.distanceToSquared(c),r),n=Math.pow(c.distanceToSquared(s),r);t<1e-4&&(t=1),e<1e-4&&(e=t),n<1e-4&&(n=t),yc.initNonuniformCatmullRom(o.x,l.x,c.x,s.x,e,t,n),bc.initNonuniformCatmullRom(o.y,l.y,c.y,s.y,e,t,n),Mc.initNonuniformCatmullRom(o.z,l.z,c.z,s.z,e,t,n)}else"catmullrom"===this.curveType&&(yc.initCatmullRom(o.x,l.x,c.x,s.x,this.tension),bc.initCatmullRom(o.y,l.y,c.y,s.y,this.tension),Mc.initCatmullRom(o.z,l.z,c.z,s.z,this.tension));return t.set(yc.calc(a),bc.calc(a),Mc.calc(a)),t}copy(n){super.copy(n),this.points=[];for(let e=0,t=n.points.length;e<t;e++){const r=n.points[e];this.points.push(r.clone())}return this.closed=n.closed,this.curveType=n.curveType,this.tension=n.tension,this}toJSON(){const n=super.toJSON();n.points=[];for(let e=0,t=this.points.length;e<t;e++){const r=this.points[e];n.points.push(r.toArray())}return n.closed=this.closed,n.curveType=this.curveType,n.tension=this.tension,n}fromJSON(n){super.fromJSON(n),this.points=[];for(let e=0,t=n.points.length;e<t;e++){var r=n.points[e];this.points.push((new vt).fromArray(r))}return this.closed=n.closed,this.curveType=n.curveType,this.tension=n.tension,this}}function wc(e,t,n,r,i){var t=.5*(r-t),i=.5*(i-n),a=e*e;return(2*n-2*r+t+i)*(e*a)+(-3*n+3*r-2*t-i)*a+t*e+n}function Sc(e,t,n,r){return(i=1-(i=e))*i*t+2*(1-e)*e*n+e*e*r;var i}function Tc(e,t,n,r,i){return(a=1-(a=e))*a*a*t+3*(a=1-e)*a*e*n+3*(1-e)*e*e*r+e*e*e*i;var a}class Cc extends mc{constructor(e=new Be,t=new Be,n=new Be,r=new Be){super(),this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new Be){const n=t;var t=this.v0,r=this.v1,i=this.v2,a=this.v3;return n.set(Tc(e,t.x,r.x,i.x,a.x),Tc(e,t.y,r.y,i.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}}Cc.prototype.isCubicBezierCurve=Ac.prototype.isCatmullRomCurve3=!0;class Ec extends mc{constructor(e=new vt,t=new vt,n=new vt,r=new vt){super(),this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new vt){const n=t;var t=this.v0,r=this.v1,i=this.v2,a=this.v3;return n.set(Tc(e,t.x,r.x,i.x,a.x),Tc(e,t.y,r.y,i.y,a.y),Tc(e,t.z,r.z,i.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 Lc extends mc{constructor(e=new Be,t=new Be){super(),this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Be){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 Be;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}}Lc.prototype.isLineCurve=Ec.prototype.isCubicBezierCurve3=!0;class Rc extends mc{constructor(e=new vt,t=new vt){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=e,this.v2=t}getPoint(e,t=new vt){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 Pc extends mc{constructor(e=new Be,t=new Be,n=new Be){super(),this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Be){const n=t;var t=this.v0,r=this.v1,i=this.v2;return n.set(Sc(e,t.x,r.x,i.x),Sc(e,t.y,r.y,i.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}}Pc.prototype.isQuadraticBezierCurve=!0;class Ic extends mc{constructor(e=new vt,t=new vt,n=new vt){super(),this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new vt){const n=t;var t=this.v0,r=this.v1,i=this.v2;return n.set(Sc(e,t.x,r.x,i.x),Sc(e,t.y,r.y,i.y),Sc(e,t.z,r.z,i.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 Nc extends mc{constructor(e=[]){super(),this.type="SplineCurve",this.points=e}getPoint(e,t=new Be){const n=t;var t=this.points,e=(t.length-1)*e,r=Math.floor(e),e=e-r,i=t[0===r?r:r-1],a=t[r],o=t[r>t.length-2?t.length-1:r+1],t=t[r>t.length-3?t.length-1:r+2];return n.set(wc(e,i.x,a.x,o.x,t.x),wc(e,i.y,a.y,o.y,t.y)),n}copy(n){super.copy(n),this.points=[];for(let e=0,t=n.points.length;e<t;e++){const r=n.points[e];this.points.push(r.clone())}return this}toJSON(){const n=super.toJSON();n.points=[];for(let e=0,t=this.points.length;e<t;e++){const r=this.points[e];n.points.push(r.toArray())}return n}fromJSON(n){super.fromJSON(n),this.points=[];for(let e=0,t=n.points.length;e<t;e++){var r=n.points[e];this.points.push((new Be).fromArray(r))}return this}}Nc.prototype.isSplineCurve=Ic.prototype.isQuadraticBezierCurve3=!0;var Dc=Object.freeze({__proto__:null,ArcCurve:gc,CatmullRomCurve3:Ac,CubicBezierCurve:Cc,CubicBezierCurve3:Ec,EllipseCurve:vc,LineCurve:Lc,LineCurve3:Rc,QuadraticBezierCurve:Pc,QuadraticBezierCurve3:Ic,SplineCurve:Nc});const Oc={triangulate:function(t,e,n=2){var r=e&&e.length,i=r?e[0]*n:t.length;let a=Fc(t,0,i,n,!0);var o=[];if(!a||a.next===a.prev)return o;let s,l,c,u,d,h,p;if(r&&(a=function(e,t,n,r){const i=[];let a,o,s,l,c;for(a=0,o=t.length;a<o;a++)s=t[a]*r,l=a<o-1?t[a+1]*r:e.length,(c=Fc(e,s,l,r,!1))===c.next&&(c.steiner=!0),i.push(function(e){let t=e,n=e;for(;(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next,t!==e;);return n}(c));for(i.sort(Vc),a=0;a<i.length;a++)!function(e,t){(t=function(e,t){let n=t;var r=e.x,i=e.y;let a=-1/0,o;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){var s=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=r&&s>a){if((a=s)===r){if(i===n.y)return n;if(i===n.next.y)return n.next}o=n.x<n.next.x?n:n.next}}}while(n=n.next,n!==t);if(!o)return null;if(r===a)return o;var l=o,c=o.x,u=o.y;let d=1/0,h;n=o;for(;r>=n.x&&n.x>=c&&r!==n.x&&Gc(i<u?r:a,i,c,u,i<u?a:r,i,n.x,n.y)&&(h=Math.abs(i-n.y)/(r-n.x),Yc(n,e)&&(h<d||h===d&&(n.x>o.x||n.x===o.x&&function(e,t){return kc(e.prev,e,t.prev)<0&&kc(t.next,e,e.next)<0}(o,n)))&&(o=n,d=h)),n=n.next,n!==l;);return o}(e,t))&&(e=Zc(t,e),Bc(t,t.next),Bc(e,e.next))}(i[a],n),n=Bc(n,n.next);return n}(t,e,a,n)),t.length>80*n){s=c=t[0],l=u=t[1];for(let e=n;e<i;e+=n)d=t[e],h=t[e+1],d<s&&(s=d),h<l&&(l=h),d>c&&(c=d),h>u&&(u=h);p=0!==(p=Math.max(c-s,u-l))?1/p:0}return zc(a,o,n,s,l,p),o}};function Fc(e,t,n,r,i){let a,o;if(i===0<function(n,r,i,a){let o=0;for(let e=r,t=i-a;e<i;e+=a)o+=(n[t]-n[e])*(n[e+1]+n[t+1]),t=e;return o}(e,t,n,r))for(a=t;a<n;a+=r)o=qc(a,e[a],e[a+1],o);else for(a=n-r;a>=t;a-=r)o=qc(a,e[a],e[a+1],o);return o&&Wc(o,o.next)&&(Qc(o),o=o.next),o}function Bc(e,t){if(!e)return e;t=t||e;let n=e,r;do{if(r=!1,n.steiner||!Wc(n,n.next)&&0!==kc(n.prev,n,n.next))n=n.next;else{if(Qc(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function zc(r,i,a,o,s,l,c){if(r){if(!c&&l){var u=r,d=o,h=s,p=l;let c=u;for(;null===c.z&&(c.z=Uc(c.x,c.y,d,h,p)),c.prevZ=c.prev,c.nextZ=c.next,(c=c.next)!==u;);c.prevZ.nextZ=null,c.prevZ=null;{var f=c;let e,t,n,r,i,a,o,s,l=1;do{for(t=f,f=null,i=null,a=0;t;){for(a++,n=t,o=0,e=0;e<l&&(o++,n=n.nextZ);e++);for(s=l;0<o||0<s&&n;)0!==o&&(0===s||!n||t.z<=n.z)?(t=(r=t).nextZ,o--):(n=(r=n).nextZ,s--),i?i.nextZ=r:f=r,r.prevZ=i,i=r;t=n}}while(i.nextZ=null,l*=2,1<a)}}let e=r,t,n;for(;r.prev!==r.next;)if(t=r.prev,n=r.next,l?function(e,t,n,r){var i=e.prev,a=e,o=e.next;if(0<=kc(i,a,o))return;var s=(i.x<a.x?i.x<o.x?i:o:a.x<o.x?a:o).x,l=(i.y<a.y?i.y<o.y?i:o:a.y<o.y?a:o).y,c=(i.x>a.x?i.x>o.x?i:o:a.x>o.x?a:o).x,u=(i.y>a.y?i.y>o.y?i:o:a.y>o.y?a:o).y,d=Uc(s,l,t,n,r),h=Uc(c,u,t,n,r);let p=e.prevZ,f=e.nextZ;for(;p&&p.z>=d&&f&&f.z<=h;){if(p!==e.prev&&p!==e.next&&Gc(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&0<=kc(p.prev,p,p.next))return;if(p=p.prevZ,f!==e.prev&&f!==e.next&&Gc(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&0<=kc(f.prev,f,f.next))return;f=f.nextZ}for(;p&&p.z>=d;){if(p!==e.prev&&p!==e.next&&Gc(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&0<=kc(p.prev,p,p.next))return;p=p.prevZ}for(;f&&f.z<=h;){if(f!==e.prev&&f!==e.next&&Gc(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&0<=kc(f.prev,f,f.next))return;f=f.nextZ}return 1}(r,o,s,l):function(e){var t=e.prev,n=e,r=e.next;if(0<=kc(t,n,r))return;let i=e.next.next;for(;i!==e.prev;){if(Gc(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&0<=kc(i.prev,i,i.next))return;i=i.next}return 1}(r))i.push(t.i/a),i.push(r.i/a),i.push(n.i/a),Qc(r),r=n.next,e=n.next;else if((r=n)===e){c?1===c?zc(r=function(e,t,n){let r=e;do{var i=r.prev,a=r.next.next;!Wc(i,a)&&Hc(i,r,r.next,a)&&Yc(i,a)&&Yc(a,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(a.i/n),Qc(r),Qc(r.next),r=e=a),r=r.next}while(r!==e);return Bc(r)}(Bc(r),i,a),i,a,o,s,l,2):2===c&&function(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){var s;if(o.i!==e.i&&function(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&&Hc(n,n.next,e,t))return 1}while(n=n.next,n!==e);return}(e,t)&&(Yc(e,t)&&Yc(t,e)&&function(e,t){let n=e,r=!1;var i=(e.x+t.x)/2,a=(e.y+t.y)/2;for(;n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next,n!==e;);return r}(e,t)&&(kc(e.prev,e,t.prev)||kc(e,t.prev,t))||Wc(e,t)&&0<kc(e.prev,e,e.next)&&0<kc(t.prev,t,t.next))}(o,e))return s=Zc(o,e),o=Bc(o,o.next),s=Bc(s,s.next),zc(o,t,n,r,i,a),zc(s,t,n,r,i,a);e=e.next}}while(o=o.next,o!==e)}(r,i,a,o,s,l):zc(Bc(r),i,a,o,s,l,1);break}}}function Vc(e,t){return e.x-t.x}function Uc(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Gc(e,t,n,r,i,a,o,s){return 0<=(i-o)*(t-s)-(e-o)*(a-s)&&0<=(e-o)*(r-s)-(n-o)*(t-s)&&0<=(n-o)*(a-s)-(i-o)*(r-s)}function kc(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Wc(e,t){return e.x===t.x&&e.y===t.y}function Hc(e,t,n,r){var i=jc(kc(e,t,n)),a=jc(kc(e,t,r)),o=jc(kc(n,r,e)),s=jc(kc(n,r,t));return i!==a&&o!==s||(0===i&&Xc(e,n,t)||(0===a&&Xc(e,r,t)||(0===o&&Xc(n,e,r)||!(0!==s||!Xc(n,t,r)))))}function Xc(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 jc(e){return 0<e?1:e<0?-1:0}function Yc(e,t){return kc(e.prev,e,e.next)<0?0<=kc(e,t,e.next)&&0<=kc(e,e.prev,t):kc(e,t,e.prev)<0||kc(e,e.next,t)<0}function Zc(e,t){const n=new Kc(e.i,e.x,e.y),r=new Kc(t.i,t.x,t.y),i=e.next,a=t.prev;return(e.next=t).prev=e,(n.next=i).prev=n,(r.next=n).prev=r,(a.next=r).prev=a,r}function qc(e,t,n,r){const i=new Kc(e,t,n);return r?(i.next=r.next,(i.prev=r).next.prev=i,r.next=i):(i.prev=i).next=i,i}function Qc(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 Kc(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class Jc{static area(n){var r=n.length;let i=0;for(let e=r-1,t=0;t<r;e=t++)i+=n[e].x*n[t].y-n[t].x*n[e].y;return.5*i}static isClockWise(e){return Jc.area(e)<0}static triangulateShape(e,t){var n=[];const r=[],i=[];$c(e),eu(n,e);let a=e.length;t.forEach($c);for(let e=0;e<t.length;e++)r.push(a),a+=t[e].length,eu(n,t[e]);const o=Oc.triangulate(n,r);for(let e=0;e<o.length;e+=3)i.push(o.slice(e,e+3));return i}}function $c(e){var t=e.length;2<t&&e[t-1].equals(e[0])&&e.pop()}function eu(t,n){for(let e=0;e<n.length;e++)t.push(n[e].x),t.push(n[e].y)}class tu extends S{constructor(n,J){super(),this.type="ExtrudeGeometry",this.parameters={shapes:n,options:J},n=Array.isArray(n)?n:[n];const $=this,ee=[],te=[];for(let e=0,t=n.length;e<t;e++)!function(e){const r=[],F=void 0!==J.curveSegments?J.curveSegments:12,p=void 0!==J.steps?J.steps:1;let n=void 0!==J.depth?J.depth:100,o=void 0===J.bevelEnabled||J.bevelEnabled,t=void 0!==J.bevelThickness?J.bevelThickness:6,i=void 0!==J.bevelSize?J.bevelSize:t-2,a=void 0!==J.bevelOffset?J.bevelOffset:0,f=void 0!==J.bevelSegments?J.bevelSegments:3;const s=J.extrudePath,B=void 0!==J.UVGenerator?J.UVGenerator:nu;void 0!==J.amount&&(console.warn("v3d.ExtrudeBufferGeometry: amount has been renamed to depth."),n=J.amount);let l,c=!1,u,d,h,m;s&&(l=s.getSpacedPoints(p),c=!0,o=!1,u=s.computeFrenetFrames(p,!1),d=new vt,h=new vt,m=new vt);o||(f=0,t=0,i=0,a=0);e=e.extractPoints(F);let v=e.shape;const g=e.holes,z=!Jc.isClockWise(v);if(z){v=v.reverse();for(let e=0,t=g.length;e<t;e++){const K=g[e];Jc.isClockWise(K)&&(g[e]=K.reverse())}}const _=Jc.triangulateShape(v,g),x=v;for(let e=0,t=g.length;e<t;e++){var V=g[e];v=v.concat(V)}function y(e,t,n){return t||console.error("v3d.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(n).add(e)}const b=v.length,M=_.length;function U(e,t,n){let r,i,a;var o=e.x-t.x,s=e.y-t.y,l=n.x-e.x,c=n.y-e.y,u=o*o+s*s;if(Math.abs(o*c-s*l)>Number.EPSILON){var d=Math.sqrt(u),h=Math.sqrt(l*l+c*c),p=t.x-s/d,t=t.y+o/d,d=((n.x-c/h-p)*c-(n.y+l/h-t)*l)/(o*c-s*l),n=(r=p+o*d-e.x,i=t+s*d-e.y,r*r+i*i);if(n<=2)return new Be(r,i);a=Math.sqrt(n/2)}else{let e=!1;o>Number.EPSILON?l>Number.EPSILON&&(e=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(s)===Math.sign(c)&&(e=!0),a=e?(r=-s,i=o,Math.sqrt(u)):(r=o,i=s,Math.sqrt(u/2))}return new Be(r/a,i/a)}const A=[];for(let e=0,t=x.length,n=t-1,r=e+1;e<t;e++,n++,r++)n===t&&(n=0),r===t&&(r=0),A[e]=U(x[e],x[n],x[r]);const w=[];let S,T=A.concat();for(let e=0,t=g.length;e<t;e++){var C=g[e];S=[];for(let e=0,t=C.length,n=t-1,r=e+1;e<t;e++,n++,r++)n===t&&(n=0),r===t&&(r=0),S[e]=U(C[e],C[n],C[r]);w.push(S),T=T.concat(S)}for(let e=0;e<f;e++){var G=e/f,k=t*Math.cos(G*Math.PI/2);const E=i*Math.sin(G*Math.PI/2)+a;for(let e=0,t=x.length;e<t;e++){var W=y(x[e],A[e],E);I(W.x,W.y,-k)}for(let e=0,t=g.length;e<t;e++){var H=g[e];S=w[e];for(let e=0,t=H.length;e<t;e++){var X=y(H[e],S[e],E);I(X.x,X.y,-k)}}}const E=i+a;for(let e=0;e<b;e++){var L=o?y(v[e],T[e],E):v[e];c?(h.copy(u.normals[0]).multiplyScalar(L.x),d.copy(u.binormals[0]).multiplyScalar(L.y),m.copy(l[0]).add(h).add(d),I(m.x,m.y,m.z)):I(L.x,L.y,0)}for(let t=1;t<=p;t++)for(let e=0;e<b;e++){var R=o?y(v[e],T[e],E):v[e];c?(h.copy(u.normals[t]).multiplyScalar(R.x),d.copy(u.binormals[t]).multiplyScalar(R.y),m.copy(l[t]).add(h).add(d),I(m.x,m.y,m.z)):I(R.x,R.y,n/p*t)}for(let e=f-1;0<=e;e--){var j=e/f,Y=t*Math.cos(j*Math.PI/2);const E=i*Math.sin(j*Math.PI/2)+a;for(let e=0,t=x.length;e<t;e++){var Z=y(x[e],A[e],E);I(Z.x,Z.y,n+Y)}for(let e=0,t=g.length;e<t;e++){var q=g[e];S=w[e];for(let e=0,t=q.length;e<t;e++){var P=y(q[e],S[e],E);c?I(P.x,P.y+l[p-1].y,l[p-1].x+Y):I(P.x,P.y,n+Y)}}}function Q(e,r){let t=e.length;for(;0<=--t;){var i=t;let n=t-1;n<0&&(n=e.length-1);for(let e=0,t=p+2*f;e<t;e++){var a=b*e,o=b*(e+1),s=r+n+a,l=r+n+o,c=(u=c=h=d=u=c=void 0,r+i+a),u=s,d=l,h=r+i+o;D(c),D(u),D(h),D(u),D(d),D(h),c=ee.length/3,O((u=B.generateSideWallUV($,ee,c-6,c-3,c-2,c-1))[0]),O(u[1]),O(u[3]),O(u[1]),O(u[2]),O(u[3])}}}function I(e,t,n){r.push(e),r.push(t),r.push(n)}function N(e,t,n){D(e),D(t),D(n);e=ee.length/3,t=B.generateTopUV($,ee,e-3,e-2,e-1);O(t[0]),O(t[1]),O(t[2])}function D(e){ee.push(r[3*e+0]),ee.push(r[3*e+1]),ee.push(r[3*e+2])}function O(e){te.push(e.x),te.push(e.y)}(function(){var e,t=ee.length/3;if(o){let t=0*b;for(let e=0;e<M;e++){var n=_[e];N(n[2]+t,n[1]+t,n[0]+t)}e=p+2*f,t=b*e;for(let e=0;e<M;e++){var r=_[e];N(r[0]+t,r[1]+t,r[2]+t)}}else{for(let e=0;e<M;e++){var i=_[e];N(i[2],i[1],i[0])}for(let e=0;e<M;e++){var a=_[e];N(a[0]+b*p,a[1]+b*p,a[2]+b*p)}}$.addGroup(t,ee.length/3-t,0)})(),function(){var e=ee.length/3;let n=0;Q(x,n),n+=x.length;for(let e=0,t=g.length;e<t;e++){var r=g[e];Q(r,n),n+=r.length}$.addGroup(e,ee.length/3-e,1)}()}(n[e]);this.setAttribute("position",new k(ee,3)),this.setAttribute("uv",new k(te,2)),this.computeVertexNormals()}toJSON(){var e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options,r=t,t=n,i=e;if(i.shapes=[],Array.isArray(r))for(let e=0,t=r.length;e<t;e++){var a=r[e];i.shapes.push(a.uuid)}else i.shapes.push(r.uuid);return void 0!==t.extrudePath&&(i.options.extrudePath=t.extrudePath.toJSON()),i}static fromJSON(n,r){const i=[];for(let e=0,t=n.shapes.length;e<t;e++){var a=r[n.shapes[e]];i.push(a)}var e=n.options.extrudePath;return void 0!==e&&(n.options.extrudePath=(new Dc[e.type]).fromJSON(e)),new tu(i,n.options)}}const nu={generateTopUV:function(e,t,n,r,i){var a=t[3*n],n=t[3*n+1],o=t[3*r],r=t[3*r+1],s=t[3*i],t=t[3*i+1];return[new Be(a,n),new Be(o,r),new Be(s,t)]},generateSideWallUV:function(e,t,n,r,i,a){var o=t[3*n],s=t[3*n+1],n=t[3*n+2],l=t[3*r],c=t[3*r+1],r=t[3*r+2],u=t[3*i],d=t[3*i+1],i=t[3*i+2],h=t[3*a],p=t[3*a+1],t=t[3*a+2];return Math.abs(s-c)<Math.abs(o-l)?[new Be(o,1-n),new Be(l,1-r),new Be(u,1-i),new Be(h,1-t)]:[new Be(s,1-n),new Be(c,1-r),new Be(d,1-i),new Be(p,1-t)]}};class ru extends lc{constructor(e=1,t=0){var 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 ru(e.radius,e.detail)}}class iu extends S{constructor(n,r=12,e=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:n,segments:r,phiStart:e,phiLength:i},r=Math.floor(r),i=ft(i,0,2*Math.PI);const a=[],o=[],s=[];var l=1/r;const c=new vt,u=new Be;for(let t=0;t<=r;t++){var d=e+t*l*i,h=Math.sin(d),p=Math.cos(d);for(let e=0;e<=n.length-1;e++)c.x=n[e].x*h,c.y=n[e].y,c.z=n[e].x*p,o.push(c.x,c.y,c.z),u.x=t/r,u.y=e/(n.length-1),s.push(u.x,u.y)}for(let t=0;t<r;t++)for(let e=0;e<n.length-1;e++){var f=e+t*n.length,m=f+n.length,v=f+n.length+1,g=f+1;a.push(f,m,g),a.push(m,v,g)}if(this.setIndex(a),this.setAttribute("position",new k(o,3)),this.setAttribute("uv",new k(s,2)),this.computeVertexNormals(),i===2*Math.PI){const x=this.attributes.normal.array,y=new vt,b=new vt,M=new vt;var _=r*n.length*3;for(let e=0,t=0;e<n.length;e++,t+=3)y.x=x[t+0],y.y=x[t+1],y.z=x[t+2],b.x=x[_+t+0],b.y=x[_+t+1],b.z=x[_+t+2],M.addVectors(y,b).normalize(),x[t+0]=x[_+t+0]=M.x,x[t+1]=x[_+t+1]=M.y,x[t+2]=x[_+t+2]=M.z}}static fromJSON(e){return new iu(e.points,e.segments,e.phiStart,e.phiLength)}}class au extends lc{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 au(e.radius,e.detail)}}class ou extends S{constructor(t,n,r){super(),this.type="ParametricGeometry",this.parameters={func:t,slices:n,stacks:r};const i=[],a=[],o=[],s=[];const l=new vt;var c=new vt,u=new vt;const d=new vt,h=new vt;t.length<3&&console.error("v3d.ParametricGeometry: Function must now modify a Vector3 as third parameter.");var p=n+1;for(let e=0;e<=r;e++){var f=e/r;for(let e=0;e<=n;e++){var m=e/n;t(m,f,c),a.push(c.x,c.y,c.z),0<=m-1e-5?(t(m-1e-5,f,u),d.subVectors(c,u)):(t(1e-5+m,f,u),d.subVectors(u,c)),0<=f-1e-5?(t(m,f-1e-5,u),h.subVectors(c,u)):(t(m,1e-5+f,u),h.subVectors(u,c)),l.crossVectors(d,h).normalize(),o.push(l.x,l.y,l.z),s.push(m,f)}}for(let t=0;t<r;t++)for(let e=0;e<n;e++){var v=t*p+e,g=t*p+e+1,_=(t+1)*p+e+1,x=(t+1)*p+e;i.push(v,g,x),i.push(g,_,x)}this.setIndex(i),this.setAttribute("position",new k(a,3)),this.setAttribute("normal",new k(o,3)),this.setAttribute("uv",new k(s,2))}}class su extends S{constructor(e=.5,t=1,n=8,r=1,i=0,a=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:a},n=Math.max(3,n);const o=[],s=[],l=[],c=[];let u=e;var d=(t-e)/(r=Math.max(1,r));const h=new vt,p=new Be;for(let e=0;e<=r;e++){for(let e=0;e<=n;e++){var f=i+e/n*a;h.x=u*Math.cos(f),h.y=u*Math.sin(f),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<r;e++){var m=e*(n+1);for(let e=0;e<n;e++){var v=e+m,g=v+n+1,_=v+n+2,x=v+1;o.push(v,g,x),o.push(g,_,x)}}this.setIndex(o),this.setAttribute("position",new k(s,3)),this.setAttribute("normal",new k(l,3)),this.setAttribute("uv",new k(c,2))}static fromJSON(e){return new su(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class lu extends S{constructor(t,h=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:h};const p=[],f=[],m=[],v=[];let n=0,g=0;if(!1===Array.isArray(t))r(t);else for(let e=0;e<t.length;e++)r(t[e]),this.addGroup(n,g,e),n+=g,g=0;function r(e){var n=f.length/3,e=e.extractPoints(h);let r=e.shape;const i=e.holes;!1===Jc.isClockWise(r)&&(r=r.reverse());for(let e=0,t=i.length;e<t;e++){const d=i[e];!0===Jc.isClockWise(d)&&(i[e]=d.reverse())}var a=Jc.triangulateShape(r,i);for(let e=0,t=i.length;e<t;e++){var o=i[e];r=r.concat(o)}for(let e=0,t=r.length;e<t;e++){var s=r[e];f.push(s.x,s.y,0),m.push(0,0,1),v.push(s.x,s.y)}for(let e=0,t=a.length;e<t;e++){var l=a[e],c=l[0]+n,u=l[1]+n,l=l[2]+n;p.push(c,u,l),g+=3}}this.setIndex(p),this.setAttribute("position",new k(f,3)),this.setAttribute("normal",new k(m,3)),this.setAttribute("uv",new k(v,2))}toJSON(){var e=super.toJSON(),n=this.parameters.shapes,r=e;if(r.shapes=[],Array.isArray(n))for(let e=0,t=n.length;e<t;e++){var i=n[e];r.shapes.push(i.uuid)}else r.shapes.push(n.uuid);return r}static fromJSON(n,r){const i=[];for(let e=0,t=n.shapes.length;e<t;e++){var a=r[n.shapes[e]];i.push(a)}return new lu(i,n.curveSegments)}}class cu extends S{constructor(n=1,r=8,i=6,a=0,o=2*Math.PI,s=0,l=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:n,widthSegments:r,heightSegments:i,phiStart:a,phiLength:o,thetaStart:s,thetaLength:l},r=Math.max(3,Math.floor(r)),i=Math.max(2,Math.floor(i));var c=Math.min(s+l,Math.PI);let u=0;const d=[],h=new vt,p=new vt,f=[],m=[],v=[],g=[];for(let e=0;e<=i;e++){const w=[];var _=e/i;let t=0;0==e&&0==s?t=.5/r:e==i&&c==Math.PI&&(t=-.5/r);for(let e=0;e<=r;e++){var x=e/r;h.x=-n*Math.cos(a+x*o)*Math.sin(s+_*l),h.y=n*Math.cos(s+_*l),h.z=n*Math.sin(a+x*o)*Math.sin(s+_*l),m.push(h.x,h.y,h.z),p.copy(h).normalize(),v.push(p.x,p.y,p.z),g.push(x+t,1-_),w.push(u++)}d.push(w)}for(let t=0;t<i;t++)for(let e=0;e<r;e++){var y=d[t][e+1],b=d[t][e],M=d[t+1][e],A=d[t+1][e+1];(0!==t||0<s)&&f.push(y,b,A),(t!==i-1||c<Math.PI)&&f.push(b,M,A)}this.setIndex(f),this.setAttribute("position",new k(m,3)),this.setAttribute("normal",new k(v,3)),this.setAttribute("uv",new k(g,2))}static fromJSON(e){return new cu(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class uu extends lc{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 uu(e.radius,e.detail)}}class du extends tu{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 S;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);var r=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(r,t),this.type="TextGeometry",this.parameters={text:e,parameters:t}}cloneWithText(e){var t=this.parameters.parameters;return new du(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 hu extends S{constructor(n=1,r=.4,i=8,a=6,o=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:n,tube:r,radialSegments:i,tubularSegments:a,arc:o},i=Math.floor(i),a=Math.floor(a);const s=[],l=[],c=[],u=[],d=new vt,h=new vt,p=new vt;for(let t=0;t<=i;t++)for(let e=0;e<=a;e++){var f=e/a*o,m=t/i*Math.PI*2;h.x=(n+r*Math.cos(m))*Math.cos(f),h.y=(n+r*Math.cos(m))*Math.sin(f),h.z=r*Math.sin(m),l.push(h.x,h.y,h.z),d.x=n*Math.cos(f),d.y=n*Math.sin(f),p.subVectors(h,d).normalize(),c.push(p.x,p.y,p.z),u.push(e/a),u.push(t/i)}for(let t=1;t<=i;t++)for(let e=1;e<=a;e++){var v=(a+1)*t+e-1,g=(a+1)*(t-1)+e-1,_=(a+1)*(t-1)+e,x=(a+1)*t+e;s.push(v,g,x),s.push(g,_,x)}this.setIndex(s),this.setAttribute("position",new k(l,3)),this.setAttribute("normal",new k(c,3)),this.setAttribute("uv",new k(u,2))}static fromJSON(e){return new hu(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class pu extends S{constructor(e=1,n=.4,r=64,i=8,a=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:n,tubularSegments:r,radialSegments:i,p:a,q:o},r=Math.floor(r),i=Math.floor(i);const s=[],l=[],c=[],u=[],d=new vt,h=new vt;var p=new vt,f=new vt;const m=new vt,v=new vt,g=new vt;for(let t=0;t<=r;++t){var _=t/r*a*Math.PI*2;S(_,a,o,e,p),S(.01+_,a,o,e,f),v.subVectors(f,p),g.addVectors(f,p),m.crossVectors(v,g),g.crossVectors(m,v),m.normalize(),g.normalize();for(let e=0;e<=i;++e){var x=e/i*Math.PI*2,y=-n*Math.cos(x),x=n*Math.sin(x);d.x=p.x+(y*g.x+x*m.x),d.y=p.y+(y*g.y+x*m.y),d.z=p.z+(y*g.z+x*m.z),l.push(d.x,d.y,d.z),h.subVectors(d,p).normalize(),c.push(h.x,h.y,h.z),u.push(t/r),u.push(e/i)}}for(let t=1;t<=r;t++)for(let e=1;e<=i;e++){var b=(i+1)*(t-1)+(e-1),M=(i+1)*t+(e-1),A=(i+1)*t+e,w=(i+1)*(t-1)+e;s.push(b,M,w),s.push(M,A,w)}function S(e,t,n,r,i){var a=Math.cos(e),o=Math.sin(e),n=n/t*e,t=Math.cos(n);i.x=r*(2+t)*.5*a,i.y=r*(2+t)*o*.5,i.z=r*Math.sin(n)*.5}this.setIndex(s),this.setAttribute("position",new k(l,3)),this.setAttribute("normal",new k(c,3)),this.setAttribute("uv",new k(u,2))}static fromJSON(e){return new pu(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class fu extends S{constructor(a,o=64,s=1,l=8,e=!1){super(),this.type="TubeGeometry",this.parameters={path:a,tubularSegments:o,radius:s,radialSegments:l,closed:e};const c=a.computeFrenetFrames(o,e),u=(this.tangents=c.tangents,this.normals=c.normals,this.binormals=c.binormals,new vt),d=new vt,n=new Be;let h=new vt;const p=[],f=[],r=[],i=[];for(let e=0;e<o;e++)t(e);t(!1===e?o:0);for(let t=0;t<=o;t++)for(let e=0;e<=l;e++)n.x=t/o,n.y=e/l,r.push(n.x,n.y);for(let t=1;t<=o;t++)for(let e=1;e<=l;e++){var m=(l+1)*(t-1)+(e-1),v=(l+1)*t+(e-1),g=(l+1)*t+e,_=(l+1)*(t-1)+e;i.push(m,v,_),i.push(v,g,_)}function t(e){h=a.getPointAt(e/o,h);var t=c.normals[e],n=c.binormals[e];for(let e=0;e<=l;e++){var r=e/l*Math.PI*2,i=Math.sin(r),r=-Math.cos(r);d.x=r*t.x+i*n.x,d.y=r*t.y+i*n.y,d.z=r*t.z+i*n.z,d.normalize(),f.push(d.x,d.y,d.z),u.x=h.x+s*d.x,u.y=h.y+s*d.y,u.z=h.z+s*d.z,p.push(u.x,u.y,u.z)}}this.setIndex(i),this.setAttribute("position",new k(p,3)),this.setAttribute("normal",new k(f,3)),this.setAttribute("uv",new k(r,2))}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new fu((new Dc[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class mu extends S{constructor(e){if(super(),this.type="WireframeGeometry",!0===e.isGeometry)console.error("v3d.WireframeGeometry no longer supports v3d.Geometry. Use v3d.BufferGeometry instead.");else{const c=[],u=[0,0],d={},h=new vt;if(null!==e.index){var t=e.attributes.position;const p=e.index;let n=e.groups;for(let e=0,t=(n=0===n.length?[{start:0,count:p.count,materialIndex:0}]:n).length;e<t;++e){var r=n[e],i=r.start;for(let t=i,e=i+r.count;t<e;t+=3)for(let e=0;e<3;e++){var a=p.getX(t+e),o=p.getX(t+(e+1)%3),a=(u[0]=Math.min(a,o),u[1]=Math.max(a,o),u[0]+","+u[1]);void 0===d[a]&&(d[a]={index1:u[0],index2:u[1]})}}for(const f in d){var s=d[f];h.fromBufferAttribute(t,s.index1),c.push(h.x,h.y,h.z),h.fromBufferAttribute(t,s.index2),c.push(h.x,h.y,h.z)}}else{var n=e.attributes.position;for(let t=0,e=n.count/3;t<e;t++)for(let e=0;e<3;e++){var l=3*t+e,l=(h.fromBufferAttribute(n,l),c.push(h.x,h.y,h.z),3*t+(e+1)%3);h.fromBufferAttribute(n,l),c.push(h.x,h.y,h.z)}}this.setAttribute("position",new k(c,3))}}}class vu extends du{constructor(n,r){super(n,r);{var i=this,a=r.alignX||"left",o=r.alignY||"bottom",s=(r=r.font,i.computeBoundingBox(),n.split(/\r\n|\r|\n/).length),l=i.boundingBox.max.x-i.boundingBox.min.x,c=i.boundingBox.max.y-i.boundingBox.min.y,u=c/(s+s-1);let e,t;switch(a){case"left":e=0;break;case"center":e=-.5*l;break;case"right":e=-l;break;default:t=0}var d=u*Math.abs(r.data.descender)/r.data.ascender;switch(o){case"topBaseline":t=0;break;case"top":t=-u;break;case"center":t=1<s?.5*c-u:-.5*u+.5*d;break;case"bottom":t=c-u+d;break;case"bottomBaseline":t=1<s?c-u-d:0;break;default:t=0}(0<Math.abs(e)||0<Math.abs(t))&&i.translate(e,t,0)}this.type="BlenderTextGeometry"}cloneWithText(e){var t=this.parameters.parameters;return new vu(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 gu extends S{constructor(e=50,n=10,t=!0,i=!0,a=!0,B=!0,z=!0){var V=[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],U=[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],o=(super(),n=Math.max(2,Math.floor(n)),3.15*(z?1:1.3)/2),s=e/o,e=(e=t?(8*n-4)*n:0)+(i?(16*n-4)*n:0)+(a?40*n*n:0);const l=new Uint32Array(3*e);e=t?4:0,e=((e+=i?8:0)+(a?20:0))*((n+1)*(n+1));const c=new Float32Array(3*e),u=new Float32Array(3*e),d=new Float32Array(2*e),h=new gt,p=(h.set(-1,3,-3,1,3,-6,3,0,-3,3,0,0,1,0,0,0),[]),G=[],k=[],f=[],m=[],v=[],g=[],W=[],H=[],_=new vt;let x,y,b,M,A=0,w=0;const S=new vt,X=new gt,j=new gt,T=new mt,C=new mt,Y=new mt,Z=new mt,q=new vt,Q=new vt,K=h.clone();K.transpose();var J=(e,t,n)=>!(c[3*e]===c[3*t]&&c[3*e+1]===c[3*t+1]&&c[3*e+2]===c[3*t+2]||c[3*e]===c[3*n]&&c[3*e+1]===c[3*n+1]&&c[3*e+2]===c[3*n+2]||c[3*t]===c[3*n]&&c[3*t+1]===c[3*n+1]&&c[3*t+2]===c[3*n+2]);for(let e=0;e<3;e++)v[e]=new gt;var $=t?32:28,E=n+1;let ee=0,L=0,R=0,te=0,P=0;for(let r=a?0:20;r<$;r++)if(i||r<20||28<=r){for(let n=0;n<3;n++){for(let t=0;t<4;t++)for(let e=0;e<4;e++)p[4*e+t]=U[3*V[16*r+4*t+e]+n],B&&20<=r&&r<28&&2!==n&&(p[4*e+t]*=1.077),z||2!==n||(p[4*e+t]*=1.3);X.set(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]),j.multiplyMatrices(X,h),v[n].multiplyMatrices(K,j)}for(let e=0;e<=n;e++){var I=e/n;for(let e=0;e<=n;e++){var N=e/n;for(M=4,y=b=1;M--;)G[M]=y,k[M]=b,y*=I,b*=N,3===M?(f[M]=m[M]=0,A=w=1):(f[M]=A*(3-M),m[M]=w*(3-M),A*=I,w*=N);T.fromArray(G),C.fromArray(k),Y.fromArray(f),Z.fromArray(m);for(let e=0;e<3;e++)(x=T.clone()).applyMatrix4(v[e]),g[e]=x.dot(C),(x=Y.clone()).applyMatrix4(v[e]),W[e]=x.dot(C),(x=T.clone()).applyMatrix4(v[e]),H[e]=x.dot(Z);q.fromArray(W),Q.fromArray(H),_.crossVectors(Q,q),_.normalize(),0===g[0]&&0===g[1]?S.set(0,g[2]>o?1:-1,0):S.set(_.x,_.z,-_.y),c[L++]=s*g[0],c[L++]=s*(g[2]-o),c[L++]=-s*g[1],u[R++]=S.x,u[R++]=S.y,u[R++]=S.z,d[te++]=1-N,d[te++]=1-I}}for(let t=0;t<n;t++)for(let e=0;e<n;e++){var D=ee*E*E+t*E+e,O=D+1,F=O+E,ne=D+E;J(D,O,F)&&(l[P++]=D,l[P++]=O,l[P++]=F),J(D,F,ne)&&(l[P++]=D,l[P++]=F,l[P++]=ne)}ee++}this.setIndex(new re(l,1)),this.setAttribute("position",new re(c,3)),this.setAttribute("normal",new re(u,3)),this.setAttribute("uv",new re(d,2)),this.computeBoundingSphere()}}var _u=Object.freeze({__proto__:null,BoxGeometry:oa,BoxBufferGeometry:oa,CircleGeometry:ac,CircleBufferGeometry:ac,ConeGeometry:sc,ConeBufferGeometry:sc,CylinderGeometry:oc,CylinderBufferGeometry:oc,DodecahedronGeometry:cc,DodecahedronBufferGeometry:cc,EdgesGeometry:fc,ExtrudeGeometry:tu,ExtrudeBufferGeometry:tu,IcosahedronGeometry:ru,IcosahedronBufferGeometry:ru,LatheGeometry:iu,LatheBufferGeometry:iu,OctahedronGeometry:au,OctahedronBufferGeometry:au,ParametricGeometry:ou,ParametricBufferGeometry:ou,PlaneGeometry:Sa,PlaneBufferGeometry:Sa,PolyhedronGeometry:lc,PolyhedronBufferGeometry:lc,RingGeometry:su,RingBufferGeometry:su,ShapeGeometry:lu,ShapeBufferGeometry:lu,SphereGeometry:cu,SphereBufferGeometry:cu,TetrahedronGeometry:uu,TetrahedronBufferGeometry:uu,TextGeometry:du,TextBufferGeometry:du,TorusGeometry:hu,TorusBufferGeometry:hu,TorusKnotGeometry:pu,TorusKnotBufferGeometry:pu,TubeGeometry:fu,TubeBufferGeometry:fu,WireframeGeometry:mu,BlenderTextGeometry:vu,BlenderTextBufferGeometry:vu,TeapotGeometry:gu,TeapotBufferGeometry:gu});class xu extends pi{constructor(e){super(),this.type="ShadowMaterial",this.color=new _t(0),this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this}}xu.prototype.isShadowMaterial=!0;class yu extends T{constructor(e){super(e),this.type="RawShaderMaterial"}}yu.prototype.isRawShaderMaterial=!0;class bu extends pi{constructor(e){super(),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new _t(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 _t(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=dn,this.normalScale=new Be(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.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.vertexTangents=!1,this.envMapParallaxType=0,this.envMapParallaxMatrix=new gt,this.envMapParallaxMatrixInv=new gt,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.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.flatShading=e.flatShading,this.vertexTangents=e.vertexTangents,this.envMapParallaxType=e.envMapParallaxType,this.envMapParallaxMatrix.copy(e.envMapParallaxMatrix),this.envMapParallaxMatrixInv.copy(e.envMapParallaxMatrixInv),this}}bu.prototype.isMeshStandardMaterial=!0;class Mu extends bu{constructor(e){super(),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Be(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,Object.defineProperty(this,"ior",{get:function(){return(1+.4*this.reflectivity)/(1-.4*this.reflectivity)},set:function(e){this.reflectivity=ft(2.5*(e-1)/(e+1),0,1)}}),this.sheen=null,this.transmission=0,this.transmissionMap=null,this.thickness=.01,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new _t(1,1,1),this.setValues(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.reflectivity=e.reflectivity,e.sheen?this.sheen=(this.sheen||new _t).copy(e.sheen):this.sheen=null,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}}Mu.prototype.isMeshPhysicalMaterial=!0;class Au extends pi{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new _t(16777215),this.specular=new _t(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _t(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=dn,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.flatShading=e.flatShading,this}}Au.prototype.isMeshPhongMaterial=!0;class wu extends pi{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new _t(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _t(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=dn,this.normalScale=new Be(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.morphTargets=!1,this.morphNormals=!1,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.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this}}wu.prototype.isMeshToonMaterial=!0;class Su extends pi{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=dn,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.morphTargets=!1,this.morphNormals=!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.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.flatShading=e.flatShading,this}}Su.prototype.isMeshNormalMaterial=!0;class Tu extends pi{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new _t(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _t(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this}}Tu.prototype.isMeshLambertMaterial=!0;class Cu extends pi{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new _t(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=dn,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.flatShading=e.flatShading,this}}class Eu extends Bl{constructor(e){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}Eu.prototype.isLineDashedMaterial=Cu.prototype.isMeshMatcapMaterial=!0;class Lu extends pi{constructor(e){super(),this.type="MeshMaskMaterial",this.morphTargets=!1,this.side=Ue,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.cameraNearFar=null,this.depthTexture=null,this.textureMatrix=null,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.morphTargets=e.morphTargets,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}}Lu.prototype.isMeshMaskMaterial=!0;class Ru{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){var n=this.parameterPositions;let r=this._cachedIndex,i=n[r],a=n[r-1];e:{t:{let e;n:{r:if(!(t<i)){for(var o=r+2;;){if(void 0===i){if(t<a)break r;return r=n.length,this._cachedIndex=r,this.afterEnd_(r-1,t,a)}if(r===o)break;if(a=i,t<(i=n[++r]))break t}e=n.length;break n}if(t>=a)break e;var s=n[1];t<s&&(r=2,a=s);for(var l=r-2;;){if(void 0===a)return this._cachedIndex=0,this.beforeStart_(0,t,i);if(r===l)break;if(i=a,t>=(a=n[--r-1]))break t}e=r,r=0}for(;r<e;){var c=r+e>>>1;t<n[c]?e=c:r=1+c}if(i=n[r],void 0===(a=n[r-1]))return this._cachedIndex=0,this.beforeStart_(0,t,i);if(void 0===i)return r=n.length,this._cachedIndex=r,this.afterEnd_(r-1,a,t)}this._cachedIndex=r,this.intervalChanged_(r,a,i)}return this.interpolate_(r,a,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}Ru.prototype.beforeStart_=Ru.prototype.copySampleValue_,Ru.prototype.afterEnd_=Ru.prototype.copySampleValue_;class Pu extends Ru{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}var Iu={},Nu=Iu;function Du(){this.N=0,this.first=null}function Ou(){this.first=null,this.last=null,this.N=0}function Fu(){this.first=null,this.last=null,this.map={}}function Bu(e){this.V=e,this.adjList=[],this.nodeInfo=[],this.edges={};for(var t=0;t<e;++t)this.adjList.push([]),this.nodeInfo.push({})}function zu(e){this.V=e,this.adjList=[],this.nodeInfo=[],this.edges={};for(var t=0;t<e;++t)this.adjList.push([]),this.nodeInfo.push({})}function Vu(e,t,n){this.v=e,this.w=t,this.weight=n}function Uu(e,t){this.s=t;var n=e.V;this.marked=[],this.edgeTo=[];for(var r=0;r<n;++r)this.marked.push(!1),this.edgeTo.push(-1);this.dfs(e,t)}function Gu(e,t){var n=e.V,r=(this.s=t,new Nu.Queue);r.enqueue(t),this.marked=[],this.edgeTo=[];for(var i=0;i<n;++i)this.marked.push(!1),this.edgeTo.push(-1);for(;!r.isEmpty();)for(var i=r.dequeue(),a=(this.marked[i]=!0,e.adj(i)),o=0;o<a.length;++o){var s=a[o];this.marked[s]||(this.edgeTo[s]=i,r.enqueue(s))}}function ku(e){this.postOrder=new Nu.Stack,this.marked=[];for(var t=e.V,n=0;n<t;++n)this.marked.push(!1);for(n=0;n<t;++n)this.marked[n]||this.dfs(e,n)}Nu.less=function(e,t,n){return n(e,t)<0},Nu.exchange=function(e,t,n){var r=e[t];e[t]=e[n],e[n]=r},Nu.StackNode=function(e){this.value=e,this.next=null},Du.prototype.push=function(e){this.first=this._push(this.first,e)},Du.prototype._push=function(e,t){if(null==e)return this.N++,new Nu.StackNode(t);var n=e;return this.N++,(e=new Nu.StackNode(t)).next=n,e},Du.prototype.pop=function(){var e,t;if(null!=this.first)return e=this.first,t=e.value,this.first=e.next,this.N--,t},Du.prototype.size=function(){return this.N},Du.prototype.isEmpty=function(){return 0==this.N},Du.prototype.peep=function(){if(null!=this.first)return this.first.value},Du.prototype.toArray=function(){for(var e=[],t=this.first;null!=t;)e.push(t.value),t=t.next;return e},Nu.Stack=Du,Nu.QueueNode=function(e){this.value=e,this.next=null},Ou.prototype.enqueue=function(e){var t=this.last;this.last=new Nu.QueueNode(e),null!=t&&(t.next=this.last),null==this.first&&(this.first=this.last),this.N++},Ou.prototype.dequeue=function(){var e,t;if(null!=this.first)return e=this.first,t=e.value,this.first=e.next,null==this.first&&(this.last=null),this.N--,t},Ou.prototype.size=function(){return this.N},Ou.prototype.isEmpty=function(){return 0==this.N},Ou.prototype.toArray=function(){for(var e=[],t=this.first;null!=t;)e.push(t.value),t=t.next;return e},Nu.Queue=Ou,Nu.LinkMapNode=function(e){this.value=e,this.prev=null,this.next=null},Fu.prototype.push=function(e,t){this.map[t]=e,null===this.first?this.first=e:(this.last.next=e).prev=this.last,this.last=e},Fu.prototype.removeNodeByKey=function(e){var t=this.map[e],n=t.prev,t=t.next;null!==n&&null!==t?(n.next=t).prev=n:null===n&&null!==t?(this.first=t).prev=null:null!==n&&null===t?(this.last=n).next=null:(this.first=null,this.last=null),delete this.map[e]},Nu.LinkMap=Fu,Bu.prototype.addNewEdge=function(e,t){this.adjList[e].push(t),this.adjList[t].push(e);var n=t<e?t+"_"+e:e+"_"+t;this.edges[n]=new Nu.Edge(e,t,0)},Bu.prototype.adj=function(e){return this.adjList[e]},Bu.prototype.node=function(e){return this.nodeInfo[e]},Bu.prototype.len=function(){return this.V},Bu.prototype.edge=function(e,t){e=t<e?t+"_"+e:e+"_"+t;return e in this.edges?this.edges[e]:null},Nu.Graph=Bu,zu.prototype.removeAll=function(){this.V=0,this.adjList=[],this.nodeInfo=[],this.edges={}},zu.prototype.addNode=function(e){e=e||{},this.V++,this.adjList.push([]),this.nodeInfo.push(e)},zu.prototype.addNewEdge=function(e,t){this.adjList[e].push(t);var n=e+"_"+t,e=new Nu.Edge(e,t,0);return this.edges[n]=e},zu.prototype.addEdge=function(e){var t=e.v,n=e.w,t=(this.adjList[t].push(n),t+"_"+n);this.edges[t]=e},zu.prototype.removeEdge=function(e,t){for(var n=this.adjList[e],r=0;r<n.length;r++)n[r]==t&&(n.splice(r,1),r--);e=e+"_"+t;e in this.edges&&delete this.edges[e]},zu.prototype.edge=function(e,t){e=e+"_"+t;return e in this.edges?this.edges[e]:null},zu.prototype.adj=function(e){return this.adjList[e]},zu.prototype.node=function(e){return this.nodeInfo[e]},zu.prototype.nodeIndex=function(e){for(var t=0;t<this.V;++t)if(this.nodeInfo[t]==e)return t;return-1},zu.prototype.reverse=function(){for(var e=new zu(this.V),t=0;t<this.V;++t)for(var n=this.adjList[t],r=0;r<n.length;++r){var i=n[r];e.addNewEdge(i,t)}return e},zu.prototype.len=function(){return this.V},zu.prototype.findInEdges=function(e){for(var t=[],n=0;n<this.V;n++)for(var r=this.adjList[n],i=0;i<r.length;i++)r[i]==e&&t.push(this.edge(n,e));return t},zu.prototype.findOutEdges=function(e){for(var t=[],n=this.adjList[e],r=0;r<n.length;r++)t.push(this.edge(e,n[r]));return t},zu.prototype.disconnect=function(e,t){this.adjList[e].splice(0);for(var n=0;n<this.V;n++){for(var r=this.adjList[n],i=0;i<r.length;i++)r[i]==e&&(r.splice(i,1),i--);var a=n+"_"+e;a in this.edges&&delete this.edges[a],(a=e+"_"+n)in this.edges&&delete this.edges[a]}if(t){for(var o=new zu(this.V-1),n=0;n<this.V;n++)if(n!=e)for(r=this.adjList[n],i=0;i<r.length;i++){var s=r[i],l=e<n?n-1:n,c=e<s?s-1:s,s=this.edge(n,s).copy();s.v=l,s.w=c,o.addEdge(s)}this.V--,this.adjList=o.adjList,this.nodeInfo.splice(e,1),this.edges=o.edges}},zu.prototype.insert=function(e,t,n){for(var r=this.V,i=e.V,a=0;a<i;a++){this.adjList.push([]),this.nodeInfo.push(function(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}(e.nodeInfo[a]));for(var o=e.adjList[a],s=0;s<o.length;s++){var l=o[s];(c=e.edge(a,l).copy()).v+=r,c.w+=r,this.addEdge(c)}}this.V+=i;for(s=0;s<t.length;s++)(c=t[s].copy()).w+=r,this.addEdge(c);for(var c,s=0;s<n.length;s++)(c=n[s].copy()).v+=r,this.addEdge(c)},zu.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 r=this.adjList[n],i=0;i<r.length;i++)t+=n+" -> "+r[i]+";"}t+="}",console.log(t)},Nu.DiGraph=zu,Vu.prototype.either=function(){return this.v},Vu.prototype.other=function(e){return e==this.v?this.w:this.v},Vu.prototype.from=function(){return this.v},Vu.prototype.to=function(){return this.w},Vu.prototype.copy=function(){var e,t=new Vu(0,0,0);for(e in this)this.hasOwnProperty(e)&&(t[e]=this[e]);return t},Nu.Edge=Vu,Uu.prototype.dfs=function(e,t){this.marked[t]=!0;for(var n=e.adj(t),r=0;r<n.length;++r){var i=n[r];this.marked[i]||(this.edgeTo[i]=t,this.dfs(e,i))}},Uu.prototype.hasPathTo=function(e){return this.marked[e]},Uu.prototype.pathTo=function(e){var t=new Nu.Stack;if(e==this.s)return[e];for(var n=e;n!=this.s;n=this.edgeTo[n])t.push(n);return t.push(this.s),t.toArray()},Nu.DepthFirstSearch=Uu,Gu.prototype.hasPathTo=function(e){return this.marked[e]},Gu.prototype.pathTo=function(e){var t=new Nu.Stack;if(e==this.s)return[e];for(var n=e;n!=this.s;n=this.edgeTo[n])t.push(n);return t.push(this.s),t.toArray()},Nu.BreadthFirstSearch=Gu,ku.prototype.dfs=function(e,t){this.marked[t]=!0;for(var n=e.adj(t),r=0;r<n.length;++r){var i=n[r];this.marked[i]||this.dfs(e,i)}this.postOrder.push(t)},ku.prototype.order=function(){return this.postOrder.toArray()},Nu.TopologicalSort=ku;var Wu=[[-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]],Hu=[[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]],Xu=function(e,t,n,r,i){return Wu[e][540*t+54*(n-1)+9*r+i]},ju=function(e,t,n,r){return Hu[e][60*t+6*(n-1)+r]};function Yu(e,r,i,a,o){return qu(e).reduce(function(e,t,n){return e+t*Xu(r,i,a,n,o)},0)}function Zu(e,r,i,a){return qu(e).reduce(function(e,t,n){return e+t*ju(r,i,a,n)},0)}function qu(e){e=Math.pow(2*e/Math.PI,1/3);return[Math.pow(1-e,5),5*Math.pow(1-e,4)*e,10*Math.pow(1-e,3)*Math.pow(e,2),10*Math.pow(1-e,2)*Math.pow(e,3),5*(1-e)*Math.pow(e,4),Math.pow(e,5)]}var Qu=function(e,t,n,r){for(var i=new Array(9),a=Math.trunc(e),o=e-a,s=0;s<9;s++){var l=Yu(n,r,0,a,s),c=Yu(n,r,1,a,s);i[s]=(1-t)*(1-o)*l+t*(1-o)*c,10!=a&&(l=Yu(n,r,0,a+1,s),c=Yu(n,r,1,a+1,s),i[s]+=(1-t)*o*l+t*o*c)}return i},Ku=function(e,t,n,r){var i=Math.trunc(e),e=e-i,a=(1-t)*(1-e)*Zu(n,r,0,i)+t*(1-e)*Zu(n,r,1,i);return 10!=i&&(a+=(1-t)*e*Zu(n,r,0,i+1)+t*e*Zu(n,r,1,i+1)),a};class Ju extends Ru{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,l=s-o,c=(n-t)/(r-t),u=1-c;for(let e=0;e!==o;++e)i[e]=a[l+e]*u+a[s+e]*c;return i}}var $u=[[.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]],ed=[[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]],td=function(e,t,n){return $u[e][2*t+n]},nd=function(e){return ed[e]};function rd(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 id={getDistParams:function(e,t){for(var n=new Array(5),r=0;r<5;r++)n[r]=td(t,r,0)*e+td(t,r,1);return n},getZenithParams:function(e,t,n){switch(n){case 0:var r=nd(n),i=new mt(r[0],r[1],r[2],r[3]),a=Math.tan((4/9-e/120)*(Math.PI-2*t)),a=new mt(e*a,a,e,1);return.06*i.dot(a)/rd(this.getDistParams(e,n),0,t);case 1:case 2:var r=nd(n),a=Math.pow(t,2),o=Math.pow(t,3),s=r[0]*o+r[1]*a+r[2]*t+r[3],l=r[4]*o+r[5]*a+r[6]*t+r[7],o=r[8]*o+r[9]*a+r[10]*t+r[11],i=new vt(s,l,o);return new vt(Math.pow(e,2),e,1).dot(i)/rd(this.getDistParams(e,n),0,t)}},getSunIlluminance:function(e,t){var n=[0,0,0];if(e[1]<0)return n;for(var r,i=[.605,.54,.445],a=[12.25,7.5,.3],o=.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(i[c],-4.08)),d=Math.exp(-s*o*Math.pow(i[c],-1.3)),h=Math.exp(.0035*-a[c]*s);n[c]=128e3*l[c]/(.212671*(r=l[c])+.71516*r+.072169*r),n[c]*=u*d*h}return n},getSunIntegral:function(e,t,n,r){function i(e){return e*e}var a=1-cos(e),e=((i(Math.PI)-2*i(e-t))*cos(e)-i(Math.PI)*cos(t))/(2*(e-t+Math.PI)*(-e+t+Math.PI)),t=n*((.0892351-.00247875*i(n))*sin(n)+cube(n)+24*n+.029745*n*cos(n))/i(i(n)+36);return 2*Math.PI*(a+e+r*t)}};class ad{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(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,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(ft(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}var od=256,sd=512,ld={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:5,"BUMP_<2.81_BL":3,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 cd extends pi{constructor(C){super();var E,_e=this;function L(e,t){for(var n=e.node(t),r=(n.originData.type,0);r<n.originData.inputs.length;r++)R(e,t,n.originData,r)}function R(e,t,n,r,i){if(!ye(e,t,r)){var a=n.inputs[r],o={name:n.name+" "+(i=i||"Input "+r),type:"",inputs:[],outputs:[]};switch(Oe(a)){case"float":o.type="VALUE"+n.type.slice(-3),o.outputs.push(a);break;case"vec3":o.type="RGB"+n.type.slice(-3);var s=a.slice();s.push(1),o.outputs.push(s);break;case"vec4":o.type="RGB"+n.type.slice(-3),o.outputs.push(a);break;default:throw new Error("Unsupported group input")}e.addNode({originData:o});i=new Iu.Edge(e.len()-1,t,0),t=(i.connections=[],{from:0,to:r});return i.connections.push(t),e.addEdge(i),1}}function P(e,t){for(var n=0;n<e.len();n++)if(e.node(n).originData.type==t)return n;return-1}function xe(e,t){Array.isArray(t)||(t=[t]);for(var n=0,r=0;r<e.len();r++)for(var i=e.node(r),a=0;a<t.length;a++){var o=t[a];i.originData.type==o&&n++}return n}function I(e,t,n){for(var r=0;r<e.length;r++){var i=e[r];if(i.from()==t&&i.to()==n)return i}return null}function N(e){return!(!D(e)&&"FALLOFF_MX"!=e)}function D(e){return"BITMAP_ENV_MX"==e||"REFLECT_REFRACT_MX"==e}function Ce(e,t){switch(e){case"BITMAP_ENV_MX":return 5==t;case"FALLOFF_MX":return 2==t;case"MATERIAL_MX":return 8==t;case"PHYSICAL_MX":return 21==t||22==t;case"REFLECT_REFRACT_MX":return 0==t;default:return!1}}function O(e){return-1<e.type.indexOf("uniform")}function F(e){return-1<e.type.indexOf("varying")}function Ee(e,t){return t=xt(t)?t:"color",_e.nodeVCAliases[e]||t}function Le(e,t,n,r){e=new El(e,t,1,n,r,Hn.DEFAULT_MAPPING,ut,ut,ht,ht);return e.needsUpdate=!0,e}function Re(e){switch(e){case on:return"1";case sn:return"2";default:return"0"}}function B(e){for(var t=0,n=0,F=0,B=0,r=0;r<e.len();r++){var i=(N=(I=e.node(r)).originData).type;I.attributes=[],I.params=[],I.inputFactors=[],I.inputs=[],I.outputs=[],xt(N.inputFactors)&&(I.inputFactors=N.inputFactors.slice(0));for(var a=0;a<N.outputs.length;a++){var z=N.outputs[a],z=N.outputTypes?N.outputTypes[a]:Oe(z);I.outputs.push({name:i.toLowerCase()+"_out"+a+"_n"+r,type:z,clamp:!1,normalize:!1})}switch("OUTPUT_MATERIAL_BL"!=i&&"OUTPUT_WORLD_BL"!=i&&"OUTPUT_MX"!=i&&"OUTPUT_MY"!=i&&"SHADING_ENGINE_MY"!=i&&("SKYDOME_LIGHT_AR"!=i||xt(N.texture))||I.outputs.push({name:"outgoingLight",type:"",clamp:!1,normalize:!1}),i){case"ATAN_AR":I.params.push(we(N.units));break;case"CLAMP_AR":I.params.push(we(N.mode));break;case"COLOR_CONVERT_AR":I.params.push(we(N.from)),I.params.push(we(N.to));break;case"COLOR_TO_FLOAT_AR":I.params.push(we(N.mode));break;case"CHECKERBOARD_AR":var o=Se(P=N.uvIndex?"uv"+String(N.uvIndex+1):"uv",2);I.attributes.push({name:P,type:"attribute vec2"}),I.params.push(o);break;case"COMPOSITE_AR":I.params.push(we(N.operation)),I.params.push(we(N.alphaOperation));break;case"FACING_RATIO_AR":I.params.push(we("normal"));break;case"COLOR_TO_FLOAT_AR":I.params.push(we(N.mode));break;case"COMPARE_AR":I.params.push(we(N.test));break;case"FACING_RATIO_AR":I.params.push(we("normal"));break;case"FLOAT_TO_INT_AR":I.params.push(we(N.mode));break;case"IMAGE_AR":var s=Me(i,N.texture),l=(I.params.push(s),_e.nodeTextures[s.name].encoding);I.params.push(we(Re(l)));break;case"LAMBERT_AR":I.params.push(we("geometryNormal"));break;case"LENGTH_AR":I.params.push(we(N.mode));break;case"MAP_TO_MTL_AR":I.params.push(Ae(N.opaqueEnabled));break;case"MIX_SHADER_AR":I.params.push(we(N.mode));break;case"NORMAL_MAP_AR":var o=Se(P="tangent",4);I.attributes.push({name:P,type:"attribute vec4"}),I.params.push(o);break;case"RGB_TO_FLOAT_AR":case"RGB_TO_VECTOR_AR":case"RGBA_TO_FLOAT_AR":case"RGB_TO_VECTOR_AR":I.params.push(we(N.mode));break;case"SHADOW_MATTE_AR":I.params.push(we("normal"));break;case"SHUFFLE_AR":I.params.push(we(N.channelR)),I.params.push(we(N.channelG)),I.params.push(we(N.channelB)),I.params.push(we(N.channelA));break;case"SKYDOME_LIGHT_AR":xt(N.texture)&&(s=Me(i,N.texture),I.params.push(s),l=_e.nodeTextures[s.name].encoding,I.params.push(we(Re(l))),I.params.push(we("normal")));break;case"STANDARD_SURFACE_AR":I.params.push(we("geometryNormal"));var V=void 0===N.thinWalled||N.thinWalled;I.params.push(Ae(V)),(0<N.inputs[15]||ye(e,r,15))&&(_e.defines.CLEARCOAT=""),(0<N.inputs[18]||ye(e,r,18))&&(_e.defines.USE_SHEEN=""),I.inputFactors.length=0;break;case"TRIGO_AR":I.params.push(we(N.function)),I.params.push(we(N.units));break;case"TWO_SIDED_AR":I.params.push(we("FRONT_FACING_VALUE"));break;case"VECTOR_TO_RGB_AR":I.params.push(we(N.mode));break;case"ATTRIBUTE_BL":(P=Ee(N.colorLayer,""))?(o=Se(P,4),I.attributes.push({name:P,type:"attribute vec4"}),I.params.push(o)):I.params.push(we("vec4(0.0, 0.0, 0.0, 1.0)"));break;case"BSDF_DIFFUSE_BL":case"BSDF_GLASS_BL":case"BSDF_GLOSSY_BL":I.params.push(we("geometryNormal"));break;case"BSDF_PRINCIPLED_BL":I.params.push(we("geometryNormal")),N.inputs.length<=23?((0<N.inputs[12]||ye(e,r,12))&&(_e.defines.CLEARCOAT=""),(0<N.inputs[10]||ye(e,r,10))&&(_e.defines.USE_SHEEN="")):((0<N.inputs[14]||ye(e,r,14))&&(_e.defines.CLEARCOAT=""),(0<N.inputs[12]||ye(e,r,12))&&(_e.defines.USE_SHEEN=""));break;case"BSDF_REFRACTION_BL":I.params.push(we("geometryNormal")),I.params.push(we("BSDF_REFRACTION_"+N.distribution));break;case"BUMP_BL":I.params.push(be(N.invert));break;case"CAMERA_BL":I.params.push(we("vViewPosition")),0<xe(e,"OUTPUT_MATERIAL_BL")||0<xe(e,"OUTPUT_WORLD_BL")?I.params.push(Ae(!0)):I.params.push(Ae(!1));break;case"CURVE_RGB_BL":case"CURVE_VEC_BL":A=_e.useFloatTex?(M=new Float32Array(1024),1):(M=new Uint8Array(1024),255);for(var c,u,d,h,p=N.curveData.length/od,a=0;a<od;a++)h=3<p?(c=A*N.curveData[p*a],u=A*N.curveData[p*a+1],d=A*N.curveData[p*a+2],A*N.curveData[p*a+3]):(c=A*(N.curveData[p*a]/2+.5),u=A*(N.curveData[p*a+1]/2+.5),d=A*(N.curveData[p*a+2]/2+.5),A),M[4*a]=ft(c,0,A),M[4*a+1]=ft(u,0,A),M[4*a+2]=ft(d,0,A),M[4*a+3]=ft(h,0,A);var f=Le(M,od,pt,_e.useFloatTex?At:Mt),m=cd.nodeTexUniName(i,t);_e.nodeTextures[m]=f,I.params.push(Me(i,t)),t++;break;case"EEVEE_SPECULAR_BL":I.params.push(we("geometryNormal")),(0<N.inputs[6]||ye(e,r,6))&&(_e.defines.CLEARCOAT="");break;case"FRESNEL_BL":case"LAYER_WEIGHT_BL":I.params.push(we("vViewPosition"));break;case"GRADIENT_RAMP_MX":A=_e.useFloatTex?(M=new Float32Array(2048),1):(M=new Uint8Array(2048),255);for(a=0;a<sd;a++)c=A*N.gradientData[3*a],u=A*N.gradientData[3*a+1],d=A*N.gradientData[3*a+2],h=1,M[4*a]=ft(c,0,A),M[4*a+1]=ft(u,0,A),M[4*a+2]=ft(d,0,A),M[4*a+3]=ft(h,0,A);f=Le(M,sd,pt,_e.useFloatTex?At:Mt),m=cd.nodeTexUniName(i,t);_e.nodeTextures[m]=f,I.params.push(Me(i,t)),t++,I.params.push(we(Te("int",N.gradientType)));var o=Se(P=N.uvIndex?"uv"+String(N.uvIndex+1):"uv",2),U=(I.attributes.push({name:P,type:"attribute vec2"}),I.params.push(o),I.params.push(we("geometryNormal")),I.params.push(we("vViewPosition")),-1<["SPHERICAL_ENVIRONMENT","CYLINDRICAL_ENVIRONMENT","SHRINK_WRAP_ENVIRONMENT","SCREEN"].indexOf(N.mapping)?I.params.push(we("MAPPING_EXPLICIT_MAP_CHANNEL")):I.params.push(we("MAPPING_"+N.mapping)),I.params.push(we("AXIS_"+N.axis)),Te("ivec2",[De(N.clampToEdgeNoExtend[0]),De(N.clampToEdgeNoExtend[1])]));I.params.push(we(U));break;case"MAPPING_BL":if(N.rotation){var v=new gt,V=new Ir;switch(V.set(N.rotation[0],N.rotation[1],N.rotation[2],"ZYX"),v.makeRotationFromEuler(V),v.scale((new vt).fromArray(N.scale)),N.vectorType){case"TEXTURE":v.setPosition((new vt).fromArray(N.translation)),v.invert();break;case"POINT":v.setPosition((new vt).fromArray(N.translation));break;case"VECTOR":break;case"NORMAL":I.outputs[0].normalize=!0,v.invert(),v.transpose();break;default:throw new Error("v3d.MeshNodeMaterial: Unknown MAPPING vector type")}I.params.push(be(v.toArray())),I.params.push(be(N.min)),I.params.push(be(N.max)),I.params.push(be(N.useMin)),I.params.push(be(N.useMax))}else I.params.push(we("NODE_MAPPING_"+N.vectorType));break;case"MAP_RANGE_BL":xt(N.interpolationType)?I.params.push(we("NODE_MAP_RANGE_INTERP_"+N.interpolationType)):I.params.push(we("NODE_MAP_RANGE_INTERP_LINEAR")),I.params.push(Ae(N.clamp));break;case"NEW_GEOMETRY_BL":I.params.push(we("FRONT_FACING_VALUE")),I.params.push(we("vViewPosition")),I.params.push(we("normal")),Pe(e,r,2)&&(_e.needsBoundingBox=!0);break;case"NORMAL_MAP_BL":var o=Se(P="tangent",4);I.attributes.push({name:P,type:"attribute vec4"}),I.params.push(o),I.params.push(we("vNormal"));break;case"TANGENT_BL":"RADIAL"===N.directionType?(I.params.push(we("TANGENT_AXIS_"+N.axis)),I.params.push(we("vViewPosition")),I.params.push(we("normal")),_e.needsBoundingBox=!0):"UV_MAP"===N.directionType&&(o=Se(P="tangent",4),I.attributes.push({name:P,type:"attribute vec4"}),I.params.push(o));break;case"TEX_BRICK_BL":I.params.push(we(Te("float",N.offset))),I.params.push(we(Te("int",N.offsetFrequency))),I.params.push(we(Te("float",N.squash))),I.params.push(we(Te("int",N.squashFrequency)));break;case"TEX_COORD_BL":I.params.push(we(`nodeTexCoordObjectMatrices[${F}]`)),I.params.push(we("vViewPosition")),I.params.push(we("normal"));o=Se(P="uv",2);I.attributes.push({name:P,type:"attribute vec2"}),I.params.push(o),Pe(e,r,0)&&(_e.needsBoundingBox=!0),_e.nodeTexCoordObject.push(null),_e.nodeTexCoordObjectMap[N.name]=F,F++;break;case"TEX_ENVIRONMENT_BL":case"TEX_ENVIRONMENT_MX":case"TEX_IMAGE_BL":var G,g=Me(i,N.texture),l=(I.params.push(g),_e.nodeTextures[g.name].encoding);I.params.push(we(Re(l))),"TEX_ENVIRONMENT_BL"==i?(G=N.projection,I.params.push(we("TEX_PROJ_"+G))):"TEX_IMAGE_BL"==i&&(I.params.push(we("normal")),G=N.projection,I.params.push(we("TEX_PROJ_"+G)),I.params.push(be(N.projectionBlend)),I.params.push(Ae(N.clampToEdgeNoExtend)));break;case"TEX_GRADIENT_BL":I.params.push(we("TEX_GRAD_"+N.gradientType));break;case"TEX_NOISE_BL":var _=xt(N.falloffFactor)?N.falloffFactor:0,k=xt(N.dispersionFactor)?N.dispersionFactor:1;I.params.push(we(Te("float",_))),I.params.push(we(Te("float",k)));break;case"TEX_SKY_BL":var x=(new vt).fromArray(N.sunDirection).angleTo(new vt(0,0,1));"PREETHAM"==N.skyType?(T=id.getDistParams(N.turbidity,0).concat([0,0,0,0]),C=id.getDistParams(N.turbidity,1).concat([0,0,0,0]),E=id.getDistParams(N.turbidity,2).concat([0,0,0,0]),L=id.getZenithParams(N.turbidity,x,0),J=id.getZenithParams(N.turbidity,x,1),$=id.getZenithParams(N.turbidity,x,2)):"HOSEK_WILKIE"==N.skyType?(_=Math.max(Math.PI/2-x,0),T=Qu(N.turbidity,N.groundAlbedo,_,0),C=Qu(N.turbidity,N.groundAlbedo,_,1),E=Qu(N.turbidity,N.groundAlbedo,_,2),L=Ku(N.turbidity,N.groundAlbedo,_,0),J=Ku(N.turbidity,N.groundAlbedo,_,1),$=Ku(N.turbidity,N.groundAlbedo,_,2)):(T=C=E=new Array(9).fill(0),L=J=$=0),I.params.push(we("TEX_SKY_"+N.skyType)),I.params.push(be([T[0],C[0],E[0]])),I.params.push(be([T[1],C[1],E[1]])),I.params.push(be([T[2],C[2],E[2]])),I.params.push(be([T[3],C[3],E[3]])),I.params.push(be([T[4],C[4],E[4]])),I.params.push(be([T[5],C[5],E[5]])),I.params.push(be([T[6],C[6],E[6]])),I.params.push(be([T[7],C[7],E[7]])),I.params.push(be([T[8],C[8],E[8]])),I.params.push(be([L,J,$])),I.params.push(be(N.sunDirection));break;case"TEX_VORONOI_BL":void 0!==N.coloring&&I.params.push(we("COLORING_"+N.coloring)),I.params.push(we("DISTANCE_"+N.distance)),I.params.push(we("FEATURE_"+N.feature));break;case"TEX_WAVE_BL":I.params.push(we("TEX_WAVE_TYPE_"+N.waveType)),I.params.push(we("TEX_WAVE_PROFILE_"+N.waveProfile)),void 0===N.bandsDirection&&(N.bandsDirection="DIAGONAL"),void 0===N.ringsDirection&&(N.ringsDirection="SPHERICAL"),I.params.push(we("TEX_WAVE_BANDS_DIR_"+N.bandsDirection)),I.params.push(we("TEX_WAVE_RINGS_DIR_"+N.ringsDirection));break;case"MATH_BL":I.outputs[0].clamp=N.useClamp;break;case"MIX_RGB_BL":switch(I.originData.blendType){case"HUE":case"SATURATION":case"VALUE":case"COLOR":_e.defines.HSV_NODES=""}I.outputs[0].clamp=N.useClamp;break;case"MIX_SHADER_BL":for(var W=-1,a=1;a<3;a++){var H=Ie(e,r,a);H&&"BSDF_TRANSPARENT_BL"==H.originData.type&&(W=a-1)}I.params.push(we(String(W)));break;case"NORMAL_BL":I.params.push(be(N.outputs[0]));break;case"RGB_BL":case"RGB_MX":g=(new mt).fromArray(N.outputs[0]);_e.nodeRGB.push(g),_e.nodeRGBMap[N.name]=n,I.params.push(we("nodeRGB["+n+"]")),n++;break;case"UVMAP_BL":k=N.uvLayer;o=Se(P=_e.nodeUVAliases[k]||"uv",2);I.attributes.push({name:P,type:"attribute vec2"}),I.params.push(o);break;case"VALUE_BL":case"VALUE_MX":case"ANIM_CURVE_TA_MY":case"ANIM_CURVE_TU_MY":case"VALUE":g=N.outputs[0];_e.nodeValue[B]=g,_e.nodeValueMap[N.name]=B,I.params.push(we("nodeValue["+B+"]")),B++;break;case"VALTORGB_BL":var X=new("STEP"==(S=N.curve).interpolation?Pu:Ju)(new Float32Array(S.input),new Float32Array(S.output),4);A=_e.useFloatTex?(M=new Float32Array(1024),1):(M=new Uint8Array(1024),255);for(a=0;a<od;a++){var j=X.evaluate(a/255);M[4*a]=A*j[0],M[4*a+1]=A*j[1],M[4*a+2]=A*j[2],M[4*a+3]=A*j[3]}f=Le(M,od,pt,_e.useFloatTex?At:Mt),m=("STEP"==S.interpolation&&(f.minFilter=dt,f.magFilter=dt),cd.nodeTexUniName(i,t));_e.nodeTextures[m]=f,I.params.push(Me(i,t)),t++;break;case"VECTOR_ROTATE_BL":void 0===N.rotationType&&(N.rotationType="AXIS_ANGLE"),void 0===N.invert&&(N.invert=!1),I.params.push(we(Te("float",N.invert?-1:1)));break;case"VECT_TRANSFORM_BL":var Y=N.vectorType,Z=N.convertFrom,q=N.convertTo,y=("NORMAL"==Y&&(I.outputs[0].normalize=!0),"");Z==q?y="VEC_TRANS_NONE":(y="VEC_TRANS_"+Z[0]+"_"+q[0],"VECTOR"!=Y&&"NORMAL"!=Y||(y+="_DIR")),I.params.push(we(y)),0<xe(e,"OUTPUT_MATERIAL_BL")||0<xe(e,"OUTPUT_WORLD_BL")?I.params.push(Ae(!0)):I.params.push(Ae(!1));break;case"VERTEX_COLOR_BL":(P=Ee(N.colorLayer,""))?(o=Se(P,4),I.attributes.push({name:P,type:"attribute vec4"}),I.params.push(o)):I.params.push(we("vec4(0.0, 0.0, 0.0, 1.0)"));break;case"BITMAP_MX":case"BITMAP_ENV_MX":case"REFLECT_REFRACT_MX":s=Me(i,N.texture),l=(I.params.push(s),"BITMAP_MX"==i?(o=Se(P=N.uvIndex?"uv"+String(N.uvIndex+1):"uv",2),I.attributes.push({name:P,type:"attribute vec2"}),I.params.push(o),I.params.push(we("MAPPING_"+N.mapping)),I.params.push(we("AXIS_"+N.axis)),U=Te("ivec2",[De(N.clampToEdgeNoExtend[0]),De(N.clampToEdgeNoExtend[1])]),I.params.push(we(U))):(I.params.push(we(N.reflectMode)),I.params.push(be(N.IOR))),_e.nodeTextures[s.name].encoding);I.params.push(we(Re(l))),"BITMAP_MX"!=i&&"BITMAP_ENV_MX"!=i||(I.params.push(Ae(N.alphaAsMono)),I.params.push(Ae(N.alphaAsRGB)),I.outputs.push({name:i.toLowerCase()+"_out1_n"+r,type:"float",clamp:!1,normalize:!1}));break;case"BLEND_MX":I.params.push(Ae(N.useCurve)),I.params.push(be(N.curveLower)),I.params.push(be(N.curveUpper));break;case"BUMP_MX":s=Me("BITMAP_MX",N.texture);I.params.push(s),I.params.push(we("-vViewPosition")),I.params.push(we("normal"));o=Se(P=N.uvIndex?"uv"+String(N.uvIndex+1):"uv",2);I.attributes.push({name:P,type:"attribute vec2"}),I.params.push(o);break;case"COLOR_CORRECTION_MX":Z=Te("ivec4",[N.rewireR,N.rewireG,N.rewireB,N.rewireA]);I.params.push(we(Z));break;case"COMPOSITE_LAYER_MX":I.params.push(we(Te("int",N.blendMode)));q=ye(e,r,1)?N.opacity:0;I.params.push(be(q));break;case"COLOR_MAP_MX":I.params.push(Ae(N.reverseGamma));break;case"FALLOFF_MX":I.params.push(we("-vViewPosition")),I.params.push(be(N.IOR));break;case"MASK_MX":I.params.push(Ae(N.maskInverted));break;case"MATERIAL_MX":I.params.push(be(N.inputFactors[9])),I.params.push(be(N.inputFactors[10])),N.inputFactors[9]=1,N.inputFactors[10]=1,I.params.push(Ae(N.selfIllumColorOn));break;case"MATTE_SHADOW_MX":I.params.push(we("normal")),I.params.push(Ae(N.receiveShadows)),I.params.push(be(N.shadowBrightness)),I.params.push(be(N.color));break;case"NOISE_MX":2==N.coordType?(o=Se(P=N.uvIndex?"uv"+String(N.uvIndex+1):"uv",2),I.attributes.push({name:P,type:"attribute vec2"}),I.params.push(o)):I.params.push(we("vViewPosition")),I.params.push(Ne(N.noiseType)),I.params.push(Ne(N.coordType));break;case"NORMAL_BUMP_MX":var o=Se(P="tangent",4),Y=(I.attributes.push({name:P,type:"attribute vec4"}),I.params.push(o),I.params.push(we("normal")),"ivec2("+De(N.flip[0])+","+De(N.flip[1])+")");I.params.push(we(Y));break;case"OUTPUT_MAP_MX":if(I.params.push(Ae(N.invert)),I.params.push(Ae(N.clamp)),I.params.push(Ae(N.alphaFromRGB)),N.colorMap){A=_e.useFloatTex?(b=N.colorMap,M=new Float32Array(1024),1):(b=Ei(N.colorMap.slice(),0,1),M=new Uint8Array(1024),255);for(var b,M,A,p=b.length/od,a=0;a<od;a++)M[4*a]=A*b[p*a],3==p?(M[4*a+1]=A*b[p*a+1],M[4*a+2]=A*b[p*a+2]):(M[4*a+1]=M[4*a],M[4*a+2]=M[4*a]),M[4*a+3]=A;f=Le(M,od,pt,_e.useFloatTex?At:Mt),m=cd.nodeTexUniName(i,t);_e.nodeTextures[m]=f,I.params.push(Me(i,t)),t++}break;case"PHYSICAL_MX":I.params.push(we("geometryNormal")),I.params.push(be(N.emitLuminance));var y=void 0===N.brdfMode||N.brdfMode,w=void 0===N.brdfLow?0:N.brdfLow,Q=void 0===N.brdfHigh?0:N.brdfHigh,S=void 0===N.brdfCurve?0:N.brdfCurve;I.params.push(Ae(!y)),I.params.push(we(Te("float",w))),I.params.push(we(Te("float",Q))),I.params.push(we(Te("float",S))),I.params.push(Ae(xt(N.roughnessInv)&&N.roughnessInv)),I.params.push(Ae(xt(N.transRoughnessLock)&&N.transRoughnessLock)),I.params.push(Ae(xt(N.transRoughnessInv)&&N.transRoughnessInv)),I.params.push(Ae(xt(N.thinWalled)&&N.thinWalled)),(0<N.inputs[18]||ye(e,r,18))&&(_e.defines.CLEARCOAT="");break;case"PHY_SUN_SKY_ENV_MX":var w=15*N.haze+2,Q=new ad,x=Math.PI/2-N.sunPolarAngle,K=Math.PI-N.sunAzimuthAngle,K=(Q.phi=x,Q.theta=K,(new vt).setFromSpherical(Q).toArray()),T=id.getDistParams(w,0),C=id.getDistParams(w,1),E=id.getDistParams(w,2),L=id.getZenithParams(w,x,0),J=id.getZenithParams(w,x,1),$=id.getZenithParams(w,x,2),R=(L=L/.06*1e3,I.params.push(be([T[0],C[0],E[0]])),I.params.push(be([T[1],C[1],E[1]])),I.params.push(be([T[2],C[2],E[2]])),I.params.push(be([T[3],C[3],E[3]])),I.params.push(be([T[4],C[4],E[4]])),I.params.push(be([L,J,$])),id.getSunIlluminance(K,w)),K=(I.params.push(be(K)),I.params.push(be(R)),I.params.push(be([0,0,0])),1500/Math.PI);I.params.push(be(N.globalIntensity/K)),I.params.push(be(N.groundColor));break;case"REFLECT_REFRACT_COLOR_MX":g=N.outputs[0];I.params.push(be(g));break;case"VERTEX_COLOR_MX":o=Se(P="color",3);I.attributes.push({name:P,type:"attribute vec3"}),I.params.push(o);break;case"BLINN_MY":I.params.push(we("geometryNormal"));break;case"BUMP_2D_MY":I.params.push(we("vNormal")),0<N.bumpInterp&&(o=Se(P="tangent",4),I.attributes.push({name:P,type:"attribute vec4"}),I.params.push(o));break;case"CHANNELS_MY":I.params.push(we(N.channelR)),I.params.push(we(N.channelG)),I.params.push(we(N.channelB)),I.params.push(we(N.channelA));break;case"COLOR_COMPOSITE_MY":I.params.push(we(N.operation));break;case"COLOR_CORRECT_MY":I.params.push(Ae(N.colClamp)),I.params.push(be(N.colClampMin)),I.params.push(be(N.colClampMax)),I.params.push(Ae(N.alphaClamp)),I.params.push(be(N.alphaClampMin)),I.params.push(be(N.alphaClampMax)),I.params.push(Ae(N.unpremultiplyInput)),I.params.push(Ae(N.premultiplyResult));break;case"COLOR_LOGIC_MY":I.params.push(we(N.operation));break;case"COLOR_MASK_MY":I.params.push(Ae(N.maskAlphaIsLuminance));break;case"COLOR_MATH_MY":I.params.push(we(N.operation));break;case"COMPOSE_MATRIX_MY":I.params.push(Ae(N.useEulerRotation)),I.params.push(we(N.inputRotateOrder));break;case"CONDITION_MY":I.params.push(we(N.operation));break;case"FILE_MY":case"ENV_SPHERE_MY":g=Me("FILE_MY",N.texture),l=(I.params.push(g),_e.nodeTextures[g.name].encoding);I.params.push(we(Re(l))),"ENV_SPHERE_MY"==i?I.params.push(we("normal")):I.params.push(Ae(_e.nodeTextures[g.name].format==wt));break;case"FLOAT_COMPOSITE_MY":case"FLOAT_LOGIC_MY":case"FLOAT_MATH_MY":I.params.push(we(N.operation));break;case"LAMBERT_MY":I.params.push(we("geometryNormal"));break;case"MULTIPLY_DIVIDE_MY":I.params.push(we(N.operation));break;case"PHONG_MY":case"PHONG_E_MY":I.params.push(we("geometryNormal"));break;case"PLACE_2D_TEXTURE_MY":o=Se(P=N.uvIndex?"uv"+String(N.uvIndex+1):"uv",2);I.attributes.push({name:P,type:"attribute vec2"}),I.params.push(o);break;case"RAMP_MY":A=_e.useFloatTex?(M=new Float32Array(2048),1):(M=new Uint8Array(2048),255);for(a=0;a<sd;a++)c=A*N.rampData[3*a],u=A*N.rampData[3*a+1],d=A*N.rampData[3*a+2],h=1,M[4*a]=ft(c,0,A),M[4*a+1]=ft(u,0,A),M[4*a+2]=ft(d,0,A),M[4*a+3]=ft(h,0,A);m=((f=Le(M,sd,pt,_e.useFloatTex?At:Mt)).wrapS=N.wrapS,f.wrapT=N.wrapT,cd.nodeTexUniName(i,t));_e.nodeTextures[m]=f,I.params.push(Me(i,t)),t++,I.params.push(we(Te("int",N.rampType)));break;case"SAMPLER_INFO_MY":I.params.push(we("FRONT_FACING_VALUE"));o=Se(P="tangent",4);I.attributes.push({name:P,type:"attribute vec4"}),I.params.push(o);o=Se(P="uv",2);I.attributes.push({name:P,type:"attribute vec2"}),I.params.push(o);break;case"UNIT_CONVERSION_MY":I.params.push(be(N.conversionFactor));break;case"VECTOR_PRODUCT_MY":I.params.push(we(N.operation)),I.params.push(Ae(N.normalizeOutput));break;case"INCIDENT":I.params.push(we("vViewPosition"));break;case"NORMAL":I.params.push(we("normal"));break;case"OSL_NODE":xt(N.texture)&&(s=Me(i,N.texture),I.params.push(s));R=N.globalVariables||[];-1<R.indexOf("P")&&I.params.push(we("oslGetP(vViewPosition)")),-1<R.indexOf("I")&&I.params.push(we("oslGetI(vViewPosition)")),-1<R.indexOf("N")&&I.params.push(we("oslGetN(normal)")),(-1<R.indexOf("u")||-1<R.indexOf("v"))&&(I.attributes.push({name:P="uv",type:"attribute vec2"}),-1<R.indexOf("u")&&I.params.push(Se(P+"_u",1,P+".x")),-1<R.indexOf("v")&&I.params.push(Se(P+"_v",1,"1.0 - "+P+".y")));break;case"POSITION":I.params.push(we("vViewPosition"));break;case"RGB_ALPHA":g=(new mt).fromArray(N.outputs[0].concat([N.outputs[1]]));_e.nodeRGB.push(g),_e.nodeRGBMap[N.name]=n,I.params.push(we("nodeRGB["+n+"]")),n++;break;case"U_FLOAT":var P,o=Se(P="uv",2);I.attributes.push({name:P,type:"attribute vec2"}),I.params.push(o)}}for(r=0;r<e.len();r++)for(var I,N,i=(N=(I=e.node(r)).originData).type,a=0;a<N.inputs.length;a++){var ee,te=N.inputs[a],ne=N.inputTypes?N.inputTypes[a]:Oe(te),D=[],re=[],ie=(pe=O=he=de=ue=ee=ce=le=se=oe=ae=ie=void 0,e),ae=r,oe=a,se=te,le=D,ce=re;for(ee in ie.edges){var ue=ie.edges[ee];if(ue.to()==ae)for(var de=ie.node(ue.from()),he=0;he<ue.connections.length;he++){var pe,O=ue.connections[he];O.to==oe&&("BITMAP_MX"!=(pe=de.originData.type)&&"BITMAP_ENV_MX"!=pe||"float"!=Oe(se)?le.push(de.outputs[O.from]):le.push(de.outputs[O.from+1]),O.channelMatrix&&ce.push(O.channelMatrix))}}var fe,me,ve,ge=Ce(i,a);D.length?(fe=I.inputFactors.length?I.inputFactors[a]:1,me=ge?"normal":Te(ne,te),re.length?(ve=D.map(function(e){return e.name}),I.inputs.push({code:function(e,t,n,r,i){for(var a=[],o=Fe(n),s=Fe(r),l=0;l<s;l++){for(var c=1==s?i:i+"["+l+"]",u=0;u<e.length;u++)for(var d=e[u],h=t[u],p=0;p<o;p++)h[p][l]&&(c=1==o?d:d+"["+p+"]");a.push(c)}return r+"("+a.join(",")+")"}(ve,re,D[0].type,ne,me)})):1==D.length?I.inputs.push({code:function(e,t,n,r,i){var a;t==n?a=e:"float"==t&&"vec3"==n?a="vec3("+[e,e,e].join(",")+")":"float"==t&&"vec4"==n?a="vec4("+[e,e,e,e].join(",")+")":"vec3"==t&&"float"==n||"vec4"==t&&"float"==n?a="("+[e+"[0]",e+"[1]",e+"[2]"].join("+")+")/3.0":"vec3"==t&&"vec4"==n?a="vec4("+e+", 1.0)":"vec4"==t&&"vec3"==n?a="vec3("+[e+"[0]",e+"[1]",e+"[2]"].join(",")+")":"float"==t&&"int"==n?a="int("+e+")":"int"==t&&"float"==n||"bool"==t&&"float"==n?a="float("+e+")":console.error("MeshNodeMaterial: Missing type conversion: "+t+" -> "+n);(i<1||1!=i&&"normal"==r)&&(a="mix("+r+","+a+","+Be(i)+")","normal"==r&&(a="normalize("+a+")"));return a}(D[0].name,D[0].type,ne,me,fe)}):console.error("MeshNodeMaterial: wrong node connections")):ge?I.inputs.push({code:"normal"}):I.inputs.push({code:Te(ne,te)})}}function ye(e,t,n){for(var r=e.findInEdges(t),i=0;i<r.length;i++)for(var a=r[i],o=0;o<a.connections.length;o++)if(a.connections[o].to==n)return 1}function Pe(e,t,n){for(var r in e.edges){var i=e.edges[r];if(i.from()==t)for(var a=0;a<i.connections.length;a++)if(i.connections[a].from==n)return 1}}function Ie(e,t,n){for(var r in e.edges){var i=e.edges[r];if(i.to()==t)for(var a=e.node(i.from()),o=0;o<i.connections.length;o++)if(i.connections[o].to==n)return a}return null}function be(e){return{name:"",type:Oe(e),value:e}}function Me(e,t){e=cd.nodeTexUniName(e,t);return{name:e,type:_e.nodeTextures[e].isCubeTexture?"uniform samplerCube":"uniform sampler2D",value:t}}function Ne(e){return{name:"",type:"int",value:e}}function Ae(e){return we(e?"true":"false")}function we(e){return{name:e,type:"",value:null}}function Se(e,t,n){return n=n||e,{name:"_vary_par_"+e,type:"varying "+z(t),value:null,attrBindName:n}}function De(e){return e?1:0}function Oe(e){return"number"==typeof e?"float":"boolean"==typeof e?"bool":z(e.length)}function z(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 Fe(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 Te(e,t){switch(e){case"float":return Be(t);case"bool":case"int":return String(t);default:for(var n=[],r=0;r<t.length;r++)n.push(Be(t[r]));return e+"("+n.join(",")+")"}}function Be(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.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.morphTargets=!1,this.morphNormals=!1,this.vertexTangents=!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 _t(16777215),this.envMap=null,this.envMapIntensity=1,this.envMapParallaxType=0,this.envMapParallaxMatrix=new gt,this.envMapParallaxMatrixInv=new gt,this.reflectivity=.5,this.materialIndex=0,xt(C)&&this.setValues(C),this.nodeGraph||(this.nodeGraph=(C=new Iu.DiGraph(1),E=_e.color,C.node(0).originData={name:"ShadelessOutput",type:"OUTPUT_MATERIAL_BL",inputs:[[E.r,E.g,E.b,1],[0,0,0,0],[0,0,0]],outputs:[],is_active_output:!0},C)),this.updateNodeGraph=function(){_e.nodeRGB=[],_e.nodeRGBMap={},_e.nodeTexCoordObject=[],_e.nodeTexCoordObjectMap={},_e.nodeValueMap={},_e.needsBoundingBox=!1,_e.nodeChunks={};var e=_e.nodeGraph,t=(_e.nodeRGBArr=new Float32Array(4*xe(e,["RGB_BL","RGB_MX","RGB_ALPHA"])),_e.nodeTexCoordObjectArr=new Float32Array(16*xe(e,"TEX_COORD_BL")),_e.nodeValue=new Float32Array(xe(e,["VALUE_BL","VALUE_MX","ANIM_CURVE_TA_MY","ANIM_CURVE_TU_MY","VALUE"])),B(e),e),n=[],r=[],i=[],a=[],o=new Iu.TopologicalSort(t).order();_e.defines.NODE_RGB_NUM=_e.nodeRGB.length,_e.defines.NODE_VALUE_NUM=_e.nodeValue.length,_e.defines.NODE_TEX_COORD_NUM=_e.nodeTexCoordObject.length;for(var s=0;s<o.length;s++){var l,c=(m=t.node(o[s])).originData.type;_e.defines["NODE_"+c]="","OUTPUT_MATERIAL_BL"!=c&&"PHYSICAL_MX"!=c&&"MATTE_SHADOW_MX"!=c&&"SHADING_ENGINE_MY"!=c&&"STANDARD_SURFACE_AR"!=c&&"LAMBERT_AR"!=c||(_e.defines.STANDARD="",_e.defines.PHYSICAL=""),"OSL_NODE"==c&&(_e.defines.USE_OSL=""),(h="OSL_NODE"!=c?(l="node_"+c.toLowerCase()+"_vert",yt[l]):m.originData.vertCode)&&n.indexOf(h)<0&&n.push(h),(p="OSL_NODE"!=c?(l="node_"+c.toLowerCase()+"_frag",yt[l]):m.originData.fragCode)&&i.indexOf(p)<0&&i.push(p);for(var u=0;u<m.attributes.length;u++){var d=m.attributes[u],h=d.type+" "+d.name+";";"uv"!=d.name&&n.indexOf(h)<0&&n.push(h)}for(var p,f,u=0;u<m.params.length;u++)O(g=m.params[u])?(p=g.type+" "+g.name+";",i.indexOf(p)<0&&i.push(p)):F(g)&&(f=g.type+" "+g.name+";",n.indexOf(f)<0&&n.push(f),f=g.type+" "+g.name+";",i.indexOf(f)<0&&i.push(f))}for(var m,s=0;s<o.length;s++){if("CHECKERBOARD_AR"==(c=(m=t.node(o[s])).originData.type)||"IMAGE_AR"==c||"TWO_SIDED_AR"==c||"ATTRIBUTE_BL"==c||"NEW_GEOMETRY_BL"==c||"NORMAL_MAP_BL"==c||"TANGENT_BL"==c||"TEX_COORD_BL"==c||"UVMAP_BL"==c||"VERTEX_COLOR_BL"==c||"BITMAP_MX"==c||"NOISE_MX"==c||"NORMAL_BUMP_MX"==c||"BUMP_MX"==c||"VERTEX_COLOR_MX"==c||"GRADIENT_RAMP_MX"==c||"BUMP_2D_MY"==c||"PLACE_2D_TEXTURE_MY"==c||"SAMPLER_INFO_MY"==c||"OSL_NODE"==c||"U_FLOAT"==c)for(var v,u=0;u<m.params.length;u++)F(g=m.params[u])&&(v=g.name+"="+g.attrBindName+";",r.indexOf(v)<0&&r.push(v));for(u=0;u<m.outputs.length;u++)(b=m.outputs[u]).type&&a.push(b.type+" "+b.name+";");for(var g,_=[],u=0;u<m.params.length;u++)!(g=m.params[u]).type||O(g)||F(g)?_.push(g.name):_.push(Te(g.type,g.value));for(u=0;u<m.inputs.length;u++){var x=m.inputs[u];_.push(x.code)}for(var y,u=0;u<m.outputs.length;u++){var b=m.outputs[u];_.push(b.name)}switch("OSL_NODE"!=c?(y="node_"+c.toLowerCase(),(c.endsWith("_AR")||c.endsWith("_BL")||c.endsWith("_MX")||c.endsWith("_MY"))&&(y=y.slice(0,-3))):y=m.originData.shaderName,c){case"MATH_BL":case"VECT_MATH_BL":y+="_"+m.originData.operation.toLowerCase();break;case"VECTOR_ROTATE_BL":y+="_"+m.originData.rotationType.toLowerCase();break;case"MIX_RGB_BL":y+="_"+m.originData.blendType.toLowerCase()}a.push(y+"("+_.join(",")+");");for(u=0;u<m.outputs.length;u++){var M=(b=m.outputs[u]).name;b.clamp&&(c=b.type,a.push(M+"=clamp("+M+","+c+"(0.0),"+c+"(1.0));")),b.normalize&&a.push(M+"=normalize("+M+");")}}_e.nodeChunks.node_pars_vertex=n.join("\n"),_e.nodeChunks.node_vertex=r.join("\n"),_e.nodeChunks.node_pars_fragment=i.join("\n"),_e.nodeChunks.node_fragment=a.join("\n"),_e.nodeChunksHash=Nn(JSON.stringify(_e.nodeChunks))};for(var e=_e.nodeGraph,t=0;t<e.len();t++){var n=e.node(t),V=n.originData.type;if("GROUP_BL"==V){n=n.originData.nodeGraph,n=_e.additionalNodeGraphs[n];if(L(e,t),n.len()<=2){for(var U=e.findInEdges(t),r=e.findOutEdges(t),G=Math.min(U.length,r.length),i=0;i<G;i++){for(var a=U[i],o=r[i],k=((l=new Iu.Edge(a.from(),o.to(),0)).connections=[],Math.min(a.connections.length,o.connections.length)),s=0;s<k;s++){var W=a.connections[s],H=o.connections[s],X={from:W.from,to:H.to};l.connections.push(X)}e.addEdge(l)}e.disconnect(t,!0),t=-1}else{for(var j=function(e,t,n){var r={inputs:[],outputs:[],removedNodes:[]},i=(r.removedNodes.push(n),P(t,"GROUP_INPUT_BL"));if(-1<i){r.removedNodes.push(i+e.len());for(var a=e.findInEdges(n),o=t.findOutEdges(i),s=0;s<a.length;s++)for(var l=a[s],c=0;c<o.length;c++)for(var u=o[c],d=0;d<l.connections.length;d++)for(var h=l.connections[d],p=0;p<u.connections.length;p++){var f=u.connections[p];h.to==f.from&&((x=I(r.inputs,l.from(),u.to()))||((x=new Iu.Edge(l.from(),u.to(),0)).connections=[],r.inputs.push(x)),y={from:h.from,to:f.to},x.connections.push(y))}}for(var i=P(t,"GROUP_OUTPUT_BL"),m=(r.removedNodes.push(i+e.len()),e.findOutEdges(n)),v=t.findInEdges(i),s=0;s<m.length;s++)for(var g=m[s],c=0;c<v.length;c++)for(var _=v[c],d=0;d<g.connections.length;d++)for(h=g.connections[d],p=0;p<_.connections.length;p++){var x,y,f=_.connections[p];h.from==f.to&&((x=I(r.outputs,_.from(),g.to()))||((x=new Iu.Edge(_.from(),g.to(),0)).connections=[],r.outputs.push(x)),y={from:f.from,to:h.to},x.connections.push(y))}return r}(e,n,t),Y=(e.insert(n,j.inputs,j.outputs),j.removedNodes.sort(function(e,t){return t-e})),i=0;i<Y.length;i++)e.disconnect(Y[i],!0);t=-1}}else if("REROUTE_BL"==V){e.findInEdges(t).length<1&&L(e,t);for(U=e.findInEdges(t),r=e.findOutEdges(t),W=(a=U[0]).connections[0],i=0;i<r.length;i++){o=r[i];(l=new Iu.Edge(a.from(),o.to(),0)).connections=[];for(s=0;s<o.connections.length;s++){H=o.connections[s],X={from:W.from,to:H.to};l.connections.push(X)}e.addEdge(l)}e.disconnect(t,!0),t=-1}else if("OSL_OUTPUT_SELECTOR_MX"==V){for(U=e.findInEdges(t),r=e.findOutEdges(t),W=(a=U[0]).connections[0],i=0;i<r.length;i++){var l,o=r[i];(l=new Iu.Edge(a.from(),o.to(),0)).connections=[];for(s=0;s<o.connections.length;s++){H=o.connections[s],X={from:W.from,to:H.to};l.connections.push(X)}e.addEdge(l)}e.disconnect(t,!0),t=-1}}for(var c=_e.nodeGraph,u=0;u<c.len();u++){"TEX_IMAGE_BL"!=(x=(T=c.node(u).originData).type)||ye(c,u,0)||(c.addNode({originData:{name:"UVMapGenerated",type:"UVMAP_BL",uvLayer:"",inputs:[],outputs:[[0,0,0]]}}),bt(c,c.len()-1,0,u,0)),"TEX_BRICK_BL"!=x&&"TEX_CHECKER_BL"!=x&&"TEX_GRADIENT_BL"!=x&&"TEX_NOISE_BL"!=x&&"TEX_WAVE_BL"!=x&&"TEX_VORONOI_BL"!=x&&"TEX_SKY_BL"!=x||ye(c,u,0)||(c.addNode({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]]}}),bt(c,c.len()-1,0,u,0)),"TEX_ENVIRONMENT_BL"!=x&&"TEX_ENVIRONMENT_MX"!=x||ye(c,u,0)||(c.addNode({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]]}}),bt(c,c.len()-1,3,u,0));var d=x;if("BSDF_PRINCIPLED_BL"==d)switch(T.inputs.length){case 23:d="BSDF_PRINCIPLED_<3.0_BL";break;case 22:d="BSDF_PRINCIPLED_<2.91.0_BL"}if("STANDARD_SURFACE_AR"==(d="BUMP_BL"==d&&4==T.inputs.length?"BUMP_<2.81_BL":d)&&25==T.inputs.length&&(console.warn("v3d.MeshNodeMaterial: adding missing params to standard surface node, please reexport your scene"),T.inputs.push([0,0,0])),"SAMPLER_INFO_MY"==d&&0==T.inputs.length&&(console.warn("v3d.MeshNodeMaterial: adding missing params to samplerInfo node, please reexport your scene"),T.inputs.push([0,0,0])),"ARNOLD_MAP_TO_MTL_MX"==d&&(console.warn("v3d.MeshNodeMaterial: renaming Map To Material node, please reexport your scene"),T.type=d="MAP_TO_MTL_AR"),d in ld&&!ye(c,u,ld[d])&&(c.addNode({originData:{name:"Normal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}}),bt(c,c.len()-1,0,u,ld[d])),"BSDF_PRINCIPLED_<2.91.0_BL"==d&&!ye(c,u,20)&&(0<T.inputs[12]||ye(c,u,12))&&(c.addNode({originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}}),bt(c,c.len()-1,0,u,20)),"BSDF_PRINCIPLED_<3.0_BL"==d&&!ye(c,u,21)&&(0<T.inputs[12]||ye(c,u,12))&&(c.addNode({originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}}),bt(c,c.len()-1,0,u,21)),"BSDF_PRINCIPLED_BL"==d&&!ye(c,u,23)&&(0<T.inputs[14]||ye(c,u,14))&&(c.addNode({originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}}),bt(c,c.len()-1,0,u,23)),"EEVEE_SPECULAR_BL"==d&&!ye(c,u,8)&&(0<T.inputs[6]||ye(c,u,6))&&(c.addNode({originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}}),bt(c,c.len()-1,0,u,8)),"OSL_NODE"==d)for(var Z=T.initializers,h=0;h<Z.length;h++){var q=Z[h];q&&!ye(c,u,h)&&(q={originData:{name:d+"init"+h,type:"OSL_NODE",shaderName:T.shaderName+"_init_"+h,inputs:[],outputs:[T.inputs[0]],fragCode:q[0],globalVariables:q[1],initializers:[]}},c.addNode(q),bt(c,c.len()-1,0,u,h))}if("NORMAL_MAP_AR"!=d||ye(c,u,1)&&ye(c,u,3)||(c.addNode({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]]}}),ye(c,u,1)||bt(c,c.len()-1,3,u,1),ye(c,u,3)||bt(c,c.len()-1,8,u,3)),"IMAGE_AR"!=d||ye(c,u,2)||(c.addNode({originData:{name:"place2dTexture",type:"PLACE_2D_TEXTURE_MY",inputs:[[0,0],[1,1],0],outputs:[[0,0]],uvIndex:0}}),bt(c,c.len()-1,0,u,2)),"FILE_MY"!=d||ye(c,u,0)||(c.addNode({originData:{name:"place2dTexture",type:"PLACE_2D_TEXTURE_MY",inputs:[[0,0],[1,1],0],outputs:[[0,0]],uvIndex:0}}),bt(c,c.len()-1,0,u,0)),"RAMP_MY"!=d||ye(c,u,0)||(c.addNode({originData:{name:"place2dTexture",type:"PLACE_2D_TEXTURE_MY",inputs:[[0,0],[1,1],0],outputs:[[0,0]],uvIndex:0}}),bt(c,c.len()-1,0,u,0)),"BITMAP_MX"!=x&&"BITMAP_ENV_MX"!=x||xt(T.mapping)||(T.mapping="EXPLICIT_MAP_CHANNEL",T.axis="XY",T.clampToEdgeNoExtend=[!1,!1],console.warn("v3d.MeshNodeMaterial: adding missing params to bitmap node, please reexport your scene")),"GRADIENT_RAMP_MX"!=x||xt(T.mapping)||(T.mapping="EXPLICIT_MAP_CHANNEL",T.axis="XY",T.clampToEdgeNoExtend=[!1,!1],console.warn("v3d.MeshNodeMaterial: adding missing params to gradient ramp node, please reexport your scene")),xt(T.output)){re=ne=te=m=ee=$=J=f=K=Q=p=void 0;var p=c,Q=u,K=T,f=K.output,J=p.findInEdges(Q),$=p.findOutEdges(Q),ee={originData:{name:K.name+"Output",type:"OUTPUT_MAP_MX",invert:f.invert,clamp:f.clamp,alphaFromRGB:f.alphaFromRGB,inputs:[[0,0,0,0],f.rgbLevel,f.rgbOffset,f.outputAmount,f.bumpAmount],outputs:[[0,0,0,0]]}};xt(f.colorMap)&&(ee.originData.colorMap=f.colorMap),p.addNode(ee);for(var m=0;m<$.length;m++)for(var te=$[m],ne=0;ne<te.connections.length;ne++){var re=te.connections[ne];bt(p,p.len()-1,0,te.to(),re.to)}for(p.disconnect(Q,!1),m=0;m<J.length;m++)p.addEdge(J[m]);bt(p,Q,0,p.len()-1,0),delete K.output}if(N(x)){if(!xt(T.inputFactors)){T.inputFactors=[];for(h=0;h<T.inputs.length;h++)T.inputFactors.push(1)}T.inputs.push([0,0,0]),T.inputFactors.push(0)}if("STANDARD_SURFACE_AR"==d&&!ye(c,u,25)&&(0<T.inputs[15]||ye(c,u,15))&&(c.addNode({originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}}),bt(c,c.len()-1,0,u,25)),"BUMP_2D_MY"==x&&0<T.bumpInterp){T.inputs[1]=[0,0,0];for(var ie=c.findInEdges(u),h=0;h<ie.length;h++)for(var ae=ie[h],oe=c.node(ae.from()).originData,se=0;se<ae.connections.length;se++)1==(lt=ae.connections[se]).to&&"FILE_MY"==oe.type?lt.from=1:1==lt.to&&"IMAGE_AR"==oe.type&&(lt.from=0)}"COLOR_CONSTANT_MY"!=x||ye(c,u,0)||ye(c,u,1)||(T.type="RGB_ALPHA",T.inputs=[]),"FLOAT_CONSTANT_MY"!=x||ye(c,u,0)||(T.type="VALUE",T.inputs=[])}for(var le=0,u=0;u<c.len();u++)if("MATERIAL_MX"==(x=(T=c.node(u).originData).type)||"PHYSICAL_MX"==x){ze=Ve=ge=ve=me=fe=_=g=pe=he=de=ue=ce=v=void 0;for(var v=c,ce=u,ue=T,de=ue.type,he=v.findInEdges(ce),pe=0;pe<he.length;pe++)for(var g=he[pe],_=v.node(g.from()).originData,fe=0;fe<g.connections.length;fe++){var me=g.connections[fe];if("MATERIAL_MX"==de&&D(_.type)&&(9==me.to?_.reflectMode="MAX_ENV_COORDS_REFLECT":10==me.to&&(_.reflectMode="MAX_ENV_COORDS_REFRACT")),Ce(de,me.to)){if("BITMAP_MX"==_.type||"OUTPUT_MAP_MX"==_.type){v.removeEdge(g.from(),g.to());var ve={originData:{name:(_="OUTPUT_MAP_MX"==_.type?Ie(v,g.from(),0).originData:_).name+"Bump"+pe,type:"BUMP_MX",texture:_.texture,uvIndex:_.uvIndex,inputs:JSON.parse(JSON.stringify(_.inputs)),outputs:[[0,0,0]]}};v.addNode(ve),bt(v,v.len()-1,0,ce,me.to),pe=-1,he=v.findInEdges(ce);break}for(var ge=0;ge<v.len();ge++){var ze,Ve=v.node(ge).originData;N(Ve.type)&&(ze=Ve.inputs.length-1,bt(v,g.from(),me.from,ge,ze),Ve.inputFactors[ze]=ue.inputFactors[me.to])}}}"MATERIAL_MX"==x&&(le=T.IOR)}for(var x,u=0;u<c.len();u++)D(x=(T=c.node(u).originData).type)&&(T.IOR=le),D(x)&&!xt(T.reflectMode)&&(T.reflectMode="MAX_ENV_COORDS_REFLECT");for(u=0;u<c.len();u++)if("COMPOSITE_MX"==(T=c.node(u).originData).type){Ze=qe=Ye=je=Xe=He=M=We=ke=Ge=b=Ue=y=void 0;for(var y=c,Ue=u,b=T,Ge=b.blendMode.length,ke=y.findInEdges(Ue),We=y.findOutEdges(Ue),M=0;M<Ge;M++){var He={originData:{name:b.name+"Layer"+M,type:"COMPOSITE_LAYER_MX",blendMode:0!=M?b.blendMode[M]:0,opacity:b.opacity[M],inputs:[[0,0,0,0]].concat(b.inputs.slice(2*M,2*M+2)),outputs:[b.outputs[M]]}};y.addNode(He);for(var Xe=0;Xe<ke.length;Xe++)for(var je=ke[Xe],Ye=0;Ye<je.connections.length;Ye++)(qe=je.connections[Ye]).to==2*M&&b.mapEnabled[M]?bt(y,je.from(),qe.from,y.len()-1,1):qe.to==2*M+1&&b.maskEnabled[M]&&bt(y,je.from(),qe.from,y.len()-1,2);0<M&&bt(y,y.len()-2,0,y.len()-1,0)}for(M=0;M<We.length;M++)for(var Ze=We[M],Xe=0;Xe<Ze.connections.length;Xe++){var qe=Ze.connections[Xe];bt(y,y.len()-1,0,Ze.to(),qe.to)}c.disconnect(u,!0)}for(u=0;u<c.len();u++)if("LAYERED_TEXTURE_MY"==(T=c.node(u).originData).type){at=S=it=rt=nt=tt=w=et=$e=Je=Ke=Qe=A=void 0;for(var A=c,Qe=u,Ke=T,Je=Ke.inputs.length/4,$e=A.findInEdges(Qe),et=A.findOutEdges(Qe),w=0;w<Je;w++){var tt={originData:{name:Ke.name+"Layer"+w,type:"LAYERED_TEXTURE_LAYER_MY",inputs:[0,[0,0,0]].concat(Ke.inputs.slice(4*w,4*w+4)),outputs:[0,[0,0,0]]}};A.addNode(tt);for(var nt=0;nt<$e.length;nt++)for(var rt=$e[nt],it=0;it<rt.connections.length;it++)(S=rt.connections[it]).to==4*w?bt(A,rt.from(),S.from,A.len()-1,2,S.channelMatrix):S.to==4*w+1?bt(A,rt.from(),S.from,A.len()-1,3,S.channelMatrix):S.to==4*w+2?bt(A,rt.from(),S.from,A.len()-1,4,S.channelMatrix):S.to==4*w+3&&bt(A,rt.from(),S.from,A.len()-1,5,S.channelMatrix);0<w&&(bt(A,A.len()-1,0,A.len()-2,0),bt(A,A.len()-1,1,A.len()-2,1))}for(w=0;w<et.length;w++)for(var at=et[w],nt=0;nt<at.connections.length;nt++){var S=at.connections[nt];bt(A,A.len()-Je,S.from,at.to(),S.to,S.channelMatrix)}c.disconnect(u,!0)}if(_e.hasNode("SKYDOME_LIGHT_AR"))for(u=0;u<c.len();u++)if("FILE_MY"==(T=c.node(u).originData).type||"IMAGE_AR"==T.type){for(var ot={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:T.texture}},st=(c.addNode(ot),c.findOutEdges(u)),h=0;h<st.length;h++)for(var lt,ct=st[h],se=0;se<ct.connections.length;se++)(lt=ct.connections[se]).from<2&&bt(c,c.len()-1,lt.from,ct.to(),lt.to);c.disconnect(u,!0),u=-1}for(u=0;u<c.len();u++)if("ENV_SPHERE_MY"==(T=c.node(u).originData).type&&2==T.inputs.length)for(ie=c.findInEdges(u),h=0;h<ie.length;h++){ae=ie[h];"FILE_MY"!=(oe=c.node(ae.from()).originData).type&&"IMAGE_AR"!=oe.type||(T.inputs.splice(0,1),T.texture=oe.texture,c.removeEdge(ae.from(),ae.to()))}for(var T,u=0;u<c.len();u++)switch((T=c.node(u).originData).type){case"BSDF_DIFFUSE_BL":case"BSDF_GLOSSY_BL":case"BSDF_TRANSLUCENT_BL":case"BSDF_PRINCIPLED_BL":R(c,u,T,0,"Color");break;case"MATERIAL_MX":R(c,u,T,0,"Ambient Color")&&(T.inputFactors[0]=1),R(c,u,T,1,"Diffuse Color")&&(T.inputFactors[1]=1);break;case"PHYSICAL_MX":R(c,u,T,1,"Base Color")&&(T.inputFactors[1]=1)}ud(_e.nodeGraph),this.updateNodeGraph()}static nodeTexUniName(e,t){return e.toLowerCase()+"_par_tex_idx"+t}static nodeGraphFromExtGraph(e){for(var t=e.nodes,n=e.edges,r=new Iu.DiGraph(t.length),i=0;i<t.length;i++){t[i];r.node(i).originData=t[i];var a,o=r.node(i).originData,s=o.type;a=s.startsWith("AI_")&&s.endsWith("_MY")?s.replace("AI_","").replace("_MY","_AR"):"STANDARD_SURFACE_MY"==s?"STANDARD_SURFACE_AR":s.endsWith("_AR")||s.endsWith("_BL")||s.endsWith("_MX")||s.endsWith("_MY")?s:s.endsWith("_MAX")?s.replace("_MAX","_MX"):"OSL_NODE"==s?s:s+"_BL",s!=(o.type=a)&&console.warn("v3d.MeshNodeMaterial: converting node type: "+s+"->"+a+", please reexport your scene")}for(i=0;i<n.length;i++){var l=n[i],c=(r.edge(l.fromNode,l.toNode)||r.addNewEdge(l.fromNode,l.toNode),r.edge(l.fromNode,l.toNode));if(c.connections=c.connections||[],xt(l.fromChannel)||xt(l.toChannel)){for(var u=null,d=0;d<c.connections.length;d++)if((f=c.connections[d]).from==l.fromOutput&&f.to==l.toInput&&f.channelMatrix){u=f.channelMatrix;break}u||(f={from:l.fromOutput,to:l.toInput,channelMatrix:u=[[0,0,0],[0,0,0],[0,0,0]]},c.connections.push(f));var h=l.fromChannel||0,p=l.toChannel||0;u[h][p]=1}else{var f={from:l.fromOutput,to:l.toInput};c.connections.push(f)}}return ud(r),r}static nodeGraphDiffuse(e,t,n="blender"){let r=new Iu.DiGraph(0),i;switch(n){case"blender":(i=e.toArray()).push(1),r.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?(r.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}}),bt(r,1,0,0,0),r.addNode({originData:{name:"Transparent",type:"BSDF_TRANSPARENT_BL",inputs:[[1,1,1,1]],outputs:[[0,0,0,0]],is_active_output:!1}}),bt(r,2,0,1,1),r.addNode({originData:{name:"Diffuse",type:"BSDF_DIFFUSE_BL",inputs:[i,0,[0,0,0]],outputs:[[0,0,0,0]],is_active_output:!1}}),bt(r,3,0,1,2)):(r.addNode({originData:{name:"Diffuse",type:"BSDF_DIFFUSE_BL",inputs:[i,0,[0,0,0]],outputs:[[0,0,0,0]],is_active_output:!1}}),bt(r,1,0,0,0));break;case"max":i=e.toArray(),r.addNode({originData:{name:"Diffuse",type:"LAMBERT_AR",inputs:[1,i,[0,0,0],[t,t,t]],outputs:[[0,0,0,0],0,[0,0,0]],is_active_output:!1}}),r.addNode({originData:{name:"Output",type:"OUTPUT_MX",inputs:[[0,0,0,0]],outputs:[],is_active_output:!0}}),bt(r,0,0,1,0);break;case"maya":i=e.toArray(),r.addNode({originData:{name:"Diffuse",type:"LAMBERT_MY",inputs:[i,[0,0,0],[0,0,0],1,.8,[1,1,1],0,[1-t,1-t,1-t]],outputs:[[0,0,0,0]],is_active_output:!1}}),r.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}}),bt(r,0,0,1,0);break;default:console.error("nodeGraphDiffuse: Incorrect material profile - "+n),r=null}return r}hasNode(e){for(var t=0;t<this.nodeGraph.len();t++)if(this.nodeGraph.node(t).originData.type==e)return!0;return!1}traverseNodes(e){for(var t=0;t<this.nodeGraph.len();t++)e(this.nodeGraph.node(t))}findNodeByName(e){for(var t=0;t<this.nodeGraph.len();t++){var n=this.nodeGraph.node(t);if(n.originData.name===e)return n}return null}needsLightPathDir(){return!!(this.hasNode("LIGHT_PATH_BL")||this.hasNode("LIGHT_PATH_MY")||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}copy(e){super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ca.clone(e.uniforms),this.linewidth=e.linewidth,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.clipping=e.clipping,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.vertexTangents=e.vertexTangents,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 Iu.DiGraph(e.nodeGraph.len());for(var t,n=0;n<this.nodeGraph.len();n++)this.nodeGraph.node(n).originData=e.nodeGraph.node(n).originData;for(t in e.nodeGraph.edges){var r=e.nodeGraph.edges[t];this.nodeGraph.addNewEdge(r.from(),r.to()).connections=r.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){e=pi.prototype.toJSON.call(this,e);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e}}function bt(e,t,n,r,i,a){e.edge(t,r)||e.addNewEdge(t,r);e=e.edge(t,r),e.connections=e.connections||[],t={from:n,to:i};a&&(t.channelMatrix=a),e.connections.push(t)}function ud(t){for(var e=-1,n=0;n<t.len();n++)if(t.node(n).originData.is_active_output){e=n;break}if(-1==e)t.removeAll();else{for(var r=new Iu.DepthFirstSearch(t.reverse(),e),i=[],n=0;n<t.len();n++)r.hasPathTo(n)||i.push(t.node(n));i.forEach(function(e){t.disconnect(t.nodeIndex(e),!0)})}}cd.prototype.isMeshNodeMaterial=!0;var dd=Object.freeze({__proto__:null,ShadowMaterial:xu,SpriteMaterial:nl,RawShaderMaterial:yu,ShaderMaterial:T,PointsMaterial:Zl,MeshPhysicalMaterial:Mu,MeshStandardMaterial:bu,MeshPhongMaterial:Au,MeshToonMaterial:wu,MeshNormalMaterial:Su,MeshLambertMaterial:Tu,MeshDepthMaterial:gs,MeshDistanceMaterial:_s,MeshBasicMaterial:fi,MeshMatcapMaterial:Cu,LineDashedMaterial:Eu,LineBasicMaterial:Bl,Material:pi,MeshMaskMaterial:Lu,MeshNodeMaterial:cd});const y={arraySlice:function(e,t,n){return y.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)},convertArray:function(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(n){var t=n.length;const r=new Array(t);for(let e=0;e!==t;++e)r[e]=e;return r.sort(function(e,t){return n[e]-n[t]}),r},sortedArray:function(n,r,i){var a=n.length;const o=new n.constructor(a);for(let e=0,t=0;t!==a;++e){var s=i[e]*r;for(let e=0;e!==r;++e)o[t++]=n[s+e]}return o},flattenJSON:function(t,n,r,i){let a=1,o=t[0];for(;void 0!==o&&void 0===o[i];)o=t[a++];if(void 0!==o){let e=o[i];if(void 0!==e)if(Array.isArray(e))for(;void 0!==(e=o[i])&&(n.push(o.time),r.push.apply(r,e)),void 0!==(o=t[a++]););else if(void 0!==e.toArray)for(;void 0!==(e=o[i])&&(n.push(o.time),e.toArray(r,r.length)),void 0!==(o=t[a++]););else for(;void 0!==(e=o[i])&&(n.push(o.time),r.push(e)),void 0!==(o=t[a++]););}},subclip:function(e,t,n,r,i=30){const a=e.clone(),o=(a.name=t,[]);for(let e=0;e<a.tracks.length;++e){const u=a.tracks[e];var s=u.getValueSize();const d=[],h=[];for(let t=0;t<u.times.length;++t){var l=u.times[t]*i;if(!(l<n||r<=l)){d.push(u.times[t]);for(let e=0;e<s;++e)h.push(u.values[t*s+e])}}0!==d.length&&(u.times=y.convertArray(d,u.times.constructor),u.values=y.convertArray(h,u.values.constructor),o.push(u))}a.tracks=o;let c=1/0;for(let e=0;e<a.tracks.length;++e)c>a.tracks[e].times[0]&&(c=a.tracks[e].times[0]);for(let e=0;e<a.tracks.length;++e)a.tracks[e].shift(-1*c);return a.resetDuration(),a},makeClipAdditive:function(t,e=0,n=t,r=30){var i=n.tracks.length,a=e/(r=r<=0?30:r);for(let e=0;e<i;++e){const f=n.tracks[e],m=f.ValueTypeName;if("bool"!==m&&"string"!==m){const v=t.tracks.find(function(e){return e.name===f.name&&e.ValueTypeName===m});if(void 0!==v){let e=0;var o=f.getValueSize();f.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(e=o/3);let t=0;var s=v.getValueSize(),l=(v.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(t=s/3),f.times.length-1);let n;if(a<=f.times[0]){var c=e,u=o-e;n=y.arraySlice(f.values,c,u)}else if(a>=f.times[l]){c=l*o+e,u=c+o-e;n=y.arraySlice(f.values,c,u)}else{const g=f.createInterpolant();l=e,o=o-e;g.evaluate(a),n=y.arraySlice(g.resultBuffer,l,o)}if("quaternion"===m){const _=(new de).fromArray(n).normalize().conjugate();_.toArray(n)}var d=v.times.length;for(let e=0;e<d;++e){var h=e*s+t;if("quaternion"===m)de.multiplyQuaternionsFlat(v.values,h,n,0,v.values,h);else{var p=s-2*t;for(let e=0;e<p;++e)v.values[h+e]-=n[e]}}}}}return t.blendMode=2501,t}};class hd extends Ru{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:tn,endingEnd:tn}}intervalChanged_(e,t,n){var r=this.parameterPositions;let i=e-2,a=e+1,o=r[i],s=r[a];if(void 0===o)switch(this.getSettings_().endingStart){case nn:i=e,o=2*t-n;break;case rn:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(void 0===s)switch(this.getSettings_().endingEnd){case nn:a=e,s=2*n-t;break;case rn:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}var l=.5*(n-t),c=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(s-n),this._offsetPrev=i*c,this._offsetNext=a*c}interpolate_(e,t,n,r){const i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,l=s-o,c=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,h=this._weightNext,p=(n-t)/(r-t),f=p*p,m=f*p;var v=-d*m+2*d*f-d*p,g=(1+d)*m+(-1.5-2*d)*f+(-.5+d)*p+1,_=(-1-h)*m+(1.5+h)*f+.5*p,x=h*m-h*f;for(let e=0;e!==o;++e)i[e]=v*a[c+e]+g*a[l+e]+_*a[s+e]+x*a[u+e];return i}}class pd{constructor(e,t,n,r){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=y.convertArray(t,this.TimeBufferType),this.values=y.convertArray(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;var r;return t.toJSON!==this.toJSON?n=t.toJSON(e):(n={name:e.name,times:y.convertArray(e.times,Array),values:y.convertArray(e.values,Array)},(r=e.getInterpolation())!==e.DefaultInterpolation&&(n.interpolation=r)),n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Pu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Ju(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new hd(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Jt:t=this.InterpolantFactoryMethodDiscrete;break;case $t:t=this.InterpolantFactoryMethodLinear;break;case en:t=this.InterpolantFactoryMethodSmooth}if(void 0!==t)return this.createInterpolant=t,this;var n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(n);this.setInterpolation(this.DefaultInterpolation)}return console.warn("v3d.KeyframeTrack:",n),this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Jt;case this.InterpolantFactoryMethodLinear:return $t;case this.InterpolantFactoryMethodSmooth:return en}}getValueSize(){return this.values.length/this.times.length}shift(n){if(0!==n){const r=this.times;for(let e=0,t=r.length;e!==t;++e)r[e]+=n}return this}scale(n){if(1!==n){const r=this.times;for(let e=0,t=r.length;e!==t;++e)r[e]*=n}return this}trim(e,t){var n,r=this.times,i=r.length;let a=0,o=i-1;for(;a!==i&&r[a]<e;)++a;for(;-1!==o&&r[o]>t;)--o;return++o,0===a&&o===i||(a>=o&&(o=Math.max(o,1),a=o-1),n=this.getValueSize(),this.times=y.arraySlice(r,a,o),this.values=y.arraySlice(this.values,a*n,o*n)),this}validate(){let n=!0;var e=this.getValueSize(),t=(e-Math.floor(e)!=0&&(console.error("v3d.KeyframeTrack: Invalid value size in track.",this),n=!1),this.times),r=this.values,i=t.length;0===i&&(console.error("v3d.KeyframeTrack: Track is empty.",this),n=!1);let a=null;for(let e=0;e!==i;e++){var o=t[e];if("number"==typeof o&&isNaN(o)){console.error("v3d.KeyframeTrack: Time is not a valid number.",this,e,o),n=!1;break}if(null!==a&&a>o){console.error("v3d.KeyframeTrack: Out of order keys.",this,e,o,a),n=!1;break}a=o}if(void 0!==r&&y.isTypedArray(r))for(let e=0,t=r.length;e!==t;++e){var s=r[e];if(isNaN(s)){console.error("v3d.KeyframeTrack: Value is not a valid number.",this,e,s),n=!1;break}}return n}optimize(){const n=y.arraySlice(this.times),r=y.arraySlice(this.values),i=this.getValueSize(),a=this.getInterpolation()===en,o=n.length-1;let s=1;for(let e=1;e<o;++e){let t=!1;var l=n[e];if(l!==n[e+1]&&(1!==e||l!==n[0]))if(a)t=!0;else{var c=e*i,u=c-i,d=c+i;for(let e=0;e!==i;++e){var h=r[c+e];if(h!==r[u+e]||h!==r[d+e]){t=!0;break}}}if(t){if(e!==s){n[s]=n[e];var p=e*i,f=s*i;for(let e=0;e!==i;++e)r[f+e]=r[p+e]}++s}}if(0<o){n[s]=n[o];for(let e=o*i,t=s*i,n=0;n!==i;++n)r[t+n]=r[e+n];++s}return s!==n.length?(this.times=y.arraySlice(n,0,s),this.values=y.arraySlice(r,0,s*i)):(this.times=n,this.values=r),this}clone(){var e=y.arraySlice(this.times,0),t=y.arraySlice(this.values,0);const n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}pd.prototype.TimeBufferType=Float32Array,pd.prototype.ValueBufferType=Float32Array,pd.prototype.DefaultInterpolation=$t;class fd extends pd{}fd.prototype.ValueTypeName="bool",fd.prototype.ValueBufferType=Array,fd.prototype.DefaultInterpolation=Jt,fd.prototype.InterpolantFactoryMethodLinear=void 0,fd.prototype.InterpolantFactoryMethodSmooth=void 0;class md extends pd{}md.prototype.ValueTypeName="color";class vd extends pd{}vd.prototype.ValueTypeName="number";class gd extends Ru{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t);let l=e*o;for(var c=l+o;l!==c;l+=4)de.slerpFlat(i,0,a,l-o,a,l,s);return i}}class _d extends pd{InterpolantFactoryMethodLinear(e){return new gd(this.times,this.values,this.getValueSize(),e)}}_d.prototype.ValueTypeName="quaternion",_d.prototype.DefaultInterpolation=$t,_d.prototype.InterpolantFactoryMethodSmooth=void 0;class xd extends pd{}xd.prototype.ValueTypeName="string",xd.prototype.ValueBufferType=Array,xd.prototype.DefaultInterpolation=Jt,xd.prototype.InterpolantFactoryMethodLinear=void 0,xd.prototype.InterpolantFactoryMethodSmooth=void 0;class yd extends pd{}class bd{constructor(e,t=-1,n,r=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=wn(),this.duration<0&&this.resetDuration()}static parse(e){const n=[],r=e.tracks,i=1/(e.fps||1);for(let e=0,t=r.length;e!==t;++e)n.push(function(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 vd;case"vector":case"vector2":case"vector3":case"vector4":return yd;case"color":return md;case"quaternion":return _d;case"bool":case"boolean":return fd;case"string":return xd}throw new Error("v3d.KeyframeTrack: Unsupported typeName: "+e)}(e.type);{var n,r;void 0===e.times&&(n=[],r=[],y.flattenJSON(e.keys,n,r,"value"),e.times=n,e.values=r)}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}(r[e]).scale(i));const t=new this(e.name,e.duration,n,e.blendMode);return t.uuid=e.uuid,t}static toJSON(e){const n=[],r=e.tracks;e={name:e.name,duration:e.duration,tracks:n,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,t=r.length;e!==t;++e)n.push(pd.toJSON(r[e]));return e}static CreateFromMorphTargetSequence(e,r,i,a){var o=r.length;const s=[];for(let n=0;n<o;n++){let e=[],t=[];e.push((n+o-1)%o,n,(n+1)%o),t.push(0,1,0);var l=y.getKeyframeOrder(e);e=y.sortedArray(e,1,l),t=y.sortedArray(t,1,l),a||0!==e[0]||(e.push(o),t.push(t[0])),s.push(new vd(".morphTargetInfluences["+r[n].name+"]",e,t).scale(1/i))}return new this(e,-1,s)}static findByName(e,t){let n=e;Array.isArray(e)||(n=e.geometry&&e.geometry.animations||e.animations);for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null}static CreateClipsFromMorphTargetSequences(n,e,t){const r={};var i=/^([\w-]*?)([\d]+)$/;for(let e=0,t=n.length;e<t;e++){const s=n[e];var a=s.name.match(i);if(a&&1<a.length){a=a[1];let e=r[a];e||(r[a]=e=[]),e.push(s)}}const o=[];for(const l in r)o.push(this.CreateFromMorphTargetSequence(l,r[l],e,t));return o}static parseAnimation(e,t){if(!e)return console.error("v3d.AnimationClip: No animation in JSONLoader data."),null;function n(e,t,n,r,i){var a,o;0!==n.length&&(a=[],o=[],y.flattenJSON(n,a,o,r),0!==a.length&&i.push(new e(t,a,o)))}const r=[];var i=e.name||"default",a=e.fps||30,o=e.blendMode;let s=e.length||-1;var l=e.hierarchy||[];for(let e=0;e<l.length;e++){var c=l[e].keys;if(c&&0!==c.length)if(c[0].morphTargets){const h={};let t;for(t=0;t<c.length;t++)if(c[t].morphTargets)for(let e=0;e<c[t].morphTargets.length;e++)h[c[t].morphTargets[e]]=-1;for(const p in h){const f=[],m=[];for(let e=0;e!==c[t].morphTargets.length;++e){var u=c[t];f.push(u.time),m.push(u.morphTarget===p?1:0)}r.push(new vd(".morphTargetInfluence["+p+"]",f,m))}s=h.length*(a||1)}else{var d=".bones["+t[e].name+"]";n(yd,d+".position",c,"pos",r),n(_d,d+".quaternion",c,"rot",r),n(yd,d+".scale",c,"scl",r)}}return 0===r.length?null:new this(i,s,r,o)}resetDuration(){let n=0;for(let e=0,t=this.tracks.length;e!==t;++e){var r=this.tracks[e];n=Math.max(n,r.times[r.times.length-1])}return this.duration=n,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}const Md={enabled:!(yd.prototype.ValueTypeName="vector"),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 Ad{constructor(e,t,n){const r=this;let i=!1,a=0,o=0,s=void 0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,!1===i&&void 0!==r.onStart&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,void 0!==r.onProgress&&r.onProgress(e,a,o),a===o&&(i=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){e=l.indexOf(e);return-1!==e&&l.splice(e,2),this},this.getHandler=function(n){for(let e=0,t=l.length;e<t;e+=2){const i=l[e];var r=l[e+1];if(i.global&&(i.lastIndex=0),i.test(n))return r}return null}}}const wd=new Ad;class Sd{constructor(e){this.manager=void 0!==e?e:wd,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(n,r){const i=this;return new Promise(function(e,t){i.load(n,e,r,t)})}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 Td={};class Cd extends Sd{constructor(e){super(e)}load(s,n,t,r){void 0===s&&(s=""),void 0!==this.path&&(s=this.path+s),s=this.manager.resolveURL(s);const l=this,e=Md.get(s);if(void 0!==e)return l.manager.itemStart(s),setTimeout(function(){n&&n(e),l.manager.itemEnd(s)},0),e;if(void 0===Td[s]){var i=s.match(/^data:(.*?)(;base64)?,(.*)$/);let e;if(i){var a=i[1],o=!!i[2];let t=i[3];t=decodeURIComponent(t),o&&(t=atob(t));try{let e;var c=(this.responseType||"").toLowerCase();switch(c){case"arraybuffer":case"blob":const u=new Uint8Array(t.length);for(let e=0;e<t.length;e++)u[e]=t.charCodeAt(e);e="blob"===c?new Blob([u.buffer],{type:a}):u.buffer;break;case"document":const d=new DOMParser;e=d.parseFromString(t,a);break;case"json":e=JSON.parse(t);break;default:e=t}setTimeout(function(){n&&n(e),l.manager.itemEnd(s)},0)}catch(e){setTimeout(function(){r&&r(e),l.manager.itemError(s),l.manager.itemEnd(s)},0)}}else{Td[s]=[],Td[s].push({onLoad:n,onProgress:t,onError:r}),(e=new XMLHttpRequest).open("GET",s,!0),e.addEventListener("load",function(n){var r=this.response,i=Td[s];if(delete Td[s],200===this.status||0===this.status){0===this.status&&console.warn("v3d.FileLoader: HTTP Status 0 received."),Md.add(s,r);for(let e=0,t=i.length;e<t;e++){const a=i[e];a.onLoad&&a.onLoad(r)}l.manager.itemEnd(s)}else{for(let e=0,t=i.length;e<t;e++){const o=i[e];o.onError&&o.onError(n)}l.manager.itemError(s),l.manager.itemEnd(s)}},!1),e.addEventListener("progress",function(n){var r=Td[s];for(let e=0,t=r.length;e<t;e++){const i=r[e];i.onProgress&&i.onProgress(n)}},!1),e.addEventListener("error",function(n){var r=Td[s];delete Td[s];for(let e=0,t=r.length;e<t;e++){const i=r[e];i.onError&&i.onError(n)}l.manager.itemError(s),l.manager.itemEnd(s)},!1),e.addEventListener("abort",function(n){var r=Td[s];delete Td[s];for(let e=0,t=r.length;e<t;e++){const i=r[e];i.onError&&i.onError(n)}l.manager.itemError(s),l.manager.itemEnd(s)},!1),void 0!==this.responseType&&(e.responseType=this.responseType),void 0!==this.withCredentials&&(e.withCredentials=this.withCredentials),e.overrideMimeType&&e.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain");for(const h in this.requestHeader)e.setRequestHeader(h,this.requestHeader[h]);e.send(null)}return l.manager.itemStart(s),e}Td[s].push({onLoad:n,onProgress:t,onError:r})}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Ed extends Sd{constructor(e){super(e)}load(t,e,n,r){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const i=this,a=Md.get(t);if(void 0!==a)return i.manager.itemStart(t),setTimeout(function(){e&&e(a),i.manager.itemEnd(t)},0),a;const o=document.createElementNS("http://www.w3.org/1999/xhtml","img");function s(){o.removeEventListener("load",s,!1),o.removeEventListener("error",l,!1),Md.add(t,this),e&&e(this),i.manager.itemEnd(t)}function l(e){o.removeEventListener("load",s,!1),o.removeEventListener("error",l,!1),r&&r(e),i.manager.itemError(t),i.manager.itemEnd(t)}return o.addEventListener("load",s,!1),o.addEventListener("error",l,!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),i.manager.itemStart(t),o.src=t,o}}class Ld extends Sd{constructor(e){super(e)}load(n,r,e,i){const a=new pa,o=new Ed(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let s=0;for(let e=0;e<n.length;++e)!function(t){o.load(n[t],function(e){a.images[t]=e,6===++s&&(a.needsUpdate=!0,r&&r(a))},void 0,i)}(e);return a}}class Rd extends Sd{constructor(e){super(e)}load(e,t,n,r){const i=this,a=new El,o=new Cd(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(i.withCredentials),o.load(e,function(e){e=i.parse(e);e&&(void 0!==e.image?a.image=e.image:void 0!==e.data&&(a.image.width=e.width,a.image.height=e.height,a.image.data=e.data),a.wrapS=void 0!==e.wrapS?e.wrapS:ut,a.wrapT=void 0!==e.wrapT?e.wrapT:ut,a.magFilter=void 0!==e.magFilter?e.magFilter:ht,a.minFilter=void 0!==e.minFilter?e.minFilter:ht,a.anisotropy=void 0!==e.anisotropy?e.anisotropy:1,void 0!==e.encoding&&(a.encoding=e.encoding),void 0!==e.flipY&&(a.flipY=e.flipY),void 0!==e.format&&(a.format=e.format),void 0!==e.type&&(a.type=e.type),void 0!==e.mipmaps&&(a.mipmaps=e.mipmaps,a.minFilter=He),1===e.mipmapCount&&(a.minFilter=ht),void 0!==e.generateMipmaps&&(a.generateMipmaps=e.generateMipmaps),a.needsUpdate=!0,t&&t(a,e))},n,r),a}}class Pd extends Sd{constructor(e){super(e)}load(t,n,e,r){const i=new Hn,a=new Ed(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,function(e){i.image=e;e=0<t.search(/\.jpe?g($|\?)/i)||0===t.search(/^data\:image\/jpeg/);i.format=e?wt:pt,i.needsUpdate=!0,void 0!==n&&n(i)},e,r),i}}class Id extends mc{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0);var t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Lc(t,e))}getPoint(e){var t=e*this.getLength(),n=this.getCurveLengths();let r=0;for(;r<n.length;){if(n[r]>=t){var i=n[r]-t;const o=this.curves[r];var a=o.getLength();return o.getPointAt(0===a?0:1-i/a)}r++}return null}getLength(){var 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 n=[];let r=0;for(let e=0,t=this.curves.length;e<t;e++)r+=this.curves[e].getLength(),n.push(r);return this.cacheLengths=n}getSpacedPoints(t=40){const n=[];for(let e=0;e<=t;e++)n.push(this.getPoint(e/t));return this.autoClose&&n.push(n[0]),n}getPoints(n=12){const r=[];let i;for(let e=0,t=this.curves;e<t.length;e++){const l=t[e];var a=l&&l.isEllipseCurve?2*n:l&&(l.isLineCurve||l.isLineCurve3)?1:l&&l.isSplineCurve?n*l.points.length:n,o=l.getPoints(a);for(let e=0;e<o.length;e++){var s=o[e];i&&i.equals(s)||(r.push(s),i=s)}}return this.autoClose&&1<r.length&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r}copy(n){super.copy(n),this.curves=[];for(let e=0,t=n.curves.length;e<t;e++){const r=n.curves[e];this.curves.push(r.clone())}return this.autoClose=n.autoClose,this}toJSON(){const n=super.toJSON();n.autoClose=this.autoClose,n.curves=[];for(let e=0,t=this.curves.length;e<t;e++){const r=this.curves[e];n.curves.push(r.toJSON())}return n}fromJSON(n){super.fromJSON(n),this.autoClose=n.autoClose,this.curves=[];for(let e=0,t=n.curves.length;e<t;e++){var r=n.curves[e];this.curves.push((new Dc[r.type]).fromJSON(r))}return this}}class Nd extends Id{constructor(e){super(),this.type="Path",this.currentPoint=new Be,e&&this.setFromPoints(e)}setFromPoints(n){this.moveTo(n[0].x,n[0].y);for(let e=1,t=n.length;e<t;e++)this.lineTo(n[e].x,n[e].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){var n=new Lc(this.currentPoint.clone(),new Be(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){e=new Pc(this.currentPoint.clone(),new Be(e,t),new Be(n,r));return this.curves.push(e),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,a){e=new Cc(this.currentPoint.clone(),new Be(e,t),new Be(n,r),new Be(i,a));return this.curves.push(e),this.currentPoint.set(i,a),this}splineThru(e){var t=[this.currentPoint.clone()].concat(e),t=new Nc(t);return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,a){var o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+o,t+s,n,r,i,a),this}absarc(e,t,n,r,i,a){return this.absellipse(e,t,n,n,r,i,a),this}ellipse(e,t,n,r,i,a,o,s){var l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+l,t+c,n,r,i,a,o,s),this}absellipse(e,t,n,r,i,a,o,s){const l=new vc(e,t,n,r,i,a,o,s);if(0<this.curves.length){const c=l.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(l);e=l.getPoint(1);return this.currentPoint.copy(e),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 Dd extends Nd{constructor(e){super(e),this.uuid=wn(),this.type="Shape",this.holes=[]}getPointsHoles(n){const r=[];for(let e=0,t=this.holes.length;e<t;e++)r[e]=this.holes[e].getPoints(n);return r}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(n){super.copy(n),this.holes=[];for(let e=0,t=n.holes.length;e<t;e++){const r=n.holes[e];this.holes.push(r.clone())}return this}toJSON(){const n=super.toJSON();n.uuid=this.uuid,n.holes=[];for(let e=0,t=this.holes.length;e<t;e++){const r=this.holes[e];n.holes.push(r.toJSON())}return n}fromJSON(n){super.fromJSON(n),this.uuid=n.uuid,this.holes=[];for(let e=0,t=n.holes.length;e<t;e++){var r=n.holes[e];this.holes.push((new Nd).fromJSON(r))}return this}}class Od extends he{constructor(e,t=1){super(),this.type="Light",this.color=new _t(e),this.intensity=t,this.isFreeLight=void 0}dispose(){}copy(e){return super.copy(e),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}}Od.prototype.isLight=!0;class Fd extends Od{constructor(e,t,n){super(e,n),this.type="HemisphereLight",this.position.copy(he.DefaultUp),this.updateMatrix(),this.groundColor=new _t(t)}copy(e){return Od.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}Fd.prototype.isHemisphereLight=!0;const Bd=new vt;class zd extends Od{constructor(e,t,n=0,r=Math.PI/3,i=0,a=1){super(e,t),this.type="SpotLight",this.position.copy(he.DefaultUp),this.updateMatrix(),this.target=new he,this.distance=n,this.angle=r,this.penumbra=i,this.decay=a,this.shadow=new Ls}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),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(){Bd.set(0,0,-1).applyQuaternion(this.quaternion).normalize(),this.target.position.addVectors(this.position,Bd),this.target.updateMatrix()}}zd.prototype.isSpotLight=!0;const Vd=new gt,Ud=new vt,Gd=new vt;class kd extends ws{constructor(){super(new da(90,1,.5,500)),this._frameExtents=new Be(4,2),this._viewportCount=6,this._viewports=[new mt(2,1,1,1),new mt(0,1,1,1),new mt(3,1,1,1),new mt(1,1,1,1),new mt(3,0,1,1),new mt(1,0,1,1)],this._cubeDirections=[new vt(1,0,0),new vt(-1,0,0),new vt(0,0,1),new vt(0,0,-1),new vt(0,1,0),new vt(0,-1,0)],this._cubeUps=[new vt(0,1,0),new vt(0,1,0),new vt(0,1,0),new vt(0,1,0),new vt(0,0,1),new vt(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix;var i=e.distance||n.far;i!==n.far&&(n.far=i,n.updateProjectionMatrix()),Ud.setFromMatrixPosition(e.matrixWorld),n.position.copy(Ud),Gd.copy(n.position),Gd.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Gd),n.updateMatrixWorld(),r.makeTranslation(-Ud.x,-Ud.y,-Ud.z),Vd.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Vd)}}kd.prototype.isPointLightShadow=!0;class Wd extends Od{constructor(e,t,n=0,r=1){super(e,t),this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new kd}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}Wd.prototype.isPointLight=!0;class Hd extends ws{constructor(){super(new Rs(-5,5,5,-5,.5,500))}updateMatrices(e){super.updateMatrices(e)}}Hd.prototype.isDirectionalLightShadow=!0;class Xd extends ws{constructor(){super(new Rs(-5,5,5,-5,.5,500)),this.maxDistance=10}copy(e){return super.copy(e),this.maxDistance=e.maxDistance,this}}Xd.prototype.isDirectionalLightShadowCSM=!0;const jd=new vt;class Yd extends Od{constructor(e,t){super(e,t),this.type="DirectionalLight",this.position.copy(he.DefaultUp),this.updateMatrix(),this.target=new he,this.shadow=new Hd}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(){jd.set(0,0,-1).applyQuaternion(this.quaternion).normalize(),this.target.position.addVectors(this.position,jd),this.target.updateMatrix()}}Yd.prototype.isDirectionalLight=!0;class Zd extends Od{constructor(e,t){super(e,t),this.type="AmbientLight"}}Zd.prototype.isAmbientLight=!0;class qd extends kd{constructor(){super()}}qd.prototype.isRectAreaLightShadow=!0;class Qd extends Od{constructor(e,t,n=10,r=10){super(e,t),this.type="RectAreaLight",this.width=n,this.height=r,this.shadow=new qd,Object.defineProperty(this,"power",{get:function(){return 2*this.intensity*Math.PI},set:function(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}}Qd.prototype.isRectAreaLight=!0;class Kd{constructor(){this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new vt)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){var n=e.x,r=e.y,e=e.z,i=this.coefficients;return t.copy(i[0]).multiplyScalar(.282095),t.addScaledVector(i[1],.488603*r),t.addScaledVector(i[2],.488603*e),t.addScaledVector(i[3],.488603*n),t.addScaledVector(i[4],n*r*1.092548),t.addScaledVector(i[5],r*e*1.092548),t.addScaledVector(i[6],.315392*(3*e*e-1)),t.addScaledVector(i[7],n*e*1.092548),t.addScaledVector(i[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){var n=e.x,r=e.y,e=e.z,i=this.coefficients;return t.copy(i[0]).multiplyScalar(.886227),t.addScaledVector(i[1],1.023328*r),t.addScaledVector(i[2],1.023328*e),t.addScaledVector(i[3],1.023328*n),t.addScaledVector(i[4],.858086*n*r),t.addScaledVector(i[5],.858086*r*e),t.addScaledVector(i[6],.743125*e*e-.247708),t.addScaledVector(i[7],.858086*n*e),t.addScaledVector(i[8],.429043*(n*n-r*r)),t}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,n){for(let e=0;e<9;e++)this.coefficients[e].addScaledVector(t.coefficients[e],n);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,n){for(let e=0;e<9;e++)this.coefficients[e].lerp(t.coefficients[e],n);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,n=0){const r=this.coefficients;for(let e=0;e<9;e++)r[e].fromArray(t,n+3*e);return this}toArray(t=[],n=0){const r=this.coefficients;for(let e=0;e<9;e++)r[e].toArray(t,n+3*e);return t}static getBasisAt(e,t){var n=e.x,r=e.y,e=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*e,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*e,t[6]=.315392*(3*e*e-1),t[7]=1.092548*n*e,t[8]=.546274*(n*n-r*r)}}Kd.prototype.isSphericalHarmonics3=!0;class Jd extends Od{constructor(e=new Kd,t=1){super(void 0,t),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}}Jd.prototype.isLightProbe=!0;class $d extends Sd{constructor(e){super(e),this.textures={}}load(t,n,e,r){const i=this,a=new Cd(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(t,function(e){try{n(i.parse(JSON.parse(e)))}catch(e){r?r(e):console.error(e),i.manager.itemError(t)}},e,r)}parse(t){const n=this.textures;function e(e){return void 0===n[e]&&console.warn("v3d.MaterialLoader: Undefined texture",e),n[e]}const r=new dd[t.type];if(void 0!==t.uuid&&(r.uuid=t.uuid),void 0!==t.name&&(r.name=t.name),void 0!==t.color&&void 0!==r.color&&r.color.setHex(t.color),void 0!==t.roughness&&(r.roughness=t.roughness),void 0!==t.metalness&&(r.metalness=t.metalness),void 0!==t.sheen&&(r.sheen=(new _t).setHex(t.sheen)),void 0!==t.emissive&&void 0!==r.emissive&&r.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==r.specular&&r.specular.setHex(t.specular),void 0!==t.shininess&&(r.shininess=t.shininess),void 0!==t.clearcoat&&(r.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(r.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.transmission&&(r.transmission=t.transmission),void 0!==t.thickness&&(r.thickness=t.thickness),void 0!==t.attenuationDistance&&(r.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==r.attenuationColor&&r.attenuationColor.setHex(t.attenuationColor),void 0!==t.fog&&(r.fog=t.fog),void 0!==t.flatShading&&(r.flatShading=t.flatShading),void 0!==t.blending&&(r.blending=t.blending),void 0!==t.combine&&(r.combine=t.combine),void 0!==t.side&&(r.side=t.side),void 0!==t.shadowSide&&(r.shadowSide=t.shadowSide),void 0!==t.opacity&&(r.opacity=t.opacity),void 0!==t.transparent&&(r.transparent=t.transparent),void 0!==t.alphaTest&&(r.alphaTest=t.alphaTest),void 0!==t.depthTest&&(r.depthTest=t.depthTest),void 0!==t.depthWrite&&(r.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(r.colorWrite=t.colorWrite),void 0!==t.stencilWrite&&(r.stencilWrite=t.stencilWrite),void 0!==t.stencilWriteMask&&(r.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(r.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(r.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(r.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(r.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(r.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(r.stencilZPass=t.stencilZPass),void 0!==t.wireframe&&(r.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(r.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(r.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(r.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(r.rotation=t.rotation),1!==t.linewidth&&(r.linewidth=t.linewidth),void 0!==t.dashSize&&(r.dashSize=t.dashSize),void 0!==t.gapSize&&(r.gapSize=t.gapSize),void 0!==t.scale&&(r.scale=t.scale),void 0!==t.polygonOffset&&(r.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(r.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(r.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.morphTargets&&(r.morphTargets=t.morphTargets),void 0!==t.morphNormals&&(r.morphNormals=t.morphNormals),void 0!==t.dithering&&(r.dithering=t.dithering),void 0!==t.alphaToCoverage&&(r.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(r.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.vertexTangents&&(r.vertexTangents=t.vertexTangents),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.toneMapped&&(r.toneMapped=t.toneMapped),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?r.vertexColors=0<t.vertexColors:r.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const a in t.uniforms){var i=t.uniforms[a];switch(r.uniforms[a]={},i.type){case"t":r.uniforms[a].value=e(i.value);break;case"c":r.uniforms[a].value=(new _t).setHex(i.value);break;case"v2":r.uniforms[a].value=(new Be).fromArray(i.value);break;case"v3":r.uniforms[a].value=(new vt).fromArray(i.value);break;case"v4":r.uniforms[a].value=(new mt).fromArray(i.value);break;case"m3":r.uniforms[a].value=(new Un).fromArray(i.value);break;case"m4":r.uniforms[a].value=(new gt).fromArray(i.value);break;default:r.uniforms[a].value=i.value}}if(void 0!==t.defines&&(r.defines=t.defines),void 0!==t.vertexShader&&(r.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(r.fragmentShader=t.fragmentShader),void 0!==t.extensions)for(const o in t.extensions)r.extensions[o]=t.extensions[o];if(void 0!==t.shading&&(r.flatShading=1===t.shading),void 0!==t.size&&(r.size=t.size),void 0!==t.sizeAttenuation&&(r.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(r.map=e(t.map)),void 0!==t.matcap&&(r.matcap=e(t.matcap)),void 0!==t.alphaMap&&(r.alphaMap=e(t.alphaMap)),void 0!==t.bumpMap&&(r.bumpMap=e(t.bumpMap)),void 0!==t.bumpScale&&(r.bumpScale=t.bumpScale),void 0!==t.normalMap&&(r.normalMap=e(t.normalMap)),void 0!==t.normalMapType&&(r.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),r.normalScale=(new Be).fromArray(e)}return void 0!==t.displacementMap&&(r.displacementMap=e(t.displacementMap)),void 0!==t.displacementScale&&(r.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(r.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(r.roughnessMap=e(t.roughnessMap)),void 0!==t.metalnessMap&&(r.metalnessMap=e(t.metalnessMap)),void 0!==t.emissiveMap&&(r.emissiveMap=e(t.emissiveMap)),void 0!==t.emissiveIntensity&&(r.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(r.specularMap=e(t.specularMap)),void 0!==t.envMap&&(r.envMap=e(t.envMap)),void 0!==t.envMapIntensity&&(r.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(r.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(r.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(r.lightMap=e(t.lightMap)),void 0!==t.lightMapIntensity&&(r.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(r.aoMap=e(t.aoMap)),void 0!==t.aoMapIntensity&&(r.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(r.gradientMap=e(t.gradientMap)),void 0!==t.clearcoatMap&&(r.clearcoatMap=e(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(r.clearcoatRoughnessMap=e(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(r.clearcoatNormalMap=e(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(r.clearcoatNormalScale=(new Be).fromArray(t.clearcoatNormalScale)),void 0!==t.transmissionMap&&(r.transmissionMap=e(t.transmissionMap)),void 0!==t.thicknessMap&&(r.thicknessMap=e(t.thicknessMap)),r}setTextures(e){return this.textures=e,this}}class eh{static decodeText(n){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(n);let r="";for(let e=0,t=n.length;e<t;e++)r+=String.fromCharCode(n[e]);try{return decodeURIComponent(escape(r))}catch(e){return r}}static extractUrlBase(e){var t=e.lastIndexOf("/");return-1===t?"./":e.substr(0,t+1)}}class th extends S{constructor(){super(),this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return(new this.constructor).copy(this)}toJSON(){const e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}th.prototype.isInstancedBufferGeometry=!0;class nh extends re{constructor(e,t,n,r=1){"number"==typeof n&&(r=n,n=!1,console.error("v3d.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,n),this.meshPerAttribute=r}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}}nh.prototype.isInstancedBufferAttribute=!0;class rh extends Sd{constructor(e){super(e)}load(t,n,e,r){const i=this,a=new Cd(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(t,function(e){try{n(i.parse(JSON.parse(e)))}catch(e){r?r(e):console.error(e),i.manager.itemError(t)}},e,r)}parse(n){const i={},a={};function r(e,t){if(void 0!==i[t])return i[t];var n=e.interleavedBuffers[t],e=function(e,t){if(void 0!==a[t])return a[t];e=e.arrayBuffers,e=e[t],e=new Uint32Array(e).buffer;return a[t]=e}(e,n.buffer),e=Ci(n.type,e);const r=new $s(e,n.stride);return r.uuid=n.uuid,i[t]=r}const o=new(n.isInstancedBufferGeometry?th:S);var e=n.data.index,t=(void 0!==e&&(e=Ci(e.type,e.array),o.setIndex(new re(e,1))),n.data.attributes);for(const m in t){var s=t[m];let e;if(s.isInterleavedBufferAttribute){var l=r(n.data,s.data);e=new tl(l,s.itemSize,s.offset,s.normalized)}else{l=Ci(s.type,s.array);const v=s.isInstancedBufferAttribute?nh:re;e=new v(l,s.itemSize,s.normalized)}void 0!==s.name&&(e.name=s.name),void 0!==s.usage&&e.setUsage(s.usage),void 0!==s.updateRange&&(e.updateRange.offset=s.updateRange.offset,e.updateRange.count=s.updateRange.count),o.setAttribute(m,e)}var c=n.data.morphAttributes;if(c)for(const g in c){var u=c[g];const _=[];for(let t=0,e=u.length;t<e;t++){var d,h=u[t];let e;e=h.isInterleavedBufferAttribute?(d=r(n.data,h.data),new tl(d,h.itemSize,h.offset,h.normalized)):(d=Ci(h.type,h.array),new re(d,h.itemSize,h.normalized)),void 0!==h.name&&(e.name=h.name),_.push(e)}o.morphAttributes[g]=_}n.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);var p=n.data.groups||n.data.drawcalls||n.data.offsets;if(void 0!==p)for(let e=0,t=p.length;e!==t;++e){var f=p[e];o.addGroup(f.start,f.count,f.materialIndex)}e=n.data.boundingSphere;if(void 0!==e){const x=new vt;void 0!==e.center&&x.fromArray(e.center),o.boundingSphere=new fr(x,e.radius)}return n.name&&(o.name=n.name),n.userData&&(o.userData=n.userData),o}}const ih={UVMapping:s,CubeReflectionMapping:L,CubeRefractionMapping:R,EquirectangularReflectionMapping:P,EquirectangularRefractionMapping:I,CubeUVReflectionMapping:N,CubeUVRefractionMapping:D},ah={RepeatWrapping:U,ClampToEdgeWrapping:ut,MirroredRepeatWrapping:G},oh={NearestFilter:dt,NearestMipmapNearestFilter:W,NearestMipmapLinearFilter:H,LinearFilter:ht,LinearMipmapNearestFilter:We,LinearMipmapLinearFilter:He};class sh extends Sd{constructor(e){super(e),"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(t,n,e,r){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const i=this,a=Md.get(t);if(void 0!==a)return i.manager.itemStart(t),setTimeout(function(){n&&n(a),i.manager.itemEnd(t)},0),a;const o={};o.credentials="anonymous"===this.crossOrigin?"same-origin":"include",o.headers=this.requestHeader,fetch(t,o).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign(i.options,{colorSpaceConversion:"none"}))}).then(function(e){Md.add(t,e),n&&n(e),i.manager.itemEnd(t)}).catch(function(e){r&&r(e),i.manager.itemError(t),i.manager.itemEnd(t)}),i.manager.itemStart(t)}}class lh{constructor(){this.type="ShapePath",this.color=new _t,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Nd,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,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,i,a){return this.currentPath.bezierCurveTo(e,t,n,r,i,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(n,e){function t(n){const r=[];for(let e=0,t=n.length;e<t;e++){var i=n[e];const a=new Dd;a.curves=i.curves,r.push(a)}return r}const r=Jc.isClockWise,i=this.subPaths;if(0===i.length)return[];if(!0===e)return t(i);let a,o,s;const l=[];if(1===i.length)return o=i[0],(s=new Dd).curves=o.curves,l.push(s),l;let c=!r(i[0].getPoints());c=n?!c:c;const u=[],d=[];let h=[],p=0;var f,m;d[p]=void 0,h[p]=[];for(let e=0,t=i.length;e<t;e++)f=(o=i[e]).getPoints(),a=r(f),(a=n?!a:a)?(!c&&d[p]&&p++,d[p]={s:new Dd,p:f},d[p].s.curves=o.curves,c&&p++,h[p]=[]):h[p].push({h:o,p:f[0]});if(!d[0])return t(i);if(1<d.length){let i=!1;const _=[];for(let e=0,t=d.length;e<t;e++)u[e]=[];for(let r=0,e=d.length;r<e;r++){var v=h[r];for(let n=0;n<v.length;n++){var g=v[n];let t=!0;for(let e=0;e<d.length;e++)!function(o,s){var e=s.length;let l=!1;for(let i=e-1,a=0;a<e;i=a++){let e=s[i],t=s[a],n=t.x-e.x,r=t.y-e.y;if(Math.abs(r)>Number.EPSILON){if(r<0&&(e=s[a],n=-n,t=s[i],r=-r),!(o.y<e.y||o.y>t.y))if(o.y===e.y){if(o.x===e.x)return 1}else{var c=r*(o.x-e.x)-n*(o.y-e.y);if(0==c)return 1;c<0||(l=!l)}}else if(o.y===e.y&&(t.x<=o.x&&o.x<=e.x||e.x<=o.x&&o.x<=t.x))return 1}return l}(g.p,d[e].p)||(r!==e&&_.push({froms:r,tos:e,hole:n}),t?(t=!1,u[e].push(g)):i=!0);t&&u[r].push(g)}}0<_.length&&(i||(h=u))}for(let n=0,e=d.length;n<e;n++){s=d[n].s,l.push(s);for(let e=0,t=(m=h[n]).length;e<t;e++)s.holes.push(m[e].h)}return l}}class ch{constructor(e){this.type="Font",this.data=e}generateShapes(e,t=100,n="left",r="topBaseline",i=-1,a=!1){var o=[];const s=function(e,t,n,r,i,a,o){const s=String(e).split("\n"),l=[];for(let e=0;e<s.length;e++){var c=s[e];l[e]=Array.from?Array.from(c):String(c).split("")}let u=t/n.resolution;o&&(u*=(n.ascender-n.descender)/(n.boundingBox.yMax-n.boundingBox.yMin));n.lineGap=n.lineGap||0,-1===a?a=(n.ascender-n.descender+n.lineGap)*u:a*=t;const d=[];let h=0,p=0;var f=l.length,m=a*f,e=a*Math.abs(n.descender)/n.ascender,v=a-e;switch(i){case"topBaseline":p=0;break;case"top":p=-v;break;case"center":p=1<f?.5*m-v:-n.ascender/2*u;break;case"bottom":p=m-a-n.descender*u;break;case"bottomBaseline":p=m-a;break;default:p=0}for(let e=0;e<l.length;e++){var g=l[e];switch(r){case"left":h=0;break;case"center":h=-uh(g,u,n)/2;break;case"right":h=-uh(g,u,n);break;default:h=0}for(let e=0;e<g.length;e++){var _=function(e,u,d,h,t){const p=t.glyphs[e]||t.glyphs["?"];if(p){const m=new lh;let n,r,i,a,o,s,l,c;if(p.o){var f=p._cachedOutline||(p._cachedOutline=p.o.split(" "));for(let e=0,t=f.length;e<t;)switch(f[e++]){case"m":n=f[e++]*u+d,r=f[e++]*u+h,m.moveTo(n,r);break;case"l":n=f[e++]*u+d,r=f[e++]*u+h,m.lineTo(n,r);break;case"q":i=f[e++]*u+d,a=f[e++]*u+h,o=f[e++]*u+d,s=f[e++]*u+h,m.quadraticCurveTo(o,s,i,a);break;case"b":i=f[e++]*u+d,a=f[e++]*u+h,o=f[e++]*u+d,s=f[e++]*u+h,l=f[e++]*u+d,c=f[e++]*u+h,m.bezierCurveTo(o,s,l,c,i,a)}}return{offsetX:p.ha*u,path:m}}console.error('v3d.Font: character "'+e+'" does not exists in font family '+t.familyName+".")}(g[e],u,h,p,n);h+=_.offsetX,d.push(_.path)}p-=a}return d}(e,t,this.data,n,r,i,a);for(let e=0,t=s.length;e<t;e++)Array.prototype.push.apply(o,s[e].toShapes());return o}}function uh(e,t,n){let r=0;for(var i=0;i<e.length;i++){var a=e[i],a=n.glyphs[a]||n.glyphs["?"];r+=a.ha*t}return r}ch.prototype.isFont=sh.prototype.isImageBitmapLoader=!0;let dh;const hh={getContext:function(){return dh=void 0===dh?new(window.AudioContext||window.webkitAudioContext):dh},setContext:function(e){dh=e}};class ph extends Sd{constructor(e){super(e)}load(r,i,e,a){const o=this,t=new Cd(this.manager);t.setResponseType("arraybuffer"),t.setPath(this.path),t.setRequestHeader(this.requestHeader),t.setWithCredentials(this.withCredentials),t.load(r,function(e){try{var t=e.slice(0);const n=hh.getContext();n.decodeAudioData(t,function(e){i(e)})}catch(e){a?a(e):console.error(e),o.manager.itemError(r)}},e,a)}}class fh extends Jd{constructor(e,t,n=1){super(void 0,n);var n=(new _t).set(e),e=(new _t).set(t),t=new vt(n.r,n.g,n.b),n=new vt(e.r,e.g,e.b),e=Math.sqrt(Math.PI),r=e*Math.sqrt(.75);this.sh.coefficients[0].copy(t).add(n).multiplyScalar(e),this.sh.coefficients[1].copy(t).sub(n).multiplyScalar(r)}}class mh extends Jd{constructor(e,t=1){super(void 0,t);t=(new _t).set(e);this.sh.coefficients[0].set(t.r,t.g,t.b).multiplyScalar(2*Math.sqrt(Math.PI))}}mh.prototype.isAmbientLightProbe=fh.prototype.isHemisphereLightProbe=!0;const vh=new gt,gh=new gt;class _h{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=xh(),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;return this.autoStart&&!this.running?(this.start(),0):(this.running&&(t=xh(),e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e),e);var t}}function xh(){return("undefined"==typeof performance?Date:performance).now()}const yh=new vt,bh=new de,Mh=new vt,Ah=new vt;class wh extends he{constructor(){super(),this.type="AudioListener",this.context=hh.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new _h}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;var n,e=this.up;this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(yh,bh,Mh),Ah.set(0,0,-1).applyQuaternion(bh),t.positionX?(n=this.context.currentTime+this.timeDelta,t.positionX.linearRampToValueAtTime(yh.x,n),t.positionY.linearRampToValueAtTime(yh.y,n),t.positionZ.linearRampToValueAtTime(yh.z,n),t.forwardX.linearRampToValueAtTime(Ah.x,n),t.forwardY.linearRampToValueAtTime(Ah.y,n),t.forwardZ.linearRampToValueAtTime(Ah.z,n),t.upX.linearRampToValueAtTime(e.x,n),t.upY.linearRampToValueAtTime(e.y,n),t.upZ.linearRampToValueAtTime(e.z,n)):(t.setPosition(yh.x,yh.y,yh.z),t.setOrientation(Ah.x,Ah.y,Ah.z,e.x,e.y,e.z))}}class Sh extends he{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)console.warn("v3d.Audio: Audio is already playing.");else{if(!1!==this.hasPlaybackControl){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()}console.warn("v3d.Audio: this Audio has no playback control.")}}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(0<this.filters.length){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(0<this.filters.length){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 Th=new vt,Ch=new de,Eh=new vt,Lh=new vt;class Rh{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 t=0;var n=this.getFrequencyData();for(let e=0;e<n.length;e++)t+=n[e];return t/n.length}}class Ph{constructor(e,t,n){this.binding=e,this.valueSize=n;let r,i,a;switch(t){case"quaternion":r=this._slerp,i=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":r=this._select,i=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:r=this._lerp,i=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=i,this._setIdentity=a,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,r=this.valueSize,i=e*r+r;let a=this.cumulativeWeight;if(0===a){for(let e=0;e!==r;++e)n[i+e]=n[e];a=t}else{e=t/(a+=t);this._mixBufferRegion(n,i,0,e,r)}this.cumulativeWeight=a}accumulateAdditive(e){var t=this.buffer,n=this.valueSize,r=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const n=this.valueSize,r=this.buffer,i=e*n+n,t=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,t<1&&(e=n*this._origIndex,this._mixBufferRegion(r,i,e,1-t,n)),0<a&&this._mixBufferRegionAdditive(r,i,this._addIndex*n,1,n);for(let e=n,t=n+n;e!==t;++e)if(r[e]!==r[e+n]){o.setValue(r,i);break}}saveOriginalState(){const e=this.binding,n=this.buffer,r=this.valueSize,i=r*this._origIndex;e.getValue(n,i);for(let e=r,t=i;e!==t;++e)n[e]=n[i+e%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){var e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){var t=this._addIndex*this.valueSize,n=t+this.valueSize;for(let e=t;e<n;e++)this.buffer[e]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){var t=this._origIndex*this.valueSize,n=this._addIndex*this.valueSize;for(let e=0;e<this.valueSize;e++)this.buffer[n+e]=this.buffer[t+e]}_select(t,n,r,e,i){if(.5<=e)for(let e=0;e!==i;++e)t[n+e]=t[r+e]}_slerp(e,t,n,r){de.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,i){i=this._workIndex*i;de.multiplyQuaternionsFlat(e,i,e,t,e,n),de.slerpFlat(e,t,e,t,e,i,r)}_lerp(t,n,r,i,a){var o=1-i;for(let e=0;e!==a;++e){var s=n+e;t[s]=t[s]*o+t[r+e]*i}}_lerpAdditive(t,n,r,i,a){for(let e=0;e!==a;++e){var o=n+e;t[o]=t[o]+t[r+e]*i}}}var Ih="\\[\\]\\.";const Nh=new RegExp("["+Ih+"]","g");var Dh="[^"+Ih+"]",Ih="[^"+Ih.replace("\\.","")+"]",Ih=(/((?:WC+[\/:])*)/.source.replace("WC",Dh),/(WCOD+)?/.source.replace("WCOD",Ih)),Oh=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Dh),Dh=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Dh);const Fh=new RegExp("^"+Ih+Oh+Dh+"$"),Bh=["material","materials","bones"];class C{constructor(e,t,n){this.path=t,this.parsedPath=n||C.parseTrackName(t),this.node=C.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 new(e&&e.isAnimationObjectGroup?C.Composite:C)(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Nh,"")}static parseTrackName(e){var t=Fh.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[1],objectName:t[2],objectIndex:t[3],propertyName:t[4],propertyIndex:t[5]};var r,t=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==t&&-1!==t&&(r=n.nodeName.substring(t+1),-1!==Bh.indexOf(r)&&(n.nodeName=n.nodeName.substring(0,t),n.objectName=r)),null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,r){if(!r||""===r||"."===r||-1===r||r===e.name||r===e.uuid)return e;if(e.skeleton){var t=e.skeleton.getBoneByName(r);if(void 0!==t)return t}if(e.children){const i=function(t){for(let e=0;e<t.length;e++){var n=t[e];if(n.name===r||n.uuid===r)return n;n=i(n.children);if(n)return n}return null};t=i(e.children);if(t)return t}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.node[this.propertyName]}_getValue_array(n,r){var i=this.resolvedProperty;for(let e=0,t=i.length;e!==t;++e)n[r++]=i[e]}_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(n,r){const i=this.resolvedProperty;for(let e=0,t=i.length;e!==t;++e)i[e]=n[r++]}_setValue_array_setNeedsUpdate(n,r){const i=this.resolvedProperty;for(let e=0,t=i.length;e!==t;++e)i[e]=n[r++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(n,r){const i=this.resolvedProperty;for(let e=0,t=i.length;e!==t;++e)i[e]=n[r++];this.targetObject.matrixWorldNeedsUpdate=!0}_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 r=this.node;var i=this.parsedPath,a=i.objectName,o=i.propertyName;let s=i.propertyIndex;if(r||(r=C.findNode(this.rootNode,i.nodeName)||this.rootNode,this.node=r),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,r){if(a){let t=i.objectIndex;switch(a){case"materials":if(!r.material)return void console.error("v3d.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!r.material.materials)return void console.error("v3d.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);r=r.material.materials;break;case"bones":if(!r.skeleton)return void console.error("v3d.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);r=r.skeleton.bones;for(let e=0;e<r.length;e++)if(r[e].name===t){t=e;break}break;default:if(void 0===r[a])return void console.error("v3d.PropertyBinding: Can not bind to objectName of node undefined.",this);r=r[a]}if(void 0!==t){if(void 0===r[t])return void console.error("v3d.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,r);r=r[t]}}let e=r[o];if(void 0===e)return i=i.nodeName,void console.error("v3d.PropertyBinding: Trying to update property for track: "+i+"."+o+" but it wasn't found.",r);let t=this.Versioning.None,n=(void 0!==(this.targetObject=r).needsUpdate?t=this.Versioning.NeedsUpdate:void 0!==r.matrixWorldNeedsUpdate&&(t=this.Versioning.MatrixWorldNeedsUpdate),this.BindingType.Direct);if(void 0!==s){if("morphTargetInfluences"===o){if(!r.geometry)return void console.error("v3d.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!r.geometry.isBufferGeometry)return void console.error("v3d.PropertyBinding: Can not bind to morphTargetInfluences on v3d.Geometry. Use v3d.BufferGeometry instead.",this);if(!r.geometry.morphAttributes)return void console.error("v3d.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==r.morphTargetDictionary[s]&&(s=r.morphTargetDictionary[s])}else if("nodeValue"==o){if(s=s.replace(/"/g,""),!r.nodeValueMap)return void console.error("v3d.PropertyBinding: Trying to animate nodes in non-node material",this);if(void 0===(s=r.nodeValueMap[s]))return void console.error("v3d.PropertyBinding: Animated node not found ",this)}if(n=this.BindingType.ArrayElement,"nodeRGB"==o){if(s=s.replace(/"/g,""),!r.nodeRGBMap)return void console.error("v3d.PropertyBinding: Trying to animate nodes in non-node material",this);if(void 0===(s=r.nodeRGBMap[s]))return void console.error("v3d.PropertyBinding: Animated node not found ",this);n=this.BindingType.HasFromToArray,e=r.nodeRGB[s]}this.resolvedProperty=e,this.propertyIndex=s}else void 0!==e.fromArray&&void 0!==e.toArray?(n=this.BindingType.HasFromToArray,this.resolvedProperty=e):Array.isArray(e)?(n=this.BindingType.EntireArray,this.resolvedProperty=e):this.propertyName=o;this.getValue=this.GetterByBindingType[n],this.setValue=this.SetterByBindingTypeAndVersioning[n][t]}else console.error("v3d.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.")}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}C.Composite=class{constructor(e,t,n){n=n||C.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];void 0!==r&&r.getValue(e,t)}setValue(n,r){const i=this._bindings;for(let e=this._targetGroup.nCachedObjects_,t=i.length;e!==t;++e)i[e].setValue(n,r)}bind(){const n=this._bindings;for(let e=this._targetGroup.nCachedObjects_,t=n.length;e!==t;++e)n[e].bind()}unbind(){const n=this._bindings;for(let e=this._targetGroup.nCachedObjects_,t=n.length;e!==t;++e)n[e].unbind()}},C.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},C.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},C.prototype.GetterByBindingType=[C.prototype._getValue_direct,C.prototype._getValue_array,C.prototype._getValue_arrayElement,C.prototype._getValue_toArray],C.prototype.SetterByBindingTypeAndVersioning=[[C.prototype._setValue_direct,C.prototype._setValue_direct_setNeedsUpdate,C.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[C.prototype._setValue_array,C.prototype._setValue_array_setNeedsUpdate,C.prototype._setValue_array_setMatrixWorldNeedsUpdate],[C.prototype._setValue_arrayElement,C.prototype._setValue_arrayElement_setNeedsUpdate,C.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[C.prototype._setValue_fromArray,C.prototype._setValue_fromArray_setNeedsUpdate,C.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class zh{constructor(){this.uuid=wn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const n={};this._indicesByUUID=n;for(let e=0,t=arguments.length;e!==t;++e)n[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const r=this._objects,i=this._indicesByUUID,a=this._paths,o=this._parsedPaths,s=this._bindings,l=s.length;let c=void 0,u=r.length,d=this.nCachedObjects_;for(let e=0,t=arguments.length;e!==t;++e){var h=arguments[e],p=h.uuid;let n=i[p];if(void 0===n){n=u++,i[p]=n,r.push(h);for(let e=0,t=l;e!==t;++e)s[e].push(new C(h,a[e],o[e]))}else if(n<d){c=r[n];var f=--d,m=r[f];i[m.uuid]=n,r[n]=m,i[p]=f,r[f]=h;for(let t=0,e=l;t!==e;++t){const v=s[t],g=v[f];let e=v[n];v[n]=g,void 0===e&&(e=new C(h,a[t],o[t])),v[f]=e}}else r[n]!==c&&console.error("v3d.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=d}remove(){const n=this._objects,r=this._indicesByUUID,i=this._bindings,a=i.length;let o=this.nCachedObjects_;for(let e=0,t=arguments.length;e!==t;++e){var s=arguments[e],l=s.uuid,c=r[l];if(void 0!==c&&c>=o){var u=o++,d=n[u];r[d.uuid]=c,n[c]=d,r[l]=u,n[u]=s;for(let e=0,t=a;e!==t;++e){const h=i[e],p=h[u],f=h[c];h[c]=p,h[u]=f}}}this.nCachedObjects_=o}uncache(){const n=this._objects,r=this._indicesByUUID,i=this._bindings,a=i.length;let o=this.nCachedObjects_,s=n.length;for(let e=0,t=arguments.length;e!==t;++e){var l=arguments[e].uuid,c=r[l];if(void 0!==c)if(delete r[l],c<o){var u=--o,l=n[u],d=--s,h=n[d];r[l.uuid]=c,n[c]=l,r[h.uuid]=u,n[u]=h,n.pop();for(let e=0,t=a;e!==t;++e){const f=i[e],m=f[u],v=f[d];f[c]=m,f[u]=v,f.pop()}}else{var p=--s,l=n[p];0<p&&(r[l.uuid]=c),n[c]=l,n.pop();for(let e=0,t=a;e!==t;++e){const g=i[e];g[c]=g[p],g.pop()}}}this.nCachedObjects_=o}subscribe_(n,r){const e=this._bindingsIndicesByPath;let t=e[n];const i=this._bindings;if(void 0!==t)return i[t];const a=this._paths,o=this._parsedPaths,s=this._objects,l=s.length,c=this.nCachedObjects_,u=new Array(l);t=i.length,e[n]=t,a.push(n),o.push(r),i.push(u);for(let e=c,t=s.length;e!==t;++e){var d=s[e];u[e]=new C(d,n,r)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const r=this._paths,i=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o],l=e[o];t[l]=n,a[n]=s,a.pop(),i[n]=i[o],i.pop(),r[n]=r[o],r.pop()}}}zh.prototype.isAnimationObjectGroup=!0;class Vh{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;const i=t.tracks,a=i.length,o=new Array(a);var s={endingStart:tn,endingEnd:tn};for(let e=0;e!==a;++e){const l=i[e].createInterpolant(null);(o[e]=l).settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,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){var r,i;return e.fadeOut(t),this.fadeIn(t),n&&(i=(n=this._clip.duration)/(r=e._clip.duration),e.warp(1,r/n,t),this.warp(i,1,t)),this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){var 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 r=this._mixer,i=r.time,a=this.timeScale;let o=this._timeScaleInterpolant;null===o&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const s=o.parameterPositions,l=o.sampleValues;return s[0]=i,s[1]=i+n,l[0]=e/a,l[1]=t/a,this}stopWarping(){var 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,r){if(this.enabled){var i=this._startTime;if(null!==i){i=(e-i)*n;if(i<0||0===n)return;this._startTime=null,t=n*i}t*=this._updateTimeScale(e);var a=this._updateTime(t),o=this._updateWeight(e);if(0<o){const s=this._interpolants,l=this._propertyBindings;if(2501===this.blendMode)for(let e=0,t=s.length;e!==t;++e)s[e].evaluate(a),l[e].accumulateAdditive(o);else for(let e=0,t=s.length;e!==t;++e)s[e].evaluate(a),l[e].accumulate(r,o)}}else this._updateWeight(e)}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const r=this._weightInterpolant;var n;null!==r&&(n=r.evaluate(e)[0],t*=n,e>r.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1)))}return this._effectiveWeight=t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const r=this._timeScaleInterpolant;var n;null!==r&&(n=r.evaluate(e)[0],t*=n,e>r.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t}_loopIsPing(e){return 2202!==this.loop||(-1==e||0==(1&e)===this._pingIsEven)}_updateTime(e){if(0===e)return this.time;if(2200!==this.loop&&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,n,r,i,a=this.timeStart,o=Math.max(a,this._clip.duration),s=o-a;return 2200===this.loop?(this.time+=e,-1===this._loopCount&&(this._loopCount=0,this._setEndings(!0,!0,!1)),(this.time<a||this.time>o)&&(this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=ft(this.time,a,o),this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1}))):(t=2202===this.loop,r=this._loopIsPing(this._loopCount)?1:-1,this.time+=r*e,r=this.time<a||this.time>o,n=!1,-1===this._loopCount&&(this._loopCount=(n=r)?-1:0,this._pingIsEven=!n,0<=e?this._setEndings(!0,0===this.repetitions,t):this._setEndings(0===this.repetitions,!0,t)),r&&(r=Math.floor((this.time-a)/s),this._loopCount+=Math.abs(r),(i=this.repetitions-this._loopCount)<=0?(this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=ft(this.time,a,o),this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})):(1==i?this._setEndings(i=e<0,!i,t):this._setEndings(!1,!1,t),(e=(this.time-a)%s)<0&&(e+=s),this.time=t?o-e:e+a,n||this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:r})))),this.time}_setEndings(e,t,n){const r=this._interpolantSettings;n?(r.endingStart=nn,r.endingEnd=nn):(r.endingStart=e?this.zeroSlopeAtStart?nn:tn:rn,r.endingEnd=t?this.zeroSlopeAtEnd?nn:tn:rn)}_scheduleFading(e,t,n){const r=this._mixer,i=r.time;let a=this._weightInterpolant;null===a&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=t,o[1]=i+e,s[1]=n,this}}class Uh extends n{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,n){const r=e._localRoot||this._root,i=e._clip.tracks,a=i.length,o=e._propertyBindings,s=e._interpolants,l=r.uuid,t=this._bindingsByRootAndName;let c=t[l];void 0===c&&(c={},t[l]=c);for(let t=0;t!==a;++t){const d=i[t],h=d.name;let e=c[h];if(void 0!==e)o[t]=e;else{if(void 0!==(e=o[t])){null===e._cacheIndex&&(++e.referenceCount,this._addInactiveBinding(e,l,h));continue}var u=n&&n._propertyBindings[t].binding.parsedPath;++(e=new Ph(C.create(r,h,u),d.ValueTypeName,d.getValueSize())).referenceCount,this._addInactiveBinding(e,l,h),o[t]=e}s[t].resultBuffer=e.buffer}}_activateAction(e){if(!this._isActiveAction(e)){null===e._cacheIndex&&(t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n],this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t));var t,n,r,i=e._propertyBindings;for(let e=0,t=i.length;e!==t;++e){const a=i[e];0==a.useCount++&&(this._lendBinding(a),a.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){var n=e._propertyBindings;for(let e=0,t=n.length;e!==t;++e){const r=n[e];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}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){e=e._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(e,t,n){const r=this._actions,i=this._actionsByClip;let a=i[t];if(void 0===a)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,i[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],r=e._cacheIndex,i=(n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null,e._clip.uuid),a=this._actionsByClip,o=a[i],s=o.knownActions,l=s[s.length-1],c=e._byClipCacheIndex,u=(l._byClipCacheIndex=c,s[c]=l,s.pop(),e._byClipCacheIndex=null,o.actionByRoot),d=(e._localRoot||this._root).uuid;delete u[d],0===s.length&&delete a[i],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){var n=e._propertyBindings;for(let e=0,t=n.length;e!==t;++e){const r=n[e];0==--r.referenceCount&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_addInactiveBinding(e,t,n){const r=this._bindingsByRootAndName,i=this._bindings;let a=r[t];void 0===a&&(a={},r[t]=a),(a[n]=e)._cacheIndex=i.length,i.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,r=n.rootNode.uuid,i=n.path,a=this._bindingsByRootAndName,o=a[r],s=t[t.length-1],l=e._cacheIndex;s._cacheIndex=l,t[l]=s,t.pop(),delete o[i],0===Object.keys(o).length&&delete a[r]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return void 0===n&&((n=new Ju(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer)).__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,i=t[r];e.__cacheIndex=r,t[r]=e,i.__cacheIndex=n,t[n]=i}clipAction(e,t,n){var r=t||this._root,i=r.uuid;let a="string"==typeof e?bd.findByName(r,e):e;r=null!==a?a.uuid:e,e=this._actionsByClip[r];let o=null;if(void 0===n&&(n=null!==a?a.blendMode:2500),void 0!==e){var s=e.actionByRoot[i];if(void 0!==s&&s.blendMode===n)return s;o=e.knownActions[0],null===a&&(a=o._clip)}if(null===a)return null;s=new Vh(this,a,t,n);return this._bindAction(s,o),this._addInactiveAction(s,r,i),s}existingAction(e,t){var t=t||this._root,n=t.uuid,t="string"==typeof e?bd.findByName(t,e):e,t=t?t.uuid:e,e=this._actionsByClip[t];return void 0!==e&&e.actionByRoot[n]||null}stopAllAction(){const t=this._actions,n=this._nActiveActions;for(let e=n-1;0<=e;--e)t[e].stop();return this}update(t){t*=this.timeScale;var n=this._actions,r=this._nActiveActions,i=this.time+=t,a=Math.sign(t),o=this._accuIndex^=1;for(let e=0;e!==r;++e){const c=n[e];c._update(i,t,a,o)}const s=this._bindings,l=this._nActiveBindings;for(let e=0;e!==l;++e)s[e].apply(o);return this}setTime(e){for(let e=this.time=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const n=this._actions,t=e.uuid,r=this._actionsByClip,i=r[t];if(void 0!==i){var a=i.knownActions;for(let e=0,t=a.length;e!==t;++e){const o=a[e],s=(this._deactivateAction(o),o._cacheIndex),l=n[n.length-1];o._cacheIndex=null,o._byClipCacheIndex=null,l._cacheIndex=s,n[s]=l,n.pop(),this._removeInactiveBindingsForAction(o)}delete r[t]}}uncacheRoot(e){var t=e.uuid,n=this._actionsByClip;for(const a in n){var r=n[a].actionByRoot[t];void 0!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}var i=this._bindingsByRootAndName[t];if(void 0!==i)for(const o in i){const s=i[o];s.restoreOriginalState(),this._removeInactiveBinding(s)}}uncacheAction(e,t){e=this.existingAction(e,t);null!==e&&(this._deactivateAction(e),this._removeInactiveAction(e))}}Uh.prototype._controlInterpolantsResultBuffer=new Float32Array(1);class Gh{constructor(e){"string"==typeof e&&(console.warn("v3d.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new Gh(void 0===this.value.clone?this.value:this.value.clone())}}class kh extends $s{constructor(e,t,n=1){super(e,t),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}}class Wh{constructor(e,t,n,r,i){this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=i,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}}Wh.prototype.isGLBufferAttribute=kh.prototype.isInstancedInterleavedBuffer=!0;const Hh=new Be;class Xh{constructor(e=new Be(1/0,1/0),t=new Be(-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(n){this.makeEmpty();for(let e=0,t=n.length;e<t;e++)this.expandByPoint(n[e]);return this}setFromCenterAndSize(e,t){t=Hh.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(t),this.max.copy(e).add(t),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){const t=Hh.copy(e).clamp(this.min,this.max);return t.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)}}Xh.prototype.isBox2=!0;const jh=new vt,Yh=new vt;class Zh{constructor(e=new vt,t=new vt){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){jh.subVectors(e,this.start),Yh.subVectors(this.end,this.start);e=Yh.dot(Yh);let n=Yh.dot(jh)/e;return n=t?ft(n,0,1):n}closestPointToPoint(e,t,n){e=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(e).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)}}class qh extends he{constructor(e){super(),this.material=e,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}}qh.prototype.isImmediateRenderObject=!0;const Qh=new vt;class Kh extends he{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;const n=new S,r=[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;e<32;e++,t++){var i=e/32*Math.PI*2,a=t/32*Math.PI*2;r.push(Math.cos(i),Math.sin(i),1,Math.cos(a),Math.sin(a),1)}n.setAttribute("position",new k(r,3));e=new Bl({fog:!1,toneMapped:!1});this.cone=new jl(n,e),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();var e=this.light.distance||1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Qh.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Qh),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Jh=new vt,$h=new gt,ep=new gt;class tp extends jl{constructor(e){var t=function t(n){const r=[];n&&n.isBone&&r.push(n);for(let e=0;e<n.children.length;e++)r.push.apply(r,t(n.children[e]));return r}(e);const n=new S,r=[],i=[];var a=new _t(0,0,1),o=new _t(0,1,0);for(let e=0;e<t.length;e++){var s=t[e];s.parent&&s.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),i.push(a.r,a.g,a.b),i.push(o.r,o.g,o.b))}n.setAttribute("position",new k(r,3)),n.setAttribute("color",new k(i,3));var l=new Bl({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,l),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){var n=this.bones;const t=this.geometry,r=t.getAttribute("position");ep.copy(this.root.matrixWorld).invert();for(let e=0,t=0;e<n.length;e++){var i=n[e];i.parent&&i.parent.isBone&&($h.multiplyMatrices(ep,i.matrixWorld),Jh.setFromMatrixPosition($h),r.setXYZ(t,Jh.x,Jh.y,Jh.z),$h.multiplyMatrices(ep,i.parent.matrixWorld),Jh.setFromMatrixPosition($h),r.setXYZ(t+1,Jh.x,Jh.y,Jh.z),t+=2)}t.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}}class np extends ee{constructor(e,t,n){super(new cu(t,4,2),new fi({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.light.updateMatrixWorld(),this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const rp=new vt,ip=new _t,ap=new _t;class op extends he{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;const r=new au(t);r.rotateY(.5*Math.PI),this.material=new fi({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);e=r.getAttribute("position"),n=new Float32Array(3*e.count);r.setAttribute("color",new re(n,3)),this.add(new ee(r,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 r=e.geometry.getAttribute("color");ip.copy(this.light.color),ap.copy(this.light.groundColor);for(let e=0,t=r.count;e<t;e++){var n=e<t/2?ip:ap;r.setXYZ(e,n.r,n.g,n.b)}r.needsUpdate=!0}e.lookAt(rp.setFromMatrixPosition(this.light.matrixWorld).negate())}}class sp extends jl{constructor(e=10,r=10,i=4473924,a=8947848){i=new _t(i),a=new _t(a);var o=r/2,s=e/r,l=e/2;const c=[],u=[];for(let e=0,t=0,n=-l;e<=r;e++,n+=s){c.push(-l,0,n,l,0,n),c.push(n,0,-l,n,0,l);const d=e===o?i:a;d.toArray(u,t),t+=3,d.toArray(u,t),t+=3,d.toArray(u,t),t+=3,d.toArray(u,t),t+=3}const t=new S;t.setAttribute("position",new k(c,3)),t.setAttribute("color",new k(u,3));e=new Bl({vertexColors:!0,toneMapped:!1});super(t,e),this.type="GridHelper"}}jl;const lp=new vt,cp=new vt,up=new vt;class dp extends he{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,void 0===t&&(t=1);let r=new S;r.setAttribute("position",new k([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));e=new Bl({fog:!1,toneMapped:!1});this.lightPlane=new Wl(r,e),this.add(this.lightPlane),(r=new S).setAttribute("position",new k([0,0,0,0,0,1],3)),this.targetLine=new Wl(r,e),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){lp.setFromMatrixPosition(this.light.matrixWorld),cp.setFromMatrixPosition(this.light.target.matrixWorld),up.subVectors(cp,lp),this.lightPlane.lookAt(cp),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(cp),this.targetLine.scale.z=up.length()}}const hp=new vt,pp=new ua;jl;function fp(e,t,n,r,i,a,o){hp.set(i,a,o).unproject(r);var s=t[e];if(void 0!==s){const l=n.getAttribute("position");for(let e=0,t=s.length;e<t;e++)l.setXYZ(s[e],hp.x,hp.y,hp.z)}}const mp=new g;class vp extends jl{constructor(e,t=16776960){var 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]),r=new Float32Array(24);const i=new S;i.setIndex(new re(n,1)),i.setAttribute("position",new re(r,3)),super(i,new Bl({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&&mp.setFromObject(this.object),!mp.isEmpty()){var e=mp.min,t=mp.max;const n=this.geometry.attributes.position,r=n.array;r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=e.x,r[4]=t.y,r[5]=t.z,r[6]=e.x,r[7]=e.y,r[8]=t.z,r[9]=t.x,r[10]=e.y,r[11]=t.z,r[12]=t.x,r[13]=t.y,r[14]=e.z,r[15]=e.x,r[16]=t.y,r[17]=e.z,r[18]=e.x,r[19]=e.y,r[20]=e.z,r[21]=t.x,r[22]=e.y,r[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}}setFromObject(e){return this.object=e,this.update(),this}copy(e){return jl.prototype.copy.call(this,e),this.object=e.object,this}}class gp extends jl{constructor(e,t=16776960){var 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]);const r=new S;r.setIndex(new re(n,1)),r.setAttribute("position",new k([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(r,new Bl({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))}}Wl;const _p=new vt;let xp,yp;class bp extends he{constructor(e=new vt(0,0,1),t=new vt(0,0,0),n=1,r=16776960,i=.2*n,a=.2*i){super(),this.type="ArrowHelper",void 0===xp&&((xp=new S).setAttribute("position",new k([0,0,0,0,1,0],3)),(yp=new oc(0,.5,1,5,1)).translate(0,-.5,0)),this.position.copy(t),this.line=new Wl(xp,new Bl({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new ee(yp,new fi({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,i,a)}setDirection(e){.99999<e.y?this.quaternion.set(0,0,0,1):e.y<-.99999?this.quaternion.set(1,0,0,0):(_p.set(e.z,0,-e.x).normalize(),e=Math.acos(e.y),this.quaternion.setFromAxisAngle(_p,e))}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}}class Mp extends jl{constructor(e=1){e=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e];const t=new S;t.setAttribute("position",new k(e,3)),t.setAttribute("color",new k([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));e=new Bl({vertexColors:!0,toneMapped:!1});super(t,e),this.type="AxesHelper"}setColors(e,t,n){const r=new _t;var i=this.geometry.attributes.color.array;return r.set(e),r.toArray(i,0),r.toArray(i,3),r.set(t),r.toArray(i,6),r.toArray(i,9),r.set(n),r.toArray(i,12),r.toArray(i,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}const Ap=new Float32Array(1),wp=new Int32Array(Ap.buffer);class Sp{static toHalfFloat(e){Ap[0]=e;e=wp[0];let t=e>>16&32768,n=e>>12&2047;var r=e>>23&255;return r<103?t:142<r?t=31744|t|((255==r?0:1)&&8388607&e):r<113?(n|=2048,t|=(n>>114-r)+(n>>113-r&1)):t=(t|=r-112<<10|n>>1)+(1&n)}}let Tp=256;const Cp=[{relSize:1,sigma:0,origin:[0,0]},{relSize:.5,sigma:.025,origin:[0,2/3]},{relSize:.25,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 Ep(e){return Cp[e].relSize*Tp}let Lp=!1;const Rp=20,Pp={[an]:0,3001:1,3002:2,3004:3,3005:4,3006:5,3007:6},Ip=new Rs;let Np=null,Dp=null,Op=null;const Fp=Cp.map(function(e,t){var t=1/(Ep(t)-1),n=-t/2,t=1+t/2,r=[n,n,t,n,t,t,n,n,t,t,n,t];const i=new Float32Array(108),a=new Float32Array(72),o=new Float32Array(36);for(let e=0;e<6;e++){var s=e%3*2/3-1,l=2<e?0:-1,s=(i.set([s,l,0,s+2/3,l,0,s+2/3,1+l,0,s,l,0,s+2/3,1+l,0,s,1+l,0],18*e),a.set(r,12*e),[e,e,e,e,e,e]);o.set(s,6*e)}const c=new S;return c.setAttribute("position",new re(i,3)),c.setAttribute("uv",new re(a,2)),c.setAttribute("faceIndex",new re(o,1)),c});let Bp=null,x=null,zp=null;Ih=(1+Math.sqrt(5))/2,Oh=1/Ih;const Vp=[new vt(1,1,1),new vt(-1,1,1),new vt(1,1,-1),new vt(-1,1,-1),new vt(0,Ih,Oh),new vt(0,Ih,-Oh),new vt(Oh,0,Ih),new vt(-Oh,0,Ih),new vt(Ih,Oh,0),new vt(-Ih,Oh,0)];class Up{constructor(e,t,n){this.flipCubemapX=!0,x=e,Object.defineProperties(this,{maxTileSize:{get:function(){return Tp},set:function(e){Tp=e}},blurLinEncodingOptimization:{get:function(){return Lp},set:function(e){Lp=e}}}),void 0!==t&&(this.maxTileSize=t),void 0!==n&&(this.blurLinEncodingOptimization=n),Wp(Np=function(e,t,n){const r=new Float32Array(e),i=new vt(0,1,0),a=new yu({defines:{n:e,cubeUV_maxTileSize:Ri(t),linEncodingOptimization:n?1:0},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},lodIdx:{value:0},poleAxis:{value:i},inputEncoding:{value:Pp[an]},outputEncoding:{value:Pp[an]}},vertexShader:Kp(),fragmentShader:`
|
|
precision highp float;
|
|
precision highp int;
|
|
varying vec3 vOutputDirection;
|
|
uniform sampler2D envMap;
|
|
uniform int samples;
|
|
uniform float weights[n];
|
|
uniform bool latitudinal;
|
|
uniform float dTheta;
|
|
uniform float lodIdx;
|
|
uniform vec3 poleAxis;
|
|
|
|
${Jp()}
|
|
|
|
#define ENVMAP_TYPE_CUBE_UV
|
|
#include <cube_uv_reflection_fragment>
|
|
|
|
vec3 getSample(float theta, vec3 axis) {
|
|
float cosTheta = cos(theta);
|
|
// Rodrigues' axis-angle rotation
|
|
vec3 sampleDirection = vOutputDirection * cosTheta
|
|
+ cross(axis, vOutputDirection) * sin(theta)
|
|
+ axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);
|
|
return bilinearCubeUV(envMap, sampleDirection, lodIdx);
|
|
}
|
|
|
|
void main() {
|
|
vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);
|
|
if (all(equal(axis, vec3(0.0))))
|
|
axis = vec3(vOutputDirection.z, 0.0, - vOutputDirection.x);
|
|
axis = normalize(axis);
|
|
gl_FragColor = vec4(0.0);
|
|
gl_FragColor.rgb += weights[0] * getSample(0.0, axis);
|
|
for (int i = 1; i < n; i++) {
|
|
if (i >= samples)
|
|
break;
|
|
float theta = dTheta * float(i);
|
|
gl_FragColor.rgb += weights[i] * getSample(-1.0 * theta, axis);
|
|
gl_FragColor.rgb += weights[i] * getSample(theta, axis);
|
|
}
|
|
gl_FragColor = linearToOutputTexel(gl_FragColor);
|
|
}
|
|
`,blending:ce,depthTest:!1,depthWrite:!1});return a.type="SphericalGaussianBlur",a}(Rp,this.maxTileSize,this.blurLinEncodingOptimization))}fromScene(t,e=0,n=.1,r=100){zp=x.getRenderTarget();var i=Gp();{var a=t,o=(t=n,n=r,i);const c=new da(90,1,t,n),u=[1,1,1,1,-1,1],d=[1,1,-1,-1,-1,1],h=x.outputEncoding,p=x.toneMapping,f=x.toneMappingExposure,m=x.getClearColor(new _t),v=x.getClearAlpha();x.toneMapping=1,x.toneMappingExposure=1,x.outputEncoding=an,a.scale.z*=-1;let e=a.background;e&&e.isColor&&(e.convertSRGBToLinear(),t=Math.max(e.r,e.g,e.b),n=Math.min(Math.max(Math.ceil(Math.log2(t)),-128),127),e=e.multiplyScalar(Math.pow(2,-n)),t=(n+128)/255,x.setClearColor(e,t),a.background=null);for(let e=0;e<6;e++){var s=e%3,l=(0==s?(c.up.set(0,u[e],0),c.lookAt(d[e],0,0)):1==s?(c.up.set(0,0,u[e]),c.lookAt(0,d[e],0)):(c.up.set(0,u[e],0),c.lookAt(0,0,d[e])),Ep(0));Xp(o,s*l,2<e?l:0,l,l),x.setRenderTarget(o),x.render(a,c)}x.toneMapping=p,x.toneMappingExposure=f,x.outputEncoding=h,x.setClearColor(m,v),a.scale.z*=-1}return 0<e&&Yp(i,0,0,e),jp(i),kp(i),i}fromEquirectangular(e){return e.magFilter=ht,e.minFilter=ht,e.generateMipmaps=!1,this.fromCubemap(e)}fromCubemap(e){zp=x.getRenderTarget();var t=Gp(e);{var n=t,r=this.flipCubemapX;const i=new Js,a=(e.isCubeTexture?null==Op&&(Op=Qp()):null==Dp&&(Dp=qp()),e.isCubeTexture?Op:Dp),o=(i.add(new ee(Fp[0],a)),a.uniforms);(o.envMap.value=e).isCubeTexture?o.flipCubemapX.value=r||!1:o.texelSize.value.set(1/e.image.width,1/e.image.height),o.inputEncoding.value=Pp[e.encoding],o.outputEncoding.value=Pp[e.encoding],r=Ep(0),Xp(n,0,0,3*r,2*r),x.setRenderTarget(n),x.render(i,Ip)}return jp(t),kp(t),t}fromCubeRenderTarget(e,t){t=Gp(e.texture,t);{var n=t,r=this.flipCubemapX;const i=new Js,a=Op=null==Op?Qp():Op,o=(i.add(new ee(Fp[0],a)),a.uniforms),s=(o.envMap.value=e.texture,o.flipCubemapX.value=r||!1,o.inputEncoding.value=Pp[e.texture.encoding],o.outputEncoding.value=Pp[n.texture.encoding],Ep(0));Xp(n,0,0,3*s,2*s),x.setRenderTarget(n),x.render(i,Ip)}return jp(t),kp(t),t}compileCubemapShader(){null==Op&&Wp(Op=Qp())}compileEquirectangularShader(){null==Dp&&Wp(Dp=qp())}dispose(){Np.dispose(),null!=Op&&Op.dispose(),null!=Dp&&Dp.dispose();for(let e=0;e<Fp.length;e++)Fp[e].dispose()}}function Gp(e,t){var n={magFilter:ht,minFilter:ht,generateMipmaps:!1,type:e?e.type:Mt,format:e?e.format:F,encoding:e?e.encoding:sn,depthBuffer:!1,stencilBuffer:!1};Object.assign(n,t);const r=Hp(n);return r.depthBuffer=!e,Bp=Hp(n),r}function kp(e){Bp.dispose(),x.setRenderTarget(zp),e.scissorTest=!1,e.setSize(e.width,e.height)}function Wp(e){const t=new Js;t.add(new ee(Fp[0],e)),x.compile(t,Ip)}function Hp(e){var t=Ep(0);const n=new ze(3*t,3*t,e);return n.texture.mapping=N,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Xp(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function jp(t){var e=x.autoClear;x.autoClear=!1;for(let e=1;e<Cp.length;e++){var n=Cp[e].sigma,r=Cp[e-1].sigma,n=Math.sqrt(n*n-r*r),r=Vp[(e-1)%Vp.length];Yp(t,e-1,e,n,r)}x.autoClear=e}function Yp(e,t,n,r,i){Zp(e,Bp,t,n,r,"latitudinal",i),Zp(Bp,e,n,n,r,"longitudinal",i)}function Zp(e,t,n,r,i,a,o){"latitudinal"!==a&&"longitudinal"!==a&&console.error("blur direction must be either latitudinal or longitudinal!");const s=new Js,l=(s.add(new ee(Fp[r],Np)),Np.uniforms);var c=Ep(n)-1;let u=isFinite(i)?Math.PI/(2*c):2*Math.PI/(2*Rp-1),d=i/u,h=isFinite(i)?1+Math.floor(3*d):Rp;h>Rp&&(h=Rp,d=(Rp-1)/3,u=i/d);const p=[];let f=0;for(let e=0;e<Rp;++e){const g=e/d;var m=Math.exp(-g*g/2);p.push(m),0==e?f+=m:e<h&&(f+=2*m)}for(let e=0;e<p.length;e++)p[e]=p[e]/f;l.envMap.value=e.texture,l.samples.value=h,l.weights.value=p,l.latitudinal.value="latitudinal"===a,o&&(l.poleAxis.value=o),l.dTheta.value=u,l.lodIdx.value=n,l.inputEncoding.value=Pp[e.texture.encoding],l.outputEncoding.value=Pp[e.texture.encoding];const v=Np.defines,[g,_]=(v.cubeUV_maxTileSize=Ri(Ep(0)),v.linEncodingOptimization=Lp?1:0,c=r,Cp[c].origin.map(function(e){return e*Tp*3}));i=Ep(r);Xp(t,g,_,3*i,2*i),x.setRenderTarget(t),x.render(s,Ip)}function qp(){var e=new Be(1,1);const t=new yu({defines:{linEncodingOptimization:0},uniforms:{envMap:{value:null},texelSize:{value:e},inputEncoding:{value:Pp[an]},outputEncoding:{value:Pp[an]}},vertexShader:Kp(),fragmentShader:`
|
|
precision mediump float;
|
|
precision mediump int;
|
|
varying vec3 vOutputDirection;
|
|
uniform sampler2D envMap;
|
|
uniform vec2 texelSize;
|
|
|
|
${Jp()}
|
|
|
|
#define RECIPROCAL_PI 0.31830988618
|
|
#define RECIPROCAL_PI2 0.15915494
|
|
|
|
void main() {
|
|
gl_FragColor = vec4(0.0);
|
|
vec3 outputDirection = normalize(vOutputDirection);
|
|
vec2 uv;
|
|
uv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5;
|
|
uv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5;
|
|
vec2 f = fract(uv / texelSize - 0.5);
|
|
uv -= f * texelSize;
|
|
vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
|
uv.x += texelSize.x;
|
|
vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
|
uv.y += texelSize.y;
|
|
vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
|
uv.x -= texelSize.x;
|
|
vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
|
vec3 tm = mix(tl, tr, f.x);
|
|
vec3 bm = mix(bl, br, f.x);
|
|
gl_FragColor.rgb = mix(tm, bm, f.y);
|
|
gl_FragColor = linearToOutputTexel(gl_FragColor);
|
|
}
|
|
`,blending:ce,depthTest:!1,depthWrite:!1});return t.type="EquirectangularToCubeUV",t}function Qp(){const e=new yu({defines:{linEncodingOptimization:0},uniforms:{envMap:{value:null},inputEncoding:{value:Pp[an]},outputEncoding:{value:Pp[an]},flipCubemapX:{value:!0}},vertexShader:Kp(),fragmentShader:`
|
|
precision mediump float;
|
|
precision mediump int;
|
|
varying vec3 vOutputDirection;
|
|
uniform samplerCube envMap;
|
|
uniform bool flipCubemapX;
|
|
|
|
${Jp()}
|
|
|
|
void main() {
|
|
gl_FragColor = vec4(0.0);
|
|
gl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3(vOutputDirection.x * (flipCubemapX ? -1.0 : 1.0), vOutputDirection.yz))).rgb;
|
|
gl_FragColor = linearToOutputTexel(gl_FragColor);
|
|
}
|
|
`,blending:ce,depthTest:!1,depthWrite:!1});return e.type="CubemapToCubeUV",e}function Kp(){return`
|
|
precision mediump float;
|
|
precision mediump int;
|
|
attribute vec3 position;
|
|
attribute vec2 uv;
|
|
attribute float faceIndex;
|
|
varying vec3 vOutputDirection;
|
|
vec3 getDirection(vec2 uv, float face) {
|
|
uv = 2.0 * uv - 1.0;
|
|
vec3 direction = vec3(uv, 1.0);
|
|
if (face == 0.0) {
|
|
direction = direction.zyx;
|
|
direction.z *= -1.0;
|
|
} else if (face == 1.0) {
|
|
direction = direction.xzy;
|
|
direction.z *= -1.0;
|
|
} else if (face == 3.0) {
|
|
direction = direction.zyx;
|
|
direction.x *= -1.0;
|
|
} else if (face == 4.0) {
|
|
direction = direction.xzy;
|
|
direction.y *= -1.0;
|
|
} else if (face == 5.0) {
|
|
direction.xz *= -1.0;
|
|
}
|
|
return direction;
|
|
}
|
|
void main() {
|
|
vOutputDirection = getDirection(uv, faceIndex);
|
|
gl_Position = vec4(position, 1.0);
|
|
}
|
|
`}function Jp(){return`
|
|
|
|
#if linEncodingOptimization
|
|
|
|
vec4 linearToOutputTexel(vec4 value) {
|
|
return value;
|
|
}
|
|
|
|
vec4 envMapTexelToLinear(vec4 color) {
|
|
return color;
|
|
}
|
|
|
|
#else
|
|
|
|
uniform int inputEncoding;
|
|
uniform int outputEncoding;
|
|
|
|
#include <encodings_pars_fragment>
|
|
|
|
vec4 inputTexelToLinear(vec4 value){
|
|
if(inputEncoding == 0){
|
|
return value;
|
|
}else if(inputEncoding == 1){
|
|
return sRGBToLinear(value);
|
|
}else if(inputEncoding == 2){
|
|
return RGBEToLinear(value);
|
|
}else if(inputEncoding == 3){
|
|
return RGBMToLinear(value, 7.0);
|
|
}else if(inputEncoding == 4){
|
|
return RGBMToLinear(value, 16.0);
|
|
}else if(inputEncoding == 5){
|
|
return RGBDToLinear(value, 256.0);
|
|
}else{
|
|
return GammaToLinear(value, 2.2);
|
|
}
|
|
}
|
|
|
|
vec4 linearToOutputTexel(vec4 value){
|
|
if(outputEncoding == 0){
|
|
return value;
|
|
}else if(outputEncoding == 1){
|
|
return LinearTosRGB(value);
|
|
}else if(outputEncoding == 2){
|
|
return LinearToRGBE(value);
|
|
}else if(outputEncoding == 3){
|
|
return LinearToRGBM(value, 7.0);
|
|
}else if(outputEncoding == 4){
|
|
return LinearToRGBM(value, 16.0);
|
|
}else if(outputEncoding == 5){
|
|
return LinearToRGBD(value, 256.0);
|
|
}else{
|
|
return LinearToGamma(value, 2.2);
|
|
}
|
|
}
|
|
|
|
vec4 envMapTexelToLinear(vec4 color) {
|
|
return inputTexelToLinear(color);
|
|
}
|
|
|
|
#endif
|
|
`}mc.create=function(e,t){return console.log("v3d.Curve.create() has been deprecated"),e.prototype=Object.create(mc.prototype),(e.prototype.constructor=e).prototype.getPoint=t,e},Nd.prototype.fromPoints=function(e){return console.warn("v3d.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)},sp.prototype.setColors=function(){console.error("v3d.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},tp.prototype.update=function(){console.error("v3d.SkeletonHelper: update() no longer needs to be called.")},Sd.prototype.extractUrlBase=function(e){return console.warn("v3d.Loader: .extractUrlBase() has been deprecated. Use v3d.LoaderUtils.extractUrlBase() instead."),eh.extractUrlBase(e)},Sd.Handlers={add:function(){console.error("v3d.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("v3d.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Xh.prototype.center=function(e){return console.warn("v3d.Box2: .center() has been renamed to .getCenter()."),this.getCenter(e)},Xh.prototype.empty=function(){return console.warn("v3d.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Xh.prototype.isIntersectionBox=function(e){return console.warn("v3d.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},Xh.prototype.size=function(e){return console.warn("v3d.Box2: .size() has been renamed to .getSize()."),this.getSize(e)},g.prototype.center=function(e){return console.warn("v3d.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},g.prototype.empty=function(){return console.warn("v3d.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},g.prototype.isIntersectionBox=function(e){return console.warn("v3d.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},g.prototype.isIntersectionSphere=function(e){return console.warn("v3d.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},g.prototype.size=function(e){return console.warn("v3d.Box3: .size() has been renamed to .getSize()."),this.getSize(e)},fr.prototype.empty=function(){return console.warn("v3d.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Ma.prototype.setFromMatrix=function(e){return console.warn("v3d.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},Zh.prototype.center=function(e){return console.warn("v3d.Line3: .center() has been renamed to .getCenter()."),this.getCenter(e)},Un.prototype.flattenToArrayOffset=function(e,t){return console.warn("v3d.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},Un.prototype.multiplyVector3=function(e){return console.warn("v3d.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3(matrix) instead."),e.applyMatrix3(this)},Un.prototype.multiplyVector3Array=function(){console.error("v3d.Matrix3: .multiplyVector3Array() has been removed.")},Un.prototype.applyToBufferAttribute=function(e){return console.warn("v3d.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3(matrix) instead."),e.applyMatrix3(this)},Un.prototype.applyToVector3Array=function(){console.error("v3d.Matrix3: .applyToVector3Array() has been removed.")},Un.prototype.getInverse=function(e){return console.warn("v3d.Matrix3: .getInverse() has been removed. Use matrixInv.copy(matrix).invert(); instead."),this.copy(e).invert()},gt.prototype.extractPosition=function(e){return console.warn("v3d.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},gt.prototype.flattenToArrayOffset=function(e,t){return console.warn("v3d.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},gt.prototype.getPosition=function(){return console.warn("v3d.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition(matrix) instead."),(new vt).setFromMatrixColumn(this,3)},gt.prototype.setRotationFromQuaternion=function(e){return console.warn("v3d.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},gt.prototype.multiplyToArray=function(){console.warn("v3d.Matrix4: .multiplyToArray() has been removed.")},gt.prototype.multiplyVector3=function(e){return console.warn("v3d.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4(matrix) instead."),e.applyMatrix4(this)},gt.prototype.multiplyVector4=function(e){return console.warn("v3d.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4(matrix) instead."),e.applyMatrix4(this)},gt.prototype.multiplyVector3Array=function(){console.error("v3d.Matrix4: .multiplyVector3Array() has been removed.")},gt.prototype.rotateAxis=function(e){console.warn("v3d.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection(matrix) instead."),e.transformDirection(this)},gt.prototype.crossVector=function(e){return console.warn("v3d.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4(matrix) instead."),e.applyMatrix4(this)},gt.prototype.translate=function(){console.error("v3d.Matrix4: .translate() has been removed.")},gt.prototype.rotateX=function(){console.error("v3d.Matrix4: .rotateX() has been removed.")},gt.prototype.rotateY=function(){console.error("v3d.Matrix4: .rotateY() has been removed.")},gt.prototype.rotateZ=function(){console.error("v3d.Matrix4: .rotateZ() has been removed.")},gt.prototype.rotateByAxis=function(){console.error("v3d.Matrix4: .rotateByAxis() has been removed.")},gt.prototype.applyToBufferAttribute=function(e){return console.warn("v3d.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4(matrix) instead."),e.applyMatrix4(this)},gt.prototype.applyToVector3Array=function(){console.error("v3d.Matrix4: .applyToVector3Array() has been removed.")},gt.prototype.makeFrustum=function(e,t,n,r,i,a){return console.warn("v3d.Matrix4: .makeFrustum() has been removed. Use .makePerspective(left, right, top, bottom, near, far) instead."),this.makePerspective(e,t,r,n,i,a)},gt.prototype.getInverse=function(e){return console.warn("v3d.Matrix4: .getInverse() has been removed. Use matrixInv.copy(matrix).invert(); instead."),this.copy(e).invert()},xa.prototype.isIntersectionLine=function(e){return console.warn("v3d.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},de.prototype.multiplyVector3=function(e){return console.warn("v3d.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion(quaternion) instead."),e.applyQuaternion(this)},de.prototype.inverse=function(){return console.warn("v3d.Quaternion: .inverse() has been renamed to invert()."),this.invert()},Mr.prototype.isIntersectionBox=function(e){return console.warn("v3d.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},Mr.prototype.isIntersectionPlane=function(e){return console.warn("v3d.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},Mr.prototype.isIntersectionSphere=function(e){return console.warn("v3d.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},ui.prototype.area=function(){return console.warn("v3d.Triangle: .area() has been renamed to .getArea()."),this.getArea()},ui.prototype.barycoordFromPoint=function(e,t){return console.warn("v3d.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,t)},ui.prototype.midpoint=function(e){return console.warn("v3d.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},ui.prototypenormal=function(e){return console.warn("v3d.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},ui.prototype.plane=function(e){return console.warn("v3d.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)},ui.barycoordFromPoint=function(e,t,n,r,i){return console.warn("v3d.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),ui.getBarycoord(e,t,n,r,i)},ui.normal=function(e,t,n,r){return console.warn("v3d.Triangle: .normal() has been renamed to .getNormal()."),ui.getNormal(e,t,n,r)},Dd.prototype.extractAllPoints=function(e){return console.warn("v3d.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},Dd.prototype.extrude=function(e){return console.warn("v3d.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new tu(this,e)},Dd.prototype.makeGeometry=function(e){return console.warn("v3d.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new lu(this,e)},Be.prototype.fromAttribute=function(e,t,n){return console.warn("v3d.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},Be.prototype.distanceToManhattan=function(e){return console.warn("v3d.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},Be.prototype.lengthManhattan=function(){return console.warn("v3d.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},vt.prototype.setEulerFromRotationMatrix=function(){console.error("v3d.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},vt.prototype.setEulerFromQuaternion=function(){console.error("v3d.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},vt.prototype.getPositionFromMatrix=function(e){return console.warn("v3d.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},vt.prototype.getScaleFromMatrix=function(e){return console.warn("v3d.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},vt.prototype.getColumnFromMatrix=function(e,t){return console.warn("v3d.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},vt.prototype.applyProjection=function(e){return console.warn("v3d.Vector3: .applyProjection() has been removed. Use .applyMatrix4(m) instead."),this.applyMatrix4(e)},vt.prototype.fromAttribute=function(e,t,n){return console.warn("v3d.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},vt.prototype.distanceToManhattan=function(e){return console.warn("v3d.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},vt.prototype.lengthManhattan=function(){return console.warn("v3d.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},mt.prototype.fromAttribute=function(e,t,n){return console.warn("v3d.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},mt.prototype.lengthManhattan=function(){return console.warn("v3d.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},he.prototype.getChildByName=function(e){return console.warn("v3d.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},he.prototype.renderDepth=function(){console.warn("v3d.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},he.prototype.translate=function(e,t){return console.warn("v3d.Object3D: .translate() has been removed. Use .translateOnAxis(axis, distance) instead."),this.translateOnAxis(t,e)},he.prototype.getWorldRotation=function(){console.error("v3d.Object3D: .getWorldRotation() has been removed. Use v3d.Object3D.getWorldQuaternion(target) instead.")},he.prototype.applyMatrix=function(e){return console.warn("v3d.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(he.prototype,{eulerOrder:{get:function(){return console.warn("v3d.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("v3d.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("v3d.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("v3d.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),ee.prototype.setDrawMode=function(){console.error("v3d.Mesh: .setDrawMode() has been removed. The renderer now always assumes v3d.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")},Object.defineProperties(ee.prototype,{drawMode:{get:function(){return console.error("v3d.Mesh: .drawMode has been removed. The renderer now always assumes v3d.TrianglesDrawMode."),0},set:function(){console.error("v3d.Mesh: .drawMode has been removed. The renderer now always assumes v3d.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),Tl.prototype.initBones=function(){console.error("v3d.SkinnedMesh: initBones() has been removed.")},da.prototype.setLens=function(e,t){console.warn("v3d.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(Od.prototype,{onlyShadow:{set:function(){console.warn("v3d.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("v3d.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("v3d.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("v3d.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("v3d.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("v3d.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("v3d.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("v3d.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("v3d.Light: .shadowCameraVisible has been removed. Use new v3d.CameraHelper(light.shadow.camera) instead.")}},shadowBias:{set:function(e){console.warn("v3d.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("v3d.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("v3d.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("v3d.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(re.prototype,{length:{get:function(){return console.warn("v3d.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("v3d.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===vn},set:function(){console.warn("v3d.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(vn)}}}),re.prototype.setDynamic=function(e){return console.warn("v3d.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?vn:mn),this},re.prototype.copyIndicesArray=function(){console.error("v3d.BufferAttribute: .copyIndicesArray() has been removed.")},re.prototype.setArray=function(){console.error("v3d.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},S.prototype.addIndex=function(e){console.warn("v3d.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},S.prototype.addAttribute=function(e,t){return console.warn("v3d.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("v3d.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):this.setAttribute(e,t):(console.warn("v3d.BufferGeometry: .addAttribute() now expects (name, attribute)."),this.setAttribute(e,new re(t,arguments[2])))},S.prototype.addDrawCall=function(e,t,n){void 0!==n&&console.warn("v3d.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("v3d.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)},S.prototype.clearDrawCalls=function(){console.warn("v3d.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},S.prototype.computeOffsets=function(){console.warn("v3d.BufferGeometry: .computeOffsets() has been removed.")},S.prototype.removeAttribute=function(e){return console.warn("v3d.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(e)},S.prototype.applyMatrix=function(e){return console.warn("v3d.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(S.prototype,{drawcalls:{get:function(){return console.error("v3d.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("v3d.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),$s.prototype.setDynamic=function(e){return console.warn("v3d.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?vn:mn),this},$s.prototype.setArray=function(){console.error("v3d.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},tu.prototype.getArrays=function(){console.error("v3d.ExtrudeGeometry: .getArrays() has been removed.")},tu.prototype.addShapeList=function(){console.error("v3d.ExtrudeGeometry: .addShapeList() has been removed.")},tu.prototype.addShape=function(){console.error("v3d.ExtrudeGeometry: .addShape() has been removed.")},Js.prototype.dispose=function(){console.error("v3d.Scene: .dispose() has been removed.")},Gh.prototype.onUpdate=function(){return console.warn("v3d.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this},Object.defineProperties(pi.prototype,{wrapAround:{get:function(){console.warn("v3d.Material: .wrapAround has been removed.")},set:function(){console.warn("v3d.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("v3d.Material: .overdraw has been removed.")},set:function(){console.warn("v3d.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("v3d.Material: .wrapRGB has been removed."),new _t}},shading:{get:function(){console.error("v3d."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("v3d."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===e}},stencilMask:{get:function(){return console.warn("v3d."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(e){console.warn("v3d."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=e}}}),Object.defineProperties(T.prototype,{derivatives:{get:function(){return console.warn("v3d.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("v3d. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),i.prototype.clearTarget=function(e,t,n,r){console.warn("v3d.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(e),this.clear(t,n,r)},i.prototype.animate=function(e){console.warn("v3d.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(e)},i.prototype.getCurrentRenderTarget=function(){return console.warn("v3d.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},i.prototype.getMaxAnisotropy=function(){return console.warn("v3d.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},i.prototype.getPrecision=function(){return console.warn("v3d.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},i.prototype.resetGLState=function(){return console.warn("v3d.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},i.prototype.supportsFloatTextures=function(){return console.warn("v3d.WebGLRenderer: .supportsFloatTextures() is now .extensions.get('OES_texture_float')."),this.extensions.get("OES_texture_float")},i.prototype.supportsHalfFloatTextures=function(){return console.warn("v3d.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get('OES_texture_half_float')."),this.extensions.get("OES_texture_half_float")},i.prototype.supportsStandardDerivatives=function(){return console.warn("v3d.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get('OES_standard_derivatives')."),this.extensions.get("OES_standard_derivatives")},i.prototype.supportsCompressedTextureS3TC=function(){return console.warn("v3d.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get('WEBGL_compressed_texture_s3tc')."),this.extensions.get("WEBGL_compressed_texture_s3tc")},i.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("v3d.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get('WEBGL_compressed_texture_pvrtc')."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},i.prototype.supportsBlendMinMax=function(){return console.warn("v3d.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get('EXT_blend_minmax')."),this.extensions.get("EXT_blend_minmax")},i.prototype.supportsVertexTextures=function(){return console.warn("v3d.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},i.prototype.supportsInstancedArrays=function(){return console.warn("v3d.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get('ANGLE_instanced_arrays')."),this.extensions.get("ANGLE_instanced_arrays")},i.prototype.enableScissorTest=function(e){console.warn("v3d.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},i.prototype.initMaterial=function(){console.warn("v3d.WebGLRenderer: .initMaterial() has been removed.")},i.prototype.addPrePlugin=function(){console.warn("v3d.WebGLRenderer: .addPrePlugin() has been removed.")},i.prototype.addPostPlugin=function(){console.warn("v3d.WebGLRenderer: .addPostPlugin() has been removed.")},i.prototype.updateShadowMap=function(){console.warn("v3d.WebGLRenderer: .updateShadowMap() has been removed.")},i.prototype.setFaceCulling=function(){console.warn("v3d.WebGLRenderer: .setFaceCulling() has been removed.")},i.prototype.allocTextureUnit=function(){console.warn("v3d.WebGLRenderer: .allocTextureUnit() has been removed.")},i.prototype.setTexture=function(){console.warn("v3d.WebGLRenderer: .setTexture() has been removed.")},i.prototype.setTexture2D=function(){console.warn("v3d.WebGLRenderer: .setTexture2D() has been removed.")},i.prototype.setTextureCube=function(){console.warn("v3d.WebGLRenderer: .setTextureCube() has been removed.")},i.prototype.getActiveMipMapLevel=function(){return console.warn("v3d.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()},Object.defineProperties(i.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("v3d.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("v3d.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("v3d.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("v3d.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("v3d.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("v3d.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("v3d.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("v3d.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("v3d.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(e){console.warn("v3d.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===e?on:an}},toneMappingWhitePoint:{get:function(){return console.warn("v3d.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("v3d.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(Os.prototype,{cullFace:{get:function(){console.warn("v3d.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("v3d.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("v3d.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("v3d.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("v3d.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("v3d.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(ze.prototype,{wrapS:{get:function(){return console.warn("v3d.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("v3d.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("v3d.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("v3d.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("v3d.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("v3d.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("v3d.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("v3d.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("v3d.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("v3d.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("v3d.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("v3d.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("v3d.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("v3d.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("v3d.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("v3d.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("v3d.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("v3d.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("v3d.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("v3d.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),Sh.prototype.load=function(e){console.warn("v3d.Audio: .load has been deprecated. Use v3d.AudioLoader instead.");const t=this,n=new ph;return n.load(e,function(e){t.setBuffer(e)}),this},Rh.prototype.getData=function(){return console.warn("v3d.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},ha.prototype.updateCubeMap=function(e,t){return console.warn("v3d.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,t)},ha.prototype.clear=function(e,t,n,r){return console.warn("v3d.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(e,t,n,r)},kn.crossOrigin=void 0,kn.loadTexture=function(e,t,n,r){console.warn("v3d.ImageUtils.loadTexture has been deprecated. Use v3d.TextureLoader() instead.");const i=new Pd,a=(i.setCrossOrigin(this.crossOrigin),i.load(e,n,void 0,r));return t&&(a.mapping=t),a},kn.loadTextureCube=function(e,t,n,r){console.warn("v3d.ImageUtils.loadTextureCube has been deprecated. Use v3d.CubeTextureLoader() instead.");const i=new Ld,a=(i.setCrossOrigin(this.crossOrigin),i.load(e,n,void 0,r));return t&&(a.mapping=t),a},kn.loadCompressedTexture=function(){console.error("v3d.ImageUtils.loadCompressedTexture has been removed. Use v3d.DDSLoader instead.")},kn.loadCompressedTextureCube=function(){console.error("v3d.ImageUtils.loadCompressedTextureCube has been removed. Use v3d.DDSLoader instead.")};var $p,ef=new vt,tf=new vt,nf=new vt,rf=new Be,af=new Be,of=new Be,sf=new vt,lf=new vt;function cf(e,t,n,r,i,a,o,s){ef.fromBufferAttribute(r,a),tf.fromBufferAttribute(r,o),nf.fromBufferAttribute(r,s);e=(r=e).material,t=t,n=n,l=ef,d=tf,u=nf,c=sf;var l,c,u,d=null===(n=e.side===Fe?n.intersectTriangle(u,d,l,!0,c):n.intersectTriangle(l,d,u,e.side!==Ue,c))?null:(lf.copy(c),lf.applyMatrix4(r.matrixWorld),(l=t.ray.origin.distanceTo(lf))<t.near||l>t.far?null:{distance:l,point:lf.clone(),object:r});return d&&(i&&(rf.fromBufferAttribute(i,a),af.fromBufferAttribute(i,o),of.fromBufferAttribute(i,s),d.uv=ui.getUV(sf,ef,tf,nf,rf,af,of,new Be)),u=new vt,d.face=new di(a,o,s,ui.getNormal(ef,tf,nf,u)),d.faceIndex=a),d}function uf(e,t,n,r,i,a){var o=3*i,s=t.index.getX(o),l=t.index.getX(1+o),o=t.index.getX(2+o),e=cf(e,n,r,t.attributes.position,t.attributes.uv,s,l,o);return e?(e.faceIndex=i,a&&a.push(e),e):null}function df(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 hf(e){for(var t=-1,n=-1/0,r=0;r<3;r++){var i=e[r+3]-e[r];n<i&&(n=i,t=r)}return t}class pf{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){for(var n=1/0,r=-1/0,i=0,a=e.length;i<a;i++)var o=e[i][t],n=Math.min(o,n),r=Math.max(o,r);this.min=n,this.max=r}setFromPoints(e,t){for(var n=1/0,r=-1/0,i=0,a=t.length;i<a;i++)var o=t[i],o=e.dot(o),n=Math.min(o,n),r=Math.max(o,r);this.min=n,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}}pf.prototype.setFromBox=($p=new vt,function(e,t){for(var n=t.min,r=t.max,i=1/0,a=-1/0,o=0;o<=1;o++)for(var s=0;s<=1;s++)for(var l=0;l<=1;l++){$p.x=n.x*o+r.x*(1-o),$p.y=n.y*s+r.y*(1-s),$p.z=n.z*l+r.z*(1-l);var c=e.dot($p),i=Math.min(c,i),a=Math.max(c,a)}this.min=i,this.max=a});ff=new vt,mf=new vt,vf=new vt;var ff,mf,vf,gf,_f,xf,yf,bf,Mf,Af,wf,Sf,Tf,Cf,Ef,Lf,Rf,Pf,If,Nf,Df,Of,Ff,Bf,zf,Vf,Uf,Gf,kf,Wf,Hf,Xf,jf,Yf,Zf,qf=function(e,t,n){var r=e.start,i=ff,a=t.start,o=mf,r=(vf.subVectors(r,a),ff.subVectors(e.end,t.start),mf.subVectors(t.end,t.start),vf.dot(o)),a=o.dot(i),e=o.dot(o),t=vf.dot(i),o=i.dot(i)*e-a*a,i=0!=o?(r*a-t*e)/o:0,t=(r+i*a)/e;n.x=i,n.y=t},Qf=(gf=new Be,_f=new vt,xf=new vt,function(e,t,n,r){qf(e,t,gf);var i,a=gf.x,o=gf.y;0<=a&&a<=1&&0<=o&&o<=1?(e.at(a,n),t.at(o,r)):0<=a&&a<=1?(o<0?t.at(0,r):t.at(1,r),e.closestPointToPoint(r,!0,n)):0<=o&&o<=1?(a<0?e.at(0,n):e.at(1,n),t.closestPointToPoint(n,!0,r)):(a=a<0?e.start:e.end,o=o<0?t.start:t.end,i=xf,e.closestPointToPoint(o,!0,e=_f),t.closestPointToPoint(a,!0,xf),e.distanceToSquared(o)<=i.distanceToSquared(a)?(n.copy(e),r.copy(o)):(n.copy(a),r.copy(i)))}),Kf=(yf=new vt,bf=new vt,Mf=new xa,Af=new Zh,function(e,t){var n=e.radius,e=e.center,r=t.a,i=t.b,a=t.c;if(Af.start=r,Af.end=i,Af.closestPointToPoint(e,!0,yf).distanceTo(e)<=n)return!0;if(Af.start=r,Af.end=a,Af.closestPointToPoint(e,!0,yf).distanceTo(e)<=n)return!0;if(Af.start=i,Af.end=a,Af.closestPointToPoint(e,!0,yf).distanceTo(e)<=n)return!0;r=t.getPlane(Mf);if(Math.abs(r.distanceToPoint(e))<=n){i=r.projectPoint(e,bf);if(t.containsPoint(i))return!0}return!1});class Jf extends ui{constructor(...e){super(...e),this.isSeparatingAxisTriangle=!0,this.satAxes=new Array(4).fill().map(function(){return new vt}),this.satBounds=new Array(4).fill().map(function(){return new pf}),this.points=[this.a,this.b,this.c],this.sphere=new fr}}Jf.prototype.update=(wf=new Array(3),function(){var e=this.a,t=this.b,n=this.c,r=(wf[0]=this.a,wf[1]=this.b,wf[2]=this.c,this.satAxes),i=this.satBounds,a=r[0],o=i[0],o=(this.getNormal(a),o.setFromPoints(a,wf),r[1]),a=i[1],a=(o.subVectors(e,t),a.setFromPoints(o,wf),r[2]),o=i[2],t=(a.subVectors(t,n),o.setFromPoints(a,wf),r[3]),o=i[3];t.subVectors(n,e),o.setFromPoints(t,wf),this.sphere.setFromPoints(this.points)}),Jf.prototype.intersectsTriangle=(Sf=new Jf,Tf=new Array(3),Cf=new Array(3),Ef=new pf,Lf=new pf,Rf=new vt,function(e){e.isSeparatingAxisTriangle||(Sf.copy(e),Sf.update(),e=Sf);var t=this.satBounds,n=this.satAxes;Cf[0]=e.a,Cf[1]=e.b,Cf[2]=e.c;for(var r=0;r<4;r++){var i=t[r],a=n[r];if(Ef.setFromPoints(a,Cf),i.isSeparated(Ef))return!1}var o=e.satBounds,s=e.satAxes;Tf[0]=this.a,Tf[1]=this.b,Tf[2]=this.c;for(var l=0;l<4;l++){var c=o[l],u=s[l];if(Ef.setFromPoints(u,Tf),c.isSeparated(Ef))return!1}for(var d=0;d<4;d++)for(var h=n[d],p=0;p<4;p++){var f=s[p];if(Rf.crossVectors(h,f),Ef.setFromPoints(Rf,Tf),Lf.setFromPoints(Rf,Cf),Ef.isSeparated(Lf))return!1}return!0}),Jf.prototype.distanceToPoint=(Pf=new vt,function(e){return this.closestPointToPoint(e,Pf),e.distanceTo(Pf)}),Jf.prototype.distanceToTriangle=(If=new vt,Nf=new vt,Df=["a","b","c"],Of=new Zh,Ff=new Zh,function(e,t=null,n=null){if(this.intersectsTriangle(e))return(t||n)&&(this.getMidpoint(If),e.closestPointToPoint(If,Nf),this.closestPointToPoint(Nf,If),t&&t.copy(If),n&&n.copy(Nf)),0;for(var r=1/0,i=0;i<3;i++){var a=void 0,o=Df[i],s=e[o],s=(this.closestPointToPoint(s,If),(a=s.distanceToSquared(If))<r&&(r=a,t&&t.copy(If),n&&n.copy(s)),this[o]);e.closestPointToPoint(s,If),(a=s.distanceToSquared(If))<r&&(r=a,t&&t.copy(s),n&&n.copy(If))}for(var l=0;l<3;l++){Of.set(this[Df[l]],this[Df[(l+1)%3]]);for(var c=0;c<3;c++){Ff.set(e[Df[c]],e[Df[(c+1)%3]]),Qf(Of,Ff,If,Nf);var u=If.distanceToSquared(Nf);u<r&&(r=u,t&&t.copy(If),n&&n.copy(Nf))}}return Math.sqrt(r)});class $f extends g{constructor(...e){super(...e),this.isOrientedBox=!0,this.matrix=new gt,this.invMatrix=new gt,this.points=new Array(8).fill().map(function(){return new vt}),this.satAxes=new Array(3).fill().map(function(){return new vt}),this.satBounds=new Array(3).fill().map(function(){return new pf}),this.alignedSatBounds=new Array(3).fill().map(function(){return new pf}),this.sphere=new fr}set(e,t,n){super.set(e,t),this.matrix=n}copy(e){super.copy(e),this.matrix.copy(e.matrix)}}$f.prototype.update=function(){for(var e=this.matrix,t=this.min,n=this.max,r=this.points,i=0;i<=1;i++)for(var a=0;a<=1;a++)for(var o=0;o<=1;o++){var s=r[+i|2*a|4*o];s.x=(i?n:t).x,s.y=(a?n:t).y,s.z=(o?n:t).z,s.applyMatrix4(e)}this.sphere.setFromPoints(this.points);for(var l=this.satBounds,c=this.satAxes,u=r[0],d=0;d<3;d++){var h=c[d],p=l[d],f=r[1<<d];h.subVectors(u,f),p.setFromPoints(h,r)}var m=this.alignedSatBounds;m[0].setFromPointsField(r,"x"),m[1].setFromPointsField(r,"y"),m[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert()},$f.prototype.intersectsBox=(Bf=new pf,function(e){if(!e.intersectsSphere(this.sphere))return!1;var t=e.min,n=e.max,r=this.satBounds,i=this.satAxes,a=this.alignedSatBounds;if(Bf.min=t.x,Bf.max=n.x,a[0].isSeparated(Bf))return!1;if(Bf.min=t.y,Bf.max=n.y,a[1].isSeparated(Bf))return!1;if(Bf.min=t.z,Bf.max=n.z,a[2].isSeparated(Bf))return!1;for(var o=0;o<3;o++){var s=i[o],l=r[o];if(Bf.setFromBox(s,e),l.isSeparated(Bf))return!1}return!0}),$f.prototype.intersectsTriangle=(zf=new Jf,Vf=new Array(3),Uf=new pf,Gf=new pf,kf=new vt,function(e){e.isSeparatingAxisTriangle||(zf.copy(e),zf.update(),e=zf);var t=this.satBounds,n=this.satAxes;Vf[0]=e.a,Vf[1]=e.b,Vf[2]=e.c;for(var r=0;r<3;r++){var i=t[r],a=n[r];if(Uf.setFromPoints(a,Vf),i.isSeparated(Uf))return!1}for(var o=e.satBounds,s=e.satAxes,l=this.points,c=0;c<3;c++){var u=o[c],d=s[c];if(Uf.setFromPoints(d,l),u.isSeparated(Uf))return!1}for(var h=0;h<3;h++)for(var p=n[h],f=0;f<4;f++){var m=s[f];if(kf.crossVectors(p,m),Uf.setFromPoints(kf,Vf),Gf.setFromPoints(kf,l),Uf.isSeparated(Gf))return!1}return!0}),$f.prototype.closestPointToPoint=function(e,t){return t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t},$f.prototype.distanceToPoint=(Wf=new vt,function(e){return this.closestPointToPoint(e,Wf),e.distanceTo(Wf)}),$f.prototype.distanceToBox=(Hf=["x","y","z"],Xf=new Array(12).fill().map(function(){return new Zh}),jf=new Array(12).fill().map(function(){return new Zh}),Yf=new vt,Zf=new vt,function(e,t=0,n=null,r=null){if(this.intersectsBox(e))return(n||r)&&(e.getCenter(Zf),this.closestPointToPoint(Zf,Yf),e.closestPointToPoint(Yf,Zf),n&&n.copy(Yf),r&&r.copy(Zf)),0;for(var i=t*t,a=e.min,o=e.max,s=this.points,l=1/0,c=0;c<8;c++){var u=s[c],d=(Zf.copy(u).clamp(a,o),u.distanceToSquared(Zf));if(d<l&&(l=d,n&&n.copy(u),r&&r.copy(Zf),d<i))return Math.sqrt(d)}for(var h=0,p=0;p<3;p++)for(var f=0;f<=1;f++)for(var m=0;m<=1;m++){var v=(p+1)%3,g=(p+2)%3,_=s[f<<v|m<<g],x=s[1<<p|f<<v|m<<g],_=(Xf[h].set(_,x),Hf[p]),x=Hf[v],v=Hf[g],g=jf[h],y=g.start,g=g.end;y[_]=a[_],y[x]=(f?a:o)[x],y[v]=m?a[v]:o[x],g[_]=o[_],g[x]=(f?a:o)[x],g[v]=m?a[v]:o[x],h++}for(var b=0;b<=1;b++)for(var M=0;M<=1;M++)for(var A=0;A<=1;A++){Zf.x=(b?o:a).x,Zf.y=(M?o:a).y,Zf.z=(A?o:a).z,this.closestPointToPoint(Zf,Yf);var w=Zf.distanceToSquared(Yf);if(w<l&&(l=w,n&&n.copy(Yf),r&&r.copy(Zf),w<i))return Math.sqrt(w)}for(var S=0;S<12;S++)for(var T=Xf[S],C=0;C<12;C++){var E=jf[C],E=(Qf(T,E,Yf,Zf),Yf.distanceToSquared(Zf));if(E<l&&(l=E,n&&n.copy(Yf),r&&r.copy(Zf),E<i))return Math.sqrt(E)}return Math.sqrt(l)});var e0,t0,n0,r0,i0,a0,o0,s0,l0,c0,u0,d0,h0,p0,f0,m0=new g,v0=new vt,g0=["x","y","z"];function _0(e,t,n,r){var i=e.a,a=e.b,e=e.c,o=n.getX(t);i.x=r.getX(o),i.y=r.getY(o),i.z=r.getZ(o),o=n.getX(t+1),a.x=r.getX(o),a.y=r.getY(o),a.z=r.getZ(o),o=n.getX(t+2),e.x=r.getX(o),e.y=r.getY(o),e.z=r.getZ(o)}class x0{constructor(){}intersectRay(e,t){return df(this.boundingData,m0),e.intersectBox(m0,t)}raycast(e,t,n,r){if(this.count)for(var i=e,a=e.geometry,o=t,s=n,l=this.offset,c=this.count,u=r,d=l,h=l+c;d<h;d++)uf(i,a,o,s,d,u);else this.left.intersectRay(n,v0)&&this.left.raycast(e,t,n,r),this.right.intersectRay(n,v0)&&this.right.raycast(e,t,n,r)}raycastFirst(e,t,n){if(this.count){for(var r=e,i=e.geometry,a=t,o=n,s=this.offset,l=this.count,c=1/0,u=null,d=s,h=s+l;d<h;d++){var p=uf(r,i,a,o,d);p&&p.distance<c&&(c=(u=p).distance)}return u}var s=this.splitAxis,l=g0[s],f=0<=n.direction[l]?(m=this.left,this.right):(m=this.right,this.left),m=m.intersectRay(n,v0)?m.raycastFirst(e,t,n):null;if(m){var v=n.origin[l],g=v-m.point[l],_=v-f.boundingData[s],v=v-f.boundingData[s+3],g=g*g;if(g<=_*_&&g<=v*v)return m}_=f.intersectRay(n,v0)?f.raycastFirst(e,t,n):null;return m&&_?m.distance<=_.distance?m:_:m||_||null}}x0.prototype.shapecast=(e0=new Jf,t0=new g,n0=new g,function(e,t,n=null,r=null){var i,a,o,s,l,c,u;if(this.count&&n){for(var d=e.geometry,h=d.index,p=d.attributes.position,d=this.offset,f=3*d,m=3*(this.count+d);f<m;f+=3)if(_0(e0,f,h,p),e0.update(),n(e0,f,f+1,f+2))return!0;return!1}return i=d=this.left,a=o=this.right,r&&(u=n0,df(i.boundingData,c=t0),df(a.boundingData,u),s=r(c),(l=r(u))<s&&(i=o,a=d,o=s,s=l,l=o,d=c,c=u,u=d)),c||df(i.boundingData,c=t0),!(!t(c,!!i.count,s,i)||!i.shapecast(e,t,n,r))||(u||df(a.boundingData,u=n0),!(!t(u,!!a.count,l,a)||!a.shapecast(e,t,n,r)))}),x0.prototype.intersectsGeometry=(r0=new Jf,i0=new Jf,a0=new ee,o0=new gt,s0=new $f,l0=new $f,function(e,t,r,n=null){if(null===n&&(t.boundingBox||t.computeBoundingBox(),s0.set(t.boundingBox.min,t.boundingBox.max,r),s0.update(),n=s0),!this.count)return a=this.left,i=this.right,df(a.boundingData,m0),!(!n.intersectsBox(m0)||!a.intersectsGeometry(e,t,r,n))||(df(i.boundingData,m0),!(!n.intersectsBox(m0)||!i.intersectsGeometry(e,t,r,n)));var i,a=e.geometry,o=a.index,s=a.attributes.position,l=t.index,c=t.attributes.position,u=this.offset,d=this.count;if(o0.copy(r).invert(),t.boundsTree)return df(this.boundingData,l0),l0.matrix.copy(o0),l0.update(),i=(a0.geometry=t).boundsTree.shapecast(a0,function(e){return l0.intersectsBox(e)},function(e){e.a.applyMatrix4(r),e.b.applyMatrix4(r),e.c.applyMatrix4(r),e.update();for(var t=3*u,n=3*(d+u);t<n;t+=3)if(_0(i0,t,o,s),i0.update(),e.intersectsTriangle(i0))return!0;return!1}),a0.geometry=null,i;for(var h=3*u,p=d+3*u;h<p;h+=3){_0(r0,h,o,s),r0.a.applyMatrix4(o0),r0.b.applyMatrix4(o0),r0.c.applyMatrix4(o0),r0.update();for(var f=0,m=l.count;f<m;f+=3)if(_0(i0,f,l,c),i0.update(),r0.intersectsTriangle(i0))return!0}}),x0.prototype.intersectsBox=(c0=new $f,function(e,t,n){return c0.set(t.min,t.max,n),c0.update(),this.shapecast(e,function(e){return c0.intersectsBox(e)},function(e){return c0.intersectsTriangle(e)})}),x0.prototype.intersectsSphere=function(e,t){return this.shapecast(e,function(e){return t.intersectsBox(e)},function(e){return Kf(t,e)})},x0.prototype.closestPointToPoint=(u0=new vt,function(e,t,n=null,r=0,i=1/0){var a=1/0;return this.shapecast(e,function(e,t,n){return n<a&&n<i},function(e){e.closestPointToPoint(t,u0);e=t.distanceTo(u0);return e<a&&(n&&n.copy(u0),a=e),e<r},function(e){return e.distanceToPoint(t)}),a}),x0.prototype.closestPointToGeometry=(d0=new Jf,h0=new $f,p0=new vt,f0=new vt,function(e,t,a,o=null,s=null,l=0,r=1/0){t.boundingBox||t.computeBoundingBox(),h0.set(t.boundingBox.min,t.boundingBox.max,a),h0.update();var c,u,d=t.attributes.position,h=t.index,p=(o&&(c=p0),s&&(u=f0),1/0);return this.shapecast(e,function(e,t,n){return n<p&&n<r},function(e){for(var t=e.sphere,n=0,r=h.count;n<r;n+=3){_0(d0,n,h,d),d0.a.applyMatrix4(a),d0.b.applyMatrix4(a),d0.c.applyMatrix4(a),d0.sphere.setFromPoints(d0.points);var i=d0.sphere,i=i.center.distanceTo(t.center)-i.radius-t.radius;if(!(p<i)){d0.update();i=e.distanceToTriangle(d0,c,u);if(i<p&&(o&&o.copy(c),s&&s.copy(u),p=i),i<l)return!0}}return!1},function(e){return h0.distanceToBox(e,Math.min(p,r))}),p});var y0=["x","y","z"];var b0=new g;class M0{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,r=n.length/3,i=new Float32Array(6*r),a=0;a<r;a++)for(var o=3*n[3*a+0],s=3*n[3*a+1],l=3*n[3*a+2],c=0;c<3;c++){var u=t[o+c],d=t[s+c],h=t[l+c],p=Math.min(u,d,h),u=(Math.max(u,d,h)-p)/2;i[6*a+2*c]=p+u,i[6*a+2*c+1]=u}return i}(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 r=0;r<n;r++)for(var i=0;i<3;i++)this.sahplanes[i][r]={p:this.bounds[6*r+2*i],tri:r}}}getAverage(e,t,n){for(var r=0,i=this.bounds,a=e,o=e+t;a<o;a++)r+=i[6*a+2*n];return r/t}getBounds(e,t,n){for(var r=1/0,i=1/0,a=1/0,o=-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],r=Math.min(r,h-p),o=Math.max(o,h+p),h=c[6*u+2],p=c[6*u+3],i=Math.min(i,h-p),s=Math.max(s,h+p),h=c[6*u+4],p=c[6*u+5],a=Math.min(a,h-p),l=Math.max(l,h+p);return n[0]=r,n[1]=i,n[2]=a,n[3]=o,n[4]=s,n[5]=l,n}partition(e,t,n){for(var r=e,i=e+t-1,a=n.pos,o=2*n.axis,s=this.geo.index.array,l=this.bounds,c=this.sahplanes;;){for(;r<=i&&l[6*r+o]<a;)r++;for(;r<=i&&l[6*i+o]>=a;)i--;if(!(r<i))return r;for(var u=0;u<3;u++){var d=s[3*r+u],d=(s[3*r+u]=s[3*i+u],s[3*i+u]=d,l[6*r+2*u]),d=(l[6*r+2*u]=l[6*i+2*u],l[6*i+2*u]=d,l[6*r+2*u+1]);l[6*r+2*u+1]=l[6*i+2*u+1],l[6*i+2*u+1]=d}if(c)for(var h=0;h<3;h++){var p=c[h][r];c[h][r]=c[h][i],c[h][i]=p}r++,i--}}getOptimalSplit(e,t,n,r){var i=-1,a=0;if(0===r)-1!==(i=hf(e))&&(a=(e[i+3]+e[i])/2);else if(1===r)-1!==(i=hf(e))&&(a=this.getAverage(t,n,i));else if(2===r){for(var o=3,s=1,l=df(e,b0),c=[l.max.x-l.min.x,l.max.y-l.min.y,l.max.z-l.min.z],u=2*(c[0]*c[1]+c[0]*c[2]+c[1]*c[2]),d=[[],[],[]],h=t,p=t+n;h<p;h++)for(var f=0;f<3;f++)d[f].push(this.sahplanes[f][h]);d.forEach(function(e){return e.sort(function(e,t){return e.p-t.p})});for(var i=-1,m=s*n,v=0;v<3;v++)for(var g=(v+1)%3,_=(v+2)%3,x=l.min[y0[v]],y=l.max[y0[v]],b=d[v],M=0,A=n,w=0;w<b.length;w++){var S=b[w],T=(M++,A--,S.p-x),C=y-S.p,E=c[g],L=c[g],R=c[_],P=c[_],E=o+s*(2*(E*R+E*T+R*T)/u*M+2*(L*P+L*C+P*C)/u*A);E<m&&(i=v,a=S.p,m=E)}}return{axis:i,pos:a}}}class A0{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(65535<t?Uint32Array:Uint16Array)(t);e.setIndex(new re(n,1));for(var r=0;r<t;r++)n[r]=r}}_getRootIndexRanges(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];for(var t=[],n=new Set,r=0,i=e.groups;r<i.length;r++){var a=i[r];n.add(a.start),n.add(a.start+a.count)}for(var o=Array.from(n.values()).sort(function(e,t){return e-t}),s=0;s<o.length-1;s++){var l=o[s],c=o[s+1];t.push({offset:l/3,count:(c-l)/3})}return t}_buildTree(e,s){this._ensureIndex(e);var t,n,l=new M0(e,s),c=!1,u=function(e,t,n,r=0){if(r>=s.maxDepth&&(c=!0),n<=s.maxLeafTris||r>=s.maxDepth)return e.offset=t,e.count=n,e;var i=l.getOptimalSplit(e.boundingData,t,n,s.strategy);if(-1===i.axis)return e.offset=t,e.count=n,e;var a,o=l.partition(t,n,i);return o===t||o===t+n?(e.offset=t,e.count=n):(e.splitAxis=i.axis,(i=e.left=new x0).boundingData=l.getBounds(a=t,t=o-t,new Float32Array(6)),u(i,a,t,r+1),(i=e.right=new x0).boundingData=l.getBounds(a=o,o=n-t,new Float32Array(6)),u(i,a,o,r+1)),e},r=[],i=this._getRootIndexRanges(e);if(1===i.length){var a=new x0,o=i[0];null!=e.boundingBox?a.boundingData=(t=e.boundingBox,(n=new Float32Array(6))[0]=t.min.x,n[1]=t.min.y,n[2]=t.min.z,n[3]=t.max.x,n[4]=t.max.y,n[5]=t.max.z,n):a.boundingData=l.getBounds(o.offset,o.count,new Float32Array(6)),u(a,o.offset,o.count),r.push(a)}else for(var d=0;d<i.length;d++){var h=i[d],p=new x0;p.boundingData=l.getBounds(h.offset,h.count,new Float32Array(6)),u(p,h.offset,h.count),r.push(p)}if(c&&s.verbose&&(console.warn(`MeshBVH: Max depth of ${s.maxDepth} reached when generating BVH. Consider increasing maxDepth.`),console.warn(this,e)),null==e.boundingBox){var f=new g;e.boundingBox=new g;for(var m=0;m<r.length;m++){var v=r[m];e.boundingBox.union(df(v.boundingData,f))}}return r}raycast(e,t,n,r){for(var i=0,a=this._roots;i<a.length;i++)a[i].raycast(e,t,n,r)}raycastFirst(e,t,n){for(var r=null,i=0,a=this._roots;i<a.length;i++){var o=a[i].raycastFirst(e,t,n);null!=o&&(null==r||o.distance<r.distance)&&(r=o)}return r}intersectsGeometry(e,t,n){for(var r=0,i=this._roots;r<i.length;r++)if(i[r].intersectsGeometry(e,t,n))return!0;return!1}shapecast(e,t,n=null,r=null){for(var i=0,a=this._roots;i<a.length;i++)if(a[i].shapecast(e,t,n,r))return!0;return!1}intersectsBox(e,t,n){for(var r=0,i=this._roots;r<i.length;r++)if(i[r].intersectsBox(e,t,n))return!0;return!1}intersectsSphere(e,t){for(var n=0,r=this._roots;n<r.length;n++)if(r[n].intersectsSphere(e,t))return!0;return!1}closestPointToGeometry(e,t,n,r,i,a,o){for(var s=1/0,l=0,c=this._roots;l<c.length;l++){var u=c[l].closestPointToGeometry(e,t,n,r,i,a,o);if(u<s&&(s=u),u<a)return u}return s}distanceToGeometry(e,t,n,r,i){return this.closestPointToGeometry(e,t,n,null,null,r,i)}closestPointToPoint(e,t,n,r,i){for(var a=1/0,o=0,s=this._roots;o<s.length;o++){var l=s[o].closestPointToPoint(e,t,n,r,i);if(l<a&&(a=l),l<r)return l}return a}distanceToPoint(e,t,n,r){return this.closestPointToPoint(e,t,null,n,r)}}var w0=new Bl({color:65416,transparent:!0,opacity:.3}),S0=(new gp).geometry,T0=new g;class C0 extends he{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 i=this;if(this._mesh.geometry.boundsTree!==this._boundsTree||this._oldDepth!==this.depth){this._oldDepth=this.depth,this._boundsTree=this._mesh.geometry.boundsTree;var a,o=0;for(this._boundsTree&&(a=function(e,t){var n,r="count"in e;t!==i.depth&&(t!==i.depth-1&&!r||((n=o<i.children.length?i.children[o]:null)||((n=new jl(S0,w0)).raycast=function(){return[]},i.add(n)),o++,df(e.boundingData,T0),T0.getCenter(n.position),n.scale.subVectors(T0.max,T0.min).multiplyScalar(.5),0===n.scale.x&&(n.scale.x=Number.EPSILON),0===n.scale.y&&(n.scale.y=Number.EPSILON),0===n.scale.z&&(n.scale.z=Number.EPSILON)),r||(a(e.left,t+1),a(e.right,t+1)))})(this._boundsTree._roots[this._group],0);this.children.length>o;)this.remove(this.children.pop())}}}class E0 extends he{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,r=0;r<t;r++)r>=this._roots.length?(n=new C0(this._mesh,this.depth,r),this.add(n),this._roots.push(n)):((n=this._roots[r]).depth=this.depth,n.update());this.position.copy(this._mesh.position),this.rotation.copy(this._mesh.rotation),this.scale.copy(this._mesh.scale)}}var L0=new Mr,R0=new gt,P0=ee.prototype.raycast;function I0(e,t){if(this.geometry.boundsTree){if(!this.isAuxClippingMesh&&void 0!==this.material){try{R0.copy(this.matrixWorld).invert()}catch(e){return}var n;L0.copy(e.ray).applyMatrix4(R0),!0===e.firstHitOnly?(n=this.geometry.boundsTree.raycastFirst(this,e,L0))&&t.push(n):this.geometry.boundsTree.raycast(this,e,L0,t)}}else P0.call(this,e,t)}function N0(e){return this.boundsTree=new A0(this,e),this.boundsTree}function D0(){this.boundsTree=null}var O0=["alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","gradientMap","lightMap","map","metalnessMap","normalMap","roughnessMap","specularMap"],F0={disposeTextures:function(t){if(O0.forEach(function(e){t[e]&&t[e].isTexture&&t[e].dispose()}),"MeshNodeMaterial"==t.type)for(var e in t.nodeTextures)t.nodeTextures[e]&&t.nodeTextures[e].dispose()}};class B0{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)}}B0.prototype.isConstraint=!0;class z0 extends B0{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)}}z0.prototype.isTargetConstraint=!0;const V0=new gt,U0=(new de).setFromAxisAngle(new vt(1,0,0),-Math.PI/2);class G0 extends z0{constructor(e){super(e),this.type="ChildOfConstraint",this.offsetMatrix=new gt,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||(V0.multiplyMatrices(this.target.matrixWorld,this.offsetMatrix),V0.decompose(e.position,e.quaternion,e.scale),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(U0))}}G0.prototype.isChildOfConstraint=!0;const k0=new vt,W0=new de,H0=new vt;class X0 extends z0{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 vt,this._offset=new vt}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(k0,W0,H0),this._firstIteration&&(this._updateObjMatrixWorld(e),e.getWorldPositionNU(this._objPosInit),this._offset.subVectors(k0,this._objPosInit),this._firstIteration=!1),this.useX&&(this.invertX&&(k0.x=-k0.x),this.useOffset&&(k0.x-=this._offset.x)),this.useY&&(this.invertY&&(k0.y=-k0.y),this.useOffset&&(k0.y-=this._offset.y)),this.useZ&&(this.invertZ&&(k0.z=-k0.z),this.useOffset&&(k0.z-=this._offset.z)),e.position.lerpVectors(this._objPosInit,k0,this.influence),e.parent&&e.parent.worldToLocal(e.position))}}X0.prototype.isCopyLocationConstraint=!0;const j0=(new de).setFromAxisAngle(new vt(1,0,0),-Math.PI/2),Y0=new vt,Z0=new de,q0=new vt;class Q0 extends z0{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 de}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(Y0,Z0,q0),this._firstIteration&&(this._updateObjMatrixWorld(e),e.matrixWorld.decompose(Y0,this._objQuatInit,q0),this._firstIteration=!1),e.quaternion.copy(this._objQuatInit),(this.useX||this.useY||this.useZ)&&("REPLACE"!=this.mixMode&&"ADD"!=this.mixMode&&("BEFORE"==this.mixMode?Z0.multiply(e.quaternion):"AFTER"==this.mixMode?Z0.premultiply(e.quaternion):this.mixMode),e.quaternion.slerp(Z0,this.influence)),e.parent&&(e.parent.matrixWorld.decompose(Y0,Z0,q0),e.quaternion.premultiply(Z0.invert())),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(j0))}}Q0.prototype.isCopyRotationConstraint=!0;const K0=new vt,J0=new de,t=new vt;class $0 extends z0{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 vt,this._volumeScaleFactor=new vt,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(K0,J0,t),this._firstIteration&&(this._updateObjMatrixWorld(e),e.matrixWorld.decompose(K0,J0,this._objInitScale),this._volumeScaleFactor.set(Math.pow(t.x-this._objInitScale.x,3),Math.pow(t.y-this._objInitScale.y,3),Math.pow(t.z-this._objInitScale.z,3)),this._firstIteration=!1),this.useMakeUniform){let e=1;this.useX&&(e*=t.x),this.useY&&(e*=t.y),this.useZ&&(e*=t.z),e=Math.pow(Math.cbrt(e),this.power),t.set(e,e,e),this.useOffset&&(this.useAdd?(t.add(this._objInitScale),t.addScalar(-1)):t.multiply(this._objInitScale))}else t.set(this.useX?Math.pow(t.x,this.power):this._objInitScale.x,this.useY?Math.pow(t.y,this.power):this._objInitScale.y,this.useZ?Math.pow(t.z,this.power):this._objInitScale.z),this.useOffset&&(this.useAdd?t.set(this.useX?t.x+this._objInitScale.x-1:t.x,this.useY?t.y+this._objInitScale.y-1:t.y,this.useZ?t.z+this._objInitScale.z-1:t.z):t.set(this.useX?t.x*this._objInitScale.x:t.x,this.useY?t.y*this._objInitScale.y:t.y,this.useZ?t.z*this._objInitScale.z:t.z));e.scale.copy(this._objInitScale),e.scale.lerp(t,this.influence)}}}$0.prototype.isCopyScaleConstraint=!0;const em=(new de).setFromAxisAngle(new vt(1,0,0),-Math.PI/2),tm=new gt,nm=new vt,rm=new de,im=new vt;class am extends z0{constructor(e){super(e),this.type="CopyTransformsConstraint",this.mixMode="REPLACE",this.influence=1,this.fixCameraLightRotation=!1,this._firstIteration=!0,this._objMatrixWorldInit=new gt}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),tm.copy(this.target.matrixWorld),"REPLACE"!=this.mixMode&&("BEFORE"==this.mixMode?tm.multiply(this._objMatrixWorldInit):"AFTER"==this.mixMode&&tm.premultiply(this._objMatrixWorldInit)),tm.decompose(nm,rm,im),this._objMatrixWorldInit.decompose(e.position,e.quaternion,e.scale),e.position.lerp(nm,this.influence),e.quaternion.slerp(rm,this.influence),e.scale.lerp(im,this.influence),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(em))}}am.prototype.isCopyTransformsConstraint=!0;const om=(new de).setFromAxisAngle(new vt(1,0,0),-Math.PI/2),sm=new vt,lm=new de,cm=new vt,um=new vt,dm=new vt,hm=new vt,pm=new vt,fm={X:0,Y:1,Z:2,"-X":3,"-Y":4,"-Z":5},mm={0:new vt(1,0,0),1:new vt(0,1,0),2:new vt(0,0,1),3:new vt(-1,0,0),4:new vt(0,-1,0),5:new vt(0,0,-1)};class vm extends z0{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(t){if(super.update(t),!this.mute&&(this.target.matrixWorld.decompose(sm,lm,cm),this._firstIteration&&(this._updateObjMatrixWorld(t),this._firstIteration=!1),t.matrixWorld.decompose(um,lm,cm),dm.subVectors(sm,um),0!=dm.length())){let e;if(dm.normalize(),hm.copy(mm[fm[this.trackAxis]]),hm.applyQuaternion(lm),0==hm.length()&&hm.copy(mm[fm[this.trackAxis]]),hm.normalize(),pm.crossVectors(hm,dm),e=hm.angleTo(dm),pm.length()<Number.EPSILON){if(Math.abs(e)<Math.PI-.01)return;if(e=Math.PI,dm.copy(mm[(fm[this.trackAxis]+2)%6]),dm.applyQuaternion(lm),pm.crossVectors(hm,dm),0==pm.length())return}pm.normalize(),t.quaternion.premultiply(lm.setFromAxisAngle(pm,e)),t.parent&&(t.parent.matrixWorld.decompose(sm,lm,cm),t.quaternion.premultiply(lm.invert())),this.fixCameraLightRotation&&(t.isCamera||t.isLight)&&t.quaternion.multiply(om)}}}vm.prototype.isDampedTrackConstraint=!0;const gm={X:new vt(1,0,0),Y:new vt(0,1,0),Z:new vt(0,0,1),"-X":new vt(-1,0,0),"-Y":new vt(0,-1,0),"-Z":new vt(0,0,-1)},_m=new vt,xm=new vt,ym=new vt,a=new vt;class bm extends z0{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){const r=e.position;a.copy(this.target.position);var t=this.target.scale,n=this.offset;if(this.useRotation){_m.copy(gm[this.floorLocation]),_m.applyQuaternion(this.target.quaternion);let e;switch(this.floorLocation){case"X":a.x+=n*t.x,ym.subVectors(r,a),e=_m.dot(ym),_m.multiplyScalar(e),xm.subVectors(ym,_m).add(a),xm.x>r.x?r.copy(xm):r.x=Math.max(r.x,a.x);break;case"Y":a.y+=n*t.y,ym.subVectors(r,a),e=_m.dot(ym),_m.multiplyScalar(e),xm.subVectors(ym,_m).add(a),xm.y>r.y?r.copy(xm):r.y=Math.max(r.y,a.y);break;case"Z":a.z+=n*t.z,ym.subVectors(r,a),e=_m.dot(ym),_m.multiplyScalar(e),xm.subVectors(ym,_m).add(a),xm.z>r.z?r.copy(xm):r.z=Math.max(r.z,a.z);break;case"-X":a.x+=n*t.x,ym.subVectors(r,a),e=_m.dot(ym),_m.multiplyScalar(e),xm.subVectors(ym,_m).add(a),xm.x<r.x?r.copy(xm):r.x=Math.min(r.x,a.x);break;case"-Y":a.y+=n*t.y,ym.subVectors(r,a),e=_m.dot(ym),_m.multiplyScalar(e),xm.subVectors(ym,_m).add(a),xm.y<r.y?r.copy(xm):r.y=Math.min(r.y,a.y);break;case"-Z":a.z+=n*t.z,ym.subVectors(r,a),e=_m.dot(ym),_m.multiplyScalar(e),xm.subVectors(ym,_m).add(a),xm.z<r.z?r.copy(xm):r.z=Math.min(r.z,a.z)}}else switch(this.floorLocation){case"X":r.x=Math.max(r.x,a.x+n);break;case"Y":r.y=Math.max(r.y,a.y+n);break;case"Z":r.z=Math.max(r.z,a.z+n);break;case"-X":r.x=Math.min(r.x,a.x+n);break;case"-Y":r.y=Math.min(r.y,a.y+n);break;case"-Z":r.z=Math.min(r.z,a.z+n)}}}}bm.prototype.isFloorConstraint=!0;const Mm=new vt,Am=new de,wm=new vt,Sm=new vt;class Tm extends z0{constructor(e){super(e),this.type="LimitDistanceConstraint",this.distance=0,this.limitMode="LIMITDIST_ONSURFACE",this.useTransformLimit=!1,this.influence=1,this._objPosInit=new vt,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(Mm,Am,wm),this._updateObjMatrixWorld(e),e.getWorldPositionNU(this._objPosInit),Sm.subVectors(this._objPosInit,Mm),this._distInit=Sm.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,Mm,(1-this._sfac)*this.influence),e.parent&&e.parent.worldToLocal(e.position)))}}Tm.prototype.isLimitDistanceConstraint=!0;class Cm extends B0{constructor(){super(),this.type="LimitLocationConstraint",this.min=(new vt).setScalar(-1/0),this.max=(new vt).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)}}Cm.prototype.isLimitLocationConstraint=!0;const Em=new Ir;class Lm extends B0{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?(Em.setFromQuaternion(e.quaternion,"XYZ"),Em.x=this._clampAngle(Em.x,this.min,this.max)):"Y"==this.axis?(Em.setFromQuaternion(e.quaternion,"YZX"),Em.y=this._clampAngle(Em.y,this.min,this.max)):"Z"==this.axis&&(Em.setFromQuaternion(e.quaternion,"ZXY"),Em.z=this._clampAngle(Em.z,this.min,this.max)),e.quaternion.setFromEuler(Em))}_clampAngle(e,t,n){return e=Math.abs(n-t)<2*Math.PI?zn(e,t,n):e}}Lm.prototype.isLimitRotationConstraint=!0;class Rm extends B0{constructor(){super(),this.type="LimitScaleConstraint",this.min=(new vt).setScalar(-1/0),this.max=(new vt).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)}}Rm.prototype.isLimitScaleConstraint=!0;const Pm=(new de).setFromAxisAngle(new vt(1,0,0),-Math.PI/2),Im=new vt,Nm=new vt,Dm=new vt,Om=new vt,Fm=new vt,Bm=new xa,zm=new vt,Vm=new vt,Um=new de;class Gm extends z0{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){var t;super.update(e),this.mute||(Dm.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),Om.set("X"==this.lockAxis?1:0,"Y"==this.lockAxis?1:0,"Z"==this.lockAxis?1:0),1!=Math.abs(Dm.dot(Om))&&(Im.setFromMatrixPosition(e.matrixWorld),Nm.setFromMatrixPosition(this.target.matrixWorld),Bm.setFromNormalAndCoplanarPoint(Om,Im),Bm.projectPoint(Nm,Fm).sub(Im),t=0<zm.crossVectors(Dm,Fm).dot(Om)?1:-1,e.setRotationFromAxisAngle(Bm.normal,t*Dm.angleTo(Fm)),e.parent&&(e.parent.matrixWorld.decompose(Vm,Um,Vm),e.quaternion.premultiply(Um.invert())),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(Pm)))}}Gm.prototype.isLockedTrackConstraint=!0;const km=new vt(0,1,0),Wm=(new de).setFromAxisAngle(new vt(1,0,0),-Math.PI/2),Hm=new xa,Xm=new vt,jm=new vt,Ym=new vt,Zm=new vt,qm=new vt,Qm=new gt,Km=new vt,Jm=new de;class $m extends z0{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(r){if(super.update(r),!this.mute){var i=this.trackAxis[this.trackAxis.length-1],a=this.upAxis[this.upAxis.length-1],o="-"==this.trackAxis[0],s="-"==this.upAxis[0];if(i!=a){Xm.setFromMatrixPosition(r.matrixWorld),jm.setFromMatrixPosition(this.target.matrixWorld),Ym.subVectors(jm,Xm),Ym.lengthSq()?Ym.normalize():Ym.set(0,-1,0),Hm.set(Ym,0),1!=Math.abs(Ym.dot(km))?Hm.projectPoint(km,Zm).normalize():Zm.set(0,0,-1),o&&Ym.negate(),s&&Zm.negate();let e="X"==i?Ym:"X"==a?Zm:null,t="Y"==i?Ym:"Y"==a?Zm:null,n="Z"==i?Ym:"Z"==a?Zm:null;e?t?n=n||qm.crossVectors(e,t):t=qm.crossVectors(n,e):e=qm.crossVectors(t,n),Qm.makeBasis(e,t,n),r.setRotationFromMatrix(Qm),r.parent&&(r.parent.matrixWorld.decompose(Km,Jm,Km),r.quaternion.premultiply(Jm.invert())),this.fixCameraLightRotation&&(r.isCamera||r.isLight)&&r.quaternion.multiply(Wm)}}}}$m.prototype.isTrackToConstraint=!0;class e1 extends z0{constructor(e){super(e),this._orthoZoom=1}copy(e){super.copy(e),this._orthoZoom=e._orthoZoom}update(e){var t,n;super.update(e),this.mute||(t=this.target,e.parent===t&&t.isOrthographicCamera?(n=this._orthoZoom/t.zoom,e.position.multiplyScalar(n),e.scale.multiplyScalar(n),this._orthoZoom=t.zoom):console.error("FixOrthoZoom: object should be a direct child of the orthographic camera"))}}e1.prototype.isFixOrthoZoomConstraint=!0;var t1=new vt,n1=new vt,r1=new de,i1=new g,a1=new fr;class o1 extends z0{constructor(e){super(e),this.type="CanvasFitConstraint",this.edgeH=0,this.edgeV=0,this.offset=0,this.useBoundingBox=!0}copy(e){return super.copy(e),this.edgeH=e.edgeH,this.edgeV=e.edgeV,this.offset=e.offset,this.useBoundingBox=e.useBoundingBox,this}update(s){if(super.update(s),!this.mute){var l=this.target;if(s.parent!==l)console.error("CanvasFitConstraint: object should be a direct child of the camera");else{let e,t,n;var c,u,d="LEFT"==this.edgeH?-1:"RIGHT"==this.edgeH?1:0,h="BOTTOM"==this.edgeV?-1:"TOP"==this.edgeV?1:0;l.isPerspectiveCamera&&(t=En(l.fov/2),e=Math.atan(l.aspect*Math.tan(t)),"LEFT"==this.edgeH&&(e*=d),"BOTTOM"==this.edgeV&&(t*=h),n=Math.abs(s.position.z));const p=s.geometry;let r=0,i=0,a=0,o=0;p&&(s.matrix.compose(s.position,s.quaternion,s.scale),o=this.useBoundingBox?(null===p.boundingBox&&p.computeBoundingBox(),i1.copy(s.geometry.boundingBox).applyMatrix4(s.matrix),u=i1.getCenter(t1).sub(s.position),c=i1.getSize(n1).addScalar(2*this.offset),r=-(.5*c.x*d+u.x),i=-(.5*c.y*h+u.y),a=c.x,c.y):(null===p.boundingSphere&&p.computeBoundingSphere(),a1.copy(s.geometry.boundingSphere).applyMatrix4(s.matrix),a1.radius+=this.offset,u=t1.copy(a1.center).sub(s.position),r=-(a1.radius*d+u.x),i=-(a1.radius*h+u.y),l.isPerspectiveCamera&&(r/=Math.cos(e),i/=Math.cos(t)),a=2*a1.radius,2*a1.radius)),"STRETCH"==this.edgeH?(s.position.x=r,0!==a&&(s.scale.applyQuaternion(r1.copy(s.quaternion)),l.isPerspectiveCamera?s.scale.x*=2*n*Math.tan(e)/a:s.scale.x*=(l.right-l.left)/l.zoom/a,s.scale.applyQuaternion(r1.copy(s.quaternion).invert()))):"NONE"!==this.edgeH&&(l.isPerspectiveCamera?s.position.x=n*Math.tan(e)+r:s.position.x=(d<0?l.left:l.right)/l.zoom+r),"STRETCH"==this.edgeV?(s.position.y=i,0!==o&&(s.scale.applyQuaternion(r1.copy(s.quaternion)),l.isPerspectiveCamera?s.scale.y*=2*n*Math.tan(t)/o:s.scale.y*=(l.top-l.bottom)/l.zoom/o,s.scale.applyQuaternion(r1.copy(s.quaternion).invert()))):"NONE"!==this.edgeV&&(l.isPerspectiveCamera?s.position.y=n*Math.tan(t)+i:s.position.y=(h<0?l.bottom:l.top)/l.zoom+i)}}}}o1.prototype.isCanvasFitConstraint=!0;class s1 extends B0{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(t){if(super.update(t),!this.mute&&this.appInstance){var n=this.appInstance.getWidth(),r=this.appInstance.getHeight();let e;switch(this.orientation){case"ALL":e=!0;break;case"LANDSCAPE":e=1<=n/r;break;case"PORTRAIT":e=n/r<1}this.appInstance.getCamera()!==t||n>=this.minWidth&&n<=this.maxWidth&&r>=this.minHeight&&r<=this.maxHeight&&e?n>=this.minWidth&&n<=this.maxWidth&&r>=this.minHeight&&r<=this.maxHeight&&e?t.traverse(e=>{e.internVisible=!0}):t.traverse(e=>{e.internVisible=!1}):(t=this.findAlternativeCamera(t,this.appInstance.scene,n,r))&&this.appInstance.setCamera(t)}}findAlternativeCamera(e,t,r,i){let a,o,s=!1;return e&&t.traverse(function(t){if(!s&&t.isCamera&&t!=e)for(let e=0;e<t.constraints.length;e++){var n=t.constraints[e];if(n.isCanvasBreakpointsConstraint){switch(n.orientation){case"ALL":a=!0;break;case"LANDSCAPE":a=1<=r/i;break;case"PORTRAIT":a=r/i<1}r>=n.minWidth&&r<=n.maxWidth&&i>=n.minHeight&&i<=n.maxHeight&&a&&(o?(console.error("CanvasBreakpointsConstraint: two or more alternative cameras"),s=!0):o=t)}}}),o}}s1.prototype.isCanvasBreakpointsConstraint=!0;var l1,c1,u1,pe={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};function d1(e){for(var t in this.isKeyDown={},pe)this.isKeyDown[pe[t]]=!1;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._domElement.addEventListener("keydown",this._keydownCb,!1),this._domElement.addEventListener("keyup",this._keyupCb,!1)}function h1(){this.posFrom=new vt,this.targetFrom=new vt,this.posTo=new vt,this.targetTo=new vt,this.sphericalFrom=new ad,this.sphericalTo=new ad,this.finishCb=function(){},this.movementType=0,this.active=!1,this.duration=0,this.clock=new _h}Object.assign(d1.prototype,{dispose:function(){this._domElement.removeEventListener("keydown",this._keydownCb,!1),this._domElement.removeEventListener("keyup",this._keyupCb,!1)}}),Object.assign(h1.prototype,{setup:(u1=new vt,function({posFrom:e=new vt,targetFrom:t=new vt,posTo:n=new vt,targetTo:r=new vt,finishCb:i=function(){},movementType:a=0}){return this.posFrom.copy(e),this.targetFrom.copy(t),this.posTo.copy(n),this.targetTo.copy(r),this.finishCb=i,this.movementType=a,1===this.movementType&&(u1.copy(this.posFrom).sub(this.targetFrom),this.sphericalFrom.setFromVector3(u1),u1.copy(this.posTo).sub(this.targetTo),this.sphericalTo.setFromVector3(u1),e=Fn(this.sphericalFrom.theta),t=Fn(this.sphericalTo.theta),(n=Math.abs(e-t))>Math.PI&&(t=e+Math.sign(e-t)*(2*Math.PI-n)),this.sphericalFrom.theta=e,this.sphericalTo.theta=t),this}),start(e){this.active=!0,this.duration=e,this.clock.start()},update:(l1=new vt,c1=new vt,function(e=function(e,t,n){}){var t,n,r,i=Cn(this.clock.getElapsedTime()/this.duration,0,1);c1.lerpVectors(this.targetFrom,this.targetTo,i),0===this.movementType?l1.lerpVectors(this.posFrom,this.posTo,i):1===this.movementType&&(t=Tn(this.sphericalFrom.radius,this.sphericalTo.radius,i),n=Tn(this.sphericalFrom.phi,this.sphericalTo.phi,i),r=Tn(this.sphericalFrom.theta,this.sphericalTo.theta,i),l1.setFromSphericalCoords(t,n,r),l1.add(c1)),e(i,l1,c1),1<=i&&(this.active=!1,this.finishCb())})});class p1 extends n{constructor(F,e){super();var l=this;this.object=F,this.domElement=void 0!==e?e:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.enableDamping=!0,this.enableRotate=!0,this.rotateSpeed=.9,this.rotateSpeedTouch=.75,this.rotateInertia=.05,this.rotateInertiaTouch=.05,this.enableZoom=!0,this.zoomSpeed=30,this.zoomSpeedKey=.2,this.zoomInertia=.05,this.enablePan=!0,this.panSpeedKey=.15,this.panInertia=.05,this.enableKeys=!0,this.gazeLevel=1.8,this.storyHeight=3;let t=!(this.collisionMeshes=[]);Object.defineProperty(this,"enablePointerLock",{get(){return t},set(e){t!==e&&(t=e,$())}}),Object.defineProperty(this,"inTween",{get(){return R.active}});var c,n,s,u,d,h=new _h,B=new vt,p=new vt,z=new vt,f=new vt,V=new de,m=new vt,v={},r=(v[pe.W]=v[pe.S]=v[pe.A]=v[pe.D]=v[pe.UP_ARROW]=v[pe.DOWN_ARROW]=v[pe.LEFT_ARROW]=v[pe.RIGHT_ARROW]=0,!1),g=new ad,_=new ad,x=new Be,y=1,b=1,i=new Be,a=new Be,M=0,A=0,w=1,S=1,T=new Be,C=new Be,U=1,G=1,E=new Ws(new vt,new vt(0,-1,0)),L=E.params.checkVisibility=!1,R=new h1,k={type:"change"},o={type:"start"},P={type:"end"},I=(this.handleResize=function(){var e,t;this.domElement===document?(this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight):(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)},n=new Be,function(e,t){return n.set((e-.5*l.screen.width-l.screen.left)/(.5*l.screen.width),(l.screen.height+2*(l.screen.top-t))/l.screen.width),n});const W=function(){const n=new Be;return function(e,t){return n.set(e,-t).multiplyScalar(2/l.screen.width)}}();function H(e){!1!==l.enabled&&(e.preventDefault(),!1!==l.enableRotate&&(a.copy(I(e.pageX,e.pageY).negate()),i.copy(a),r=!0,document.addEventListener("mousemove",N,!1),document.addEventListener("mouseup",D,!1),document.addEventListener("mouseleave",D,!1),l.dispatchEvent(o)))}function N(e){!1!==l.enabled&&(e.preventDefault(),r&&!1!==l.enableRotate&&(a.copy(I(e.pageX,e.pageY).negate()),x.add(a).sub(i),i.copy(a),y=l.rotateSpeed,b=l.rotateInertia))}function D(e){!1!==l.enabled&&(e.preventDefault(),r=!1,document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",D),document.removeEventListener("mouseleave",D),l.dispatchEvent(P))}function X(e){if(!1!==l.enabled&&!1!==l.enableZoom){switch(e.preventDefault(),e.stopPropagation(),e.deltaMode){case 2:A-=.025*e.deltaY,w=l.zoomSpeed,S=l.zoomInertia;break;case 1:A-=.01*e.deltaY,w=l.zoomSpeed,S=l.zoomInertia;break;default:A-=25e-5*e.deltaY,w=l.zoomSpeed,S=l.zoomInertia}l.dispatchEvent(o),l.dispatchEvent(P)}}function j(e){!1!==l.enabled&&(e=e.touches[0],r=!0,a.copy(I(e.pageX,e.pageY).negate()),i.copy(a),l.dispatchEvent(o))}function Y(e){!1!==l.enabled&&(e.preventDefault(),e=e.touches[0],!1!==l.enableRotate&&(a.copy(I(e.pageX,e.pageY).negate()),x.add(a).sub(i),i.copy(a),y=l.rotateSpeedTouch,b=l.rotateInertiaTouch))}function Z(e){if(!1!==l.enabled){if(0===e.touches.length)r=!1;else{if(!1===l.enableRotate)return;r=!0,a.copy(I(e.touches[0].pageX,e.touches[0].pageY).negate()),i.copy(a)}l.dispatchEvent(P)}}function q(e){!1!==l.enabled&&e.preventDefault()}function Q(e){l.domElement.requestPointerLock()}function K(e){document.pointerLockElement===l.domElement?(l.dispatchEvent(o),document.addEventListener("mousemove",O)):(l.dispatchEvent(P),document.removeEventListener("mousemove",O))}function J(e){console.error("Pointer lock failed")}function O(e){e.preventDefault(),l.enabled&&l.enableRotate&&(x.add(W(e.movementX,e.movementY).negate()),y=l.rotateSpeed,b=l.rotateInertia)}function $(){ee(),l.domElement.addEventListener("contextmenu",q),l.enablePointerLock?(l.domElement.addEventListener("click",Q),document.addEventListener("pointerlockchange",K),document.addEventListener("pointerlockerror",J)):l.domElement.addEventListener("mousedown",H),l.domElement.addEventListener("wheel",X),l.domElement.addEventListener("touchstart",j),l.domElement.addEventListener("touchend",Z),l.domElement.addEventListener("touchmove",Y),(c=new d1(window)).onKeyDown=function(e){e.keyCode in v&&(v[e.keyCode]=1)}}function ee(){l.domElement.removeEventListener("contextmenu",q),l.domElement.removeEventListener("click",Q),document.removeEventListener("pointerlockchange",K),document.removeEventListener("pointerlockerror",J),document.removeEventListener("mousemove",O),l.domElement.removeEventListener("mousedown",H),l.domElement.removeEventListener("wheel",X),l.domElement.removeEventListener("touchstart",j),l.domElement.removeEventListener("touchend",Z),l.domElement.removeEventListener("touchmove",Y),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",D),document.removeEventListener("mouseleave",D),c&&c.dispose()}this.update=function(){if(R.active)R.update(function(e,t,n){if(l.object.position.copy(t),l.object.lookAt(n),1<=e){for(var r in _.set(0,0,0),x.set(0,0),A=M=0,T.set(0,0),C.set(0,0),v)v[r]=0;h.getDelta()}});else{l.object.getLocalDirection(m),g.setFromVector3(m),g.theta+=_.theta*y,g.phi+=_.phi*y,g.makeSafe(),m.setFromSpherical(g),B.copy(m).add(l.object.position),l.object.lookAtLocal(B),l.object.isPerspectiveCamera?l.object.position.addScaledVector(m,M):l.object.isOrthographicCamera&&(l.object.zoom*=1+.15*M,l.object.updateProjectionMatrix()),p.copy(m).cross(l.object.up).setLength(-T.x),p.add(z.copy(l.object.up).setLength(T.y)),l.object.position.add(p);var e,t=h.getDelta();for(e in _.set(_.radius,x.y,x.x),x.x=l.enableDamping?On(x.x,0,t,b,.001):0,x.y=l.enableDamping?On(x.y,0,t,b,.001):0,_.set(_.radius,_.phi-x.y,_.theta-x.x),T.copy(C),C.x=l.enableDamping?On(C.x,0,t,G,.001):0,C.y=l.enableDamping?On(C.y,0,t,G,.001):0,T.sub(C),T.multiplyScalar(U),M=A,A=l.enableDamping?On(A,0,t,S,.001):0,M=(M-A)*w,v){var n,r=e==pe.A||e==pe.LEFT_ARROW||e==pe.D||e==pe.RIGHT_ARROW,i=e==pe.W||e==pe.UP_ARROW||e==pe.S||e==pe.DOWN_ARROW,a=r?l.panInertia:l.zoomInertia,o=r?l.panSpeedKey:l.zoomSpeedKey;a=c.isKeyDown[e]?v[e]=1:(n=v[e],v[e]=On(v[e],0,t,a,.001),n-v[e]),l.enabled&&l.enableKeys&&(r&&!l.enablePan||i&&!l.enableZoom||(a*=60*t*o,e==pe.A||e==pe.LEFT_ARROW?T.x+=a:e==pe.D||e==pe.RIGHT_ARROW?T.x-=a:e==pe.W||e==pe.UP_ARROW?M+=a:e!=pe.S&&e!=pe.DOWN_ARROW||(M-=a)))}}l.collisionMeshes.length&&(E.ray.origin.copy(l.object.position),E.far=l.storyHeight,0<(s=E.intersectObjects(l.collisionMeshes)).length?(s=s[0],l.object.position.y=s.point.y+l.gazeLevel,L=!0):L&&l.object.position.copy(f));var s=!1;1e-6<f.distanceToSquared(l.object.position)&&(f.copy(l.object.position),s=!0),V.dot(l.object.quaternion)<1-1e-6&&(V.copy(l.object.quaternion),s=!0),s&&l.dispatchEvent(k)},this.forceMouseUp=function(){D({preventDefault:function(){}})},this.dispose=ee,this.releaseFromCollision=function(){L=!1},this.tween=(s=new vt,u=new vt,d=new vt,function(e,t,n,r,i){l.object.parent&&(e=s.copy(e),l.object.parent.worldToLocal(e));var a=l.object.getWorldPosition(u),o=d.subVectors(t,a).length(),o=l.object.getWorldDirection(d).multiplyScalar(o).add(a);e.manhattanDistanceTo(l.object.position)<1e-5&&t.manhattanDistanceTo(o)<1e-5?void 0!==r&&r():R.setup({posFrom:l.object.position,targetFrom:o,posTo:e,targetTo:t,finishCb:r,movementType:i}).start(n)}),$(),this.handleResize(),this.update()}}class f1 extends n{constructor(e,B){super();var n,r,z,V,s,l=this,i={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},U=(this.object=e,this.domElement=void 0!==B?B:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.enableDamping=!0,this.enableRotate=!0,this.rotateSpeed=.9,this.rotateSpeedTouch=.75,this.rotateInertia=.05,this.rotateInertiaTouch=.05,this.enableZoom=!0,this.zoomSpeed=150,this.zoomSpeedKey=.5,this.zoomSpeedTouch=20,this.zoomInertia=.05,this.zoomInertiaTouch=.05,this.enablePan=!0,this.panSpeed=20,this.panSpeedKey=.15,this.panSpeedTouch=15,this.panInertia=.05,this.panInertiaTouch=.05,this.enableKeys=!0,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.mouseButtons={ROTATE:fe.LEFT,ZOOM:fe.MIDDLE,PAN:fe.RIGHT},Object.defineProperty(this,"inTween",{get(){return P.active}}),new _h),G=new vt,c=new vt,k=new vt,W=new Be,H=new vt,X=new de,a=i.NONE,u=new vt,d={},h=(d[pe.W]=d[pe.S]=d[pe.A]=d[pe.D]=d[pe.UP_ARROW]=d[pe.DOWN_ARROW]=d[pe.LEFT_ARROW]=d[pe.RIGHT_ARROW]=0,new d1(window)),p=(h.onKeyDown=function(e){e.keyCode in d&&(d[e.keyCode]=1)},new ad),f=new ad,m=new Be,v=1,g=1,o=new Be,_=new Be,x=0,y=0,b=1,M=1,A=0,w=0,S=new Be,T=new Be,C=1,E=1,L=new Be,R=new Be,P=new h1,j={type:"change"},I={type:"start"},t={type:"end"},N=(this.handleResize=function(){var e,t;this.domElement===document?(this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight):(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)},n=new Be,function(e,t){return n.set((e-l.screen.left)/l.screen.width,(t-l.screen.top)/l.screen.height),n}),D=(r=new Be,function(e,t){return r.set((e-.5*l.screen.width-l.screen.left)/(.5*l.screen.width),(l.screen.height+2*(l.screen.top-t))/l.screen.width),r});function Y(e){if(!1!==l.enabled){switch(e.preventDefault(),e.button){case l.mouseButtons.ROTATE:if(!1===l.enableRotate)return;_.copy(D(e.pageX,e.pageY).negate()),o.copy(_),a=i.ROTATE;break;case l.mouseButtons.ZOOM:case l.mouseButtons.PAN:if(!1===l.enablePan)return;L.copy(N(e.pageX,e.pageY)),R.copy(L),a=e.button==l.mouseButtons.PAN?i.PAN:i.ZOOM}document.addEventListener("mousemove",O,!1),document.addEventListener("mouseup",F,!1),document.addEventListener("mouseleave",F,!1),l.dispatchEvent(I)}}function O(e){!1!==l.enabled&&(e.preventDefault(),a===i.ROTATE?!1!==l.enableRotate&&(_.copy(D(e.pageX,e.pageY).negate()),m.add(_).sub(o),o.copy(_),v=l.rotateSpeed,g=l.rotateInertia):a!==i.PAN&&a!==i.ZOOM||!1!==l.enablePan&&(R.copy(N(e.pageX,e.pageY)),T.add(R).sub(L),L.copy(R),C=l.panSpeed,E=l.panInertia))}function F(e){!1!==l.enabled&&(e.preventDefault(),a=i.NONE,document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",F),document.removeEventListener("mouseleave",F),l.dispatchEvent(t))}function Z(e){if(!1!==l.enabled&&!1!==l.enableZoom){switch(e.preventDefault(),e.stopPropagation(),e.deltaMode){case 2:y-=.025*e.deltaY,b=l.zoomSpeed,M=l.zoomInertia;break;case 1:y-=.01*e.deltaY,b=l.zoomSpeed,M=l.zoomInertia;break;default:y-=25e-5*e.deltaY,b=l.zoomSpeed,M=l.zoomInertia}l.dispatchEvent(I),l.dispatchEvent(t)}}function q(e){if(!1!==l.enabled){var t=e.touches[0],n=e.touches[1];if(1===e.touches.length){if(!1===l.enableRotate)return;a=i.TOUCH_ROTATE,_.copy(D(t.pageX,t.pageY).negate()),o.copy(_)}else{if(!1===l.enableZoom&&!1===l.enablePan)return;a=i.TOUCH_ZOOM_PAN,l.enableZoom&&(e=N(t.pageX-n.pageX,t.pageY-n.pageY),A=w=e.length()),l.enablePan&&(e=N((t.pageX+n.pageX)/2,(t.pageY+n.pageY)/2),L.copy(e),R.copy(L))}l.dispatchEvent(I)}}function Q(e){if(!1!==l.enabled){e.preventDefault();var t=e.touches[0],n=e.touches[1];if(1===e.touches.length)!1!==l.enableRotate&&(_.copy(D(t.pageX,t.pageY).negate()),m.add(_).sub(o),o.copy(_),v=l.rotateSpeedTouch,g=l.rotateInertiaTouch);else!1===l.enableZoom&&!1===l.enablePan||(e=N(t.pageX-n.pageX,t.pageY-n.pageY),e=(w=e.length())-A,A=w,t=N((t.pageX+n.pageX)/2,(t.pageY+n.pageY)/2),R.copy(t),t=(n=W.subVectors(R,L)).length(),L.copy(R),l.enableZoom&&Math.abs(e)>Math.abs(t)&&(y+=e,b=l.zoomSpeedTouch,M=l.zoomInertiaTouch),l.enablePan&&Math.abs(e)<=Math.abs(t)&&(T.add(n),C=l.panSpeedTouch,E=l.panInertiaTouch))}}function K(e){if(!1!==l.enabled){switch(e.touches.length){case 0:a=i.NONE;break;case 1:if(!1===l.enableRotate)return;a=i.TOUCH_ROTATE,_.copy(D(e.touches[0].pageX,e.touches[0].pageY).negate()),o.copy(_)}l.dispatchEvent(t)}}function J(e){!1!==l.enabled&&e.preventDefault()}this.update=function(){if(P.active)P.update(function(e,t,n){if(l.object.position.copy(t),l.object.lookAt(n),1<=e){for(var r in f.set(0,0,0),m.set(0,0),y=x=0,S.set(0,0),T.set(0,0),d)d[r]=0;U.getDelta()}});else{l.object.getLocalDirection(u),p.setFromVector3(u),p.theta+=f.theta*v,p.phi+=f.phi*v,p.theta=Math.max(l.minAzimuthAngle,Math.min(l.maxAzimuthAngle,p.theta)),p.phi=Math.max(l.minPolarAngle,Math.min(l.maxPolarAngle,p.phi)),p.makeSafe(),u.setFromSpherical(p),G.copy(u).add(l.object.position),l.object.lookAtLocal(G),l.object.isPerspectiveCamera?l.object.position.addScaledVector(u,x):l.object.isOrthographicCamera&&(l.object.zoom*=1+.15*x,l.object.updateProjectionMatrix()),c.copy(u).cross(l.object.up).setLength(-S.x),c.add(k.copy(l.object.up).setLength(S.y)),l.object.position.add(c);var e,t=U.getDelta();for(e in f.set(f.radius,m.y,m.x),m.x=l.enableDamping?On(m.x,0,t,g,.001):0,m.y=l.enableDamping?On(m.y,0,t,g,.001):0,f.set(f.radius,f.phi-m.y,f.theta-m.x),S.copy(T),T.x=l.enableDamping?On(T.x,0,t,E,.001):0,T.y=l.enableDamping?On(T.y,0,t,E,.001):0,S.sub(T),S.multiplyScalar(C),x=y,y=l.enableDamping?On(y,0,t,M,.001):0,x=(x-y)*b,d){var n,r=e==pe.A||e==pe.LEFT_ARROW||e==pe.D||e==pe.RIGHT_ARROW,i=e==pe.W||e==pe.UP_ARROW||e==pe.S||e==pe.DOWN_ARROW,a=r?l.panInertia:l.zoomInertia,o=r?l.panSpeedKey:l.zoomSpeedKey;a=h.isKeyDown[e]?d[e]=1:(n=d[e],d[e]=On(d[e],0,t,a,.001),n-d[e]),l.enabled&&l.enableKeys&&(r&&!l.enablePan||i&&!l.enableZoom||(a*=60*t*o,e==pe.A||e==pe.LEFT_ARROW?S.x+=a:e==pe.D||e==pe.RIGHT_ARROW?S.x-=a:e==pe.W||e==pe.UP_ARROW?x+=a:e!=pe.S&&e!=pe.DOWN_ARROW||(x-=a)))}}var s=!1;1e-6<H.distanceToSquared(l.object.position)&&(H.copy(l.object.position),s=!0),X.dot(l.object.quaternion)<1-1e-6&&(X.copy(l.object.quaternion),s=!0),s&&l.dispatchEvent(j)},this.forceMouseUp=function(){F({preventDefault:function(){}})},this.dispose=function(){this.domElement.removeEventListener("contextmenu",J,!1),this.domElement.removeEventListener("mousedown",Y,!1),this.domElement.removeEventListener("wheel",Z,!1),this.domElement.removeEventListener("touchstart",q,!1),this.domElement.removeEventListener("touchend",K,!1),this.domElement.removeEventListener("touchmove",Q,!1),document.removeEventListener("mousemove",O,!1),document.removeEventListener("mouseup",F,!1),document.removeEventListener("mouseleave",F,!1),h.dispose()},this.tween=(z=new vt,V=new vt,s=new vt,function(e,t,n,r,i){l.object.parent&&(e=z.copy(e),l.object.parent.worldToLocal(e));var a=l.object.getWorldPosition(V),o=s.subVectors(t,a).length(),o=l.object.getWorldDirection(s).multiplyScalar(o).add(a);e.manhattanDistanceTo(l.object.position)<1e-5&&t.manhattanDistanceTo(o)<1e-5?void 0!==r&&r():P.setup({posFrom:l.object.position,targetFrom:o,posTo:e,targetTo:t,finishCb:r,movementType:i}).start(n)}),this.domElement.addEventListener("contextmenu",J,!1),this.domElement.addEventListener("mousedown",Y,!1),this.domElement.addEventListener("wheel",Z,!1),this.domElement.addEventListener("touchstart",q,!1),this.domElement.addEventListener("touchend",K,!1),this.domElement.addEventListener("touchmove",Q,!1),this.handleResize(),this.update()}}class m1 extends n{constructor(e,B){super(),this.object=e,this.domElement=void 0!==B?B:document,this.enabled=!0,this.targetObj=new he,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!0,this.enableZoom=!0,this.zoomSpeed=5,this.zoomSpeedTouch=1,this.zoomInertia=.05,this.zoomInertiaTouch=.05,this.enableRotate=!0,this.rotateSpeed=1.2,this.rotateSpeedTouch=.7,this.rotateInertia=.05,this.rotateInertiaTouch=.05,this.enablePan=!0,this.panSpeed=1.3,this.screenSpacePanning=!0,this.panSpeedKey=15,this.panInertia=.05,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.mouseButtons={ROTATE:fe.LEFT,ZOOM:fe.MIDDLE,PAN:fe.RIGHT},this.target0=this.targetObj.position.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,Object.defineProperty(this,"inTween",{get(){return D.active},set(e){D.active=e}}),this.getPolarAngle=function(){return m.phi},this.getAzimuthalAngle=function(){return m.theta},this.saveState=function(){h.targetObj.updateWorldMatrix(!0,!1),h.target0.setFromMatrixPosition(h.targetObj.matrixWorld),h.position0.copy(h.object.position),h.zoom0=h.object.zoom},this.forceMouseUp=function(){F()},this.reset=(z=new vt,function(){h.targetObj.updateWorldMatrix(!0,!1);var e=z.copy(h.target0);h.targetObj.worldToLocal(e),h.targetObj.position.add(e),h.object.position.copy(h.position0),h.object.zoom=h.zoom0,h.object.updateProjectionMatrix(),h.dispatchEvent(G),h.update(),f=p.NONE}),this.update=(o=new vt,s=new vt,l=new de,c=new de,V=new vt(0,1,0),u=new vt,d=new de,function(){var i=h.object.position;if(h.targetObj.updateWorldMatrix(!0,!1),D.active)D.update(function(e,t,n){if(i.copy(t),s.copy(n),h.object.lookAt(s),1<=e){for(var r in v.set(0,0,0),_.set(0,0,0),g=1,L.set(0,0),y)y[r]=0;A.set(0,0),Y.getDelta()}});else{s.setFromMatrixPosition(h.targetObj.matrixWorld),o.copy(i).sub(s),l.setFromUnitVectors(h.object.up,V),c.copy(l).invert(),o.applyQuaternion(l),m.setFromVector3(o),h.autoRotate&&f===p.NONE&&Z(2*Math.PI/60/60*h.autoRotateSpeed),m.theta+=v.theta,m.phi+=v.phi,isFinite(h.minAzimuthAngle)&&isFinite(h.maxAzimuthAngle)&&(m.theta=zn(m.theta,h.minAzimuthAngle,h.maxAzimuthAngle)),m.phi=Math.max(h.minPolarAngle,Math.min(h.maxPolarAngle,m.phi)),m.makeSafe(),h.object.isPerspectiveCamera?(m.radius*=g,m.radius=Math.max(h.minDistance,Math.min(h.maxDistance,m.radius))):h.object.isOrthographicCamera&&(h.object.zoom/=g,h.object.zoom=Math.max(h.minZoom,Math.min(h.maxZoom,h.object.zoom)),h.object.updateProjectionMatrix()),s.add(_),o.setFromSpherical(m),o.applyQuaternion(c),i.copy(s).add(o),h.object.lookAt(s),v.set(0,0,0),_.set(0,0,0);var e,t,n=Y.getDelta();M.copy(A),A.x=h.enableDamping?On(A.x,0,n,S,1):0,A.y=h.enableDamping?On(A.y,0,n,S,1):0,M.sub(A);var r=(a=h.domElement===document?h.domElement.body:h.domElement).clientWidth,a=a.clientHeight;for(e in r&&a&&(Z(2*Math.PI*M.x/r*w),r=2*Math.PI*M.y/a*w,v.phi-=r),E.copy(L),L.x=h.enableDamping?On(L.x,0,n,h.panInertia,.1):0,L.y=h.enableDamping?On(L.y,0,n,h.panInertia,.1):0,E.sub(L),E.multiplyScalar(h.panSpeed),y)t=W.isKeyDown[e]?y[e]=1:(t=y[e],y[e]=On(y[e],0,n,h.panInertia,.1),t-y[e]),h.enabled&&h.enableKeys&&h.enablePan&&(t*=60*n*h.panSpeedKey,e==pe.A||e==pe.LEFT_ARROW?E.x+=t:e==pe.D||e==pe.RIGHT_ARROW?E.x-=t:e==pe.W||e==pe.UP_ARROW?E.y+=t:e!=pe.S&&e!=pe.DOWN_ARROW||(E.y-=t));ee(E.x,E.y),g=N,N=h.enableDamping?On(N,1,n,j,.01):1,g/=N}return h.targetObj.position.copy(s),!!(x||u.distanceToSquared(h.object.position)>k||8*(1-d.dot(h.object.quaternion))>k)&&(h.dispatchEvent(G),u.copy(h.object.position),d.copy(h.object.quaternion),!(x=!1))}),this.dispose=function(){h.domElement.removeEventListener("contextmenu",ue,!1),h.domElement.removeEventListener("mousedown",ie,!1),h.domElement.removeEventListener("wheel",oe,!1),h.domElement.removeEventListener("touchstart",se,!1),h.domElement.removeEventListener("touchend",ce,!1),h.domElement.removeEventListener("touchmove",le,!1),document.removeEventListener("mousemove",ae,!1),document.removeEventListener("mouseup",F,!1),document.removeEventListener("mouseleave",F,!1),W.dispose()},this.tween=(U=new vt,a=new vt,function(e,t,n,r,i){h.targetObj.updateWorldMatrix(!0,!1),a.setFromMatrixPosition(h.targetObj.matrixWorld),h.object.parent&&(e=U.copy(e),h.object.parent.worldToLocal(e));e.manhattanDistanceTo(h.object.position)<1e-5&&t.manhattanDistanceTo(a)<1e-5?void 0!==r&&r():D.setup({posFrom:h.object.position,targetFrom:a,posTo:e,targetTo:t,finishCb:r,movementType:i}).start(n)});var z,o,s,l,c,V,u,d,U,a,h=this,G={type:"change"},i={type:"start"},t={type:"end"},p={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY_PAN:4},f=p.NONE,k=1e-6,m=new ad,v=new ad,g=1,_=new vt,x=!1,y={},W=(y[pe.W]=y[pe.S]=y[pe.A]=y[pe.D]=y[pe.UP_ARROW]=y[pe.DOWN_ARROW]=y[pe.LEFT_ARROW]=y[pe.RIGHT_ARROW]=0,new d1(window)),b=(W.onKeyDown=function(e){e.keyCode in y&&(y[e.keyCode]=1)},new Be),H=new Be,M=new Be,A=new Be,w=1,S=1,T=new Be,C=new Be,E=new Be,L=new Be,R=new Be,P=new Be,I=new Be,N=1,X=1,j=1,Y=new _h,D=new h1;function O(){return Math.pow(.95,X)}function Z(e){v.theta-=e}function q(e,t){H.set(e,t),A.add(H).sub(b),b.copy(H)}n=new vt;var n,r,Q,K,J=function(e,t){n.setFromMatrixColumn(t,0),n.multiplyScalar(-e),_.add(n)},$=(r=new vt,function(e,t){!0===h.screenSpacePanning?r.setFromMatrixColumn(t,1):(r.setFromMatrixColumn(t,0),r.crossVectors(h.object.up,r)),r.multiplyScalar(e),_.add(r)}),ee=(Q=new vt,K=new vt,function(e,t){var n,r=h.domElement===document?h.domElement.body:h.domElement,i=r.clientWidth,r=r.clientHeight;i&&r&&(h.object.isPerspectiveCamera?(h.targetObj.updateWorldMatrix(!0,!1),K.setFromMatrixPosition(h.targetObj.matrixWorld),n=h.object.position,Q.copy(n).sub(K),n=Q.length(),n*=Math.tan(h.object.fov/2*Mn),J(2*e*n/r,h.object.matrix),$(2*t*n/r,h.object.matrix)):h.object.isOrthographicCamera?(J(e*(h.object.right-h.object.left)/h.object.zoom/i,h.object.matrix),$(t*(h.object.top-h.object.bottom)/h.object.zoom/r,h.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),h.enablePan=!1))});function te(e){h.object.isPerspectiveCamera?N/=e:h.object.isOrthographicCamera?(N/=e,x=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),h.enableZoom=!1)}function ne(e){h.object.isPerspectiveCamera?N*=e:h.object.isOrthographicCamera?(N*=e,x=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),h.enableZoom=!1)}function re(e){var t;t=e.clientX,e=e.clientY,C.set(t,e),L.add(C).sub(T),T.copy(C)}function ie(e){if(!1!==h.enabled){switch(e.preventDefault(),e.button){case h.mouseButtons.ROTATE:if(!1===h.enableRotate)return;b.set(e.clientX,e.clientY),f=p.ROTATE;break;case h.mouseButtons.ZOOM:case h.mouseButtons.PAN:if(!1===h.enablePan)return;T.set(e.clientX,e.clientY),f=p.PAN}f!==p.NONE&&(document.addEventListener("mousemove",ae,!1),document.addEventListener("mouseup",F,!1),document.addEventListener("mouseleave",F,!1),h.dispatchEvent(i))}}function ae(e){if(!1!==h.enabled)switch(e.preventDefault(),f){case p.ROTATE:if(!1===h.enableRotate)return;q(e.clientX,e.clientY),w=h.rotateSpeed,S=h.rotateInertia;break;case p.DOLLY:if(!1===h.enableZoom)return;P.set(e.clientX,e.clientY),I.subVectors(P,R),0<I.y?te(O()):I.y<0&&ne(O()),R.copy(P),h.update();break;case p.PAN:if(!1===h.enablePan)return;re(e)}}function F(e){!1!==h.enabled&&(document.removeEventListener("mousemove",ae,!1),document.removeEventListener("mouseup",F,!1),document.removeEventListener("mouseleave",F,!1),h.dispatchEvent(t),f=p.NONE)}function oe(e){!1===h.enabled||!1===h.enableZoom||f!==p.NONE&&f!==p.ROTATE||(e.preventDefault(),e.stopPropagation(),h.dispatchEvent(i),e=e,X=h.zoomSpeed,j=h.zoomInertia,e.deltaY<0?ne(O()):0<e.deltaY&&te(O()),h.update(),h.dispatchEvent(t))}function se(e){if(!1!==h.enabled){switch(e.touches.length){case 1:if(!1===h.enableRotate)return;b.set(e.touches[0].pageX,e.touches[0].pageY),f=p.TOUCH_ROTATE;break;case 2:if(!1===h.enableZoom&&!1===h.enablePan)return;t=e,h.enableZoom&&(X=h.zoomSpeedTouch,j=h.zoomInertiaTouch,r=t.touches[0].pageX-t.touches[1].pageX,n=t.touches[0].pageY-t.touches[1].pageY,r=Math.sqrt(r*r+n*n),R.set(0,r)),h.enablePan&&(n=.5*(t.touches[0].pageX+t.touches[1].pageX),r=.5*(t.touches[0].pageY+t.touches[1].pageY),T.set(n,r)),h.update(),f=p.TOUCH_DOLLY_PAN;break;default:f=p.NONE}var t,n,r;f!==p.NONE&&h.dispatchEvent(i)}}function le(e){var t,n,r;if(!1!==h.enabled)switch(e.preventDefault(),e.touches.length){case 1:if(!1===h.enableRotate)return;if(f!==p.TOUCH_ROTATE)return;q(e.touches[0].pageX,e.touches[0].pageY),w=h.rotateSpeedTouch,S=h.rotateInertiaTouch;break;case 2:if(!1===h.enableZoom&&!1===h.enablePan)return;if(f!==p.TOUCH_DOLLY_PAN)return;n=(t=e).touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY,n=Math.sqrt(n*n+r*r),P.set(0,n),I.subVectors(P,R),R.copy(P),r=.5*(t.touches[0].pageX+t.touches[1].pageX),n=.5*(t.touches[0].pageY+t.touches[1].pageY),C.set(r,n),E.subVectors(C,T),T.copy(C),h.enableZoom&&Math.abs(I.length())>Math.abs(E.length())&&(0<I.y?ne(O()):I.y<0&&te(O())),h.enablePan&&Math.abs(I.length())<Math.abs(E.length())&&L.add(E),h.update();break;default:f=p.NONE}}function ce(e){!1!==h.enabled&&(h.dispatchEvent(t),f=p.NONE)}function ue(e){!1!==h.enabled&&e.preventDefault()}h.domElement.addEventListener("contextmenu",ue,!1),h.domElement.addEventListener("mousedown",ie,!1),h.domElement.addEventListener("wheel",oe,!1),h.domElement.addEventListener("touchstart",se,!1),h.domElement.addEventListener("touchend",ce,!1),h.domElement.addEventListener("touchmove",le,!1),this.update()}}function v1(e){this.sourceTexture=e,this.camera=new Rs(-1,1,1,-1,0,1),this.shader=new T({type:"CubeCopy",uniforms:{faceIdx:{value:0},cubemap:{value:null}},vertexShader:`
|
|
uniform int faceIdx;
|
|
|
|
varying vec3 vCubeDirection;
|
|
|
|
vec3 uvToCubeDirection(vec2 uv, int face) {
|
|
vec3 dir;
|
|
uv = 2.0 * uv - 1.0;
|
|
|
|
if (face == 0) {
|
|
dir = vec3(1.0, -uv.y, -uv.x);
|
|
} else if (face == 1) {
|
|
dir = vec3(-1.0, -uv.y, uv.x);
|
|
} else if (face == 2) {
|
|
dir = vec3(uv.x, 1.0, uv.y);
|
|
} else if (face == 3) {
|
|
dir = vec3(uv.x, -1.0, -uv.y);
|
|
} else if (face == 4) {
|
|
dir = vec3(uv.x, -uv.y, 1.0);
|
|
} else if (face == 5) {
|
|
dir = vec3(-uv.x, -uv.y, -1.0);
|
|
}
|
|
return dir;
|
|
}
|
|
|
|
void main() {
|
|
vCubeDirection = uvToCubeDirection(uv, faceIdx);
|
|
gl_Position = vec4(position, 1.0);
|
|
}
|
|
`,fragmentShader:`
|
|
uniform samplerCube cubemap;
|
|
|
|
varying vec3 vCubeDirection;
|
|
|
|
void main() {
|
|
gl_FragColor = mapTexelToLinear(textureCube(cubemap, vCubeDirection));
|
|
|
|
#include <tonemapping_fragment>
|
|
|
|
gl_FragColor = linearToOutputTexel(gl_FragColor);
|
|
}
|
|
`}),this.shader.map=e,this.shader.uniforms.cubemap.value=e,this.planeMesh=new ee(new Sa(2,2),this.shader),this.scene=new Js,this.scene.add(this.camera),this.scene.add(this.planeMesh)}function g1(e,t){this.sourceTexture=e,this.resolution=void 0!==t?t:256;e=this.resolution,t={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 fa(e,e,t),this.renderTarget.texture.name="EquiCube.cube",this.camera=new Rs(-1,1,1,-1,0,1e3),this.shader=new T(E.equicube),this.planeMesh=new ee(new Sa(2,2),this.shader),this.planeMesh.material.side=Ue,this.scene=new Js,this.scene.add(this.planeMesh),this.scene.add(this.camera),this.invertU=!1,this.offsetU=0,this.shader.uniforms.tEquirect.value=this.sourceTexture}Object.defineProperties(m1.prototype,{center:{get:function(){return console.warn("v3d.OrbitControls: .center has been deprecated, use .targetObj instead"),new vt}},target:{get:function(){return console.warn("v3d.OrbitControls: .target has been deprecated, use .targetObj instead"),new vt},set:function(){console.warn("v3d.OrbitControls: .target has been deprecated, use .targetObj instead")}},noZoom:{get:function(){return console.warn("v3d.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),!this.enableZoom},set:function(e){console.warn("v3d.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),this.enableZoom=!e}},noRotate:{get:function(){return console.warn("v3d.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),!this.enableRotate},set:function(e){console.warn("v3d.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),this.enableRotate=!e}},noPan:{get:function(){return console.warn("v3d.OrbitControls: .noPan has been deprecated. Use .enablePan instead."),!this.enablePan},set:function(e){console.warn("v3d.OrbitControls: .noPan has been deprecated. Use .enablePan instead."),this.enablePan=!e}},noKeys:{get:function(){return console.warn("v3d.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),!this.enableKeys},set:function(e){console.warn("v3d.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),this.enableKeys=!e}},staticMoving:{get:function(){return console.warn("v3d.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),!this.enableDamping},set:function(e){console.warn("v3d.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),this.enableDamping=!e}}}),v1.prototype={constructor:v1,render:function(e,t,n=1){var r=e.toneMapping,i=e.toneMappingExposure,a=e.getRenderTarget();e.toneMapping=1,e.toneMappingExposure=n;for(var o=0;o<6;o++)e.setRenderTarget(t,o),this.shader.uniforms.faceIdx.value=o,e.render(this.scene,this.camera);e.toneMapping=r,e.toneMappingExposure=i,e.setRenderTarget(a)},dispose:function(){this.planeMesh.geometry.dispose(),this.planeMesh.material.dispose()}},g1.prototype={constructor:g1,update:function(e){var t=e.gammaInput,n=e.gammaOutput,r=e.toneMapping,i=e.toneMappingExposure,a=e.getRenderTarget();e.toneMapping=1,e.toneMappingExposure=1,e.gammaInput=!1,e.gammaOutput=!1,this.renderToCubeMapTarget(e,this.renderTarget),e.setRenderTarget(a),e.toneMapping=r,e.toneMappingExposure=i,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()}};class _1 extends n{constructor(){super(),this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setCamera(e){}setSize(e,t){}dispose(){}render(e,t,n,r,i){console.error("v3d.Pass: .render() must be implemented in derived pass.")}}const x1=new Rs(-1,1,1,-1,0,1),y1=new Sa(2,2);class b1{constructor(e){this._mesh=new ee(y1,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,x1)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}static dispose(){y1.dispose()}}class M1 extends _1{constructor(e,t,n){super(),this.damp=t,this.shader=E.afterimage,this.uniforms=ca.clone(this.shader.uniforms),this.uniforms.damp.value=this.damp,this.textureComp=new ze(e.x,e.y,n),this.textureOld=new ze(e.x,e.y,n),this.shaderMaterial=new T({uniforms:this.uniforms,vertexShader:this.shader.vertexShader,fragmentShader:this.shader.fragmentShader}),this.compFsQuad=new b1(this.shaderMaterial);t=new fi;this.copyFsQuad=new b1(t)}dispose(){this.textureComp.dispose(),this.textureOld.dispose()}render(e,t,n,r,i){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):(e.setRenderTarget(t),this.clear&&e.clear()),this.copyFsQuad.render(e);n=this.textureOld;this.textureOld=this.textureComp,this.textureComp=n}setSize(e,t){this.textureComp.setSize(e,t),this.textureOld.setSize(e,t)}}class A1 extends _1{constructor(e,t,n,r,i){super(),this.strength=void 0!==t?t:1,this.radius=n,this.threshold=r,this.resolution=void 0!==e?new Be(e.x,e.y):new Be(256,256),i=i||{minFilter:ht,magFilter:ht,format:pt},this.clearColor=new _t(0,0,0),this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;var a=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);this.renderTargetBright=new ze(a,o,i),this.renderTargetBright.texture.name="BloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(var s=0;s<this.nMips;s++){var l=new ze(a,o,i);l.texture.name="BloomPass.h"+s,l.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(l),(l=new ze(a,o,i)).texture.name="BloomPass.v"+s,l.texture.generateMipmaps=!1,this.renderTargetsVertical.push(l),a=Math.round(a/2),o=Math.round(o/2)}for(var n=E.bloomLumHighPass,c=(this.highPassUniforms=ca.clone(n.uniforms),this.highPassUniforms.luminosityThreshold.value=r,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new T({type:"BloomHighPass",uniforms:this.highPassUniforms,vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,defines:{}}),this.separableBlurMaterials=[],[3,5,7,9,11]),a=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2),s=0;s<this.nMips;s++)this.separableBlurMaterials.push(this.getSeperableBlurMaterial(c[s])),this.separableBlurMaterials[s].uniforms.texSize.value=new Be(a,o),a=Math.round(a/2),o=Math.round(o/2);this.compositeMaterial=this.getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1,this.compositeMaterial.needsUpdate=!0;this.compositeMaterial.uniforms.bloomFactors.value=[1,.8,.6,.4,.2],this.bloomTintColors=[new vt(1,1,1),new vt(1,1,1),new vt(1,1,1),new vt(1,1,1),new vt(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors;e=E.copy;this.copyUniforms=ca.clone(e.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new T({type:"BloomCopy",defines:Object.assign({},e.defines),uniforms:this.copyUniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,blending:J,blendEquation:$,blendEquationAlpha:$,blendSrc:Me,blendDst:xe,blendSrcAlpha:_e,blendDstAlpha:xe,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new _t,this.oldClearAlpha=1,this.basic=new fi,this.fsQuad=new b1(null)}dispose(){for(var e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose()}setSize(e,t){var n=Math.round(e/2),r=Math.round(t/2);this.renderTargetBright.setSize(n,r);for(var i=0;i<this.nMips;i++)this.renderTargetsHorizontal[i].setSize(n,r),this.renderTargetsVertical[i].setSize(n,r),this.separableBlurMaterials[i].uniforms.texSize.value=new Be(n,r),n=Math.round(n/2),r=Math.round(r/2)}render(e,t,n,r,i){e.getClearColor(this.oldClearColor),this.oldClearAlpha=e.getClearAlpha();for(var a=e.autoClear,o=(e.autoClear=!1,e.setClearColor(this.clearColor,0),i&&e.context.disable(e.context.STENCIL_TEST),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),this.renderTargetBright),s=0;s<this.nMips;s++)this.fsQuad.material=this.separableBlurMaterials[s],this.separableBlurMaterials[s].uniforms.colorTexture.value=o.texture,this.separableBlurMaterials[s].uniforms.direction.value=A1.BlurDirectionX,e.setRenderTarget(this.renderTargetsHorizontal[s]),e.clear(),this.fsQuad.render(e),this.separableBlurMaterials[s].uniforms.colorTexture.value=this.renderTargetsHorizontal[s].texture,this.separableBlurMaterials[s].uniforms.direction.value=A1.BlurDirectionY,e.setRenderTarget(this.renderTargetsVertical[s]),e.clear(),this.fsQuad.render(e),o=this.renderTargetsVertical[s];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,i&&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=a}getSeperableBlurMaterial(e){return new T({type:"BloomSeparableBlur",defines:{KERNEL_RADIUS:e,SIGMA:e},uniforms:{colorTexture:{value:null},texSize:{value:new Be(.5,.5)},direction:{value:new Be(.5,.5)}},vertexShader:yt.pp_plane_vert,fragmentShader:yt.pp_bloom_separable_blur_frag})}getCompositeMaterial(e){return new T({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:yt.pp_plane_vert,fragmentShader:yt.pp_bloom_composite_frag})}}A1.BlurDirectionX=new Be(1,0),A1.BlurDirectionY=new Be(0,1);class w1 extends _1{constructor(e,t,n){super(),this.scene=e,this.camera=t;var e=n.width||window.innerWidth||1,r=n.height||window.innerHeight||1,e=new ze(e,r,{minFilter:ht,magFilter:ht,format:pt}),r=(this.renderTargetDepth=e.clone(),this.renderTargetDepth.texture.name="BokehPass.depth",this.materialDepth=new gs,this.materialDepth.depthPacking=ln,this.materialDepth.blending=ce,E.bokeh),e=ca.clone(r.uniforms);e.tDepth.value=this.renderTargetDepth.texture,e.focus.value=xt(n.focus)?n.focus:1,e.aperture.value=xt(n.aperture)?n.aperture:1,e.maxblur.value=xt(n.maxblur)?n.maxblur:1,e.depthLeakThreshold.value=xt(n.depthLeakThreshold)?n.depthLeakThreshold:.2,e.nearClip.value=t.near,e.farClip.value=t.far,e.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 T({type:"Bokeh",defines:Object.assign({},r.defines),uniforms:e,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader}),this.uniforms=e,this.camera2=new Rs(-1,1,1,-1,0,1),this.scene2=new Js,this.quad2=new ee(new Sa(2,2),null),this.quad2.frustumCulled=!1,this.scene2.add(this.quad2),this.oldClearColor=new _t,this.oldClearAlpha=1}render(e,t,n,r,i){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.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 S1 extends _1{constructor(e,t){super(),this.textureID=void 0!==t?t:"tDiffuse",e instanceof T?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=ca.clone(e.uniforms),this.material=new T({type:"ShaderPass",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new b1(this.material)}render(e,t,n,r,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?e.setRenderTarget(null):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)),this.fsQuad.render(e)}dispose(){this.material.dispose()}}class T1 extends S1{constructor(){super(E.brightness_contrast),this.material.type="Grayscale"}get brightness(){return this.uniforms.brightness.value}set brightness(e){this.uniforms.brightness.value=e}get constrast(){return this.uniforms.contrast.value}set constrast(e){this.uniforms.contrast.value=e}}class C1 extends S1{constructor(e,t,n,r){super(E.fxaa),this.material.type="FXAA",this.width=void 0!==n?n:512,this.height=void 0!==r?r:256,this.needsSwap=!1}setSize(e,t){this.width=e,this.height=t,this.uniforms.resolution.value.set(1/e,1/t)}}class E1 extends S1{constructor(){super(E.grayscale),this.material.type="Grayscale"}}class L1 extends _1{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n,r,i){var a,o,s=e.context,l=e.state;l.buffers.color.setMask(!1),l.buffers.depth.setMask(!1),l.buffers.color.setLocked(!0),l.buffers.depth.setLocked(!0),o=this.inverse?(a=0,1):(a=1,0),l.buffers.stencil.setTest(!0),l.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),l.buffers.stencil.setFunc(s.ALWAYS,a,4294967295),l.buffers.stencil.setClear(o),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),l.buffers.color.setLocked(!1),l.buffers.depth.setLocked(!1),l.buffers.stencil.setFunc(s.EQUAL,1,4294967295),l.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP)}setCamera(e){this.camera=e}}class R1 extends _1{constructor(){super(),this.needsSwap=!1}render(e,t,n,r,i){e.state.buffers.stencil.setTest(!1)}}function P1(){this.positions=[],this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],this.counters=[],this.geometry=new S,this.widthCallback=null}function I1(e,t,n,r,i){var a;if(e=e.subarray||e.slice?e:e.buffer,n=n.subarray||n.slice?n:n.buffer,e=t?e.subarray?e.subarray(t,i&&t+i):e.slice(t,i&&t+i):e,n.set)n.set(e,r);else for(a=0;a<e.length;a++)n[a+r]=e[a]}function N1(e){this.headEdge=this.tailEdge=e,this.headIndex=e.index0,this.tailIndex=e.index1,this.indexCount=2}function D1(e,t){this.index0=e,this.index1=t,this.edge0=null,this.edge1=null}function O1(){this.geometry=new S}function F1(e,t,n){var r=e.headIndex,e=e.tailIndex;return t[r][0]||t[e][0]||n[r][0]||n[e][0]||null}P1.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()},P1.prototype.compareV3=function(e,t){e*=6,t*=6;return this.positions[e]===this.positions[t]&&this.positions[1+e]===this.positions[1+t]&&this.positions[2+e]===this.positions[2+t]},P1.prototype.copyV3=function(e){e*=6;return[this.positions[e],this.positions[1+e],this.positions[2+e]]},P1.prototype.process=function(){var e=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];for(var t,n=0;n<e;n++)this.side.push(1),this.side.push(-1);for(n=0;n<e;n++)t=this.widthCallback?this.widthCallback(n/(e-1)):1,this.width.push(t),this.width.push(t);for(var r,n=0;n<e;n++)this.uvs.push(n/(e-1),0),this.uvs.push(n/(e-1),1);r=this.compareV3(0,e-1)?this.copyV3(e-2):this.copyV3(0),this.previous.push(r[0],r[1],r[2]),this.previous.push(r[0],r[1],r[2]);for(n=0;n<e-1;n++)r=this.copyV3(n),this.previous.push(r[0],r[1],r[2]),this.previous.push(r[0],r[1],r[2]);for(n=1;n<e;n++)r=this.copyV3(n),this.next.push(r[0],r[1],r[2]),this.next.push(r[0],r[1],r[2]);r=this.compareV3(e-1,0)?this.copyV3(1):this.copyV3(e-1),this.next.push(r[0],r[1],r[2]),this.next.push(r[0],r[1],r[2]);for(n=0;n<e-1;n++){var i=2*n;this.indices_array.push(i,1+i,2+i),this.indices_array.push(2+i,1+i,3+i)}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 re(new Float32Array(this.positions),3),previous:new re(new Float32Array(this.previous),3),next:new re(new Float32Array(this.next),3),side:new re(new Float32Array(this.side),1),width:new re(new Float32Array(this.width),1),uv:new re(new Float32Array(this.uvs),2),counters:new re(new Float32Array(this.counters),1),index:new re(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)},P1.prototype.advance=function(e){var t=this.attributes.position.array,n=this.attributes.previous.array,r=this.attributes.next.array,i=t.length;I1(t,0,n,0,i),I1(t,6,t,0,i-6),t[i-6]=e.x,t[i-5]=e.y,t[i-4]=e.z,t[i-3]=e.x,t[i-2]=e.y,t[i-1]=e.z,I1(t,6,r,0,i-6),r[i-6]=e.x,r[i-5]=e.y,r[i-4]=e.z,r[i-3]=e.x,r[i-2]=e.y,r[i-1]=e.z,this.attributes.position.needsUpdate=!0,this.attributes.previous.needsUpdate=!0,this.attributes.next.needsUpdate=!0},P1.updateAttributes=function(e){var t=e.attributes.position.array,n=(e.attributes.previous.array,e.attributes.next.array,new P1);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(N1.prototype,{mergeStrip:function(e){var t=this.headIndex,n=e.headIndex,r=this.tailIndex,i=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==i?(this.headEdge.linkToEdge(e.tailEdge),e.tailEdge.linkToEdge(this.headEdge),this.headEdge=e.headEdge,this.headIndex=e.headIndex,this.indexCount+=e.indexCount-1):r==n?(this.tailEdge.linkToEdge(e.headEdge),e.headEdge.linkToEdge(this.tailEdge),this.tailEdge=e.tailEdge,this.tailIndex=e.tailIndex,this.indexCount+=e.indexCount-1):r==i&&(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,r=this.headEdge,i=e[t++]=this.headIndex;null!==r;){var i=r.index0==i?r.index1:r.index0,a=(e[t++]=i,r.edge0);(a=a!=n&&null!==a?a:r.edge1)==n&&(a=null),n=r,r=a}return e}}),Object.assign(D1.prototype,{linkToEdge:function(e){null===this.edge0?this.edge0=e:null===this.edge1&&(this.edge1=e)}}),Object.assign(O1.prototype,{fromBufferGeometry:function(e){var r,n,i,a,o,s,l,c,u,d,h=e.getAttribute("position"),e=e.getIndex();void 0!==h&&(r=[],null!==e?function(e){for(var t=e.length%2?e.length-1:e.length,n={},r={},i=0;i<t;i+=2){var a=(u=new N1(new D1(e[i],e[i+1]))).headIndex,o=u.tailIndex;n[a]=n[a]||[],n[o]=n[o]||[],r[a]=r[a]||[],r[o]=r[o]||[],n[a].push(u),r[o].push(u)}var s,l=new Iu.LinkMap;for(s in n)n[s].length&&l.push(new Iu.LinkMapNode(n[s]),s);for(var c=[],u=l.first&&l.first.value[0];u;){n[a=u.headIndex].splice(n[a].indexOf(u),1);r[o=u.tailIndex].splice(r[o].indexOf(u),1),0==n[a].length&&l.removeNodeByKey(a);for(var d=F1(u,n,r);null!==d;)n[a=d.headIndex].splice(n[a].indexOf(d),1),r[o=d.tailIndex].splice(r[o].indexOf(d),1),0==n[a].length&&l.removeNodeByKey(a),u.mergeStrip(d),d=F1(u,n,r);c.push(u),u=l.first&&l.first.value[0]}return c}(e.array).forEach(function(e){var t=new P1,n=new Float32Array(3*e.indexCount);e.getIndicesFlat().forEach(function(e,t){n.set(h.array.subarray(3*e,3*e+3),3*t)}),t.setGeometry(n),r.push(t)}):((e=new P1).setGeometry(h.array),r.push(e)),n=[],i=[],a=[],o=[],s=[],l=[],c=[],u=[],d=0,r.forEach(function(e){n=n.concat(e.positions),i=i.concat(e.previous),a=a.concat(e.next),o=o.concat(e.side),s=s.concat(e.width),l=l.concat(e.uvs),c=c.concat(e.counters);var t=e.indices_array.map(function(e){return e+d});u=u.concat(t),d+=e.positions.length/3}),this.geometry.setAttribute("position",new re(new Float32Array(n),3)),this.geometry.setAttribute("previous",new re(new Float32Array(i),3)),this.geometry.setAttribute("next",new re(new Float32Array(a),3)),this.geometry.setAttribute("side",new re(new Float32Array(o),1)),this.geometry.setAttribute("width",new re(new Float32Array(s),1)),this.geometry.setAttribute("uv",new re(new Float32Array(l),2)),this.geometry.setAttribute("counters",new re(new Float32Array(c),1)),e=65535<Si(u)?Uint32Array:Uint16Array,this.geometry.setIndex(new re(new e(u),1)))}});class B1 extends yu{constructor(e){super(),this.type="MeshLineMaterial",this.lineWidth=1,this.sizeAttenuation=1,this.color=new _t(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 Be(1,1),this.uniforms={lineWidth:{value:1},sizeAttenuation:{value:1},color:{value:new _t(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 Be(1,1)}},this.vertexShader=yt.raw_meshline_vert,this.fragmentShader=yt.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}}B1.prototype.isMeshLineMaterial=!0;class z1 extends _1{constructor(e,t,n,r){super(),this.renderScene=t,this.renderCamera=n,this.selectedObjects=void 0!==r?r:[],this.visibleEdgeColor=new mt(1,1,1,1),this.hiddenEdgeColor=new mt(.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 Be(e.x,e.y):new Be(256,256);t={minFilter:ht,magFilter:ht,format:pt},n=Math.round(this.resolution.x/this.downSampleRatio),r=Math.round(this.resolution.y/this.downSampleRatio),this.renderTargetMaskBuffer=new ze(this.resolution.x,this.resolution.y,t),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.renderTargetDepthBuffer=new ze(this.resolution.x,this.resolution.y,t),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new ze(n,r,t),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new ze(n,r,t),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new ze(Math.round(n/2),Math.round(r/2),t),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new ze(n,r,t),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new ze(Math.round(n/2),Math.round(r/2),t),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1,this.separableBlurMaterial1=this.getSeparableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value=new Be(n,r),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this.getSeparableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value=new Be(Math.round(n/2),Math.round(r/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this.getOverlayMaterial(),e=E.copy;this.copyUniforms=ca.clone(e.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new T({defines:Object.assign({},e.defines),uniforms:this.copyUniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,blending:ce,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new _t,this.oldClearAlpha=1,this.basic=new fi({toneMapped:!1}),this.fsQuad=new b1(null),this.camera=new Rs(-1,1,1,-1,0,1),this.tempPulseColor1=new mt,this.tempPulseColor2=new mt,this.textureMatrix=new gt,this.visibilityState=new WeakMap,this._depthMaterial=new gs({blending:ce,depthPacking:ln,side:Ue}),this._maskMaterial=new Lu({side:Ue})}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);e=Math.round(e/this.downSampleRatio),t=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(e,t),this.renderTargetBlurBuffer1.setSize(e,t),this.renderTargetEdgeBuffer1.setSize(e,t),this.separableBlurMaterial1.uniforms.texSize.value=new Be(e,t),e=Math.round(e/2),t=Math.round(t/2),this.renderTargetBlurBuffer2.setSize(e,t),this.renderTargetEdgeBuffer2.setSize(e,t),this.separableBlurMaterial2.uniforms.texSize.value=new Be(e,t)}saveVisibilityState(){const t=this;t.renderScene.traverse(function(e){e instanceof ee&&t.visibilityState.set(e,e.visible)})}restoreVisibilityState(){const t=this;t.renderScene.traverse(function(e){e instanceof ee&&(e.visible=t.visibilityState.get(e))})}changeVisibilityOfSelectedObjects(t){const n=this;function e(e){e instanceof ee&&n.visibilityState.get(e)&&(e.visible=t)}for(var r=0;r<n.selectedObjects.length;r++)for(var i=n.selectedObjects[r],a=(e(i),i.children),o=0;o<a.length;o++){var s=a[o];s.isMesh&&s.isMaterialGeneratedMesh&&e(s)}}changeVisibilityOfNonSelectedObjects(r){const i=this;var a=[];function e(e){e instanceof ee&&i.visibilityState.get(e)&&a.push(e)}for(var t=0;t<i.selectedObjects.length;t++)for(var n=i.selectedObjects[t],o=(e(n),n.children),s=0;s<o.length;s++){var l=o[s];l.isMesh&&l.isMaterialGeneratedMesh&&e(l)}i.renderScene.traverse(function(e){if(e instanceof ee&&i.visibilityState.get(e)){for(var t=!1,n=0;n<a.length;n++)if(a[n].id===e.id){t=!0;break}t||(e.visible=r)}})}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,r,i){var a,o;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&&(e.getClearColor(this.oldClearColor),this.oldClearAlpha=e.getClearAlpha(),a=e.autoClear,e.autoClear=!1,i&&e.context.disable(e.context.STENCIL_TEST),e.setClearColor(16777215,1),o=this.renderScene.background,this.renderScene.background=null,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 Be(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=o,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),0<this.pulsePeriod&&(o=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2,this.tempPulseColor1.multiplyScalar(o),this.tempPulseColor2.multiplyScalar(o)),this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value=new Be(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=z1.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=z1.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=z1.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=z1.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,i&&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=a)}getEdgeDetectionMaterial(){return new T({type:"OutlineEdgeDetection",defines:{HIDDEN_EDGE_ALPHA:1},uniforms:{maskTexture:{value:null},texSize:{value:new Be(.5,.5)},visibleEdgeColor:{value:new mt(1,1,1,1)},hiddenEdgeColor:{value:new mt(1,1,1,1)}},vertexShader:yt.pp_plane_vert,fragmentShader:yt.pp_outline_edge_frag})}getSeparableBlurMaterial(e){return new T({type:"OutlineSeparableBlur",defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new Be(.5,.5)},direction:{value:new Be(.5,.5)},kernelRadius:{value:1}},vertexShader:yt.pp_plane_vert,fragmentShader:yt.pp_outline_blur_frag})}getOverlayMaterial(){return new T({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:yt.pp_plane_vert,fragmentShader:yt.pp_outline_overlay_frag,blending:J,blendEquation:$,blendEquationAlpha:$,blendSrc:Me,blendDst:Ae,blendSrcAlpha:xe,blendDstAlpha:xe,depthTest:!1,depthWrite:!1,transparent:!0})}setCamera(e){this.renderCamera=e}}z1.BlurDirectionX=new Be(1,0),z1.BlurDirectionY=new Be(0,1);class V1 extends _1{constructor(e,t,n,r,i){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=void 0!==i?i:0,this.oldClearColor=new _t,this.oldClearAlpha=1,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1}render(e,t,n,r,i){var a=e.autoClear;e.autoClear=!1,this.scene.overrideMaterial=this.overrideMaterial,this.clearColor&&(e.getClearColor(this.oldClearColor),this.oldClearAlpha=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,this.oldClearAlpha),this.scene.overrideMaterial=null,e.autoClear=a}setCamera(e){this.camera=e}}class U1 extends _1{constructor(e,t,n,r){super(),this.scene=e,this.camera=t,this.sampleLevel=4,this.unbiased=!0,this.clearColor=void 0!==n?n:0,this.clearAlpha=void 0!==r?r:0,this.oldClearColor=new _t,this.oldClearAlpha=1;e=E.copy;this.copyUniformsAccum=ca.clone(e.uniforms),this.copyMaterialAccum=new T({type:"SSAACopyAccum",defines:Object.assign({},e.defines),uniforms:this.copyUniformsAccum,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,premultipliedAlpha:!0,transparent:!0,blending:q,depthTest:!1,depthWrite:!1}),this.fsQuadAccum=new b1(this.copyMaterialAccum),this.copyUniformsFinal=ca.clone(e.uniforms),this.copyMaterialFinal=new T({type:"SSAACopyFinal",defines:Object.assign({},e.defines),uniforms:this.copyUniformsFinal,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,premultipliedAlpha:!1,transparent:!1,blending:ce,depthTest:!1,depthWrite:!1}),this.fsQuadFinal=new b1(this.copyMaterialFinal),this.iterative=!1,this.iterativeFrame=0}_getJitterOffsets(){return U1.JitterVectors[Math.max(0,Math.min(this.sampleLevel,5))]}_isLastIterativeFrame(){var 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");for(var r,i,a=this._getJitterOffsets(),o=e.autoClear,s=(e.autoClear=!1,e.getClearColor(this.oldClearColor),this.oldClearAlpha=e.getClearAlpha(),1/a.length),l=(this.copyUniformsAccum.tDiffuse.value=this.sampleRenderTarget.texture,n.width),c=n.height,u=this.camera.view?this.camera.view.offsetX:0,d=this.camera.view?this.camera.view.offsetY:0,h=(this.iterative?(i=this.iterativeFrame,r=performance.now()):i=0,a.length),p=i;p<h;p++){this.dispatchEvent({type:"iteration",frame:p});var f=a[p],f=(this.camera.setViewOffset&&this.camera.setViewOffset(l,c,u+.0625*f[0],d+.0625*f[1],l,c),s);if(this.unbiased&&(f+=1/32*((p+.5)/a.length-.5)),this.copyUniformsAccum.opacity.value=f,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===p&&(e.setClearColor(0,0),e.clear()),this.fsQuadAccum.render(e),this.iterativeFrame=p,this.iterative&&4<performance.now()-r)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(l,c,u,d,l,c),e.autoClear=o,e.setClearColor(this.oldClearColor,this.oldClearAlpha)}isLastIterativeFrame(){console.error("isLastIterativeFrame() deprectated, use pass event listener instead")}setCamera(e){this.camera=e}}U1.JitterVectors=[[[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 G1 extends _1{constructor(e,t,n){super(),this.enabled=!0,this.needsSwap=!1,this.objects=(n=n||{}).objects||[],this.steps=xt(n.steps)||10,this.stride=xt(n.stride)||30,this.binarySearchSteps=xt(n.binarySearchSteps)||4,this.renderTargetScale=xt(n.renderTargetScale)||.5,this.thickness=xt(n.thickness)||.01,this.maxDistance=xt(n.maxDistance)||100,this.jitter=xt(n.jitter)||1,this.useRefract=xt(n.useRefract)||!1,this.renderAfter=xt(n.renderAfter)||[],this.simpleRefraction=xt(n.simpleRefraction)||!1,this.scene=e,this.camera=t,this._prevClearColor=new _t,this._depthBuffer=new ze(256,256,{minFilter:dt,magFilter:dt,format:pt,type:je}),this._depthBuffer.texture.name="SSRPass.Depth",this._depthBuffer.texture.generateMipmaps=!1,this._depthMaterial=new gs,this._depthMaterial.depthPacking=3202,this._backfaceDepthBuffer=this._depthBuffer.clone(),this._backfaceDepthBuffer.texture.name="SSRPass.Depth",this._backfaceDepthMaterial=new gs,this._backfaceDepthMaterial.depthPacking=3202,this._backfaceDepthMaterial.side=Fe,this.basic=new fi,this.fsQuad=new b1(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(var e=0;e<this.objects.length;e++){var t=(n=this.objects[e]).material;t&&(this._setLayer(n,0),delete t.defines.USE_SSR,delete t.defines.USE_SSR_REFRACT,t.needsUpdate=!0)}this.objects.splice(0);for(e=0;e<this.renderAfter.length;e++){var n=this.renderAfter[e];this._setLayer(n,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,r,i){var a=this,o=(e.getClearColor(this._prevClearColor),e.getClearAlpha()),s=e.autoClear,l=(e.autoClear=!0,e.setClearColor(new _t(0,0,0),0),this.scene.background),c=(this.scene.background=null,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=Ue),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.v3d.oldLayersMask=e.layers.mask,e.layers.enable(a.useRefract?5:3),a.renderAfter.length&&e.layers.enable(a.useRefract?6:4))});for(var h=0;h<this.objects.length;h++){var p=(f=this.objects[h]).material;p&&p.isMeshNodeMaterial&&(this._setLayer(f,this.useRefract?5:3),p.defines.USE_SSR="",this.useRefract&&(p.defines.USE_SSR_REFRACT="",this.simpleRefraction&&(p.defines.SSR_SIMPLE_REFRACT="")),p.ssrParams={invProjectionMatrix:(new gt).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},p.needsUpdate=!0,p.defines.MAX_STEPS!==this.steps&&(p.defines.MAX_STEPS=Math.floor(this.steps),p.needsUpdate=!0),p.defines.BINARY_SEARCH_ITERATIONS!==this.binarySearchSteps&&(p.defines.BINARY_SEARCH_ITERATIONS=Math.floor(this.binarySearchSteps),p.needsUpdate=!0))}for(h=0;h<this.renderAfter.length;h++){var f=this.renderAfter[h];this._setLayer(f,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.v3d&&(e.layers.mask=e.userData.v3d.oldLayersMask,delete e.userData.v3d.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,o),e.autoClear=s}}class k1 extends S1{constructor(){super(E.tonemap),this.material.type="ToneMap"}}const W1={Bloom:A1,Bokeh:w1,"Brightness/Contrast":T1,FXAA:C1,Grayscale:E1,Mask:L1,Outline:z1,Render:V1,SSAA:U1,SSR:G1,ToneMapping:k1,"Copy/Other":S1},H1={getPageParams:function(e){let t=(e=e||window).location.href.toString();const n={};if(-1==t.indexOf("?"))return n;const r=t.split("#")[0].split("?")[1].split("&");for(let e=0;e<r.length;e++){var i=r[e].split("="),a=decodeURIComponent(i[0]);1==i.length?n[a]="":n[a]=decodeURIComponent(i[1])}return n},updatePageParam:function(e,t,n){let r=null,i="",a=e.split("?"),o=a[0],s=a[1],l="",c,u;if(s){c=s.split("#"),u=c[0],(r=c[1])&&(s=u),a=s.split("&");for(let e=0;e<a.length;e++)a[e].split("=")[0]!=t&&(i+=l+a[e],l="&")}else c=o.split("#"),u=c[0],r=c[1],u&&(o=u);r&&(n+="#"+r);e=l+""+t+"="+n;return o+"?"+i+e},loadScript:function(e,t,n,r){function i(e){o.removeEventListener("load",i,!1),o.removeEventListener("error",a,!1),t.removeChild(o),n(e)}function a(e){o.removeEventListener("load",i,!1),o.removeEventListener("error",a,!1),t.removeChild(o),r(e)}const o=document.createElement("script");o.addEventListener("load",i,!1),o.addEventListener("error",a,!1),t.appendChild(o),o.src=e},drawWatermark:function(e){const t=e.container;if(3483952072==Nn(xn)){var n=["color: #fff;","opacity: 0;","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");const r=document.createElement("div");r.innerHTML=`<a href="" target="_blank" style="${n}">MADE WITH VERGE3D TRIAL</a>`,t.appendChild(r),setTimeout(function(){t.contains(r)&&890310108==Nn(r.textContent)||e.dispose()},1e3)}},isXML:function(e){return null!==e.match(/.*\.xml$/)},isJS:function(e){return null!==e.match(/.*\.js$/)},createLineObjectHTML:function(d,h,p,e,t,f){console.warn("v3d.AppUtils.createLineObjectHTML has been deprecated. Use v3d.LineHTML instead."),e=e||2,t=t?t.convertSRGBToLinear():new _t(1,0,.2),f=f||5;const m=new vt(1,0,0),n=new P1;n.setGeometry([0,0,0,m.x,m.y,m.z]);t=new B1({color:t,lineWidth:e,sizeAttenuation:0});const v=new ee(n.geometry,t),g=(v.name=h.name+"_LINE",h.add(v),new vt),_=new vt,x=new de;d.renderCallbacks.push(function(){d.camera.updateMatrixWorld(),h.traverseAncestors(function(e){e.updateMatrixWorld()});var e=p.getBoundingClientRect(),t=(e.left+e.right)/2,n=(e.top+e.bottom)/2;const r=h.getWorldPosition(g);r.project(d.camera);var i=(r.x+1)/2*d.getWidth(),a=(1-r.y)/2*d.getHeight(),o=(n-a)/(t-i),s=(e.height+2*f)/(e.width+2*f);let l,c;Math.abs(o)>s?(c=n<a?Math.min(e.bottom+f,a):Math.max(e.top-f,a),l=(c-a)/o+i):(l=i<t?Math.max(e.left-f,i):Math.min(e.right+f,i),c=(l-i)*o+a),s=2*l/d.getWidth()-1,n=1-2*c/d.getHeight();const u=_.set(s,n,0);u.unproject(d.camera),h.worldToLocal(u),t=u.length(),v.scale.set(t,t,t),u.normalize(),e=x.setFromUnitVectors(m,u),v.setRotationFromQuaternion(e)})},addToAppList:function(e){const t=Pi();t.v3d&&(t.v3d.apps=t.v3d.apps||[],-1==t.v3d.apps.indexOf(e)&&t.v3d.apps.push(e))},removeFromAppList:function(e){const t=Pi();t.v3d&&t.v3d.apps&&(-1<(e=t.v3d.apps.indexOf(e))&&t.v3d.apps.splice(e,1))},printPerformanceInfo:function(x,y){y=y||1;const b=x.renderer.info,M=b.autoReset,A=(b.autoReset=!1,b.reset(),x.frame);for(let e=0;e<b.programs.length;e++)b.programs[e].profile.calcRenderTime=!0;function w(e,t){t?console.log("%c"+e,"color:red"):console.log(e)}setTimeout(function(){if(w("--- Verge3D Performance Profile ("+y+"s) ---"),x.scene){var c=x.frame-A,u=Math.round(x._loadingTime),u=(w(`Scene Loading Time: ${u}ms`,1e4<u),-1!=x._loadSceneURL.indexOf(".xz",x._loadSceneURL.length-3)),u=(w("Asset Compression: "+(u?"yes":"no"),0==u),c/y),u=(w("FPS: "+u,u<30),b.render.calls/c),u=(w("Render Calls: "+u,1e3<u),b.render.triangles/c),u=(w("Triangles Rendered: "+u,1e6<u),w("Geometry Buffers: "+b.memory.geometries,200<b.memory.geometries),w("HDR Rendering: "+(x.useHDR?"yes":"no")),x.renderer.getDrawingBufferSize(new Be));w("Viewport Resolution: "+u.x+"x"+u.y),w(`Pixel Ratio: ${x.renderer.getPixelRatio()} (current) / ${window.devicePixelRatio} (device)`);let e="N/A";switch(x._envIBLMode){case 0:e="PMREM";break;case 1:e="Light Probe + Cubemap";break;case 2:e="Light Probe"}w(`Image-Based Lighting: ${e} ${x._pmremMaxTileSize}px`);let t=0,n=0,r=0,i=0,a=0,o=0;x.scene.traverse(function(e){e.isLight&&(t++,e.castShadow&&e.shadow&&(i++,a=e.shadow.mapSize.width,o=e.shadow.mapSize.height)),e.isCubeReflectionProbe&&n++,e.isPlaneReflectionProbe&&r++}),w("Lights: "+t,10<t),w(`Reflection Probes: ${n} (cube) / ${r} (plane) `,3<n||1<r);const p=[];if(x.postprocessing){const v=x.postprocessing.composer.passes;v.forEach(function(e){for(var t in W1)if(e instanceof W1[t])return void p.push(t);p.push("Undefined")})}w("Post-Processing: "+(p.length?p.join(","):"N/A"));let s="N/A";if(i&&x.renderer.shadowMap&&x.renderer.shadowMap.enabled){switch(x.renderer.shadowMap.type){case te:s="Basic";break;case le:s="Bilinear";break;case ne:s="PCF";break;case ie:s="PCF (Bilinear)";break;case se:s="PCF (Poisson Disk)";break;case oe:s="ESM";break;case ae:s="VSM";break;default:s="Unknown"}s+=` ${i}x${a}x`+o}w("Shadow Map: "+s,4<i||2048<a||2048<o);const f=b.programs.slice(0);w("Materials and Shaders: "+f.length,100<f),f.sort(function(e,t){return t.profile.renderTime-e.profile.renderTime});let l=0;for(let e=0;e<f.length;e++){const g=f[e],_=(g.profile.calcRenderTime=!1,g.profile.materials);var d=g.profile.renderTime/c;w(" "+(0==_.length?"System Material":_.join(","))+" - "+g.name+" - "+String(Math.round(10*d)/10)+"ms",16<d),l+=d,g.profile.renderTime=0}w("Total Render Time: "+String(Math.round(10*l)/10)+"ms",16<l),w("Textures & Render Buffers: "+b.memory.textures,100<b.memory.textures);const m=Array.from(b.memory.textureSpecs.values());m.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<m.length;e++){var h=m[e];w(` ${h.name||"N/A"} - ${h.type} - ${h.width}x`+h.height,4096<=h.width||4096<=h.height)}b.autoReset=M}else w("Scene not loaded")},1e3*y)}},X1={prepareRenderer:function(e){var t=ma.getGPUVendor(e);const n=ma.getGPUModel(e);var r=ma.checkAndroid();r&&"ARM"===t&&"Mali-T760"===n&&(e.compatSettings.saturateSpecEnvBlenderApprox=!0),-1<n.toLowerCase().indexOf("intel")&&(e.compatSettings.simplifiedSRGB=!0),e.compatSettings.gtaoDisableBkgFix=r}};class j1{constructor(e,t){var n=(this.sourceTexture=e).image.width,r=e.image.height,t={format:pt,magFilter:ht,minFilter:1008,type:t,generateMipmaps:!0,anisotropy:e.anisotropy,encoding:an,wrapS:e.wrapS,wrapT:e.wrapT};this.renderTarget=new ze(n,r,t),this.renderTarget.texture.name=e.name,this.renderTarget.texture.flipY=e.flipY,this.camera=new Rs(-1,1,1,-1,0,1),this.shader=new T({type:"RGBEToFloat",uniforms:ca.clone(E.copy.uniforms),vertexShader:E.copy.vertexShader,fragmentShader:E.copy.fragmentShader,defines:{MAP_TEXELS:1}}),this.planeMesh=new ee(new Sa(2,2),this.shader),this.planeMesh.material.map=e,this.scene=new Js,this.scene.add(this.planeMesh),this.scene.add(this.camera),this.shader.uniforms.tDiffuse.value=e,this.shader.uniforms.opacity.value=1}update(e){var t=e.toneMapping,n=e.toneMappingExposure,r=e.getRenderTarget();e.toneMapping=1,e.toneMappingExposure=1,e.setRenderTarget(this.renderTarget),e.render(this.scene,this.camera),e.setRenderTarget(r),e.toneMapping=t,e.toneMappingExposure=n}dispose(){this.renderTarget.dispose(),this.planeMesh.geometry.dispose(),this.planeMesh.material.dispose()}}const Y1={_useHalfFloatCubemaps(e){return!!ma.checkHalfFloatTex(e,!0)&&(!/Firefox/.test(navigator.userAgent)||!/Android/.test(navigator.userAgent))},renderSceneToCubemap(e,t,n,{camPos:r=new vt,clipStart:i=.1,clipEnd:a=100}={}){var o=this._useHalfFloatCubemaps(t);o||(console.warn("v3d.RenderUtils: disabling half float cubemaps"),n.texture.type=Mt);const s=new ha(i,a,n);s.position.copy(r);let l=e.worldMaterial;if(null!==l&&l.isMeshNodeMaterial){if(o)for(var c in l.nodeTextures){var u=l.nodeTextures[c];if(u.encoding===sn){const h=new j1(u,je);h.update(t),l.nodeTextures[c]=h.renderTarget.texture,l.updateNodeGraph()}}const d=new ee(new oa(1,1,1),l);d.material.side=Fe,d.material.defines.WORLD_NODES=1,new ha(.1,10,n).update(t,d),d.geometry.disposeBoundsTree&&d.geometry.disposeBoundsTree(),d.geometry.dispose();i=e.background,a=(e.background=null,t.autoClearColor);t.autoClearColor=!1,s.update(t,e),t.autoClearColor=a,e.background=i}else s.update(t,e);return s.renderTarget},renderWorldNodeMatToCubemap(e,t,n,r){t.isMeshNodeMaterial||console.error("v3d.RenderUtils.renderWorldNodeMatToCubemap(): material is not an instance of MeshNodeMaterial.");const i=new Js;return i.worldMaterial=t,this.renderSceneToCubemap(i,e,new fa(n,r))},assignAllLayersMask:function(e){var 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}},Z1=new g,q1=new fr,Q1=new gt,K1=new vt,J1=new vt;class $1 extends he{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 fa(e,{encoding:on,format:pt,generateMipmaps:!0,minFilter:He,type:je}),this._exposureRenderTargetCube=this._renderTargetCube.clone(),this.renderTarget=null,this.matrixWorldInverse=new gt}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,r=n.boundsTree,i=Q1;try{i.copy(e.matrixWorld).invert()}catch(e){return!1}switch(i.multiply(this.matrixWorld),this.influenceType){case 0:t=!0;break;case 1:q1.center.setScalar(0),q1.radius=this.influenceDistance,q1.applyMatrix4(i),t=r?r.intersectsSphere(e,q1):(null===n.boundingBox&&n.computeBoundingBox(),n.boundingBox.intersectsSphere(q1));break;case 2:var a=K1.setScalar(0),o=J1.setScalar(2*this.influenceDistance);Z1.setFromCenterAndSize(a,o),t=r?r.intersectsBox(e,Z1,i):(Z1.applyMatrix4(i),null===n.boundingBox&&n.computeBoundingBox(),n.boundingBox.intersectsBox(Z1))}return t}update(e,t){const n={},r=(e.traverse(e=>{!e.isCubeReflectionProbe&&this._isVisible(e)||(n[e.id]=e.layers.mask,e.layers.disableAll())}),e.worldMaterial);var i=null!==r&&r.isMeshNodeMaterial&&r.needsLightPathDir();let a;i&&(a=r.defines.LIGHT_PATH_IS_CAM_RAY,r.defines.LIGHT_PATH_IS_CAM_RAY=0),Y1.renderSceneToCubemap(e,t,this._renderTargetCube,{camPos:this.position,clipStart:this.probeClipStart,clipEnd:this.probeClipEnd}),this._exposureRenderTargetCube.texture.type=this._renderTargetCube.texture.type;const o=new v1(this._renderTargetCube.texture);o.render(t,this._exposureRenderTargetCube,this.probeIntensity),o.dispose(),this.renderTarget=this.onUpdate(this._exposureRenderTargetCube),i&&(r.defines.LIGHT_PATH_IS_CAM_RAY=a),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){return null===this.visibilityGroup||(!e.isMesh||-1!==e.groupNames.indexOf(this.visibilityGroup)^this.visibilityGroupInv)}}$1.prototype.isCubeReflectionProbe=!0;class ev{constructor(e,t){var n;this.renderer=e,void 0===t&&(n={minFilter:ht,magFilter:ht,format:pt,stencilBuffer:!0},e=e.getDrawingBufferSize(),(t=new ze(e.width,e.height,n)).texture.name="EffectComposer.rt1",t.texture.encoding=on),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 S1(E.copy),this._previousFrameTime=Date.now(),this._pixelRatio=1}swapBuffers(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e);var t=this.renderer.getDrawingBufferSize(new Be);e.setSize(t.width,t.height)}insertPass(e,t){this.passes.splice(t,0,e)}isLastEnabledPass(e){for(var t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){void 0===e&&(e=.001*(Date.now()-this._previousFrameTime)),this._previousFrameTime=Date.now();for(var t,n,r=this.renderer.getRenderTarget(),i=!1,a=this.passes.length,o=0;o<a;o++)!1!==(n=this.passes[o]).enabled&&(n.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(o),n.render(this.renderer,this.writeBuffer,this.readBuffer,e,i),n.needsSwap&&(i&&((t=this.renderer.context).stencilFunc(t.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),t.stencilFunc(t.EQUAL,1,4294967295)),this.swapBuffers()),n instanceof L1?i=!0:n instanceof R1&&(i=!1));this.renderer.setRenderTarget(r)}reset(e){var t;void 0===e&&(t=this.renderer.getDrawingBufferSize(new Be),(e=this.renderTarget1.clone()).setSize(t.width,t.height)),this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){e*=this._pixelRatio,t*=this._pixelRatio,this.renderTarget1.setSize(e,t),this.renderTarget2.setSize(e,t);for(var n=0;n<this.passes.length;n++)this.passes[n].setSize(e,t)}setPixelRatio(e){this._pixelRatio=e}getPixelRatio(e){return this._pixelRatio}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}getActiveSSAAPass(){return this.passes[0]instanceof U1?this.passes[0]:null}insertPassAfter(e,t){for(var n=0,r=0;r<this.passes.length;r++)-1<t.indexOf(this.passes[r])&&(n=r+1);this.insertPass(e,n)}enableAllPasses(){for(var e=0;e<this.passes.length;e++)this.passes[e].enabled=!0}disableAllPasses(){for(var 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 tv,_=void 0!==_?_:{},nv={};for(tv in _)_.hasOwnProperty(tv)&&(nv[tv]=_[tv]);var rv,iv,av,ov,sv=!1,lv=!1,cv=!1,sv="object"==typeof window,lv="function"==typeof importScripts,cv="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node&&!sv&&!lv,Dh=!sv&&!cv&&!lv,Ih="";cv?(Ih=__dirname+"/",rv=function(e,t){var n=zv(e);return n?t?n:n.toString():(av=av||require("fs"),e=(ov=ov||require("path")).normalize(e),av.readFileSync(e,t?null:"utf8"))},iv=function(e){e=rv(e,!0);return vv((e=e.buffer?e:new Uint8Array(e)).buffer),e},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),"undefined"!=typeof module&&(module.exports=_),process.on("uncaughtException",function(e){if(!(e instanceof function(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}))throw e}),process.on("unhandledRejection",Pv),_.inspect=function(){return"[Emscripten Module object]"}):Dh?("undefined"!=typeof read&&(rv=function(e){var t=zv(e);return t?Fv(t):read(e)}),iv=function(e){var t=zv(e);return t||("function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(vv("object"==typeof(t=read(e,"binary"))),t))},"undefined"!=typeof print&&((console="undefined"==typeof console?{}:console).log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print)):(sv||lv)&&(lv?Ih=self.location.href:document.currentScript&&(Ih=document.currentScript.src),Ih=0!==Ih.indexOf("blob:")?Ih.substr(0,Ih.lastIndexOf("/")+1):"",rv=function(t){try{var n=new XMLHttpRequest;return n.open("GET",t,!1),n.send(null),n.responseText}catch(e){n=zv(t);if(n)return Fv(n);throw e}},lv&&(iv=function(t){try{var n=new XMLHttpRequest;return n.open("GET",t,!1),n.responseType="arraybuffer",n.send(null),new Uint8Array(n.response)}catch(e){n=zv(t);if(n)return n;throw e}}));var uv=_.print||console.log.bind(console),dv=_.printErr||console.warn.bind(console);for(tv in nv)nv.hasOwnProperty(tv)&&(_[tv]=nv[tv]);nv=null,_.arguments&&_.arguments,_.thisProgram&&_.thisProgram,_.wasmBinary&&(fv=_.wasmBinary);var hv,pv={Memory:function(e){return{buffer:new ArrayBuffer(65536*e.initial),grow:function(e){return jv(e)}}},Table:function(e){var n=new Array(e.initial);return n.grow=function(e){1<=n.length&&Pv("Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH."),n.push(null)},n.set=function(e,t){n[e]=t},n.get=function(e){return n[e]},n},Module:function(e){return{}},Instance:function(e,t){var n,r,i,a,y,g,b,M,_,A,x,o,s,l,h,w,c,u="function"==typeof u?u:function(e){var t,n,r,i,a,o,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",c=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");r=s.indexOf(e.charAt(c++)),t=(15&(i=s.indexOf(e.charAt(c++))))<<4|(a=s.indexOf(e.charAt(c++)))>>2,n=(3&a)<<6|(o=s.indexOf(e.charAt(c++))),l+=String.fromCharCode(r<<2|i>>4),64!==a&&(l+=String.fromCharCode(t)),64!==o&&(l+=String.fromCharCode(n)),c<e.length;);return l};function S(e,t,n){var r,i=0;if(8192<=n>>>0)s(0|e,0|t,0|n);else{if(r=e+n|0,3&(e^t)){if(r>>>0<4)n=e;else if((i=r-4|0)>>>0<e>>>0)n=e;else for(n=e;;)if(y[0|n]=M[0|t],y[n+1|0]=M[t+1|0],y[n+2|0]=M[t+2|0],y[n+3|0]=M[t+3|0],t=t+4|0,!((n=n+4|0)>>>0<=i>>>0))break}else{e:if((0|n)<1)n=e;else if(3&e)for(n=e;;){if(y[0|n]=M[0|t],t=t+1|0,r>>>0<=(n=n+1|0)>>>0)break e;if(!(3&n))break}else n=e;if(!((e=-4&r)>>>0<64||(i=e+-64|0)>>>0<n>>>0))for(;;)if(b[n>>2]=b[t>>2],b[n+4>>2]=b[t+4>>2],b[n+8>>2]=b[t+8>>2],b[n+12>>2]=b[t+12>>2],b[n+16>>2]=b[t+16>>2],b[n+20>>2]=b[t+20>>2],b[n+24>>2]=b[t+24>>2],b[n+28>>2]=b[t+28>>2],b[n+32>>2]=b[t+32>>2],b[n+36>>2]=b[t+36>>2],b[n+40>>2]=b[t+40>>2],b[n+44>>2]=b[t+44>>2],b[n+48>>2]=b[t+48>>2],b[n+52>>2]=b[t+52>>2],b[n+56>>2]=b[t+56>>2],b[n+60>>2]=b[t+60>>2],t=t- -64|0,!((n=n- -64|0)>>>0<=i>>>0))break;if(!(e>>>0<=n>>>0))for(;;)if(b[n>>2]=b[t>>2],t=t+4|0,!((n=n+4|0)>>>0<e>>>0))break}if(n>>>0<r>>>0)for(;;)if(y[0|n]=M[0|t],t=t+1|0,(0|r)==(0|(n=n+1|0)))break}}function T(e,t,n){if(n^=-1,t)for(;;)if(n=b[1056+((M[0|e]^255&n)<<2)>>2]^n>>>8,e=e+1|0,!(t=t+-1|0))break;return-1^n}function p(e){var t;e&&(t=b[e+1200>>2],b[t+60>>2]&&C(b[t+24>>2]),C(t),C(e))}function f(e){var t;return!((0|(e=(t=b[263312])+(e+3&-4)|0))<=-1)&&(e>>>0<=(a.byteLength/65536|0)<<16>>>0||l(0|e))?(b[263312]=e,t):(b[263185]=48,-1)}function C(e){var t,n=0,r=0,i=0,a=0,o=0,s=0;e:if(e){t=(i=e+-8|0)+(e=-8&(r=b[e+-4>>2]))|0;t:if(!(1&r)){if(!(3&r))break e;if((i=i-(r=b[i>>2])|0)>>>0<A[263190])break e;if(e=e+r|0,b[263191]!=(0|i))if(r>>>0<=255)a=b[i+8>>2],r=r>>>3|0,(0|(n=b[i+12>>2]))==(0|a)?b[263186]=b[263186]&N(r):(b[a+12>>2]=n,b[n+8>>2]=a);else{if(s=b[i+24>>2],(0|i)!=(0|(r=b[i+12>>2])))n=b[i+8>>2],b[n+12>>2]=r,b[r+8>>2]=n;else if((n=b[(a=i+20|0)>>2])||(n=b[(a=i+16|0)>>2])){for(;;)if(o=a,!((n=b[(a=(r=n)+20|0)>>2])||(a=r+16|0,n=b[r+16>>2])))break;b[o>>2]=0}else r=0;if(s){a=b[i+28>>2];n:{if(b[(n=1053048+(a<<2)|0)>>2]==(0|i)){if(b[n>>2]=r)break n;b[263187]=b[263187]&N(a);break t}if(!(b[s+(b[s+16>>2]==(0|i)?16:20)>>2]=r))break t}b[r+24>>2]=s,(n=b[i+16>>2])&&(b[r+16>>2]=n,b[n+24>>2]=r),(n=b[i+20>>2])&&(b[r+20>>2]=n,b[n+24>>2]=r)}}else if(3==(3&(r=b[4+t>>2])))return b[263188]=e,b[4+t>>2]=-2&r,b[i+4>>2]=1|e,void(b[e+i>>2]=e)}if(!(t>>>0<=i>>>0)&&1&(r=b[4+t>>2])){t:{if(!(2&r)){if(b[263192]==(0|t)){if(b[263192]=i,e=b[263189]+e|0,b[263189]=e,b[i+4>>2]=1|e,b[263191]!=(0|i))break e;return b[263188]=0,void(b[263191]=0)}if(b[263191]==(0|t))return b[263191]=i,e=b[263188]+e|0,b[263188]=e,b[i+4>>2]=1|e,void(b[e+i>>2]=e);e=(-8&r)+e|0;n:if(r>>>0<=255)r=r>>>3|0,(0|(n=b[8+t>>2]))==(0|(a=b[12+t>>2]))?b[263186]=b[263186]&N(r):(b[n+12>>2]=a,b[a+8>>2]=n);else{if(s=b[24+t>>2],(0|t)!=(0|(r=b[12+t>>2])))n=b[8+t>>2],b[n+12>>2]=r,b[r+8>>2]=n;else if((n=b[(a=20+t|0)>>2])||(n=b[(a=16+t|0)>>2])){for(;;)if(o=a,!((n=b[(a=(r=n)+20|0)>>2])||(a=r+16|0,n=b[r+16>>2])))break;b[o>>2]=0}else r=0;if(s){a=b[28+t>>2];r:{if(b[(n=1053048+(a<<2)|0)>>2]==(0|t)){if(b[n>>2]=r)break r;b[263187]=b[263187]&N(a);break n}if(!(b[s+(b[s+16>>2]==(0|t)?16:20)>>2]=r))break n}b[r+24>>2]=s,(n=b[16+t>>2])&&(b[r+16>>2]=n,b[n+24>>2]=r),(n=b[20+t>>2])&&(b[r+20>>2]=n,b[n+24>>2]=r)}}if(b[i+4>>2]=1|e,b[e+i>>2]=e,b[263191]!=(0|i))break t;return void(b[263188]=e)}b[4+t>>2]=-2&r,b[i+4>>2]=1|e,b[e+i>>2]=e}if(e>>>0<=255)return r=1052784+((e=e>>>3|0)<<3)|0,e=(n=b[263186])&(e=1<<e)?b[r+8>>2]:(b[263186]=e|n,r),b[r+8>>2]=i,b[e+12>>2]=i,b[i+12>>2]=r,void(b[i+8>>2]=e);b[i+16>>2]=0,(a=e>>>8|(n=b[i+20>>2]=0))&&(n=31,16777215<e>>>0||(n=a,n=28+((n=((n=(n<<=a=a+1048320>>>16&8)<<(s=n+520192>>>16&4))<<(o=n+245760>>>16&2)>>>15|0)-(o|a|s)|0)<<1|e>>>n+21&1)|0)),o=1053048+((b[(r=i)+28>>2]=n)<<2)|0;t:{n:{if((a=b[263187])&(r=1<<n)){for(a=e<<(31==(0|n)?0:25-(n>>>1|0)|0),r=b[o>>2];;){if((-8&b[(n=r)+4>>2])==(0|e))break n;if(r=a>>>29|0,a<<=1,!(r=b[(o=n+(4&r)|0)+16>>2]))break}b[o+16>>2]=i,b[i+24>>2]=n}else b[263187]=r|a,b[o>>2]=i,b[i+24>>2]=o;b[i+12>>2]=i,b[i+8>>2]=i;break t}e=b[n+8>>2],b[e+12>>2]=i,b[n+8>>2]=i,b[i+24>>2]=0,b[i+12>>2]=n,b[i+8>>2]=e}if(e=b[263194]+-1|0,!(b[263194]=e)){for(i=1053200;;)if(i=(e=b[i>>2])+8|0,!e)break;b[263194]=-1}}}}function E(e,t){var n;if(t&&(y[(n=e+t|0)-1|0]=0,!(t>>>(y[0|e]=0)<3||(y[n-2|0]=0,y[e+1|0]=0,y[n-3|0]=0,t>>>(y[e+2|0]=0)<7||(y[n-4|0]=0,t>>>(y[e+3|0]=0)<9||(b[(e=(n=0-e&3)+e|0)>>2]=0,(n=t-n&-4)>>>(b[(t=n+e|0)+-4>>2]=0)<9||(b[e+8>>2]=0,b[e+4>>2]=0,b[t+-8>>2]=0,n>>>(b[t+-12>>2]=0)<25||(b[e+24>>2]=0,b[e+20>>2]=0,b[e+16>>2]=0,b[e+12>>2]=0,b[t+-16>>2]=0,b[t+-20>>2]=0,b[t+-24>>2]=0,b[t+-28>>2]=0,(t=(t=n)-(n=4&e|24)|0)>>>0<32))))))))for(e=e+n|0;;)if(b[e+24>>2]=0,b[e+28>>2]=0,b[e+16>>2]=0,b[e+20>>2]=0,b[e+8>>2]=0,b[e+12>>2]=0,b[e>>2]=0,e=e+32|(b[e+4>>2]=0),!(31<(t=t+-32|0)>>>0))break}function L(e){var t,n=0,r=0,i=0,a=0,o=0,s=0,l=0,c=0,u=0,d=0;h=t=h-16|0;e:{t:{n:{r:{i:{a:{o:{s:{l:{c:{u:{if(e>>>0<=244){if(3&(n=(o=b[263186])>>>(e=(s=e>>>0<11?16:e+11&-8)>>>3|0)|0)){e=(n=b[(a=(r=e+(1&(-1^n))|0)<<3)+1052792>>2])+8|0,(0|(i=b[n+8>>2]))==(0|(a=a+1052784|0))?b[263186]=N(r)&o:(b[i+12>>2]=a,b[a+8>>2]=i),b[n+4>>2]=3|(r<<=3),b[(n=n+r|0)+4>>2]=1|b[n+4>>2];break e}if(s>>>0<=(c=b[263188])>>>0)break u;if(n){r=n=(e=(0-(e=(0-(r=2<<e)|r)&n<<e)&e)-1|0)>>>12&16,n=b[(i=(r=((r=(r|=n=(e=e>>>n|0)>>>5&8)|(n=(e=e>>>n|0)>>>2&4)|(n=(e=e>>>n|0)>>>1&2))|(n=(e=e>>>n|0)>>>1&1))+(e>>>n|0)|0)<<3)+1052792>>2],(0|(e=b[n+8>>2]))==(0|(i=i+1052784|0))?(o=N(r)&o,b[263186]=o):(b[e+12>>2]=i,b[i+8>>2]=e),e=n+8|0,b[n+4>>2]=3|s,b[(l=n+s|0)+4>>2]=1|(a=(r<<=3)-s|0),b[n+r>>2]=a,c&&(n=1052784+((r=c>>>3|0)<<3)|0,i=b[263191],r=(r=1<<r)&o?b[n+8>>2]:(b[263186]=r|o,n),b[n+8>>2]=i,b[r+12>>2]=i,b[i+12>>2]=n,b[i+8>>2]=r),b[263191]=l,b[263188]=a;break e}if(!(d=b[263187]))break u;for(r=n=(e=(d&0-d)-1|0)>>>12&16,n=b[1053048+(((r=(r|=n=(e=e>>>n|0)>>>5&8)|(n=(e=e>>>n|0)>>>2&4)|(n=(e=e>>>n|0)>>>1&2))|(n=(e=e>>>n|0)>>>1&1))+(e>>>n|0)<<2)>>2],i=(-8&b[n+4>>2])-s|0,r=n;;){if(!(e=b[r+16>>2])&&!(e=b[r+20>>2]))break;i=(r=(a=(-8&b[e+4>>2])-s|0)>>>0<i>>>0)?a:i,n=r?e:n,r=e}if(u=b[n+24>>2],(0|(a=b[n+12>>2]))!=(0|n)){e=b[n+8>>2],b[e+12>>2]=a,b[a+8>>2]=e;break t}if(!(e=b[(r=n+20|0)>>2])){if(!(e=b[n+16>>2]))break c;r=n+16|0}for(;;)if(l=r,!((e=b[(r=(a=e)+20|0)>>2])||(r=a+16|0,e=b[a+16>>2])))break;b[l>>2]=0;break t}if(s=-1,!(4294967231<e>>>0)&&(s=-8&(n=e+11|0),c=b[263187])){r=0-s|0,(n=n>>>8|(o=0))&&(o=31,16777215<s>>>0||(o=28+((e=((o=(n<<=i=n+1048320>>>16&8)<<(e=n+520192>>>16&4))<<(n=o+245760>>>16&2)>>>15|0)-(n|e|i)|0)<<1|s>>>e+21&1)|0));d:{h:{if(i=b[1053048+(o<<2)>>2])for(n=s<<(31==(0|o)?0:25-(o>>>1|0)|0),e=0;;){if(!(r>>>0<=(l=(-8&b[i+4>>2])-s|0)>>>0||(a=i,r=l))){r=0,e=i;break h}if(l=b[i+20>>2],i=b[16+((n>>>29&4)+i|0)>>2],e=!l||(0|l)==(0|i)?e:l,n<<=0!=(0|i),!i)break}else e=0;if(!(e|a)){if(!(e=(0-(e=2<<o)|e)&c))break u;i=n=(e=(e&0-e)-1|0)>>>12&16,e=b[1053048+(((i=(i|=n=(e=e>>>n|0)>>>5&8)|(n=(e=e>>>n|0)>>>2&4)|(n=(e=e>>>n|0)>>>1&2))|(n=(e=e>>>n|0)>>>1&1))+(e>>>n|0)<<2)>>2]}if(!e)break d}for(;;)if(r=(n=(i=(-8&b[e+4>>2])-s|0)>>>0<r>>>0)?i:r,a=n?e:a,!(e=(n=b[e+16>>2])||b[e+20>>2]))break}if(!(!a|r>>>0>=b[263188]-s>>>0)){if(l=b[a+24>>2],(0|a)!=(0|(n=b[a+12>>2]))){e=b[a+8>>2],b[e+12>>2]=n,b[n+8>>2]=e;break n}if(!(e=b[(i=a+20|0)>>2])){if(!(e=b[a+16>>2]))break l;i=a+16|0}for(;;)if(o=i,!((e=b[(i=(n=e)+20|0)>>2])||(i=n+16|0,e=b[n+16>>2])))break;b[o>>2]=0;break n}}}if(s>>>0<=(n=b[263188])>>>0){e=b[263191],16<=(r=n-s|0)>>>0?(b[263188]=r,b[263191]=i=e+s|0,b[i+4>>2]=1|r,b[e+n>>2]=r,b[e+4>>2]=3|s):(b[263191]=0,b[263188]=0,b[e+4>>2]=3|n,b[(n=e+n|0)+4>>2]=1|b[n+4>>2]),e=e+8|0;break e}if(s>>>0<(i=b[263189])>>>0){b[263189]=n=i-s|0,e=b[263192],b[263192]=r=e+s|0,b[r+4>>2]=1|n,b[e+4>>2]=3|s,e=e+8|0;break e}if((r=(o=(r=a=s+47|(e=0))+(n=b[263304]?b[263306]:(b[263307]=-1,b[263308]=-1,b[263305]=4096,b[263306]=4096,b[263304]=12+t&-16^1431655768,b[263309]=0,b[263297]=0,4096))|0)&(l=0-n|0))>>>0<=s>>>0)break e;if((n=b[263296])&&(u=(c=b[263294])+r|0)>>>0<=c>>>0|n>>>0<u>>>0)break e;if(4&M[1053188])break a;u:{d:{if(n=b[263192])for(e=1053192;;){if((c=b[e>>2])+b[e+4>>2]>>>0>n>>>0&&c>>>0<=n>>>0)break d;if(!(e=b[e+8>>2]))break}if(-1==(0|(n=f(0))))break o;if(o=r,(o=(i=(e=b[263305])+-1|0)&n?(r-n|0)+(n+i&0-e)|0:o)>>>0<=s>>>0|2147483646<o>>>0)break o;if((e=b[263296])&&(l=(i=b[263294])+o|0)>>>0<=i>>>0|e>>>0<l>>>0)break o;if((0|n)!=(0|(e=f(o))))break u;break i}if(2147483646<(o=l&o-i)>>>0)break o;if((0|(n=f(o)))==(b[e>>2]+b[e+4>>2]|0))break s;e=n}if(!(s+48>>>0<=o>>>0|2147483646<o>>>0|-1==(0|(n=e)))){if(2147483646<(e=(e=b[263306])+(a-o|0)&0-e)>>>0)break i;if(-1!=(0|f(e))){o=e+o|0;break i}f(0-o|0);break o}if(-1!=(0|n))break i;break o}a=0;break t}n=0;break n}if(-1!=(0|n))break i}b[263297]=4|b[263297]}if(2147483646<r>>>0)break r;if(n=f(r),(e=f(0))>>>0<=n>>>0|-1==(0|n)|-1==(0|e))break r;if((o=e-n|0)>>>0<=s+40>>>0)break r}e=b[263294]+o|0,(b[263294]=e)>>>0>A[263295]&&(b[263295]=e);i:{a:{o:{if(r=b[263192]){for(e=1053192;;){if(((i=b[e>>2])+(a=b[e+4>>2])|0)==(0|n))break o;if(!(e=b[e+8>>2]))break}break a}for((e=b[263190])>>>0<=n>>>0&&e||(b[263190]=n),e=0,b[263299]=o,b[263298]=n,b[263194]=-1,b[263195]=b[263304],b[263301]=0;;)if(b[(r=e<<3)+1052792>>2]=i=r+1052784|0,b[r+1052796>>2]=i,32==(0|(e=e+1|0)))break;b[263189]=i=(e=o+-40|0)-(r=n+8&7?-8-n&7:0)|0,b[263192]=r=n+r|0,b[r+4>>2]=1|i,b[4+(e+n|0)>>2]=40,b[263193]=b[263308];break i}if(!(8&M[e+12|0]|n>>>0<=r>>>0|r>>>0<i>>>0)){b[e+4>>2]=a+o,b[263192]=n=(e=r+8&7?-8-r&7:0)+r|0,i=b[263189]+o|0,b[263189]=e=i-e|0,b[n+4>>2]=1|e,b[4+(r+i|0)>>2]=40,b[263193]=b[263308];break i}}n>>>0<(a=b[263190])>>>0&&(b[263190]=n,a=0),i=n+o|0,e=1053192;a:{o:{s:{l:{c:{u:{for(;;){if((0|i)==b[e>>2])break;if(!(e=b[e+8>>2]))break u}if(!(8&M[e+12|0]))break c}for(e=1053192;;){if((i=b[e>>2])>>>0<=r>>>0&&r>>>0<(a=i+b[e+4>>2]|0)>>>0)break l;e=b[e+8>>2]}}if(b[e>>2]=n,b[e+4>>2]=b[e+4>>2]+o,b[(u=(n+8&7?-8-n&7:0)+n|0)+4>>2]=3|s,e=((n=i+(i+8&7?-8-i&7:0)|0)-u|0)-s|0,l=s+u|0,(0|n)==(0|r)){b[263192]=l,e=b[263189]+e|0,b[263189]=e,b[l+4>>2]=1|e;break o}if(b[263191]==(0|n)){b[263191]=l,e=b[263188]+e|0,b[263188]=e,b[l+4>>2]=1|e,b[e+l>>2]=e;break o}if(1==(3&(r=b[n+4>>2]))){d=-8&r;c:if(r>>>0<=255)a=r>>>3|0,r=b[n+8>>2],(0|(i=b[n+12>>2]))==(0|r)?b[263186]=b[263186]&N(a):(b[r+12>>2]=i,b[i+8>>2]=r);else{if(c=b[n+24>>2],(0|(o=b[n+12>>2]))!=(0|n))r=b[n+8>>2],b[r+12>>2]=o,b[o+8>>2]=r;else if((s=b[(i=n+20|0)>>2])||(s=b[(i=n+16|0)>>2])){for(;;)if(r=i,!((s=b[(i=(o=s)+20|0)>>2])||(i=o+16|0,s=b[o+16>>2])))break;b[r>>2]=0}else o=0;if(c){r=b[n+28>>2];u:{if(b[(i=1053048+(r<<2)|0)>>2]==(0|n)){if(b[i>>2]=o)break u;b[263187]=b[263187]&N(r);break c}if(!(b[c+(b[c+16>>2]==(0|n)?16:20)>>2]=o))break c}b[o+24>>2]=c,(r=b[n+16>>2])&&(b[o+16>>2]=r,b[r+24>>2]=o),(r=b[n+20>>2])&&(b[o+20>>2]=r,b[r+24>>2]=o)}}n=n+d|0,e=e+d|0}if(b[n+4>>2]=-2&b[n+4>>2],b[l+4>>2]=1|e,(b[e+l>>2]=e)>>>0<=255){e=1052784+((n=e>>>3|0)<<3)|0,n=(r=b[263186])&(n=1<<n)?b[e+8>>2]:(b[263186]=n|r,e),b[e+8>>2]=l,b[n+12>>2]=l,b[l+12>>2]=e,b[l+8>>2]=n;break o}if((i=e>>>8|(n=0))&&(n=31,16777215<e>>>0||(n=28+((n=((s=(i<<=a=i+1048320>>>16&8)<<(n=i+520192>>>16&4))<<(i=s+245760>>>16&2)>>>15|0)-(i|n|a)|0)<<1|e>>>n+21&1)|0)),b[(r=l)+28>>2]=n,b[l+16>>2]=0,r=1053048+(n<<2)|(b[l+20>>2]=0),(i=b[263187])&(a=1<<n)){for(i=e<<(31==(0|n)?0:25-(n>>>1|0)|0),n=b[r>>2];;){if((-8&b[(r=n)+4>>2])==(0|e))break s;if(n=i>>>29|0,i<<=1,!(n=b[(a=(4&n)+r|0)+16>>2]))break}b[a+16>>2]=l}else b[263187]=i|a,b[r>>2]=l;b[l+24>>2]=r,b[l+12>>2]=l,b[l+8>>2]=l;break o}for(b[263189]=l=(e=o+-40|0)-(i=n+8&7?-8-n&7:0)|0,b[263192]=i=n+i|0,b[i+4>>2]=1|l,b[4+(e+n|0)>>2]=40,b[263193]=b[263308],b[(i=(e=(a+(a+-39&7?39-a&7:0)|0)-47|0)>>>0<r+16>>>0?r:e)+4>>2]=27,e=b[263301],b[i+16>>2]=b[263300],b[i+20>>2]=e,e=b[263299],b[i+8>>2]=b[263298],b[i+12>>2]=e,b[263300]=i+8,b[263299]=o,b[263298]=n,e=i+24|(b[263301]=0);;)if(b[e+4>>2]=7,n=e+8|0,e=e+4|0,!(n>>>0<a>>>0))break;if((0|r)==(0|i))break i;if(b[i+4>>2]=-2&b[i+4>>2],b[r+4>>2]=1|(a=i-r|0),(b[i>>2]=a)>>>0<=255){e=1052784+((n=a>>>3|0)<<3)|0,n=(i=b[263186])&(n=1<<n)?b[e+8>>2]:(b[263186]=n|i,e),b[e+8>>2]=r,b[n+12>>2]=r,b[r+12>>2]=e,b[r+8>>2]=n;break i}if(b[r+16>>2]=0,(i=a>>>8|(e=b[r+20>>2]=0))&&(e=31,16777215<a>>>0||(e=28+((e=((l=(i<<=o=i+1048320>>>16&8)<<(e=i+520192>>>16&4))<<(i=l+245760>>>16&2)>>>15|0)-(i|e|o)|0)<<1|a>>>e+21&1)|0)),n=1053048+((b[(n=r)+28>>2]=e)<<2)|0,(i=b[263187])&(o=1<<e)){for(e=a<<(31==(0|e)?0:25-(e>>>1|0)|0),n=b[n>>2];;){if((0|a)==(-8&b[(i=n)+4>>2]))break a;if(n=e>>>29|0,e<<=1,!(n=b[(o=i+(4&n)|0)+16>>2]))break}b[o+16>>2]=r,b[r+24>>2]=i}else b[263187]=i|o,b[n>>2]=r,b[r+24>>2]=n;b[r+12>>2]=r,b[r+8>>2]=r;break i}e=b[r+8>>2],b[e+12>>2]=l,b[r+8>>2]=l,b[l+24>>2]=0,b[l+12>>2]=r,b[l+8>>2]=e}e=u+8|0;break e}e=b[i+8>>2],b[e+12>>2]=r,b[i+8>>2]=r,b[r+24>>2]=0,b[r+12>>2]=i,b[r+8>>2]=e}if(!((e=b[263189])>>>0<=s>>>0)){b[263189]=n=e-s|0,e=b[263192],b[263192]=r=e+s|0,b[r+4>>2]=1|n,b[e+4>>2]=3|s,e=e+8|0;break e}}b[263185]=48,e=0;break e}n:if(l){e=b[a+28>>2];r:{if(b[(i=1053048+(e<<2)|0)>>2]==(0|a)){if(b[i>>2]=n)break r;c=N(e)&c,b[263187]=c;break n}if(!(b[l+(b[l+16>>2]==(0|a)?16:20)>>2]=n))break n}b[n+24>>2]=l,(e=b[a+16>>2])&&(b[n+16>>2]=e,b[e+24>>2]=n),(e=b[a+20>>2])&&(b[n+20>>2]=e,b[e+24>>2]=n)}n:if(r>>>0<=15)b[a+4>>2]=3|(e=r+s|0),b[(e=e+a|0)+4>>2]=1|b[e+4>>2];else if(b[a+4>>2]=3|s,b[(i=a+s|0)+4>>2]=1|r,(b[r+i>>2]=r)>>>0<=255)e=1052784+((n=r>>>3|0)<<3)|0,n=(r=b[263186])&(n=1<<n)?b[e+8>>2]:(b[263186]=n|r,e),b[e+8>>2]=i,b[n+12>>2]=i,b[i+12>>2]=e,b[i+8>>2]=n;else{(s=r>>>8|(e=0))&&(e=31,16777215<r>>>0||(e=28+((e=((l=(s<<=o=s+1048320>>>16&8)<<(e=s+520192>>>16&4))<<(s=l+245760>>>16&2)>>>15|0)-(s|e|o)|0)<<1|r>>>e+21&1)|0)),b[(n=i)+28>>2]=e,b[i+16>>2]=0,n=1053048+(e<<2)|(b[i+20>>2]=0);r:{if((s=1<<e)&c){for(e=r<<(31==(0|e)?0:25-(e>>>1|0)|0),s=b[n>>2];;){if((-8&b[(n=s)+4>>2])==(0|r))break r;if(s=e>>>29|0,e<<=1,!(s=b[(o=(4&s)+n|0)+16>>2]))break}b[o+16>>2]=i}else b[263187]=s|c,b[n>>2]=i;b[i+24>>2]=n,b[i+12>>2]=i,b[i+8>>2]=i;break n}e=b[n+8>>2],b[e+12>>2]=i,b[n+8>>2]=i,b[i+24>>2]=0,b[i+12>>2]=n,b[i+8>>2]=e}e=a+8|0;break e}t:if(u){e=b[n+28>>2];n:{if(b[(r=1053048+(e<<2)|0)>>2]==(0|n)){if(b[r>>2]=a)break n;b[263187]=N(e)&d;break t}if(!(b[u+(b[u+16>>2]==(0|n)?16:20)>>2]=a))break t}b[a+24>>2]=u,(e=b[n+16>>2])&&(b[a+16>>2]=e,b[e+24>>2]=a),(e=b[n+20>>2])&&(b[a+20>>2]=e,b[e+24>>2]=a)}i>>>0<=15?(b[n+4>>2]=3|(e=i+s|0),b[(e=e+n|0)+4>>2]=1|b[e+4>>2]):(b[n+4>>2]=3|s,b[(s=n+s|0)+4>>2]=1|i,b[i+s>>2]=i,c&&(e=1052784+((r=c>>>3|0)<<3)|0,a=b[263191],r=(r=1<<r)&o?b[e+8>>2]:(b[263186]=r|o,e),b[e+8>>2]=a,b[r+12>>2]=a,b[a+12>>2]=e,b[a+8>>2]=r),b[263191]=s,b[263188]=i),e=n+8|0}return h=16+t|0,e}function m(e){var t,n,r,i=0,a=0,o=0,s=0,l=0,c=0,u=0,d=0,h=0,p=0,f=0,m=0,v=0,a=b[e+40>>2],h=b[e+32>>2];if(!(a>>>0<=h>>>0)&&(i=b[e+104>>2])&&(l=b[e+84>>2],!(A[e+36>>2]<=l>>>0|A[e+48>>2]<=l>>>0))){if(b[e+104>>2]=i-(c=(a=a-h|0)>>>0<i>>>0?a:i),i=(-1^l)+h|0,i=h>>>0<=l>>>0?b[e+44>>2]+i|0:i,l=b[e+24>>2],a=M[i+l|0],b[e+32>>2]=h+1,y[l+h|0]=a,o=c+-1|0)for(;;)if(i=(0|(a=i+1|0))==b[e+44>>2]?0:a,c=b[e+24>>2],l=M[i+c|0],a=b[e+32>>2],b[e+32>>2]=a+1,y[a+c|0]=l,!(o=o+-1|0))break;h=b[e+32>>2],A[e+36>>2]>=h>>>0||(b[e+36>>2]=h)}e:{t:if(!(h>>>0>=A[e+40>>2]))for(t=e+1756|0,n=e+2784|0,r=e+84|0;;){if((l=b[e+16>>2])>>>0>A[e+20>>2])break t;if(c=p=(((f=b[e+100>>2])<<5)+e|0)+((u=b[e+116>>2]&h)<<1)|0,16777216<=(s=b[e>>2])>>>0?o=b[e+4>>2]:(s<<=8,b[e>>2]=s,b[e+16>>2]=a=l+1|0,o=M[b[e+12>>2]+l|0]|b[e+4>>2]<<8,b[e+4>>2]=o,l=a),a=_[c+120>>1],o>>>0<(i=x(a,s>>>11|0))>>>0){b[e>>2]=i,g[c+120>>1]=a+(2048-a>>>5|0),s=h+-1|0,s=h?s:b[e+44>>2]+s|0,u=b[e+108>>2],p=0,m=(a=(b[e+112>>2]&h)<<u)+((p=(c=b[e+36>>2])?M[b[e+24>>2]+s|0]:p)>>>8-u|0)|0,s=1;n:{if(f>>>0<=6)for(;;)if(c=3812+((s<<=1)+(x(m,1536)+e|0)|0)|0,16777215<i>>>0?a=i:(b[e>>2]=a=i<<8,b[e+16>>2]=i=l+1|0,o=M[b[e+12>>2]+l|0]|o<<8,b[e+4>>2]=o,l=i),u=_[c>>1],(i=x(u,a>>>11|0))>>>0<=o>>>0?(b[e+4>>2]=o=o-i|0,b[e>>2]=i=a-i|0,g[c>>1]=u-(u>>>5|0),s|=1):(b[e>>2]=i,g[c>>1]=u+(2048-u>>>5|0)),!(s>>>0<256))break n;for(s=(-1^(a=b[e+84>>2]))+h|0,s=h>>>0<=a>>>0?b[e+44>>2]+s|0:s,c=c?M[b[e+24>>2]+s|0]:0,s=1,d=256;;)if(f=d&(c<<=1),u=3812+((x(m,1536)+e|0)+((f+d|0)+s<<1)|0)|0,16777215<i>>>0?p=i:(b[e>>2]=p=i<<8,b[e+16>>2]=a=l+1|0,o=M[b[e+12>>2]+l|0]|o<<8,b[e+4>>2]=o,l=a),u=_[(v=a=u)>>1],a=(i=x(u,p>>>11|0))>>>0<=o>>>0?(b[e+4>>2]=o=o-i|0,b[e>>2]=i=p-i|0,p=1,u-(u>>>5|(d=0))|0):(b[e>>2]=i,u+(2048-u>>>5|(p=0))|0),g[v>>1]=a,d^=f,!((s=s<<1|p)>>>0<256))break}(b[e+32>>2]=h+1,y[b[e+24>>2]+h|0]=s,h=b[e+32>>2],A[e+36>>2]<h>>>0&&(b[e+36>>2]=h),(a=b[e+100>>2])>>>0<=3)?b[e+100>>2]=0:b[e+100>>2]=a>>>0<=9?a+-3:a+-6}else{b[e+4>>2]=o=o-i|0,b[e>>2]=i=s-i|0,g[c+120>>1]=a-(a>>>5|0),c=m=(f<<1)+e|0,16777215<i>>>0?a=l:(i<<=8,b[e>>2]=i,b[e+16>>2]=a=l+1|0,o=M[b[e+12>>2]+l|0]|o<<8,b[e+4>>2]=o),f=_[c+504>>1];n:if((l=x(f,i>>>11|0))>>>0<=o>>>0){b[e+4>>2]=o=o-l|0,b[e>>2]=i=i-l|0,g[c+504>>1]=f-(f>>>5|0),16777215<i>>>0?c=a:(i<<=8,b[e>>2]=i,b[e+16>>2]=c=a+1|0,o=M[b[e+12>>2]+a|0]|o<<8,b[e+4>>2]=o),a=_[m+528>>1];r:{if(o>>>0<(s=x(a,i>>>11|0))>>>0){if(b[e>>2]=s,g[m+528>>1]=a+(2048-a>>>5|0),s>>>0<=16777215&&(s<<=8,b[e>>2]=s,b[e+16>>2]=c+1,o=M[b[e+12>>2]+c|0]|o<<8,b[e+4>>2]=o),i=_[p+600>>1],(a=x(i,s>>>11|0))>>>0<=o>>>0){b[e+4>>2]=o-a,b[e>>2]=s-a,g[p+600>>1]=i-(i>>>5|0);break r}b[e>>2]=a,g[p+600>>1]=i+(2048-i>>>5|0),b[e+104>>2]=1,b[e+100>>2]=A[e+100>>2]<7?9:11;break n}b[e+4>>2]=o=o-s|0,b[e>>2]=i=i-s|0,g[m+528>>1]=a-(a>>>5|0),16777215<i>>>0?a=c:(i<<=8,b[e>>2]=i,b[e+16>>2]=a=c+1|0,o=M[b[e+12>>2]+c|0]|o<<8,b[e+4>>2]=o),c=_[m+552>>1],o>>>0<(l=x(c,i>>>11|0))>>>0?(b[e>>2]=l,g[m+552>>1]=c+(2048-c>>>5|0),i=b[e+88>>2]):(b[e+4>>2]=o=o-l|0,b[e>>2]=i=i-l|0,g[m+552>>1]=c-(c>>>5|0),i>>>0<=16777215&&(i<<=8,b[e>>2]=i,b[e+16>>2]=a+1,o=M[b[e+12>>2]+a|0]|o<<8,b[e+4>>2]=o),l=_[m+576>>1],o>>>0<(a=x(l,i>>>11|0))>>>0?(b[e>>2]=a,g[m+576>>1]=l+(2048-l>>>5|0),i=b[e+92>>2]):(b[e+4>>2]=o-a,b[e>>2]=i-a,g[m+576>>1]=l-(l>>>5|0),i=b[e+96>>2],b[e+96>>2]=b[e+92>>2]),b[e+92>>2]=b[e+88>>2]),b[e+88>>2]=b[e+84>>2],b[e+84>>2]=i}b[e+100>>2]=A[e+100>>2]<7?8:11,P(e,n,u)}else{for(b[e>>2]=l,g[c+504>>1]=f+(2048-f>>>5|0),b[e+96>>2]=b[e+92>>2],a=b[e+88>>2],b[e+88>>2]=b[e+84>>2],b[e+92>>2]=a,b[e+100>>2]=A[e+100>>2]<7?7:10,P(e,t,u),l=(a=b[e+104>>2])>>>0<6?a+-2|0:3,i=b[e>>2],o=1;;)if(c=(o<<=1)+((l<<7)+e|0)|0,16777216<=i>>>0?s=b[e+4>>2]:(i<<=8,b[e>>2]=i,a=b[e+16>>2],b[e+16>>2]=a+1,s=M[a+b[e+12>>2]|0]|b[e+4>>2]<<8,b[e+4>>2]=s),u=_[c+984>>1],(a=x(u,i>>>11|0))>>>0<=s>>>0?(b[e+4>>2]=s=s-a|0,b[e>>2]=i=i-a|0,g[c+984>>1]=u-(u>>>5|0),o|=1):(b[e>>2]=a,g[c+984>>1]=u+(2048-u>>>5|0),i=a),!(o>>>0<64))break;if((l=o+-64|0)>>>0<=3)b[e+84>>2]=l;else if(b[e+84>>2]=d=1&l|2,a=l>>>1|0,l>>>0<=13){for(l=1538+((((b[e+84>>2]=p=d<<(c=a+-1|0))<<(d=1))+r|0)+(0-o<<1)|0)|0,o=0;;)if(u=l+(d<<=1)|0,16777215<i>>>0?a=i:(b[e>>2]=a=i<<8,i=b[e+16>>2],b[e+16>>2]=i+1,s=M[i+b[e+12>>2]|0]|s<<8,b[e+4>>2]=s),f=_[u>>1],s>>>0<(i=x(f,a>>>11|0))>>>0?(b[e>>2]=i,g[u>>1]=f+(2048-f>>>5|0)):(b[e+4>>2]=s=s-i|0,b[e>>2]=i=a-i|0,g[u>>1]=f-(f>>>5|0),b[e+84>>2]=p=(1<<o)+p|0,d|=1),!((o=o+1|0)>>>0<c>>>0))break}else{for(l=a+-5|0;;)if(16777215<i>>>0?o=i:(b[e>>2]=o=i<<8,a=b[e+16>>2],b[e+16>>2]=a+1,s=M[a+b[e+12>>2]|0]|s<<8,b[e+4>>2]=s),b[e>>2]=i=o>>>1|0,b[e+84>>2]=d=(a=(c=s-i|0)>>31)+(d<<1|1)|0,b[e+4>>2]=s=c+(i&a)|0,!(l=l+-1|0))break;d<<=4,b[e+84>>2]=d,o>>>0<=33554431&&(i<<=8,b[e>>2]=i,a=b[e+16>>2],b[e+16>>2]=a+1,s=M[a+b[e+12>>2]|0]|s<<8,b[e+4>>2]=s),l=_[(a=e)+1726>>1],c=1724+(a+(l=(i=s>>>0<(o=x(l,i>>>11|0))>>>0?(b[e>>2]=o,g[e+1726>>1]=l+(2048-l>>>5|0),2):(b[e+4>>2]=s=s-o|0,b[e>>2]=o=i-o|0,d|=1,b[e+84>>2]=d,g[e+1726>>1]=l-(l>>>5|0),3))<<1)|0)|0,o>>>0<=16777215&&(o<<=8,b[e>>2]=o,a=b[e+16>>2],b[e+16>>2]=a+1,s=M[a+b[e+12>>2]|0]|s<<8,b[e+4>>2]=s),a=_[c>>1],(i=x(a,o>>>11|0))>>>0<=s>>>0?(b[e+4>>2]=s=s-i|0,b[e>>2]=i=o-i|0,g[c>>1]=a-(a>>>5|0),b[e+84>>2]=d=d+2|0,l|=1):(b[e>>2]=i,g[c>>1]=a+(2048-a>>>5|0)),c=1724+((l<<=1)+e|0)|0,i>>>0<=16777215&&(i<<=8,b[e>>2]=i,a=b[e+16>>2],b[e+16>>2]=a+1,s=M[a+b[e+12>>2]|0]|s<<8,b[e+4>>2]=s),a=_[c>>1],(o=x(a,i>>>11|0))>>>0<=s>>>0?(b[e+4>>2]=s=s-o|0,b[e>>2]=o=i-o|0,g[c>>1]=a-(a>>>5|0),b[e+84>>2]=d=d+4|0,l|=1):(b[e>>2]=o,g[c>>1]=a+(2048-a>>>5|0)),o>>>0<=16777215&&(o<<=8,b[e>>2]=o,a=b[e+16>>2],b[e+16>>2]=a+1,s=M[a+b[e+12>>2]|0]|s<<8,b[e+4>>2]=s),l=_[(a=1724+((l<<1)+e|0)|0)>>1],(i=x(l,o>>>11|0))>>>0<=s>>>0?(b[e+4>>2]=s-i,b[e>>2]=o-i,g[a>>1]=l-(l>>>5|0),b[e+84>>2]=d+8):(b[e>>2]=i,g[a>>1]=l+(2048-l>>>5|0))}}if(l=b[e+84>>2],A[e+36>>2]<=l>>>(i=0)|A[e+48>>2]<=l>>>0)break e;if(u=b[e+32>>2],a=b[e+40>>2]-u|0,i=b[e+104>>2],b[e+104>>2]=i-(c=a>>>0<i>>>0?a:i),i=u+(-1^l)|0,i=u>>>0<=l>>>0?b[e+44>>2]+i|0:i,l=b[e+24>>2],a=M[i+l|0],b[e+32>>2]=u+1,y[l+u|0]=a,s=c+-1|0)for(;;)if(i=(0|(a=i+1|0))==b[e+44>>2]?0:a,c=b[e+24>>2],l=M[i+c|0],a=b[e+32>>2],b[e+32>>2]=a+1,y[a+c|0]=l,!(s=s+-1|0))break;h=b[e+32>>2],A[e+36>>2]>=h>>>0||(b[e+36>>2]=h)}if(!(h>>>0<A[e+40>>2]))break}i=1,16777215<(a=b[e>>2])>>>0||(b[e>>2]=a<<8,a=b[e+16>>2],b[e+16>>2]=a+1,b[e+4>>2]=M[a+b[e+12>>2]|0]|b[e+4>>2]<<8)}return i}function R(e,t,n){var r=0,i=0,a=0;e:if(n){for(;;){if((0|(r=M[0|e]))!=(0|(i=M[0|t])))break;if(t=t+1|0,e=e+1|0,!(n=n+-1|0))break e}a=r-i|0}return a}function P(e,t,n){var r,i=0,a=0,o=0,s=0,l=0,c=0;for(16777216<=(s=b[e>>2])>>>0?o=b[e+4>>2]:(b[e>>2]=s<<=8,a=b[e+16>>2],b[e+16>>2]=a+1,o=M[a+b[e+12>>2]|0]|b[e+4>>2]<<8,b[e+4>>2]=o),a=_[t>>1],a=o>>>0<(i=x(a,s>>>11|0))>>>0?(b[e>>2]=i,g[t>>1]=a+(2048-a>>>5|0),c=4+((n<<4)+t|0)|0,l=2,8):(b[e+4>>2]=o=o-i|0,b[e>>2]=s=s-i|0,g[t>>1]=a-(a>>>5|0),s>>>0<=16777215&&(b[e>>2]=s<<=8,a=b[e+16>>2],b[e+16>>2]=a+1,o=M[a+b[e+12>>2]|0]|o<<8,b[e+4>>2]=o),a=_[t+2>>1],o>>>0<(i=x(a,s>>>11|0))>>>0?(b[e>>2]=i,g[t+2>>1]=a+(2048-a>>>5|0),c=260+((n<<4)+t|0)|0,l=10,8):(b[e+4>>2]=o=o-i|0,b[e>>2]=i=s-i|0,g[t+2>>1]=a-(a>>>5|0),c=t+516|0,l=18,256)),b[e+104>>2]=l,t=1;;)if(s=c+(t<<=1)|0,16777215<i>>>0?n=i:(b[e>>2]=n=i<<8,i=b[e+16>>2],b[e+16>>2]=i+1,o=M[i+b[e+12>>2]|0]|o<<8,b[e+4>>2]=o),r=_[s>>1],(i=x(r,n>>>11|0))>>>0<=o>>>0?(b[e+4>>2]=o=o-i|0,b[e>>2]=i=n-i|0,g[s>>1]=r-(r>>>5|0),t|=1):(b[e>>2]=i,g[s>>1]=(2048-r>>>5|0)+r),!(t>>>0<a>>>0))break;b[e+104>>2]=(t-a|0)+l}function I(e){for(var t,n,r,i=0,a=0,o=0,s=0,l=0,c=0,u=e+28392|0,d=e+28388|0;;){i=b[e+64>>2];e:{t:{n:{r:{i:{a:{o:{s:{l:{c:{u:{d:{h:{p:{f:{if(a=b[132105],(o=b[132106])>>>0<=a>>>0){if(7==(0|i))break f;return 0}if(8<i>>>0)continue;switch(i-1|0){case 4:break l;case 3:break c;case 2:break u;case 1:break d;case 0:break h;case 6:break f;case 7:break a;case 5:break s;default:break p}}i=b[e+76>>2];break o}if(b[132105]=a+(l=1),!(i=M[b[132104]+a|0]))break i;if(!(1!=(0|i)&&i>>>0<=223)){g[e+80>>1]=256,b[e+60>>2]||(o=b[132108],b[e+24>>2]=o+b[132107],b[e+44>>2]=b[132109]-o),b[e+28>>2]=0,b[e+32>>2]=0,b[e+36>>2]=0,b[e+40>>2]=0;break n}if(M[e+80|0])return 7;break n}b[132105]=a+1,i=M[b[132104]+a|0],b[e+64>>2]=2,b[e+72>>2]=b[e+72>>2]+(i<<8);continue}b[132105]=a+1,i=M[b[132104]+a|0],b[e+64>>2]=3,b[e+72>>2]=1+(i+b[e+72>>2]|0);continue}b[132105]=a+1,i=M[b[132104]+a|0],b[e+64>>2]=4,b[e+76>>2]=i<<8;continue}b[132105]=a+1,i=M[b[132104]+a|0],b[e+64>>2]=b[e+68>>2],b[e+76>>2]=1+(i+b[e+76>>2]|0);continue}if(b[132105]=a+1,l=7,224<(i=M[b[132104]+a|0])>>>0)break i;if(o=e,s=i>>>(a=0)<45?0:(i=(i=i+-45|0)-x(s=((255&i)>>>0)/45|0,45)|0,s+1|0),b[o+116>>2]=-1<<s^-1,9<=(255&i)>>>0&&(a=(o=((255&(i=i+-9|0))>>>0)/9|0)+1|0,i=i-x(o,9)|0),b[e+112>>2]=a,i&=255,4<(b[e+108>>2]=i)+a>>>0)break i;for(b[e+112>>2]=-1<<a^-1,b[e+100>>2]=i=0,b[e+92>>2]=0,b[e+96>>2]=0,b[e+84>>2]=0,b[e+88>>2]=0;;)if(g[120+((i<<1)+e|0)>>1]=1024,14134==(0|(i=i+1|0)))break;b[e+64>>2]=6,b[e+8>>2]=5,b[e>>2]=-1,b[e+4>>2]=0}if((l=b[e+76>>2])>>>0<5)return 7;if(a=b[e+8>>2])for(i=b[132105],s=b[132106];;){if((0|i)==(0|s))return 0;if(c=b[e+4>>2],b[132105]=o=i+1|0,i=M[b[132104]+i|0],b[e+8>>2]=a=a+-1|0,b[e+4>>2]=i|c<<8,i=o,!a)break}b[e+64>>2]=7,b[e+76>>2]=i=l+-5|0}o=b[e+32>>2],a=(a=b[132109]-b[132108]|0)>>>0<(l=b[e+72>>2])>>>0?a:l,l=b[e+44>>2],b[e+40>>2]=a>>>0<l-o>>>0?o+a|0:l,a=(s=b[132106])-(o=b[132105])|0,l=b[e+28388>>2];o:{if(!i||l){if(S(4+(l+d|0)|0,s=b[132104]+o|0,i=a>>>0<(i=(i=i-l|0)>>>0<(o=42-l|0)>>>0?i:o)>>>0?a:i),(0|(o=(a=b[e+28388>>2])+i|0))==b[e+76>>2])E(4+(i+(a+d|0)|0)|0,63-o|0),o=i+b[e+28388>>2]|0;else{if(o>>>0<=20){b[e+28388>>2]=o,b[132105]=i+b[132105];break o}o=o+-21|0}if(b[e+16>>2]=0,b[e+12>>2]=u,b[e+20>>2]=o,l=7,!m(e))break i;if(o=b[e+16>>2],(a=b[e+28388>>2])+i>>>0<o>>>0)break i;if(i=b[e+76>>2]-o|0,b[e+76>>2]=i,o>>>0<a>>>0){!function(e,t,n){var r=0,i=0;s:if((0|e)!=(0|t)){if(!(e>>>0<t+n>>>0&&t>>>0<(i=e+n|0)>>>0))return S(e,t,n);if(r=3&(e^t),e>>>0<t>>>0){if(!r){if(3&e)for(;;){if(!n)break s;if(y[0|e]=M[0|t],t=t+1|0,n=n+-1|0,!(3&(e=e+1|0)))break}if(!(n>>>0<=3)){for(r=n;;)if(b[e>>2]=b[t>>2],t=t+4|0,e=e+4|0,!(3<(r=r+-4|0)>>>0))break;n&=3}}if(n)for(;;)if(y[0|e]=M[0|t],e=e+1|0,t=t+1|0,!(n=n+-1|0))break}else{if(!r){if(3&i)for(;;){if(!n)break s;if(y[0|(r=(n=n+-1|0)+e|0)]=M[t+n|0],!(3&r))break}if(!(n>>>0<=3))for(;;)if(b[(n=n+-4|0)+e>>2]=b[t+n>>2],!(3<n>>>0))break}if(n)for(;;)if(y[(n=n+-1|0)+e|0]=M[t+n|0],!n)break}}}(u,4+(o+d|0)|0,b[e+28388>>2]=i=a-o|0);break o}o=b[132105]+(o-a|0)|0,b[132105]=o,b[e+28388>>2]=0,a=(s=b[132106])-o|0}if(21<=a>>>0){if(l=b[132104],b[e+16>>2]=o,b[e+12>>2]=l,b[e+20>>2]=a>>>0<i+21>>>0?s+-21|0:i+o|0,l=7,!m(e))break i;if((i=b[e+76>>2])>>>0<(a=(o=b[e+16>>2])-b[132105]|0)>>>0)break i;if(b[e+76>>2]=i=i-a|0,b[132105]=o,20<(a=b[132106]-o|0)>>>0)break o}S(u,b[132104]+o|0,i=i>>>0<a>>>0?i:a),b[e+28388>>2]=i,b[132105]=i+b[132105]}if(a=(i=b[e+32>>2])-(l=b[e+28>>2])|0,b[(o=e)+60>>2]&&((0|i)==b[e+44>>2]&&(b[e+32>>2]=0),S(b[132107]+b[132108]|0,l+b[e+24>>2]|0,a),i=b[e+32>>2]),b[o+28>>2]=i,i=a+b[132108]|0,b[132108]=i,o=b[e+72>>2]-a|0,!(b[e+72>>2]=o)){if(l=7,b[e+4>>2]|(b[e+76>>2]|b[e+104>>2]))break i;b[e+64>>2]=0;break t}if(((l=0)|i)==b[132109])break i;if(b[132105]!=b[132106]|A[e+28388>>2]>=A[e+76>>2])continue;break i}if(!(s=b[e+76>>2]))break r;if(!(o>>>(l=0)<=a>>>0))for(;;){if((i=b[132109])>>>0<=(c=b[132108])>>>0)break i;if(r=s,t=b[e+32>>2],n=b[e+44>>2]-t|0,b[e+76>>2]=r-(s=s>>>0<(i=n>>>0<(i=(o=o-a|0)>>>0<(i=i-c|0)>>>0?o:i)>>>0?n:i)>>>0?s:i),S(b[e+24>>2]+t|0,b[132104]+a|0,s),i=s+b[e+32>>2]|0,b[e+32>>2]=i,A[e+36>>2]<i>>>0&&(b[e+36>>2]=i),b[(o=e)+60>>2]&&((0|i)==b[e+44>>2]&&(b[e+32>>2]=0),S(b[132107]+b[132108]|0,b[132104]+b[132105]|0,s),i=b[e+32>>2]),b[o+28>>2]=i,b[132108]=s+b[132108],a=s+b[132105]|0,b[132105]=a,!(s=b[e+76>>2]))break r;if(!(a>>>0<(o=b[132106])>>>0))break}}return l}b[e+64>>2]=0;continue}if(-1<i<<24>>24)break e;if(b[e+64>>2]=1,b[e+72>>2]=i<<16&2031616,192<=i>>>0){b[e+68>>2]=5,y[e+81|0]=0;continue}if(M[e+81|0])return 7;if(b[e+68>>2]=6,i>>>0<160)continue;for(b[e+84>>2]=0,b[e+88>>2]=0,b[e+100>>2]=i=0,b[e+92>>2]=0,b[e+96>>2]=0;;)if(g[120+((i<<1)+e|0)>>1]=1024,14134==(0|(i=i+1|0)))break}b[e+8>>2]=5,b[e>>2]=-1,b[e+4>>2]=0;continue}if(!(i>>>0<=2))break;b[e+64>>2]=3,b[e+68>>2]=8}return 7}function v(){var e,t,n=0;if(e=L(1208)){if(b[e+36>>2]=2,t=0,n=(t=L(28456))?(b[t+52>>2]=8388608,b[t+60>>2]=2,b[t+56>>2]=0,b[t+24>>2]=0,t):0,b[e+1200>>2]=n)return y[e+40|0]=0,b[e>>2]=0,b[e+4>>2]=0,b[e+24>>2]=0,E(e+72|(b[e+28>>2]=0),100),b[e+172>>2]=12,e;C(e)}return 0}function d(e){var t,n,r,i,a=0,o=0,s=0,l=0,c=0,u=0,d=0,h=0,p=0,f=0,m=0,v=0,g=0,o=b[e+36>>2]?b[e>>2]:(y[e+40|0]=0,b[e>>2]=0,b[e+4>>2]=0,b[e+24>>2]=0,E(e+72|(b[e+28>>2]=0),100),b[e+172>>2]=12,0),_=b[132108],x=b[132105];b[e+16>>2]=x,n=e+96|0,v=(a=e)+182|0,r=a+176|0,d=a+168|0;e:{t:{n:{r:{i:{for(;;)if(!(9<o>>>0)){e=d;a:{o:{s:{l:{c:{u:switch(o-1|0){case 1:u=b[132106],o=b[132104],l=b[a+172>>2],s=b[a+168>>2];break c;default:if(s=b[132105],o=b[132106]-s|0,c=b[a+168>>2],u=b[a+172>>2]-c|0,S(8+(c+d|0)|0,s+b[132104]|0,o=o>>>0<u>>>0?o:u),b[132105]=o+b[132105],o=o+b[a+168>>2]|(l=0),s=b[a+172>>2],b[a+168>>2]=(0|s)==(0|o)?0:o,(0|o)!=(0|s))break e;if(b[a>>2]=1,R(r,1024,6)){l=5;break e}if((0|T(v,2,0))!=(M[a+184|0]|M[a+185|0]<<8|(M[a+186|0]<<16|M[a+187|0]<<24))){l=7;break e}if(l=6,M[0|v])break e;if(o=M[a+183|0],15<(b[a+32>>2]=o)>>>0)break e;if(l=2,!(1<<o&19)|4<o>>>0)break e;break;case 4:break o;case 3:break s;case 2:break l;case 0:break u;case 8:break n;case 7:break r;case 6:break i;case 5:break a}if((0|(u=b[132106]))==(0|(s=b[132105]))){l=0;break e}if(o=b[132104],!(c=M[s+o|0])){b[132105]=s+1,b[a+16>>2]=s,b[a>>2]=o=6;continue}b[a+168>>2]=0,b[a>>2]=2,b[a+172>>2]=l=4+(c<<2)|0,b[a+64>>2]=l,s=0}if(c=u,S(8+(e+s|0)|0,o+(u=b[132105])|0,c=(c=c-u|0)>>>0<(l=l-s|0)>>>0?c:l),b[132105]=c+b[132105],e=c+b[a+168>>2]|(l=0),o=b[a+172>>2],b[a+168>>2]=(0|o)==(0|e)?0:e,(0|e)!=(0|o))break e;if(o=T(r,b[a+172>>2]=e=e+-4|0,0),p=b[a+172>>2],(0|o)!=(M[(e=p+a|0)+176|0]|M[e+177|0]<<8|(M[e+178|0]<<16|M[e+179|0]<<24))){l=7;break e}if(b[a+168>>2]=2,63&(t=y[a+177|0])){l=6;break e}if(o=2,c=s=g=h=-1,64&t){for((u=b[a+4>>2])||(b[a+8>>2]=0,b[a+12>>2]=0);;){if(p>>>0<=o>>>0){l=7;break e}f=M[8+(o+d|0)|0],b[a+168>>2]=o=o+1|0,i=b[(e=a)+12>>2],m=127&f,l=31&(s=u),s=32<=(63&s)>>>0?(c=m<<l,0):(c=(1<<l)-1&m>>>32-l,m<<l),s|=b[a+8>>2],c=l=c|i,b[e+8>>2]=s,b[e+12>>2]=c;c:{if(!(128&f)){if(f|!u)break c;l=7;break e}if(63!=(0|(b[a+4>>2]=u=u+(l=7)|0)))continue;break e}break}b[a+4>>2]=0}if(b[a+48>>2]=s,b[a+52>>2]=c,(0|t)<=-1){for((u=b[a+4>>2])||(b[a+8>>2]=0,b[a+12>>2]=0);;){if(p>>>0<=o>>>0){l=7;break e}f=M[8+(o+d|0)|0],b[a+168>>2]=o=o+1|0,m=b[(e=a)+12>>2],h=127&f,l=31&(s=u),h=(s=32<=(63&s)>>>0?(c=h<<l,0):(c=(1<<l)-1&h>>>32-l,h<<l))|b[a+8>>2],g=s=c|m,b[e+8>>2]=h,b[e+12>>2]=s;c:{if(!(128&f)){if(f|!u)break c;l=7;break e}if(63!=(0|(b[a+4>>2]=u=u+(l=7)|0)))continue;break e}break}b[a+4>>2]=0}if(b[a+56>>2]=h,b[a+60>>2]=g,p-o>>>0<2){l=7;break e}if(b[a+168>>2]=s=o+1|0,33!=M[8+(o+d|0)|0]){l=6;break e}if(b[a+168>>2]=e=o+2|0,1!=M[8+(s+d|0)|0]){l=6;break e}if(l=7,(0|e)==(0|p))break e;if(b[a+168>>2]=o+3,l=function(e,t){var n=0,r=0;n=6;c:if(!(39<t>>>0)){if(t=(1&t|2)<<11+(t>>>1|0),b[e+48>>2]=t,r=b[e+60>>2]){if(n=4,t>>>0>A[e+52>>2])break c;if(b[e+44>>2]=t,!(2!=(0|r)|A[e+56>>2]>=t>>>0||(C(b[e+24>>2]),t=L(b[e+48>>2]),b[e+24>>2]=t)))return b[e+56>>2]=0,3}b[e+28388>>2]=0,b[e+64>>2]=0,y[e+80|0]=1,b[e+104>>2]=0,n=0}return n}(b[a+1200>>2],M[8+(e+d|0)|0]))break e;o=b[a+168>>2],s=b[a+172>>2];c:{for(;;){if(s>>>0<=o>>>0)break c;if(c=o+d|0,o=b[a+168>>2]=e=o+1|0,M[c+8|0])break}l=6;break e}b[a+168>>2]=0,b[a+80>>2]=0,b[a+84>>2]=0,b[a+72>>2]=0,b[a+76>>2]=0,b[a>>2]=3}if(b[a+16>>2]=b[132105],b[a+20>>2]=b[132108],l=I(b[a+1200>>2]),e=b[(o=a)+76>>2],u=c=(s=b[132105]-b[a+16>>2]|0)+b[a+72>>2]|0,s=e=c>>>0<s>>>0?e+1|0:e,b[o+72>>2]=c,b[o+76>>2]=e,e=b[a+84>>2],p=b[a+20>>2],c=e=(f=(c=h=b[132108]-p|0)+b[a+80>>2]|0)>>>0<c>>>0?e+1|0:e,b[o+80>>2]=f,b[o+84>>2]=e,(0|(e=b[a+52>>2]))==(0|s)&u>>>0>A[a+48>>2]|e>>>0<s>>>0){l=7;break e}if((0|(e=b[a+60>>2]))==(0|c)&f>>>0>A[a+56>>2]|e>>>0<c>>>0){l=7;break e}o=b[a+32>>2]+-1|0;l:if(!(3<o>>>0)){e=a;c:{u:switch(o-1|0){default:o=T(p+b[132107]|0,h,b[a+24>>2]),s=0;break c;case 0:case 1:break l;case 2:break u}o=function(e,t,n,r){var i=0;if(n^=-1,r^=-1,t)for(;;)if(i=2080+((M[0|e]^255&n)<<3)|0,n=b[i>>2]^((255&r)<<24|n>>>8),r=b[4+i>>2]^r>>>8,e=e+1|0,!(t=t+-1|0))break;return w=-1^r,-1^n}(p+b[132107]|0,h,b[a+24>>2],b[a+28>>2]),s=w}b[e+24>>2]=o,b[e+28>>2]=s}if(1!=(0|l))break e;if(o=e=b[a+52>>2],!(-1==(0|(s=b[a+48>>2]))&-1==(0|o)|b[a+72>>2]==(0|s)&b[a+76>>2]==(0|o))){l=7;break e}if(e=b[a+80>>2],o=b[a+84>>2],c=u=b[a+60>>2],-1==(0|(s=b[a+56>>2]))&-1==(0|c))s=e,c=o;else if(l=7,(0|e)!=(0|s)|(0|o)!=(0|c))break e;c=c+b[a+108>>2]|0,(o=s+b[a+104>>2]|0)>>>0<s>>>0&&(c=c+1|0),b[a+104>>2]=o,b[a+108>>2]=c,c=b[a+100>>2],e=b[a+76>>2],e=(e=(u=(s=b[a+64>>2])+b[a+72>>2]|0)>>>0<s>>>0?e+1|0:e)+c|0,e=(s=u+b[a+96>>2]|0)>>>0<u>>>0?e+1|0:e,(s=(c=s)+M[b[a+32>>2]+1040|0]|0)>>>0<c>>>0&&(e=e+1|0),b[a+96>>2]=s,b[a+100>>2]=e,b[a+112>>2]=T(n,24,b[a+112>>2]),b[a>>2]=4,o=b[a+92>>2],(s=b[a+88>>2]+1|0)>>>0<1&&(o=o+1|0),b[a+88>>2]=s,b[a+92>>2]=o}if(c=b[a+76>>2],3&(s=b[a+72>>2]))for(o=b[132105],u=b[132106];;){if((0|o)==(0|u)){l=0;break e}if(b[132105]=e=o+1|0,M[b[132104]+o|0]){l=7;break e}if((s=s+1|0)>>>0<1&&(c=c+1|0),b[a+72>>2]=s,b[a+76>>2]=c,o=e,!(3&s))break}b[a>>2]=5}o:{s:if(!(3<(o=(e=b[a+32>>2])+-1|0)>>>0)){l:switch(o-1|0){default:for(o=b[132105],l=b[132106];;){if((0|o)==(0|l)){l=0;break e}if(u=b[a+24>>2],s=b[a+28>>2],e=b[a+4>>2],b[132105]=c=o+1|0,h=M[b[132104]+o|0],p=u,o=s,u=31&e,(0|h)!=(255&(32<=(63&e)>>>0?o>>>u|0:((1<<u)-1&o)<<32-u|p>>>u))){l=7;break e}if(o=c,!((b[a+4>>2]=e=e+8|0)>>>0<32))break}b[a+24>>2]=0,b[a+28>>2]=0;break o;case 0:case 1:break s;case 2:break l}for(o=b[132105],l=b[132106];;){if((0|o)==(0|l)){l=0;break e}if(u=b[a+24>>2],s=b[a+28>>2],e=b[a+4>>2],b[132105]=c=o+1|0,h=M[b[132104]+o|0],p=u,o=s,u=31&e,(0|h)!=(255&(32<=(63&e)>>>0?o>>>u|0:((1<<u)-1&o)<<32-u|p>>>u))){l=7;break e}if(o=c,!((b[a+4>>2]=e=e+8|0)>>>0<64))break}b[a+24>>2]=0,b[a+28>>2]=0;break o}if(o=b[a+4>>2],!((e=M[e+1040|0])>>>0<=o>>>0))for(l=b[132105],s=b[132106];;){if((0|l)==(0|s)){l=0;break e}if(b[132105]=l=l+1|0,(0|e)==(0|(b[a+4>>2]=o=o+1|0)))break}}b[a+4>>2]=0,b[a>>2]=o=1;continue}break}for(f=a+144|0;;){m=b[132106],h=b[132104],(e=b[a+4>>2])||(b[a+8>>2]=0,b[a+12>>2]=0),o=b[132105];a:{for(;;){if(m>>>0<=o>>>0)l=0;else if(d=M[o+h|0],b[132105]=o=o+1|0,v=b[(u=a)+12>>2],p=127&d,l=31&e,s=32<=(63&e)>>>0?(c=p<<l,0):(c=(1<<l)-1&p>>>32-l,p<<l),s|=b[a+8>>2],c=l=c|v,b[u+8>>2]=s,b[u+12>>2]=c,128&d){if(63!=(0|(b[a+4>>2]=e=e+(l=7)|0)))continue}else{if(d|!e)break a;l=7}break}e=b[a+132>>2],(d=(c=(s=o)-(o=b[a+16>>2])|0)+b[a+128>>2]|0)>>>0<c>>>0&&(e=e+1|0),b[a+128>>2]=d,b[a+132>>2]=e,b[a+24>>2]=T(o+h|0,c,b[a+24>>2]),b[a+28>>2]=0;break e}b[a+4>>2]=0;a:{if((e=b[a+120>>2])>>>0<=2){o:switch(e-1|0){default:if(b[a+136>>2]=s,b[a+140>>2]=c,(0|s)!=b[a+88>>2]|(0|c)!=b[a+92>>2]){l=7;break e}b[a+120>>2]=1;break a;case 1:e=c+b[a+156>>2]|0,(c=s+b[a+152>>2]|0)>>>0<s>>>0&&(e=e+1|0),b[a+152>>2]=c,b[a+156>>2]=e,b[a+160>>2]=T(f,24,b[a+160>>2]),b[a+120>>2]=1,c=b[a+140>>2]+-1|0,(o=b[a+136>>2]+-1|0)>>>0<4294967295&&(c=c+1|0),s=o,b[a+136>>2]=o,b[a+140>>2]=c;break a;case 0:break o}b[a+120>>2]=2,e=c+b[a+148>>2]|0,(c=s+b[a+144>>2]|0)>>>0<s>>>0&&(e=e+1|0),b[a+144>>2]=c,b[a+148>>2]=e}s=b[a+136>>2],c=b[a+140>>2]}if(!(s|c))break}b[a>>2]=7}s=b[a+132>>2],p=((o=b[132105])+(((c=b[a+16>>2])-o|0)-(d=b[a+128>>2])&3)|0)-c|0;i:{for(;;){if(e=s,(l=(u=h=o-c|0)+d|0)>>>0<u>>>0&&(e=e+1|0),!(3&(u=l)))break i;if(l=b[132104],b[132106]==(0|o)){b[a+128>>2]=u,b[a+132>>2]=e,b[a+24>>2]=T(l+c|0,h,b[a+24>>2]),l=b[a+28>>2]=0;break e}if(u=o+l|0,o=b[132105]=e=o+1|0,M[0|u])break}l=7;break e}if(o=b[132104],b[a+128>>2]=u,b[a+132>>2]=e,b[a+24>>2]=T(o+c|0,p,b[a+24>>2]),l=7,R(n,a+144|(b[a+28>>2]=0),24))break e;b[a>>2]=8}for(o=b[132105],l=b[132106];;){if((0|o)==(0|l)){l=0;break e}if(d=b[a+24>>2],c=b[a+28>>2],s=b[a+4>>2],b[132105]=e=o+1|0,u=b[132104],h=M[u+o|0],p=d,o=c,d=31&s,(0|h)!=(255&(32<=(63&s)>>>0?o>>>d|0:((1<<d)-1&o)<<32-d|p>>>d))){l=7;break e}if(o=e,!((b[a+4>>2]=s=s+8|0)>>>0<32))break}b[a+172>>2]=12,b[a+24>>2]=0,b[a+28>>2]=0,b[a>>2]=9,b[a+4>>2]=0,o=12;break t}e=b[132105],u=b[132104],l=b[132106],o=b[a+172>>2]}S(176+(a+(c=b[a+168>>2])|0)|0,e+u|0,o=(s=l-e|0)>>>0<(o=o-c|0)>>>0?s:o),b[132105]=o+b[132105],e=o+b[a+168>>2]|(l=0),o=b[a+172>>2],b[a+168>>2]=(0|o)==(0|e)?0:e,(0|e)==(0|o)&&(l=7,23129==(M[a+186|0]|M[a+187|0]<<8)&&(0|T(a+180|0,6,0))==(M[a+176|0]|M[a+177|0]<<8|(M[a+178|0]<<16|M[a+179|0]<<24))&&(o=b[a+132>>2],M[a+184|0]|(M[a+180|0]|M[a+181|0]<<8|(M[a+182|0]<<16|M[a+183|0]<<24))!=((3&o)<<30|b[a+128>>2]>>>2)|(e=o>>>2|0)||(l=b[a+32>>2]==M[a+185|0]?1:7)))}e:{if(!b[a+36>>2]){if(l){if(a=1==(0|l),e=l,l=1,a)break e}else e=b[132105]==b[132106]?7:8;return b[132108]=_,b[132105]=x,e}if(!(b[132105]!=(0|x)|l|b[132108]!=(0|_)))return e=M[a+40|0],y[a+40|0]=1,e<<3;y[a+40|0]=0}return l}function N(e){var t;return(-1>>>(t=31&e)&-2)<<t|(-1<<(e=0-e&31)&-2)>>>e}return n=Uv,c=(r=hv).buffer,i=new Uint8Array(c),(c=function(e,t){var n,r;if("undefined"==typeof Buffer)for(n=u(t),r=0;r<n.length;r++)i[e+r]=n.charCodeAt(r);else for(n=Buffer.from(t,"base64"),r=0;r<n.length;r++)i[e+r]=n[r]})(1024,"/Td6WFo="),c(1041,"BAQECAgIEBAQICAgQEBA"),c={Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array,NaN:NaN,Infinity:1/0,Math:Math},n=n,a=r.buffer,n.memory,y=new c.Int8Array(a),g=new c.Int16Array(a),b=new c.Int32Array(a),M=new c.Uint8Array(a),_=new c.Uint16Array(a),A=new c.Uint32Array(a),new c.Float32Array(a),new c.Float64Array(a),x=c.Math.imul,c.Math.fround,c.Math.abs,c.Math.clz32,c.Math.min,c.Math.max,c.Math.floor,c.Math.ceil,c.Math.sqrt,o=n.abort,c.NaN,c.Infinity,s=n.emscripten_memcpy_big,l=n.emscripten_resize_heap,h=6296128,w=0,{exports:{__wasm_call_ctors:function(){},init_decompressor:function(){for(var e=0,t=(b[132108]=0,b[132109]=524288,b[132107]=528448,b[132105]=0,b[132106]=0,b[132104]=4128,0),n=0,r=0;t=((n=(0-(1&(t=(0-(1&(t=((n=r>>>1|0)^0-(1&r)&-306674912)>>>1|0))&-306674912^(n=(t^0-(1&n)&-306674912)>>>1|0))>>>1|0))&-306674912^(t=(t^0-(1&n)&-306674912)>>>1|0))>>>1|0)^0-(1&t)&-306674912)>>>1|0,b[1056+(r<<2)>>2]=0-(1&t)&-306674912^(t^0-(1&n)&-306674912)>>>1,256!=(0|(r=r+1|0)););for(var i,a,o=0,s=0,l=0,c=0,u=0,d=0;s=(o=c)>>>1|0,l=1&(o=(1&o)<<31|u>>>1),s^=0-(0<(a=1&u)>>>0)&-915646571,a=o^0-a&-679014590,o=s>>>1|0,o^=0-(0<l>>>0)&-915646571,l=(s=(1&s)<<31|a>>>1)^0-l&-679014590,a=o>>>1|0,l=1&(o=(1&o)<<31|l>>>1),i=0-(s&=1)&-679014590,s=a^0-(0<s>>>0)&-915646571,a=o^i,o=s>>>1|0,a=0-l&-679014590^(s=(1&s)<<31|a>>>1),o=(l=o^0-(0<l>>>0)&-915646571)>>>1|0,s=(1&(o^=0-(0<(s&=1)>>>0)&-915646571))<<31|(s=(l=(1&l)<<31|a>>>1)^0-s&-679014590)>>>1,o=(l=0-(0<(a=1&l)>>>0)&-915646571^o>>>1)>>>1|0,a=1&(l=(1&l)<<31|(s^0-a&-679014590)>>>1),l^=0-(s&=1)&-679014590,s=(o^=0-(0<s>>>0)&-915646571)>>>1|0,b[(i=2080+(d<<3)|0)>>2]=0-a&-679014590^((1&o)<<31|l>>>1),b[4+i>>2]=s^0-(0<a>>>0)&-915646571,d=d+1|0,o=c,256!=(0|(u=c=u+1|0))|(c=o=c>>>0<1?o+1|0:o););return e=v(),0|(e=(b[263184]=e)?0:(p(0),1))},decompress:function(){var e,t=0;e:{if((e=d(b[263184]))>>>0<=8){t:switch(e-1|0){case 0:return p(b[263184]),0;case 2:return p(b[263184]),1;case 3:return p(b[263184]),2;case 4:return p(b[263184]),4;case 5:return p(b[263184]),5;case 6:case 7:break t;default:break e}return p(b[263184]),6}p(b[263184]),t=7}return 0|t},get_in_buffer_ptr:function(){return b[132104]},get_out_buffer_ptr:function(){return b[132107]},in_buffer_set_pos:function(e){b[132105]=e|=0},in_buffer_set_size:function(e){b[132106]=(e|=0)>>>0<524288?e:524288},out_buffer_set_pos:function(e){b[132108]=e|=0},out_buffer_set_size:function(e){b[132109]=(e|=0)>>>0<524288?e:524288},get_curr_output_length:function(){return b[132108]},is_input_end_reached:function(){return b[132105]==b[132106]|0},stackSave:function(){return 0|h},stackAlloc:function(e){return 0|(h=e=h-(e|=0)&-16)},stackRestore:function(e){h=e|=0},__growWasmMemory:function(e){return 0|o()}}}},instantiate:function(t,n){return{then:function(e){e({instance:new pv.Instance(new pv.Module(t,n))})}}},RuntimeError:Error},fv=[],Oh=("object"!=typeof pv&&dv("no native wasm support detected"),new pv.Table({initial:1,maximum:1,element:"anyfunc"})),mv=!1;function vv(e,t){e||Pv("Assertion failed: "+t)}function gv(e){var t=_["_"+e];return vv(t,"Cannot call unknown function "+e+", make sure it is exported"),t}function _v(e,u,t,n){var r={string:function(e){var t,n=0;return null!=e&&0!==e&&(t=1+(e.length<<2),n=Hv(t),function(e,t,n,r){if(!(0<r))return;for(var i=n,a=n+r-1,o=0;o<e.length;++o){var s,l=e.charCodeAt(o);if(55296<=l&&l<=57343&&(s=e.charCodeAt(++o),l=65536+((1023&l)<<10)|1023&s),l<=127){if(a<=n)break;t[n++]=l}else if(l<=2047){if(a<=n+1)break;t[n++]=192|l>>6,t[n++]=128|63&l}else if(l<=65535){if(a<=n+2)break;t[n++]=224|l>>12,t[n++]=128|l>>6&63,t[n++]=128|63&l}else{if(a<=n+3)break;t[n++]=240|l>>18,t[n++]=128|l>>12&63,t[n++]=128|l>>6&63,t[n++]=128|63&l}}t[n]=0}(e,bv,n,t)),n},array:function(e){var t=Hv(e.length);return yv.set(e,t),t}};var e=gv(e),i=[],a=0;if(n)for(var o=0;o<n.length;o++){var s=r[t[o]];s?(0===a&&(a=Wv()),i[o]=s(n[o])):i[o]=n[o]}e=function(e){if("string"!==u)return"boolean"===u?Boolean(e):e;if(e=e){for(var t=bv,n=e,r=n+(e=c),i=n;t[i]&&!(r<=i);)++i;if(16<i-n&&t.subarray&&xv)return xv.decode(t.subarray(n,i));for(var a="";n<i;){var o,s,l=t[n++];128&l?(s=63&t[n++],192==(224&l)?a+=String.fromCharCode((31&l)<<6|s):(o=63&t[n++],(l=224==(240&l)?(15&l)<<12|s<<6|o:(7&l)<<18|s<<12|o<<6|63&t[n++])<65536?a+=String.fromCharCode(l):(s=l-65536,a+=String.fromCharCode(55296|s>>10,56320|1023&s)))):a+=String.fromCharCode(l)}return a}return"";var c}(e.apply(null,i));return 0!==a&&Xv(a),e}var xv="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var yv,bv;Dh=_.TOTAL_MEMORY||16777216;function Mv(e){for(;0<e.length;){var t,n=e.shift();"function"==typeof n?n():"number"==typeof(t=n.func)?void 0===n.arg?_.dynCall_v(t):_.dynCall_vi(t,n.arg):t(void 0===n.arg?null:n.arg)}}hv=_.wasmMemory||new pv.Memory({initial:Dh/65536,maximum:Dh/65536}),Dh=(Gv=hv?hv.buffer:Gv).byteLength,Gv=Dh=Gv,_.HEAP8=yv=new Int8Array(Dh),_.HEAP16=new Int16Array(Dh),_.HEAP32=Gv=new Int32Array(Dh),_.HEAPU8=bv=new Uint8Array(Dh),_.HEAPU16=new Uint16Array(Dh),_.HEAPU32=new Uint32Array(Dh),_.HEAPF32=new Float32Array(Dh),_.HEAPF64=new Float64Array(Dh),Gv[263312]=6296288;var Av=[],wv=[],Sv=[],Tv=[];function Cv(){if(_.preRun)for("function"==typeof _.preRun&&(_.preRun=[_.preRun]);_.preRun.length;)e=_.preRun.shift(),Av.unshift(e);var e;Mv(Av)}function Ev(){if(_.postRun)for("function"==typeof _.postRun&&(_.postRun=[_.postRun]);_.postRun.length;)e=_.postRun.shift(),Tv.unshift(e);var e;Mv(Tv)}var Lv=0,Rv=null;function Pv(e){throw _.onAbort&&_.onAbort(e),uv(e+=""),dv(e),mv=!0,new pv.RuntimeError(e="abort("+e+"). Build with -s ASSERTIONS=1 for more info.")}_.preloadedImages={},_.preloadedAudios={};var Iv="data:application/octet-stream;base64,";function Nv(e){return String.prototype.startsWith?e.startsWith(Iv):0===e.indexOf(Iv)}var Dv="xz.wasm";function Ov(){try{if(fv)return new Uint8Array(fv);var e=zv(Dv);if(e)return e;if(iv)return iv(Dv);throw"both async and sync fetching of the wasm failed"}catch(e){Pv(e)}}function Fv(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];255<r&&(r&=255),t.push(String.fromCharCode(r))}return t.join("")}Nv(Dv)||(Dh=Dv,Dv=_.locateFile?_.locateFile(Dh,Ih):Ih+Dh),wv.push({func:function(){kv()}});var Bv="function"==typeof atob?atob:function(e){var t,n,r,i,a,o,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",c=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");r=s.indexOf(e.charAt(c++)),t=(15&(i=s.indexOf(e.charAt(c++))))<<4|(a=s.indexOf(e.charAt(c++)))>>2,n=(3&a)<<6|(o=s.indexOf(e.charAt(c++))),l+=String.fromCharCode(r<<2|i>>4),64!==a&&(l+=String.fromCharCode(t)),64!==o&&(l+=String.fromCharCode(n)),c<e.length;);return l};function zv(t){if(Nv(t)){var n,t=t.slice(Iv.length);if("boolean"==typeof cv&&cv){try{n=Buffer.from(t,"base64")}catch(e){n=new Buffer(t,"base64")}return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}try{for(var e=Bv(t),r=new Uint8Array(e.length),i=0;i<e.length;++i)r[i]=e.charCodeAt(i);return r}catch(e){throw new Error("Converting base64 string to bytes failed.")}}}var Vv,Uv={emscripten_memcpy_big:function(e,t,n){bv.set(bv.subarray(t,t+n),e)},emscripten_resize_heap:function(e){Pv("OOM")},memory:hv,table:Oh},Gv=function(){var t={env:Uv,wasi_snapshot_preview1:Uv};function n(e,t){var e=e.exports;_.asm=e,Lv--,_.monitorRunDependencies&&_.monitorRunDependencies(Lv),0==Lv&&Rv&&(e=Rv,Rv=null,e())}function r(e){n(e.instance)}function i(e){return(fv||!sv&&!lv||"function"!=typeof fetch?new Promise(function(e,t){e(Ov())}):fetch(Dv,{credentials:"same-origin"}).then(function(e){if(e.ok)return e.arrayBuffer();throw"failed to load wasm binary file at '"+Dv+"'"}).catch(Ov)).then(function(e){return pv.instantiate(e,t)}).then(e,function(e){dv("failed to asynchronously prepare wasm: "+e),Pv(e)})}if(Lv++,_.monitorRunDependencies&&_.monitorRunDependencies(Lv),_.instantiateWasm)try{return _.instantiateWasm(t,n)}catch(e){return dv("Module.instantiateWasm callback failed with error: "+e),!1}return fv||"function"!=typeof pv.instantiateStreaming||Nv(Dv)||"function"!=typeof fetch?i(r):fetch(Dv,{credentials:"same-origin"}).then(function(e){return pv.instantiateStreaming(e,t).then(r,function(e){dv("wasm streaming compile failed: "+e),dv("falling back to ArrayBuffer instantiation"),i(r)})}),{}}(),kv=(_.asm=Gv,_.___wasm_call_ctors=function(){return(kv=_.___wasm_call_ctors=_.asm.__wasm_call_ctors).apply(null,arguments)}),Wv=(_._init_decompressor=function(){return(_._init_decompressor=_.asm.init_decompressor).apply(null,arguments)},_._decompress=function(){return(_._decompress=_.asm.decompress).apply(null,arguments)},_._get_in_buffer_ptr=function(){return(_._get_in_buffer_ptr=_.asm.get_in_buffer_ptr).apply(null,arguments)},_._get_out_buffer_ptr=function(){return(_._get_out_buffer_ptr=_.asm.get_out_buffer_ptr).apply(null,arguments)},_._in_buffer_set_pos=function(){return(_._in_buffer_set_pos=_.asm.in_buffer_set_pos).apply(null,arguments)},_._in_buffer_set_size=function(){return(_._in_buffer_set_size=_.asm.in_buffer_set_size).apply(null,arguments)},_._out_buffer_set_pos=function(){return(_._out_buffer_set_pos=_.asm.out_buffer_set_pos).apply(null,arguments)},_._out_buffer_set_size=function(){return(_._out_buffer_set_size=_.asm.out_buffer_set_size).apply(null,arguments)},_._get_curr_output_length=function(){return(_._get_curr_output_length=_.asm.get_curr_output_length).apply(null,arguments)},_._is_input_end_reached=function(){return(_._is_input_end_reached=_.asm.is_input_end_reached).apply(null,arguments)},_.stackSave=function(){return(Wv=_.stackSave=_.asm.stackSave).apply(null,arguments)}),Hv=_.stackAlloc=function(){return(Hv=_.stackAlloc=_.asm.stackAlloc).apply(null,arguments)},Xv=_.stackRestore=function(){return(Xv=_.stackRestore=_.asm.stackRestore).apply(null,arguments)},jv=_.__growWasmMemory=function(){return(jv=_.__growWasmMemory=_.asm.__growWasmMemory).apply(null,arguments)};function Yv(e){function t(){Vv||(Vv=!0,mv||(Mv(wv),Mv(Sv),_.onRuntimeInitialized&&_.onRuntimeInitialized(),Ev()))}0<Lv||(Cv(),0<Lv||(_.setStatus?(_.setStatus("Running..."),setTimeout(function(){setTimeout(function(){_.setStatus("")},1),t()},1)):t()))}if(_.asm=Gv,_.cwrap=function(e,t,n,r){var i=(n=n||[]).every(function(e){return"number"===e});return"string"!==t&&i&&!r?gv(e):function(){return _v(e,t,n,arguments)}},Rv=function e(){Vv||Yv(),Vv||(Rv=e)},_.run=Yv,_.preInit)for("function"==typeof _.preInit&&(_.preInit=[_.preInit]);0<_.preInit.length;)_.preInit.pop()();Yv(),_._lock=!1;var Zv=["","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"];function qv(e){this.manager=void 0!==e?e:wd}Object.assign(qv.prototype,{crossOrigin:"Anonymous",load:function(r,i,a,o){void 0===r&&(r=""),void 0!==this.path&&(r=this.path+r);var s=this,e=Md.get(r);if(void 0!==e)return s.manager.itemStart(r),setTimeout(function(){i&&i(e),s.manager.itemEnd(r)},0),e;var t=new XMLHttpRequest;return t.open("GET",r,!0),t.addEventListener("load",function(e){var t,n=e.target.response;200===this.status||0===this.status?(0===this.status&&console.warn("v3d.XZLoader: HTTP Status 0 received."),t=function(){_._lock?setTimeout(t,1):s.decompressArrayBuffer(n,function(e){setTimeout(function(){i&&i(e),s.manager.itemEnd(r),Md.add(r,e)},1)},function(e){a&&a((+e+2)/3)},function(e){o&&o(e),s.manager.itemEnd(r),s.manager.itemError(r)})},setTimeout(t,1)):(o&&o(e),s.manager.itemEnd(r),s.manager.itemError(r))},!1),a&&t.addEventListener("progress",function(e){e=2*(e.lengthComputable?e.loaded/e.total:1)/3;a(e)},!1),t.addEventListener("error",function(e){o&&o(e),s.manager.itemEnd(r),s.manager.itemError(r)},!1),t.responseType="arraybuffer",t.send(null),s.manager.itemStart(r),t},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this},decompressArrayBuffer:function(e,a,o,s){var l=this;function c(e){var t=l._emGetInBufferPtr();_.HEAPU8.set(e,t),l._emInBufferSetPos(0),l._emInBufferSetSize(e.length),u()}function u(){l._emOutBufferSetPos(0)}_._lock=!0;var t=l._emInitDecompressor();if(0!=t)return console.error("XZLoader._emInitDecompressor: error code "+t+" ("+Zv[t]+")"),void(s&&s(t));var d=new Uint8Array(e),h=d.length,p=[],f=0,m=Math.min(524288,h),v=0;c(d.subarray(f,m)),function e(){var t,n,r,i=l._emDecompress();i?(console.error("XZLoader._emDecompress: error code "+i+" ("+Zv[i]+")"),_._lock=!1,s&&s(i)):(i=l._emGetCurrOutputLength(),p.push((r=l._emGetOutBufferPtr(),new Uint8Array(_.HEAPU8.subarray(r,r+i)))),u(),l._emIsInputEndReached()&&(f=m,m=Math.min(m+524288,h),c(d.subarray(f,m))),o&&o(f/h),f==m?(r=p.reduce(function(e,t,n,r){return e+t.length},0),t=new Uint8Array(r),n=0,p.forEach(function(e){t.set(e,n),n+=e.length}),_._lock=!1,a&&a(t.buffer)):++v%2==0?setTimeout(e,1):e())}()},_emInitDecompressor:_.cwrap("init_decompressor","number"),_emDecompress:_.cwrap("decompress","number"),_emGetInBufferPtr:_.cwrap("get_in_buffer_ptr","number"),_emGetOutBufferPtr:_.cwrap("get_out_buffer_ptr","number"),_emInBufferSetPos:_.cwrap("in_buffer_set_pos",null,["number"]),_emInBufferSetSize:_.cwrap("in_buffer_set_size",null,["number"]),_emOutBufferSetPos:_.cwrap("out_buffer_set_pos",null,["number"]),_emOutBufferSetSize:_.cwrap("out_buffer_set_size",null,["number"]),_emGetCurrOutputLength:_.cwrap("get_curr_output_length","number"),_emIsInputEndReached:_.cwrap("is_input_end_reached","number")});class Qv extends Sd{constructor(e){super(e),this.reversed=!1}load(e,t,n,r){var i=this,a=new Cd(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.load(e,function(e){t(i.parse(e))},n,r)}parse(e){if("undefined"==typeof opentype)return console.warn("v3d.TTFLoader: The loader requires opentype.js. Make sure it's included before using the loader."),null;for(var t=opentype.parse(e),n=this.reversed,r=Math.round,i={},a=1e3/(t.unitsPerEm||2048),o=t.encoding.cmap.glyphIndexMap,s=Object.keys(o),l=0;l<s.length;l++){var c,u=s[l],d=t.glyphs.glyphs[o[u]];void 0!==u&&(c={ha:r(d.advanceWidth*a),x_min:r(d.xMin*a),x_max:r(d.xMax*a),o:""},n&&(d.path.commands=function(e){var t,n=[],i=(e.forEach(function(e){"m"===e.type.toLowerCase()?(t=[e],n.push(t)):"z"!==e.type.toLowerCase()&&t.push(e)}),[]);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;0<n;n--){var r=e[n],t={type:r.type};void 0!==r.x2&&void 0!==r.y2?(t.x1=r.x2,t.y1=r.y2,t.x2=r.x1,t.y2=r.y1):void 0!==r.x1&&void 0!==r.y1&&(t.x1=r.x1,t.y1=r.y1),t.x=e[n-1].x,t.y=e[n-1].y,i.push(t)}}),i}(d.path.commands)),d.path.commands.forEach(function(e){"c"===e.type.toLowerCase()&&(e.type="b"),c.o+=e.type.toLowerCase()+" ",void 0!==e.x&&void 0!==e.y&&(c.o+=r(e.x*a)+" "+r(e.y*a)+" "),void 0!==e.x1&&void 0!==e.y1&&(c.o+=r(e.x1*a)+" "+r(e.y1*a)+" "),void 0!==e.x2&&void 0!==e.y2&&(c.o+=r(e.x2*a)+" "+r(e.y2*a)+" ")}),i[String.fromCodePoint(d.unicode)]=c)}return{glyphs:i,familyName:t.getEnglishName("fullName"),ascender:r(t.tables.os2.sTypoAscender*a),descender:r(t.tables.os2.sTypoDescender*a),lineGap:t.tables.os2.sTypoLineGap*a,underlinePosition:t.tables.post.underlinePosition,underlineThickness:t.tables.post.underlineThickness,boundingBox:{xMin:t.tables.head.xMin*a,xMax:t.tables.head.xMax*a,yMin:t.tables.head.yMin*a,yMax:t.tables.head.yMax*a},resolution:1e3,original_font_information:t.tables.name}}}class Kv extends Rd{constructor(e){super(e),this.type=Mt}parse(e){var i,a,n=-1,_=1,r=2,x=3,y=4,b=function(e,t){switch(e){case _:console.error("RGBELoader Read Error: "+(t||""));break;case r:console.error("RGBELoader Write Error: "+(t||""));break;case x:console.error("RGBELoader Bad File Format: "+(t||""));break;default:console.error("RGBELoader: Error: "+(t||""))}return n},l=1,c=2,u=4,d="\n",h=function(e,t,n){t=t||1024;for(var r=e.pos,i=-1,a=0,o="",s=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));(i=s.indexOf(d))<0&&a<t&&r<e.byteLength;)o+=s,a+=s.length,r+=128,s+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));return-1<i&&(!1!==n&&(e.pos+=a+i+1),o+s.slice(0,i))},t=(i=new Float32Array(1),a=new Int32Array(i.buffer),function(e,t,n,r){var i=e[t+3],i=Math.pow(2,i-128)/255;n[r+0]=o(e[t+0]*i),n[r+1]=o(e[t+1]*i),n[r+2]=o(e[t+2]*i)});function o(e){i[0]=e;var e=a[0],t=e>>16&32768,n=e>>12&2047,r=e>>23&255;return r<103?t:142<r?31744|t|((255==r?0:1)&&8388607&e):r<113?t|((n|=2048)>>114-r)+(n>>113-r&1):(t|r-112<<10|n>>1)+(1&n)}var s,p,f,m,v,e=new Uint8Array(e),g=(e.pos=0,function(e){var t,n,r=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,i=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,a=/^\s*FORMAT=(\S+)\s*$/,o=/^\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};if(e.pos>=e.byteLength||!(t=h(e)))return b(_,"no header found");if(!(n=t.match(/^#\?(\S+)$/)))return b(x,"bad initial token");for(s.valid|=l,s.programtype=n[1],s.string+=t+"\n";;){if(!1===(t=h(e)))break;if(s.string+=t+"\n","#"===t.charAt(0))s.comments+=t+"\n";else if((n=t.match(r))&&(s.gamma=parseFloat(n[1],10)),(n=t.match(i))&&(s.exposure=parseFloat(n[1],10)),(n=t.match(a))&&(s.valid|=c,s.format=n[1]),(n=t.match(o))&&(s.valid|=u,s.height=parseInt(n[1],10),s.width=parseInt(n[2],10)),s.valid&c&&s.valid&u)break}return s.valid&c?s.valid&u?s:b(x,"missing image size specifier"):b(x,"missing format specifier")}(e));if(n!==g){var M=g.width,A=g.height,w=function(e,t,n){var r,i,a,o,s,l,c,u,d,h,p,f,m,v=t,g=n;if(v<8||32767<v||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(v!==(e[2]<<8|e[3]))return b(x,"wrong scanline width");if(!(r=new Uint8Array(4*t*n))||!r.length)return b(y,"unable to allocate buffer space");for(a=i=0,u=4*v,m=new Uint8Array(4),l=new Uint8Array(u);0<g&&a<e.byteLength;){if(a+4>e.byteLength)return b(_);if(m[0]=e[a++],m[1]=e[a++],m[2]=e[a++],m[3]=e[a++],2!=m[0]||2!=m[1]||(m[2]<<8|m[3])!=v)return b(x,"bad rgbe scanline format");for(c=0;c<u&&a<e.byteLength;){if((f=128<(o=e[a++]))&&(o-=128),0===o||u<c+o)return b(x,"bad scanline data");if(f)for(s=e[a++],d=0;d<o;d++)l[c++]=s;else l.set(e.subarray(a,a+o),c),c+=o,a+=o}for(h=v,d=0;d<h;d++)r[i]=l[d+(p=0)],p+=v,r[i+1]=l[d+p],p+=v,r[i+2]=l[d+p],p+=v,r[i+3]=l[d+p],i+=4;g--}return r}(e.subarray(e.pos),M,A);if(n!==w){switch(this.type){case Mt:var S=w,T=F,C=Mt;break;case At:for(var E=w.length/4*3,L=new Float32Array(E),R=0;R<E;R++)f=L,m=3*R,v=void 0,v=(s=w)[(p=4*R)+3],v=Math.pow(2,v-128)/255,f[m+0]=s[p+0]*v,f[m+1]=s[p+1]*v,f[m+2]=s[p+2]*v;S=L,T=wt,C=At;break;case je:for(var E=w.length/4*3,P=new Uint16Array(E),R=0;R<E;R++)t(w,4*R,P,3*R);S=P,T=wt,C=je;break;default:console.error("v3d.RGBELoader: unsupported type: ",this.type)}return{width:M,height:A,data:S,header:g.string,gamma:g.gamma,exposure:g.exposure,format:T,type:C}}}return null}setDataType(e){return this.type=e,this}load(e,n,t,r){return Rd.prototype.load.call(this,e,function(e,t){switch(e.type){case Mt:e.encoding=sn,e.minFilter=dt,e.magFilter=dt,e.generateMipmaps=!1,e.flipY=!0;break;case At:case je:e.encoding=an,e.minFilter=ht,e.magFilter=ht,e.generateMipmaps=!1,e.flipY=!0}n&&n(e,t)},t,r)}}const Jv=new g,$v=new gt,eg=new vt,tg=new vt,ng=new mt;class rg extends he{constructor(){super(),this.type="PlaneReflectionProbe",this.influenceDistance=1,this.falloff=.5,this.probeClipStart=.1,this.planeSize=new Be(1,1),this.qualityFactor=.75,this.visibilityGroup=null,this.visibilityGroupInv=!1,this.reflectorPlane=new xa,this.normal=new vt,this.reflectorWorldPosition=new vt,this.cameraWorldPosition=new vt,this.rotationMatrix=new gt,this.lookAtPosition=new vt(0,0,-1),this.clipPlane=new mt,this.view=new vt,this.target=new vt,this.textureMatrix=new gt,this.virtualCamera=new da;var e={minFilter:ht,magFilter:ht,format:wt,encoding:on};this.renderTarget=new ze(1024,1024,e),this.matrixWorldInverse=new gt,this.boundingBox=new g}_calcLocalBounding(){var e=eg.setScalar(0),t=tg.set(2*this.planeSize.x,2*this.influenceDistance/this.scale.y,2*this.planeSize.y);this.boundingBox.setFromCenterAndSize(e,t)}makeMultisampleRenderTarget(e){const t=this.renderTarget;t.samples=e,this.renderTarget=new Yn(t.width,t.height),this.renderTarget.copy(t),t.dispose()}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,r=n.boundsTree,i=$v;try{i.copy(e.matrixWorld).invert()}catch(e){return!1}return i.multiply(this.matrixWorld),Jv.copy(this.boundingBox),t=r?r.intersectsBox(e,Jv,i):(Jv.applyMatrix4(i),null===n.boundingBox&&n.computeBoundingBox(),n.boundingBox.intersectsBox(Jv))}update(e,t,n){const r={},i=(e.traverse(e=>{!e.isPlaneReflectionProbe&&this._isVisible(e)||(r[e.id]=e.layers.mask,e.layers.disableAll())}),this.reflectorWorldPosition),a=(i.setFromMatrixPosition(this.matrixWorld),this.cameraWorldPosition),o=(a.setFromMatrixPosition(t.matrixWorld),this.rotationMatrix),s=(o.extractRotation(this.matrixWorld),this.normal),l=(s.set(0,1,0),s.applyMatrix4(o),this.view);if(l.subVectors(i,a),0<l.dot(s))e.traverse(e=>{!e.isPlaneReflectionProbe&&this._isVisible(e)||(e.layers.mask=r[e.id])});else{l.reflect(s).negate(),l.add(i),o.extractRotation(t.matrixWorld);const h=this.lookAtPosition,p=(h.set(0,0,-1),h.applyMatrix4(o),h.add(a),this.target),f=(p.subVectors(i,h),p.reflect(s).negate(),p.add(i),this.virtualCamera),m=(f.position.copy(l),f.up.set(0,1,0),f.up.applyMatrix4(o),f.up.reflect(s),f.lookAt(p),f.far=t.far,f.updateMatrixWorld(),f.projectionMatrix),v=(m.copy(t.projectionMatrix),this.textureMatrix),g=(v.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),v.multiply(m),v.multiply(f.matrixWorldInverse),this.reflectorPlane),_=(g.setFromNormalAndCoplanarPoint(s,i),g.applyMatrix4(f.matrixWorldInverse),this.clipPlane);_.set(g.normal.x,g.normal.y,g.normal.z,g.constant),ng.x=(Math.sign(_.x)+m.elements[8])/m.elements[0],ng.y=(Math.sign(_.y)+m.elements[9])/m.elements[5],ng.z=-1,ng.w=(1+m.elements[10])/m.elements[14],_.multiplyScalar(2/_.dot(ng)),m.elements[2]=_.x,m.elements[6]=_.y,m.elements[10]=_.z+1-this.probeClipStart,m.elements[14]=_.w;var c=n.getRenderTarget(),u=n.xr.enabled,d=n.shadowMap.autoUpdate,u=(n.xr.enabled=!1,n.shadowMap.autoUpdate=!1,n.setRenderTarget(this.renderTarget),n.state.buffers.depth.setMask(!0),!1===n.autoClear&&n.clear(),n.render(e,f),n.xr.enabled=u,n.shadowMap.autoUpdate=d,n.setRenderTarget(c),t.viewport);void 0!==u&&n.state.viewport(u),e.traverse(e=>{!e.isPlaneReflectionProbe&&this._isVisible(e)||(e.layers.mask=r[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){return null===this.visibilityGroup||(!e.isMesh||-1!==e.groupNames.indexOf(this.visibilityGroup)^this.visibilityGroupInv)}}rg.prototype.isPlaneReflectionProbe=!0;var ig={init:function(e,t){void 0!==e&&void 0!==t||console.error("RectAreaLightUniformsLib: Missing LTC data (required in Verge3D)");var n=new Float32Array(e),r=new Float32Array(t);O.LTC_FLOAT_1=new El(n,64,64,pt,At,s,ut,ut,ht,dt,1),O.LTC_FLOAT_2=new El(r,64,64,pt,At,s,ut,ut,ht,dt,1);const i=new Uint16Array(e.length),a=(e.forEach(function(e,t){i[t]=Sp.toHalfFloat(e)}),new Uint16Array(t.length));t.forEach(function(e,t){a[t]=Sp.toHalfFloat(e)}),O.LTC_HALF_1=new El(i,64,64,pt,je,s,ut,ut,ht,dt,1),O.LTC_HALF_2=new El(a,64,64,pt,je,s,ut,ut,ht,dt,1)}};const ag=new vt,og=new vt;class sg extends he{constructor(){super(),this.type="ClippingPlaneObject",this.plane=new xa,this.clippingGroup=null,this.clipShadows=!1,this.negated=!1,this.clipIntersection=!1,this.crossSection=!1,this.crossSectionColor=new _t(16711680),this.crossSectionOpacity=1,this.crossSectionRenderSide=Ve,this.crossSectionSize=100,this._crossMatProfile="blender"}updatePlane(){this.updateWorldMatrix(!0,!1),this.getWorldPosition(ag);var e=this.matrixWorld.elements;og.set(e[4],e[5],e[6]).normalize(),this.plane.setFromNormalAndCoplanarPoint(og,ag),this.negated&&this.plane.negate()}updateMatrixWorld(e){he.prototype.updateMatrixWorld.call(this,e),this.updatePlane()}needsClippingPlane(e){return e.isMesh&&(0<=e.groupNames.indexOf(this.clippingGroup)||null===this.clippingGroup)&&!e.isAuxClippingMesh}assignToObject(n,r=0){var i=this.plane;const a=n.material;var o=n.geometry;if(a.clippingPlanes=a.clippingPlanes||[],-1==a.clippingPlanes.indexOf(i)&&a.clippingPlanes.push(i),a.clipShadows=this.clipShadows,a.clipIntersection=this.clipIntersection,this.crossSection){this.cleanupAuxMeshes(n);const u=new fi;u.depthWrite=!1,u.depthTest=!1,u.colorWrite=!1,u.stencilWrite=!0,u.stencilFunc=519,u.clipShadows=this.clipShadows,u.clipIntersection=this.clipIntersection;var s=!!n.isSkinnedMesh,l=n.morphTargetInfluences,c=xt(l)&&0<l.length;c&&(u.morphTargets=!0,u.morphNormals=xt(o.morphAttributes.normal));const d=u.clone();d.name="ClipCrossSectionStencilBack",d.side=Fe,d.clippingPlanes=[i],d.stencilFail=pn,d.stencilZFail=pn,d.stencilZPass=pn;let e;s?(e=new Tl(o,d)).skeleton=n.skeleton:e=new ee(o,d),e.renderOrder=r,e.name="ClipCrossSectionStencilBack",e.isAuxClippingMesh=!0,c&&(e.morphTargetInfluences=l.slice()),n.add(e);const h=u.clone();h.name="ClipCrossSectionStencilFront",h.side=Ve,h.clippingPlanes=[i],h.stencilFail=fn,h.stencilZFail=fn,h.stencilZPass=fn;let t;s?(t=new Tl(o,h)).skeleton=n.skeleton:t=new ee(o,h),t.renderOrder=r+.1,t.name="ClipCrossSectionStencilFront",t.isAuxClippingMesh=!0,c&&(t.morphTargetInfluences=l.slice()),n.add(t),a.isMeshNodeMaterial&&(this._crossMatProfile=a.profile)}}createCrossSectionPlane(e,t){this.cleanupAuxMeshes();const n=new cd({name:"ClipCrossSectionColor",nodeGraph:cd.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:7681,stencilZFail:7681,stencilZPass:7681,side:this.crossSectionRenderSide}),r=(this.crossSectionOpacity<1&&(n.transparent=!0,n.premultipliedAlpha=!0,n.blending=J,n.blendEquation=$,n.blendSrc=xe,n.blendDst=Ae),new Sa(this.crossSectionSize,this.crossSectionSize)),i=(this.negated?r.rotateX(-Math.PI/2):r.rotateX(Math.PI/2),new ee(r,n));i.name="ClipCrossSectionColor",i.isAuxClippingMesh=!0,i.renderOrder=t,i.onAfterRender=function(e){e.clearStencil()},this.add(i)}cleanupAuxMeshes(t=null){if(t)for(let e=t.children.length-1;0<=e;e--){const n=t.children[e];n.isAuxClippingMesh&&n.material.clippingPlanes[0]==this.plane&&(n.geometry.dispose(),n.material.dispose(),t.remove(n))}else for(let e=this.children.length-1;0<=e;e--){const r=this.children[e];r.isAuxClippingMesh&&(r.geometry.dispose(),r.material.dispose(),this.remove(r))}}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}}sg.prototype.isClippingPlaneObject=!0;class lg{constructor(e="ORBIT",t=!0,n=1,r=1){this.type=e,this.enablePan=t,this.enableKeys=!0,this.rotateSpeed=n,this.moveSpeed=r,this.orbitMinDistance=0,this.orbitMaxDistance=1/0,this.orbitMinZoom=0,this.orbitMaxZoom=1/0,this.orbitMinPolarAngle=0,this.orbitMaxPolarAngle=Math.PI,this.orbitMinAzimuthAngle=-1/0,this.orbitMaxAzimuthAngle=1/0,this.orbitTarget=null,this.collisionMaterial=null,this.gazeLevel=1.8,this.storyHeight=3,this.enablePointerLock=!1}copy(e){return this.type=e.type,this.enablePan=e.enablePan,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.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){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;break;case"FLYING":e.panSpeedTouch*=this.moveSpeed,e.zoomSpeedKey*=this.moveSpeed;break;case"FIRST_PERSON":e.gazeLevel=this.gazeLevel,e.storyHeight=this.storyHeight,e.zoomSpeedKey*=this.moveSpeed,e.enablePointerLock=this.enablePointerLock;break;default:return void console.error("ControlSettings: unsupported control type")}e.enablePan=this.enablePan,e.enableKeys=this.enableKeys,e.rotateSpeed*=this.rotateSpeed,e.rotateSpeedTouch*=this.rotateSpeed,e.panSpeed*=this.moveSpeed,e.panSpeedKey*=this.moveSpeed,e.zoomSpeed*=this.moveSpeed,e.zoomSpeedTouch*=this.moveSpeed}}const cg=["IMAGE_AR","SKYDOME_LIGHT_AR","TEXTURE_BL","TEX_IMAGE_BL","TEX_ENVIRONMENT_BL","BITMAP_MX","BITMAP_ENV_MX","TEX_ENVIRONMENT_MX","REFLECT_REFRACT_MX","FILE_MY","TEXTURE","TEX_IMAGE","TEX_ENVIRONMENT","TEX_ENVIRONMENT_MAX","BITMAP_MAX","BITMAP_ENV_MAX","REFLECT_REFRACT_MAX","AI_SKYDOME_LIGHT_MY","OSL_NODE"];class ug extends Sd{constructor(e){super(e),this.onProgress=null}load(e,t,n,r){const i=this,a=(i.onProgress=n||function(){},this.path&&"string"==typeof this.path?this.path:eh.extractUrlBase(e)),o=-1!=e.indexOf(".xz",e.length-3);let s;o?s=new qv(i.manager):(s=new Cd(i.manager)).setResponseType("arraybuffer");const l=function(e){i.onProgress&&i.onProgress(.3*e*100)};let c=l;s instanceof Cd&&(c=function(e){e=e.lengthComputable?e.loaded/e.total:1;l(e)}),s.load(e,function(e){i.parse(e,a,t,r,o)},c,r)}setPath(e){this.path=e}parse(e,t,o,n,r){const s=this;let i;const a={};var l=Lg(new Uint8Array(e,0,4)),l=(i=l===fg?(a[b.KHR_BINARY_GLTF]=new vg(e),a[b.KHR_BINARY_GLTF].content):Lg(new Uint8Array(e)),JSON.parse(i));if(void 0===l.asset||l.asset.version[0]<2)n(new Error("v3d.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));else{const c=l.asset.generator||"";if(-1<c.indexOf("Verge3D")&&"ALL"!=_n){const d=[["Blender","BLENDER"],["3ds Max","MAX"],["Maya","MAYA"]];d.forEach(function(e){var t=e[0],e=e[1];-1<c.indexOf(t)&&_n!=e&&console.warn("The glTF asset was exported from "+t+". It may not be fully compatible with Verge3D "+Li()+".")})}const u=new Ng(l,a,{path:t||this.path,crossOrigin:this.crossOrigin,loadBinXZ:r,manager:this.manager,onProgress:function(e){s.onProgress&&s.onProgress(e)}});u.parse(function(e,t,n,r,i,a){e={scene:e,scenes:t,world:n,cameras:r,animations:i,renderer:a};s.onProgress&&s.onProgress(100),o(e)},n)}}}function dg(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const b={KHR_BINARY_GLTF:"KHR_binary_glTF",S8S_V3D_ANIMATION_DATA:"S8S_v3d_animation_data",S8S_V3D_DATA:"S8S_v3d_data",S8S_V3D_CAMERA_DATA:"S8S_v3d_camera_data",S8S_V3D_MATERIAL_DATA:"S8S_v3d_material_data",S8S_V3D_MESH_DATA:"S8S_v3d_mesh_data",S8S_V3D_NODE_DATA:"S8S_v3d_node_data",S8S_V3D_SCENE_DATA:"S8S_v3d_scene_data",S8S_V3D_TEXTURE_DATA:"S8S_v3d_texture_data"};class hg{constructor(e){this.parser=e,this.name=b.S8S_V3D_DATA;var t,n=e.json,e=e.getExt(n,b.S8S_V3D_DATA)||{},r=(this.lights={},e.lights||{});for(t in r){const c=r[t];let e;var i=(new _t).fromArray(c.color),a=c.intensity;switch(c.type){case"point":e=new Wd(i,a);break;case"directional":e=new Yd(i,a),xt(c.shadow)&&xt(c.shadow.csm)&&(e.shadow=new Xd);break;case"spot":e=new zd(i,a);break;case"area":e=new Qd(i,a,c.width,c.height);break;case"hemisphere":e=new Fd(i,new _t(0,0,0),a);break;case"ambient":e=new Zd(i,a)}e&&(xt(c.distance)&&(e.distance=c.distance),xt(c.decay)&&(e.decay=c.decay,"blender"==c.profile&&(e.userData.usePowerUnits=!0,e.power=e.intensity)),xt(c.angle)&&(e.angle=c.angle),xt(c.penumbra)&&(e.penumbra=c.penumbra),e.isRectAreaLight&&ig.init(c.ltcMat1,c.ltcMat2),xt(c.shadow)?(xt(c.shadow.enabled)||(c.shadow.enabled=!0),e.castShadow=c.shadow.enabled,e.shadow.bias=c.shadow.bias,xt(c.shadow.expBias)&&(e.shadow.expBias=c.shadow.expBias),xt(c.shadow.slopeScaledBias)&&(e.shadow.slopeScaledBias=c.shadow.slopeScaledBias),e.shadow.radius=c.shadow.radius,e.shadow.mapSize.width=c.shadow.mapSize,e.shadow.mapSize.height=c.shadow.mapSize,e.shadow.camera.near=c.shadow.cameraNear,e.shadow.camera.far=c.shadow.cameraFar,e.isSpotLight?(e.shadow.camera.fov=Ln(c.shadow.cameraFov),e.shadow.useMinFov90="blender"===c.profile):e.isDirectionalLight&&(xt(c.shadow.cameraOrthoLeft)&&xt(c.shadow.cameraOrthoRight)&&xt(c.shadow.cameraOrthoBottom)&&xt(c.shadow.cameraOrthoTop)&&(e.shadow.camera.left=c.shadow.cameraOrthoLeft,e.shadow.camera.right=c.shadow.cameraOrthoRight,e.shadow.camera.bottom=c.shadow.cameraOrthoBottom,e.shadow.camera.top=c.shadow.cameraOrthoTop),e.shadow.isDirectionalLightShadowCSM&&(e.shadow.maxDistance=c.shadow.csm.maxDistance)),e.shadow.camera.updateProjectionMatrix()):e.castShadow=!1,e.name=c.name||"light_"+t,this.lights[t]=e)}this.nodeGraphs={};var o,s=e.nodeGraphs||[];for(o in s){var l=s[o];this.nodeGraphs[o]=l}}loadCurve(i,a){const o=this.parser;var e=o.json,e=o.getExt(e,b.S8S_V3D_DATA);const s=e.curves[i];let t=!1,l=!1,c;if("number"==typeof s.font){const n=e.fonts[s.font];c=n.uri,void 0!==n.bufferView&&(c=o.getDependency("bufferView",n.bufferView).then(function(e){l=!0;e=new Blob([e],{type:n.mimeType});return c=URL.createObjectURL(e)}))}else t=!0,c=s.font;return Promise.resolve(c).then(function(n){if(t)return new ch(n);if("undefined"==typeof opentype)return null;const r=new Qv;return r.setCrossOrigin(o.options.crossOrigin),new Promise(function(e,t){r.load(Eg(n,o.options.path),e,void 0,t)}).then(function(e){return new ch(e)},function(e){return null})}).then(function(t){!0===l&&URL.revokeObjectURL(c);let e=s.type;null===t&&(e="empty");let n;if("font"===e){var r=0<s.bevelSize||0<s.bevelThickness,t=new du(s.text,{font:t,size:s.size,height:s.height,curveSegments:s.curveSegments,bevelEnabled:r,bevelThickness:s.bevelThickness,bevelSize:s.bevelSize,bevelSegments:s.bevelSegments,alignX:s.alignX,alignY:s.alignY,lineHeight:s.lineHeight,scaledEmSize:s.scaledEmSize});let e;e=a&&a[s.material]?a[s.material]:new bu({color:new _t(.8,.8,.8)}),n=new ee(t,e)}else n=new he;return n.name=s.name||"curve_"+i,n})}}class pg{constructor(e){this.name=b.S8S_V3D_MATERIAL_DATA}extendParams(t,e,n){e=e.extensions[this.name];const r=[];if(xt(e.nodeGraph)){var i,a=e.nodeGraph;t.nodeGraph=cd.nodeGraphFromExtGraph(a);for(let e=0;e<a.nodes.length;e++){const d=a.nodes[e];-1<cg.indexOf(d.type)&&xt(d.texture)?(i=cd.nodeTexUniName(d.type,d.texture),r.push(n.assignTextureNode(t,i,d.texture))):"RAMP_MY"==d.type&&(d.wrapS=yg[d.wrapS]||U,d.wrapT=yg[d.wrapT]||U)}var o=n.extensions[b.S8S_V3D_DATA];if(o)for(var s in t.additionalNodeGraphs={},o.nodeGraphs){var l=o.nodeGraphs[s];t.additionalNodeGraphs[s]=cd.nodeGraphFromExtGraph(l);for(let e=0;e<l.nodes.length;e++){var c,u=l.nodes[e];-1<cg.indexOf(u.type)&&(c=cd.nodeTexUniName(u.type,u.texture),r.push(n.assignTextureNode(t,c,u.texture)))}}}return xt(e.profile)&&(t.profile=e.profile),xt(e.renderSide)&&(t.side=Tg[e.renderSide]),xt(e.useShadows)&&(t.receiveShadow=e.useShadows),xt(e.useCastShadows)&&(t.castShadow=e.useCastShadows),xt(e.depthWrite)&&(t.depthWrite=e.depthWrite),xt(e.depthTest)&&(t.depthTest=e.depthTest),xt(e.dithering)&&(t.dithering=e.dithering),xt(e.materialIndex)&&(t.materialIndex=e.materialIndex),Promise.all(r)}}const fg="glTF",mg={JSON:1313821514,BIN:5130562};class vg{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:Lg(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==fg)throw new Error("v3d.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("v3d.GLTFLoader: Legacy binary file detected. Use GLTFLoader instead.");const n=new DataView(e,12);let r=0;for(;r<n.byteLength;){var i,a=n.getUint32(r,!0),o=(r+=4,n.getUint32(r,!0));r+=4,o===mg.JSON?(i=new Uint8Array(e,12+r,a),this.content=Lg(i)):o===mg.BIN&&(i=12+r,this.body=e.slice(i,i+a)),r+=a}if(null===this.content)throw new Error("v3d.GLTFLoader: JSON content not found.")}}const gg={FLOAT:5126,FLOAT_MAT3:35675,const: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},_g={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},xg={9728:dt,9729:ht,9984:1004,9985:1007,9986:1005,9987:1008},yg={33071:ut,33648:G,10497:U},bg={32774:$,32778:ue,32779:me},Mg={0:_e,1:xe,768:ye,769:be,770:Me,771:Ae,772:we,773:Se,774:Te,775:Ce,776:Ee},Ag={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},wg={CATMULLROMSPLINE:en,CUBICSPLINE:en,LINEAR:$t,STEP:Jt},Sg={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"},Tg={FRONT:Ve,BACK:Fe,DOUBLE:Ue};function Cg(t,n,r){if(!t)return Promise.resolve();let i;const a=[];if("[object Array]"===Object.prototype.toString.call(t)){i=[];var o=t.length;for(let e=0;e<o;e++){const s=n.call(r||this,t[e],e);s&&(a.push(s),s instanceof Promise?s.then(function(e,t){i[e]=t}.bind(this,e)):i[e]=s)}}else for(var e in i={},t)if(t.hasOwnProperty(e)){const l=n.call(r||this,t[e],e);l&&(a.push(l),l instanceof Promise?l.then(function(e,t){i[e]=t}.bind(this,e)):i[e]=l)}return Promise.all(a).then(function(){return i})}function Eg(e,t){return"string"!=typeof e||""===e?"":/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:(t||"")+e}function Lg(n){if(void 0!==window.TextDecoder)return(new TextDecoder).decode(n);let r="";for(let e=0,t=n.length;e<t;e++)r+=String.fromCharCode(n[e]);return r}function Rg(e,t){return xt(e.attributes.color)&&!t.isMeshNodeMaterial}function Pg(e){return void 0===e.attributes.normal}function Ig(e,t,n,r){var i=Rg(e,t),e=Pg(e),a=t.isMeshNodeMaterial&&(t.nodeValue.length||t.nodeRGB.length),o=t.morphTargets,s=t.isMeshNodeMaterial&&t.hasNode("TEX_COORD_BL"),n=t.isMeshNodeMaterial&&0<Object.getOwnPropertyNames(n).length&&t.hasNode("UVMAP_BL"),r=t.isMeshNodeMaterial&&0<Object.getOwnPropertyNames(r).length&&(t.hasNode("ATTRIBUTE_BL")||t.hasNode("VERTEX_COLOR_BL"));return i||e||a||o||s||n||r}class Ng{constructor(e,t,n){this.json=e||{},this.extensions=t||{},this.options=n||{},this.onProgress=n.onProgress||function(){},this.cache=new dg,this.clonedResources={materials:[]},e.extensionsUsed&&(0<=e.extensionsUsed.indexOf(b.S8S_V3D_DATA)&&(t[b.S8S_V3D_DATA]=new hg(this)),0<=e.extensionsUsed.indexOf(b.S8S_V3D_MATERIAL_DATA)&&(t[b.S8S_V3D_MATERIAL_DATA]=new pg(e)))}_withDependencies(t){const n=this,r={};for(let e=0;e<t.length;e++){const a=t[e],o="load"+a.charAt(0).toUpperCase()+a.slice(1);var i=n.cache.get(a);void 0!==i?r[a]=i:n[o]&&(i=new Promise(function(e){e(o)}).then(function(e){return n[e]()}),n.cache.add(a,i),r[a]=i)}return Cg(r,function(e){return e})}parse(p,e){const f=this,m=this.json;this.cache.removeAll(),this._withDependencies(["scenes","nodes","materials","cameras","animations","clonedMaterials"]).then(function(r){const t=[];r.scenes=r.scenes||[];for(let e=0;e<r.scenes.length;e++)t.push(r.scenes[e]);var e,n=xt(m.scene)?m.scenes[m.scene]:m.scenes[0];const i=xt(m.scene)?r.scenes[m.scene]:t[0],a={},o=(!n||(e=f.getExt(n,b.S8S_V3D_SCENE_DATA))&&xt(e.worldMaterial)&&(a.material=r.materials[e.worldMaterial]),r.materials=r.materials||[],[].concat(r.materials,r.clonedMaterials)),s=(o.forEach(function(n){n.isMeshNodeMaterial&&n.traverseNodes(function(e){var t;"TEX_COORD_BL"===e.originData.type&&(t=r.nodes[e.originData.object])&&(e=n.nodeTexCoordObjectMap[e.originData.name],n.nodeTexCoordObject[e]=t)})}),[]);r.cameras=r.cameras||[];for(let e=0;e<r.cameras.length;e++){const d=r.cameras[e];let t=!1;d.traverseAncestors(function(e){e==i&&(t=!0)}),t&&s.push(d)}const l=[];r.animations=r.animations||[];for(let e=0;e<r.animations.length;e++){const h=r.animations[e];h.clip&&void 0!==h.clip.name&&(h.clip.name=h.clip.name),l.push(h)}const c={};if(n){var u=f.getExt(n,b.S8S_V3D_SCENE_DATA);if(u){if(xt(u.shadowMap)){switch(c.shadowMap={enabled:!0},u.shadowMap.type){case"BASIC":c.shadowMap.type=te;break;case"BILINEAR":c.shadowMap.type=le;break;case"PCF":c.shadowMap.type=ne;break;case"PCFSOFT":c.shadowMap.type=ie;break;case"PCFPOISSON":c.shadowMap.type=se;break;case"ESM":c.shadowMap.type=oe}let n;n=u.shadowMap.renderSingleSided?u.shadowMap.renderReverseSided?Fe:Ve:Ue,i.traverse(function(e){const t=e.material;t&&(t.shadowSide=n)}),c.esmDistanceScale=u.shadowMap.esmDistanceScale}if(xt(u.physicallyCorrectLights)&&(c.physicallyCorrectLights=u.physicallyCorrectLights),xt(u.aaMethod)&&(c.aaMethod=u.aaMethod),xt(u.useHDR)&&(c.useHDR=u.useHDR),xt(u.unitsScaleFactor)?c.unitsScaleFactor=u.unitsScaleFactor:c.unitsScaleFactor=1,xt(u.toneMapping))switch(u.toneMapping.type){case"logarithmicMax":c.toneMapping=6,c.toneMappingBrightness=u.toneMapping.brightness,c.toneMappingContrast=u.toneMapping.contrast,c.toneMappingMidTones=u.toneMapping.midTones,c.toneMappingPhysicalScale=u.toneMapping.physicalScale,c.toneMappingChromaticAdaptation=u.toneMapping.chromaticAdaptation,c.toneMappingWhiteColor=(new _t).fromArray(u.toneMapping.whiteColor),c.toneMappingColorDifferentiation=u.toneMapping.colorDifferentiation,c.toneMappingExteriorDaylight=u.toneMapping.exteriorDaylight;break;case"physicalMax":c.toneMapping=7,c.toneMappingWhiteBalance=(new _t).fromArray(u.toneMapping.whiteBalance),c.toneMappingHighlights=u.toneMapping.highlights,c.toneMappingMidTones=u.toneMapping.midTones,c.toneMappingShadows=u.toneMapping.shadows,c.toneMappingSaturation=u.toneMapping.saturation,c.toneMappingPhysicalScale=u.toneMapping.physicalScale,c.toneMappingAperture=u.toneMapping.aperture,c.toneMappingShutter=u.toneMapping.shutter,c.toneMappingISO=u.toneMapping.iso,c.toneMappingVignetting=u.toneMapping.vignetting;break;case"filmicBlender":c.toneMapping=8}if(xt(u.pmremMaxTileSize)&&(c.pmremMaxTileSize=u.pmremMaxTileSize),xt(u.iblEnvironmentMode))switch(u.iblEnvironmentMode){case"PMREM":c.iblEnvironmentMode=0;break;case"PROBE_CUBEMAP":c.iblEnvironmentMode=1;break;case"PROBE":c.iblEnvironmentMode=2;break;default:c.iblEnvironmentMode=0}}}p(i,t,a,s,l,c)}).catch(e)}getDependency(e,t){const n=this;var r=e+":"+t;let i=n.cache.get(r);if(!i){const a="load"+e.charAt(0).toUpperCase()+e.slice(1);i=new Promise(function(e){e()}).then(function(){return n[a](t)}),n.cache.add(r,i)}return i}loadBuffer(e){const a=this,o=this.json.buffers[e];if(o.type&&"arraybuffer"!==o.type)throw new Error("v3d.GLTFLoader: %s buffer type is not supported.",o.type);if(void 0===o.uri&&0===e)return Promise.resolve(this.extensions[b.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(e){let t,n;s.loadBinXZ?(t=Eg(o.uri,s.path)+".xz",n=new qv):(t=Eg(o.uri,s.path),(n=new Cd).setResponseType("arraybuffer"));function r(e){a.onProgress&&(e=100*(.3+.7*e),a.onProgress(e))}let i=r;n instanceof Cd&&(i=function(e){e=e.lengthComputable?e.loaded/e.total:1;r(e)}),n.load(t,e,i)})}loadBufferView(e){const r=this.json.bufferViews[e];return this.getDependency("buffer",r.buffer).then(function(e){var t=r.byteLength||0,n=r.byteOffset||0;return e.slice(n,n+t)})}loadAccessors(){const e=this,l=this.json;return Cg(l.accessors,function(s){return e.getDependency("bufferView",s.bufferView).then(function(e){var t=Ag[s.type];const n=_g[s.componentType];var r=n.BYTES_PER_ELEMENT,i=r*t,a=l.bufferViews[s.bufferView].byteStride;let o;return a&&a!==i?(o=new n(e),i=new $s(o,a/r),new tl(i,t,s.byteOffset/r)):(o=new n(e,s.byteOffset,s.count*t),new re(o,t))})})}loadTexture(e){const t=this,n=this.json,a=this.options;this.extensions;const r=window.URL||window.webkitURL,i=n.textures[e],o=n.images[i.source];let s=o.uri,l=!1;const c=t.getExt(i,b.S8S_V3D_TEXTURE_DATA);let u,d=(u=c&&("linear"==c.colorSpace||"non-color"==c.colorSpace)?an:on,!0);return"image/jpeg"===o.mimeType&&(d=!1),void 0!==o.bufferView&&(s=this.getDependency("bufferView",o.bufferView).then(function(e){"image/png"===o.mimeType&&(d=6===new DataView(e,25,1).getUint8(0,!1)),l=!0;e=new Blob([e],{type:o.mimeType});return s=r.createObjectURL(e)})),Promise.resolve(s).then(function(r){"hdr"!=r.split(".").pop()&&"image/vnd.radiance"!=o.mimeType||(u=sn);let i=t.options.manager.getHandler(r);return(i=i||new(u==sn?Kv:Pd)).setCrossOrigin(a.crossOrigin),new Promise(function(e,t){const n=i.load(Eg(r,a.path),e,void 0,function(e){t(n)})}).then(function(e){return e},function(e){return e})}).then(function(e){!0===l&&r.revokeObjectURL(s),e.flipY=!1,void 0!==i.name&&(e.name=i.name),d||(e.format=wt);var t=(n.samplers||{})[i.sampler]||{};return e.magFilter=xg[t.magFilter]||ht,e.minFilter=xg[t.minFilter]||1008,e.wrapS=yg[t.wrapS]||U,e.wrapT=yg[t.wrapT]||U,(e.encoding=u)==sn&&(e.minFilter=ht,e.magFilter=ht),c&&(xt(c.anisotropy)&&(e.anisotropy=c.anisotropy),xt(c.uvTransform)&&(e.matrix=(new Un).fromArray(c.uvTransform),e.matrixAutoUpdate=!1)),e})}assignTexture(t,n,e){return this.getDependency("texture",e).then(function(e){t[n]=e})}assignTextureNode(t,n,e){return this.getDependency("texture",e).then(function(e){t.nodeTextures=t.nodeTextures||{},t.nodeTextures[n]=e})}loadMaterials(){const l=this;var e=this.json;const c=this.extensions;return Cg(e.materials,function(t){let n;const r={},e=[],i=l.getExt(t,b.S8S_V3D_MATERIAL_DATA);if(xt(t.pbrMetallicRoughness)?(n=bu,a=t.pbrMetallicRoughness,r.color=new _t(1,1,1),r.opacity=1,Array.isArray(a.baseColorFactor)&&(o=a.baseColorFactor,r.color.fromArray(o),r.opacity=o[3]),xt(a.baseColorTexture)&&e.push(l.assignTexture(r,"map",a.baseColorTexture.index)),r.metalness=xt(a.metallicFactor)?a.metallicFactor:1,r.roughness=xt(a.roughnessFactor)?a.roughnessFactor:1,xt(a.metallicRoughnessTexture)&&(o=a.metallicRoughnessTexture.index,e.push(l.assignTexture(r,"metalnessMap",o)),e.push(l.assignTexture(r,"roughnessMap",o))),xt(t.normalTexture)&&(e.push(l.assignTexture(r,"normalMap",t.normalTexture.index)),r.normalScale=new Be(1,1),xt(t.normalTexture.scale)&&r.normalScale.set(t.normalTexture.scale,t.normalTexture.scale)),xt(t.occlusionTexture)&&(e.push(l.assignTexture(r,"aoMap",t.occlusionTexture.index)),xt(t.occlusionTexture.strength)&&(r.aoMapIntensity=t.occlusionTexture.strength)),xt(t.emissiveFactor)&&(r.emissive=(new _t).fromArray(t.emissiveFactor)),xt(t.emissiveTexture)&&e.push(l.assignTexture(r,"emissiveMap",t.emissiveTexture.index))):n=i?cd:bu,i){const s=c[b.S8S_V3D_MATERIAL_DATA];e.push(s.extendParams(r,t,l))}!0===t.doubleSided&&(r.side=Ue);var a=t.alphaMode||Sg.OPAQUE,o=a!==Sg.OPAQUE,a=a===Sg.MASK;return r.premultipliedAlpha=o,r.transparent=o,r.alphaTest=a?xt(t.alphaCutoff)?t.alphaCutoff:.5:0,o&&(i&&xt(i.blendMode)?(a=i.blendMode,r.blending=J,xt(a.blendEquation)&&(r.blendEquation=bg[a.blendEquation]),xt(a.blendEquationAlpha)&&(r.blendEquationAlpha=bg[a.blendEquationAlpha]),xt(a.srcRGB)&&(r.blendSrc=Mg[a.srcRGB]),xt(a.dstRGB)&&(r.blendDst=Mg[a.dstRGB]),xt(a.srcAlpha)&&(r.blendSrcAlpha=Mg[a.srcAlpha]),xt(a.dstAlpha)&&(r.blendDstAlpha=Mg[a.dstAlpha])):l.assignDefaultBlending(r)),i&&!0===i.alphaToCoverage&&(r.alphaToCoverage=!0),i&&xt(i.gtaoVisible)&&(r.gtaoVisible=i.gtaoVisible),Promise.all(e).then(function(){const e=new n(r);return void 0!==t.name&&(e.name=t.name),t.extras&&(e.userData.v3d=t.extras),(t.pbrMetallicRoughness||e.isMeshNodeMaterial)&&e.envMap&&(e.envMap.mapping=P,e.envMap.flipY=!0),e.isMeshStandardMaterial&&(e.map&&(e.map.encoding=on),e.emissiveMap&&(e.emissiveMap.encoding=on),e.normalScale&&i&&xt(i.profile)&&"max"==i.profile&&(e.normalScale.y=-e.normalScale.y)),e})})}loadClonedMaterials(){const e=this;return this._withDependencies(["meshes","nodes"]).then(function(){return Promise.resolve(e.clonedResources.materials)})}loadGeometries(e){const s=this;return this._withDependencies(["accessors"]).then(function(o){return Cg(e,function(e){const t=new S;var n,r=e.attributes;for(n in r){var i=r[n];if(void 0===i)return;var a=o.accessors[i];switch(n){case"POSITION":t.setAttribute("position",a);break;case"NORMAL":t.setAttribute("normal",a);break;case"TEXCOORD_0":case"TEXCOORD0":case"TEXCOORD":t.setAttribute("uv",a);break;case"COLOR_0":case"COLOR0":case"COLOR":t.setAttribute("color",a);break;case"WEIGHTS_0":case"WEIGHT":t.setAttribute("skinWeight",a);break;case"JOINTS_0":case"JOINT":t.setAttribute("skinIndex",a);break;case"TANGENT":t.setAttribute("tangent",a);break;default:-1<n.indexOf("TEXCOORD_")&&t.setAttribute(s.texcoordToAttrName(n),a),-1<n.indexOf("COLOR_")&&t.setAttribute(s.colorToAttrName(n),a)}}return void 0!==e.indices&&t.setIndex(o.accessors[e.indices]),t})})}loadMeshes(){const L=this,e=this.json;return this._withDependencies(["accessors","materials"]).then(function(E){return Cg(e.meshes,function(A,w){const S=new Us,T=A.primitives||[],C=L.getExt(A,b.S8S_V3D_MESH_DATA);return L.loadGeometries(T).then(function(n){for(let t=0;t<T.length;t++){var r=T[t];const f=n[t];var i=void 0===r.material?new bu({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Ve,receiveShadow:!0,castShadow:!0}):E.materials[r.material];i.aoMap&&void 0===f.attributes.uv2&&void 0!==f.attributes.uv&&f.setAttribute("uv2",new re(f.attributes.uv.array,2));let e;if(r.mode===gg.TRIANGLES||void 0===r.mode)e=new ee(f,i);else if(r.mode===gg.TRIANGLE_STRIP)(e=new ee(f,i)).drawMode=1;else if(r.mode===gg.TRIANGLE_FAN)(e=new ee(f,i)).drawMode=2;else if(r.mode===gg.LINES)if(C){const g=new O1;g.fromBufferGeometry(f);var a=new B1({color:xt(C.lineColor)?(new _t).fromArray(C.lineColor):new _t(1,1,1),lineWidth:xt(C.lineWidth)?C.lineWidth:1,sizeAttenuation:0});(e=new ee(g.geometry,a)).userData.originalLineGeom=f}else e=new jl(f,i);else if(r.mode===gg.LINE_STRIP)e=new Wl(f,i);else if(r.mode===gg.LINE_LOOP)e=new Yl(f,i);else{if(r.mode!==gg.POINTS)throw new Error("v3d.GLTFLoader: Primitive mode unsupported: ",r.mode);e=new $l(f,i)}if(e.name=A.name||"mesh_"+w,void 0!==r.targets){o=void 0;s=void 0;a=void 0;l=void 0;c=void 0;u=void 0;d=void 0;var o=e;var s=A;a=r;var l=E;const _=o.geometry,x=o.material;var c=a.targets;const y=_.morphAttributes;y.position=[],y.normal=[],x.morphTargets=!0;for(let e=0,t=c.length;e<t;e++){var u=c[e],d=xt(s.extras)&&xt(s.extras.targetNames)?s.extras.targetNames[e]:"morphTarget"+e;let n,r;if(void 0!==u.POSITION){n=l.accessors[u.POSITION].clone();const b=_.attributes.position;for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,n.getX(e)+b.getX(e),n.getY(e)+b.getY(e),n.getZ(e)+b.getZ(e))}else n=_.attributes.position.clone();if(void 0!==u.NORMAL){x.morphNormals=!0,r=l.accessors[u.NORMAL].clone();const M=_.attributes.normal;for(let e=0,t=r.count;e<t;e++)r.setXYZ(e,r.getX(e)+M.getX(e),r.getY(e)+M.getY(e),r.getZ(e)+M.getZ(e))}else r=_.attributes.normal.clone();u.TANGENT,n.name=d,r.name=d,y.position.push(n),y.normal.push(r)}if(o.updateMorphTargets(),void 0!==s.weights)for(let e=0,t=s.weights.length;e<t;e++)o.morphTargetInfluences[e]=s.weights[e]}const m={},v={};if(e.material.isMeshNodeMaterial&&C){if(C.uvLayers)for(var h in C.uvLayers)m[h]=L.texcoordToAttrName(C.uvLayers[h]);if(C.colorLayers)for(var p in C.colorLayers)v[p]=L.colorToAttrName(C.colorLayers[p])}if(Ig(e.geometry,e.material,m,v)&&(e.material=e.material.clone(),L.clonedResources.materials.push(e.material)),e.material.isMeshNodeMaterial&&(Object.assign(e.material.nodeUVAliases,m),Object.assign(e.material.nodeVCAliases,v),e.material.updateNodeGraph()),Rg(f,e.material)&&(e.material.vertexColors=!0,e.material.needsUpdate=!0),Pg(f)&&(e.material.flatShading=!0),!(1<T.length))return e;e.name+="_"+t,e.isMaterialGeneratedMesh=!0,S.add(e)}return S})})})}loadCameras(){var e=this.json;const o=this;return Cg(e.cameras,function(e){let t;var n,r,i=e[e.type];if(i){"perspective"===e.type?(n=i.aspectRatio||1,r=i.yfov,t=new da(Ln(r),n,i.znear||1,i.zfar||2e6)):"orthographic"===e.type&&(t=new Rs(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),xt(e.name)&&(t.name=e.name);const a=o.getExt(e,b.S8S_V3D_CAMERA_DATA);if(a){if(t.controls=new lg(a.controls,a.enablePan,a.rotateSpeed,a.moveSpeed),t.viewportFit.type=3,xt(a.viewportFitType))switch(a.viewportFitType){case"VERTICAL":t.viewportFit.type=1;break;case"HORIZONTAL":t.viewportFit.type=2;break;case"AUTO":t.viewportFit.type=3;break;case"FILL":t.viewportFit.type=4;break;case"OVERSCAN":t.viewportFit.type=5}xt(a.viewportFitInitialAspect)&&(t.viewportFit.initialAspect=a.viewportFitInitialAspect),xt(a.orbitMinDistance)&&(t.controls.orbitMinDistance=a.orbitMinDistance),xt(a.orbitMaxDistance)&&(t.controls.orbitMaxDistance=a.orbitMaxDistance),xt(a.orbitMinZoom)&&(t.controls.orbitMinZoom=a.orbitMinZoom),xt(a.orbitMaxZoom)&&(t.controls.orbitMaxZoom=a.orbitMaxZoom),xt(a.orbitMinPolarAngle)&&(t.controls.orbitMinPolarAngle=a.orbitMinPolarAngle),xt(a.orbitMaxPolarAngle)&&(t.controls.orbitMaxPolarAngle=a.orbitMaxPolarAngle),xt(a.orbitMinAzimuthAngle)&&(t.controls.orbitMinAzimuthAngle=a.orbitMinAzimuthAngle),xt(a.orbitMaxAzimuthAngle)&&(t.controls.orbitMaxAzimuthAngle=a.orbitMaxAzimuthAngle),xt(a.orbitTarget)&&(a.orbitTarget instanceof Array?(t.controls.orbitTarget=new he,t.controls.orbitTarget.position.fromArray(a.orbitTarget)):o._withDependencies(["nodes"]).then(function(e){t.controls.orbitTarget=e.nodes[a.orbitTarget]})),xt(a.fpsCollisionMaterial)&&(t.controls.collisionMaterial=a.fpsCollisionMaterial),xt(a.fpsGazeLevel)&&(t.controls.gazeLevel=a.fpsGazeLevel),xt(a.fpsStoryHeight)&&(t.controls.storyHeight=a.fpsStoryHeight),xt(a.enablePointerLock)&&(t.controls.enablePointerLock=a.enablePointerLock)}return e.extras&&(t.userData.v3d=e.extras),t}console.warn("v3d.GLTFLoader: Missing camera parameters.")})}loadSkins(){const e=this.json;return this._withDependencies(["accessors"]).then(function(t){return Cg(e.skins,function(e){return{joints:e.joints,inverseBindMatrices:t.accessors[e.inverseBindMatrices]}})})}loadAnimations(){const x=this,e=this.json;return this._withDependencies(["accessors","materials","nodes"]).then(function(_){return Cg(e.animations,function(t,e){const o=[];let n=-1;for(let e=0;e<t.channels.length;e++){var s=t.channels[e],l=t.samplers[s.sampler];if(l&&-1<l.input&&-1<l.output){const f=s.target,i=void 0!==f.node?f.node:f.id;var s=void 0!==t.parameters?t.parameters[l.input]:l.input,r=void 0!==t.parameters?t.parameters[l.output]:l.output,c=_.accessors[s];if(!(c.count<=1)){var u=_.accessors[r];const m=_.nodes[i];if(m){n=m.id,m.updateMatrix(),m.matrixAutoUpdate=!0;let r,i="";switch(f.path){case"weights":r=vd,i="morphTargetInfluences";break;case"rotation":r=_d,i="quaternion";break;case"translation":r=yd,i="position";break;case"scale":r=yd,i="scale";break;case"intensity":r=vd,i="intensity";break;default:r=yd;let e;-1<f.path.indexOf("nodeValue")?(e=f.path.match(/".*"/g)[0],i="material.nodeValue["+e+"]"):-1<f.path.indexOf("nodeRGB")&&(e=f.path.match(/".*"/g)[0],i="material.nodeRGB["+e+"]")}s=m.name||m.uuid;"CATMULLROMSPLINE"==l.interpolation&&console.warn("v3d.GLTFLoader: CATMULLROMSPLINE interpolation is not supported. Using CUBICSPLINE instead.");let a=xt(l.interpolation)?wg[l.interpolation]:$t;const v=[];"weights"==f.path?m.traverse(function(e){e.isMesh&&e.material.morphTargets&&v.push(e.name||e.uuid)}):-1<f.path.indexOf("material")?m.traverse(function(t){if(t.isMesh&&t.material.isMeshNodeMaterial){let e=!1;var n;(e=!f.extras||(e=_.materials[f.extras.material].name===t.material.name,n=f.path.match(/\["(.*)"\]/),e&&null!==n&&null!==t.material.findNodeByName(n[1])))&&v.push(t.name||t.uuid)}}):v.push(s);for(let e=0,t=v.length;e<t;e++){var d=y.arraySlice(c.array,0);let n=y.arraySlice(u.array,0);if(a==en){const g=new n.constructor(n.length/3);var h=g.length/d.length;for(let t=0;t<g.length/h;t++)for(let e=0;e<h;e++)g[h*t+e]=n[3*h*t+h+e];a=$t,n=g}o.push(new r(v[e]+"."+i,d,n,a))}}}}}const i=xt(t.name)?t.name:"animation_"+e,a={clip:new bd(i,void 0,o),nodeId:n,auto:!0,loop:2201,repetitions:1/0,startAt:0};e=x.getExt(t,b.S8S_V3D_ANIMATION_DATA);if(e){a.auto=e.auto;var p=e.repeatInfinite?1/0:e.repeatCount;switch(e.loop){case"ONCE":a.loop=2200;break;case"REPEAT":a.loop=2201,a.repetitions=p;break;case"PING_PONG":a.loop=2202,a.repetitions=p}a.startAt=e.offset}return a})})}loadNodes(){const g=this.json,_=this,t=g.nodes||[],e=g.skins||[],n={},i={};for(var r in e.forEach(function(e){e.joints.forEach(function(e){t[e].isBone=!0})}),t){r=t[r];xt(r.mesh)&&(xt(n[r.mesh])||(n[r.mesh]=i[r.mesh]=0),n[r.mesh]++)}var a=_.getExt(g,b.S8S_V3D_DATA);let o;return a&&a.curves&&a.curves.length&&(o=a.curves),_._withDependencies(["materials","meshes","skins","cameras"]).then(function(t){return xt(o)?new Promise(function(e){Ni("opentype.js",function(){e(t)},function(){console.error("GLTFLoader: opentype.js module not found, please copy it to your app directory"),e(t)})}):Promise.resolve(t)}).then(function(n){return Cg(o,function(e,t){return _.getExt(_,b.S8S_V3D_DATA).loadCurve(t,n.materials)}).then(function(e){return n.curves=e,n})}).then(function(v){return Cg(g.nodes,function(t){var n=_.getExt(t,b.S8S_V3D_NODE_DATA);if(!0===t.isBone)return new Cl;if(void 0!==t.mesh){let e=v.meshes[t.mesh];return 0<i[t.mesh]&&((e=e.clone()).name+="_instance_"+i[t.mesh],void 0!==e.geometry&&void 0!==e.material&&Ig(e.geometry,e.material,e.material.nodeUVAliases,e.material.nodeVCAliases)&&(e.material=e.material.clone(),_.clonedResources.materials.push(e.material))),i[t.mesh]++,e}if(void 0!==t.camera)return v.cameras[t.camera];if(n&&xt(n.curve))return v.curves[n.curve];if(n&&xt(n.light)){const e=_.getExt(_,b.S8S_V3D_DATA).lights;return e[n.light].clone()}if(n&&xt(n.lightProbe)){t=_.getExt(g,b.S8S_V3D_DATA).lightProbes[n.lightProbe];let e;if("CUBEMAP"==(t.type||"CUBEMAP")){switch(e=new $1,t.influenceType){case"ELIPSOID":e.influenceType=1;break;case"BOX":e.influenceType=2}switch(t.parallaxType){case"ELIPSOID":e.parallaxType=1;break;case"BOX":e.parallaxType=2}e.parallaxDistance=t.parallaxDistance,e.probeClipEnd=t.clipEnd,e.probeIntensity=t.intensity,xt(t.influenceGroup)&&(e.influenceGroup=t.influenceGroup),xt(t.influenceGroupInv)&&(e.influenceGroupInv=t.influenceGroupInv)}else(e=new rg).falloff=t.falloff,xt(t.planeSize)&&e.planeSize.set(t.planeSize[0],t.planeSize[1]);return e.influenceDistance=t.influenceDistance,e.probeClipStart=t.clipStart,e.visibilityGroup=t.visibilityGroup,e.visibilityGroupInv=t.visibilityGroupInv,e}if(n&&xt(n.clippingPlane)){const r=new sg;t=_.getExt(g,b.S8S_V3D_DATA).clippingPlanes[n.clippingPlane];return r.clippingGroup=t.clippingGroup,r.clipShadows=t.clipShadows,r.negated=t.negated,r.clipIntersection=t.clipIntersection,r.crossSection=t.crossSection,r.crossSectionColor=(new _t).fromArray(t.color),r.crossSectionOpacity=t.opacity,r.crossSectionSize=t.size,xt(t.renderSide)&&(r.crossSectionRenderSide=Tg[t.renderSide]),r}return new he}).then(function(m){return Cg(m,function(o,e){const s=g.nodes[e];if(xt(s.skin)){const c=[];var t=0<o.children.length?o.children:[o];for(let e=0;e<t.length;e++){const u=t[e];if(u.isMesh){var n=v.skins[s.skin],r=u.geometry,i=u.material.clone();_.clonedResources.materials.push(i);const d=new Tl(r,i),h=(d.morphTargetInfluences=u.morphTargetInfluences,d.name=u.name,d.isMaterialGeneratedMesh=u.isMaterialGeneratedMesh,[]),p=[];for(let e=0,t=n.joints.length;e<t;e++){var a=n.joints[e],l=m[a];if(l){h.push(l);const f=new gt;xt(n.inverseBindMatrices)&&f.fromArray(n.inverseBindMatrices.array,16*e),p.push(f)}else console.warn('v3d.GLTFLoader: Joint "%s" could not be found.',a)}d.bind(new Pl(h,p),d.matrixWorld),c.push(d)}}c.length&&(0<o.children.length?(o.remove.apply(o,o.children),o.add.apply(o,c)):o=c[0])}return o.traverse(function(n){var e=o==n,r=_.getExt(s,b.S8S_V3D_NODE_DATA);if(e){if(void 0!==s.name&&(n.name=s.name),void 0!==s.matrix){const t=new gt;t.fromArray(s.matrix),n.applyMatrix4(t)}else void 0!==s.translation&&n.position.fromArray(s.translation),void 0!==s.rotation&&n.quaternion.fromArray(s.rotation),void 0!==s.scale&&n.scale.fromArray(s.scale);e=r&&r.target?m[r.target]:null;if((n.isDirectionalLight||n.isSpotLight)&&(e?(n.target=e,n.isFreeLight=!1):n.isFreeLight=!0),n.isCamera&&n.controls&&"FIRST_PERSON"==n.controls.type&&(n.controls.collisionMaterial=v.materials[n.controls.collisionMaterial]),r&&r.hidden&&(n.visible=!1),r&&xt(r.constraints))for(let t=0;t<r.constraints.length;t++){const i=r.constraints[t];"lockedTrack"==i.type?(i.trackAxis=i.trackAxis.toUpperCase(),i.lockAxis=i.lockAxis||"Y"):"trackTo"==i.type?(i.trackAxis=i.trackAxis.toUpperCase(),i.upAxis=i.upAxis||"Y"):"floor"==i.type&&(i.floorLocation=i.floorLocation.toUpperCase());let e=null;switch(i.type){case"copyLocation":(e=new X0(m[i.target])).useX=!xt(i.useX)||i.useX,e.useY=!xt(i.useY)||i.useY,e.useZ=!xt(i.useZ)||i.useZ,e.invertX=!!xt(i.invertX)&&i.invertX,e.invertY=!!xt(i.invertY)&&i.invertY,e.invertZ=!!xt(i.invertZ)&&i.invertZ,e.useOffset=!xt(i.useOffset)||i.useOffset,e.influence=xt(i.influence)?i.influence:1;break;case"copyRotation":(e=new Q0(m[i.target])).useX=!xt(i.useX)||i.useX,e.useY=!xt(i.useY)||i.useY,e.useZ=!xt(i.useZ)||i.useZ,e.invertX=!!xt(i.invertX)&&i.invertX,e.invertY=!!xt(i.invertY)&&i.invertY,e.invertZ=!!xt(i.invertZ)&&i.invertZ,e.mixMode=xt(i.mixMode)?i.mixMode:"REPLACE",e.influence=xt(i.influence)?i.influence:1,e.fixCameraLightRotation=!!xt(i.fixCameraLightRotation)&&i.fixCameraLightRotation;break;case"copyScale":(e=new $0(m[i.target])).useX=!xt(i.useX)||i.useX,e.useY=!xt(i.useY)||i.useY,e.useZ=!xt(i.useZ)||i.useZ,e.power=xt(i.power)?i.power:1,e.useMakeUniform=!!xt(i.useMakeUniform)&&i.useMakeUniform,e.useOffset=!!xt(i.useOffset)&&i.useOffset,e.useAdd=!!xt(i.useAdd)&&i.useAdd,e.influence=xt(i.influence)?i.influence:1;break;case"copyTransforms":(e=new am(m[i.target])).mixMode=xt(i.mixMode)?i.mixMode:"REPLACE",e.influence=xt(i.influence)?i.influence:1,e.fixCameraLightRotation=!!xt(i.fixCameraLightRotation)&&i.fixCameraLightRotation;break;case"dampedTrack":(e=new vm(m[i.target])).trackAxis=i.trackAxis,e.influence=xt(i.influence)?i.influence:1,e.fixCameraLightRotation=!!xt(i.fixCameraLightRotation)&&i.fixCameraLightRotation;break;case"limitDistance":(e=new Tm(m[i.target])).distance=xt(i.distance)?i.distance:0,e.limitMode=xt(i.limitMode)?i.limitMode:"LIMITDIST_INSIDE",e.useTransformLimit=!!xt(i.useTransformLimit)&&i.useTransformLimit,e.influence=xt(i.influence)?i.influence:1;break;case"limitLocation":(e=new Cm).min.set(Number(i.minX),Number(i.minY),Number(i.minZ)),e.max.set(Number(i.maxX),Number(i.maxY),Number(i.maxZ));break;case"limitRotation":(e=new Lm).axis=i.axis,e.min=i.min,e.max=i.max;break;case"limitScale":(e=new Rm).min.set(Number(i.minX),Number(i.minY),Number(i.minZ)),e.max.set(Number(i.maxX),Number(i.maxY),Number(i.maxZ));break;case"lockedTrack":(e=new Gm(m[i.target])).trackAxis=i.trackAxis,e.lockAxis=i.lockAxis,e.fixCameraLightRotation=!!xt(i.fixCameraLightRotation)&&i.fixCameraLightRotation;break;case"trackTo":(e=new $m(m[i.target])).trackAxis=i.trackAxis,e.upAxis=i.upAxis,e.fixCameraLightRotation=!!xt(i.fixCameraLightRotation)&&i.fixCameraLightRotation;break;case"childOf":(e=new G0(m[i.target])).offsetMatrix=(new gt).fromArray(i.offsetMatrix),e.fixCameraLightRotation=!!xt(i.fixCameraLightRotation)&&i.fixCameraLightRotation;break;case"floor":(e=new bm(m[i.target])).floorLocation=i.floorLocation,e.offset=i.offset,e.useRotation=!!xt(i.useRotation)&&i.useRotation;break;case"fixOrthoZoom":e=new e1(m[i.target]);break;case"canvasFit":(e=new o1(m[i.target])).edgeH=i.edgeH,e.edgeV=i.edgeV,e.useBoundingBox="BOX"==i.fitShape,e.offset=i.offset;break;case"canvasBreakpoints":(e=new s1).minWidth=Number(i.minWidth),e.maxWidth=Number(i.maxWidth),e.minHeight=Number(i.minHeight),e.maxHeight=Number(i.maxHeight),e.orientation=i.orientation}e&&(e.name=i.name,e.mute=i.mute,n.constraints.push(e))}}if(n.isMesh&&(r&&xt(r.useCastShadows)?n.castShadow=r.useCastShadows:xt(n.material.castShadow)&&(n.castShadow=n.material.castShadow),r&&xt(r.useShadows)?n.receiveShadow=r.useShadows:xt(n.material.receiveShadow)&&(n.receiveShadow=n.material.receiveShadow)),r&&xt(r.objectIndex)&&(n.objectIndex=r.objectIndex),r&&xt(r.objectColor)&&(n.objectColor=(new _t).fromArray(r.objectColor)),s.extras&&(n.userData.v3d=s.extras),r&&(n.renderOrder=r.renderOrder,n.frustumCulled=r.frustumCulling,xt(r.groupNames)&&(n.groupNames=r.groupNames),xt(r.hidpiCompositing)&&(n.hidpiCompositing=r.hidpiCompositing)),n.isMesh&&n.material.isMeshNodeMaterial){const a=n.material;(a.hasNode("MATTE_SHADOW_MX")||a.hasNode("SHADOW_MATTE_AR")||a.hasNode("AI_SHADOW_MATTE_MY"))&&(a.transparent=!1,a.premultipliedAlpha=!0,_.assignDefaultBlending(a),n.renderOrder-=1e3,n.castShadow=!1,n.receiveShadow=!0)}}),o})})})}loadScenes(){const o=this.json,a=this,s=this.extensions;return this._withDependencies(["nodes"]).then(function(i){return Cg(o.scenes,function(e){const n=new Js;xt(e.name)&&(n.name=e.name),e.extras&&(n.userData.v3d=e.extras);var r=e.nodes||[];for(let e=0,t=r.length;e<t;e++)!function n(e,t,r){var i=r[e],t=(t.add(i),(i.isDirectionalLight||i.isSpotLight)&&i.isFreeLight&&t.add(i.target),o.nodes[e]);if(t.children){var a=t.children;for(let e=0,t=a.length;e<t;e++)n(a[e],i,r)}}(r[e],n,i.nodes);var t,e=a.getExt(e,b.S8S_V3D_SCENE_DATA);return e&&(xt(e.light)&&(t=s[b.S8S_V3D_DATA].lights,n.add(t[e.light])),xt(e.postprocessing)&&(n.postprocessing=e.postprocessing)),n})})}getExt(e,t){return e.extensions&&e.extensions[t]?e.extensions[t]:null}texcoordToAttrName(e){return"TEXCOORD_0"==e?"uv":"uv"+String(Number(e.split("TEXCOORD_")[1])+1)}colorToAttrName(e){return"COLOR_0"==e?"color":"color"+String(Number(e.split("COLOR_")[1])+1)}assignDefaultBlending(e){e.blending=J,e.blendEquation=$,e.blendSrc=xe,e.blendDst=Ae}}const Dg=new _t;class Og extends n{constructor(e,t,n=512,r=512){super(),this.scene=e,this.camera=t,this.width=n,this.height=r,this.distance=.1,this.factor=1,this.precision=1,this.bentNormals=!1,this.bounceApprox=!1,this.noiseTexture=this.createNoiseTexture(),this.fsQuad=new b1(null);e=new ic;e.type=Xe,this.renderTargetNormalDepth=new ze(this.width,this.height,{format:wt,depthTexture:e,depthBuffer:!0}),this.renderTargetGTAO=new ze(this.width,this.height),this.renderTargetBlurX=new ze(this.width,this.height),this.renderTarget=new ze(this.width,this.height),this.materialNormal=new Su({}),this.materialGTAO=new T({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 gt},resolution:{value:new Be}},vertexShader:yt.pp_plane_vert,fragmentShader:yt.pp_gtao_frag}),this.materialBlur=new T({type:"GTAOBlur",defines:{},uniforms:{tDiffuse:{value:null},tNormal:{value:null},direction:{value:new Be},resolution:{value:new Be}},customPrepTokens:{BLUR_RADIUS_PX:2},vertexShader:yt.pp_plane_vert,fragmentShader:yt.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();var t=e instanceof ee&&e.material&&!e.material.gtaoVisible,n=e instanceof ee&&e.material&&e.material.isMeshNodeMaterial&&(0<e.material.alphaTest||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 ee&&e.material&&e.material.isMeshNodeMaterial&&(e.material.defines.NORMAL_OUTPUT=Number(0<e.material.alphaTest||e.material.alphaToCoverage),e.material.needsUpdate=!0)})}_restoreNodeAlphaClipHashMaterials(){this.scene.traverse(e=>{e instanceof ee&&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,r,i,a){var o=e.getRenderTarget(),s=e.getClearColor(Dg),l=e.getClearAlpha(),c=e.autoClear,u=this.scene.background;e.setRenderTarget(n),null!=r&&(e.setClearColor(r),e.setClearAlpha(null!=i?i:0),e.clear()),e.autoClear=!1,a&&(this.scene.background=null),t&&(this.scene.overrideMaterial=t),e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.setRenderTarget(o),e.setClearColor(s),e.setClearAlpha(l),e.autoClear=c,this.scene.background=u}_renderPass(e,t,n,r,i){var a=e.getRenderTarget(),o=e.getClearColor(Dg),s=e.getClearAlpha(),l=e.autoClear;e.setRenderTarget(n),null!=r&&(e.setClearColor(r),e.setClearAlpha(null!=i?i:0),e.clear()),e.autoClear=!1,this.fsQuad.material=t,this.fsQuad.render(e),e.setRenderTarget(a),e.setClearColor(o),e.setClearAlpha(s),e.autoClear=l}createNoiseTexture(){var t=new Uint8Array([65,247,203,177,54,149,96,135,122,62,109,206,27,217,152,103,250,78,122,228,3,83,233,160,45,242,108,40,125,93,201,35,231,187,254,207,147,13,87,134,246,197,177,224,59,92,132,169,49,183,140,3,58,165,27,204,12,83,196,4,159,183,92,197,170,140,24,127,109,255,35,210,79,193,178,141,168,11,69,130,182,27,147,47,191,170,66,13,187,76,0,197,161,66,146,172,104,134,58,97,182,232,162,115,34,73,2,238,162,188,6,243,218,31,69,193,244,87,146,130,248,172,225,104,235,21,218,117,236,49,87,155,228,69,15,166,235,24,48,86,119,238,195,90,6,221,165,105,20,255,120,146,211,129,88,236,21,52,245,17,73,158,24,7,126,43,64,190,218,95,128,23,207,46,113,145,85,102,229,119,40,106,222,66,49,152,31,126,46,145,57,10,191,104,213,3,42,197,182,104,147,1,223,252,60,34,161,45,244,61,208,133,89,199,37,56,245,29,174,152,114,190,212,127,179,238,216,195,246,109,26,240,170,51,155,108,81,249,28,195,60,175,153,19,208,177,15,187,114,211,93,72,178,203,82,162,28,72,179,242,160,83,120,55,214,128,156,100,180,136,214,106,144,117,30,231,71,155,177,106,94,224,47,69,229,99,83,4,45,114,87,141,72,156,203,79,139,13,232,181,137,67,159,212,10,130,254,77,52,160,235,80,5,241,192,18,254,111,227,131,248,147,115,59,133,207,26,248,91,67,31,202,13,78,229,16,201,82,183,52,240,18,221,7,139,163,202,12,134,32,164,224,198,63,33,170,51,224,101,19,116,211,61,198,36,226,121,93,236,38,200,97,141,123,33,102,139,165,58,133,157,4,96,41,199,13,219,98,16,227,144,39,189,172,237,113,53,189,126,67,173,156,4,101,141,114,205,63,191,79,118,241,185,57,143,248,102,154,229,121,0,178,38,150,186,254,89,4,101,173,17,186,54,112,167,0,215,247,63,203,227,42,85,220,34,207,64,173,80,51,186,37,171,73,110,161,9,220,81,140,164,241,25,95,253,38,215,194,170,43,85,125,250,21,40,149,108,208,76,21,130,12,183,252,94,210,241,129,68,44,165,127,242,47,152,82,142,223,71,28,179,86,189,150,24,176,122,104,184,141,239,120,225,135,89,253,125,193,243,60,97,123,44,5,212,104,148,50,223,135,120,74,248,29,229,158,53,177,214,88,5,168,42,192,90,213,74,28,135,59,83,9,225,110,27,145,215,70,205,251,22,194,155,243,133,46,8,115,73,249,14,233,77,47,23,154,106,165,205,2,152,49,24,206,232,150,183,251,66,34,203,185,20,86,57,10,150,96,186,3,137,234,102,63,254,221,119,232,174,53,148,202,162,115,195,173,154,203,235,79,189,114,6,131,105,43,91,118,59,226,162,95,213,136,55,194,163,94,212,10,240,28,64,232,104,84,178,137,74,17,198,89,131,171,77,113,160,236,199,225,128,65,209,108,75,34,155,196,132,29,157,67,112,36,240,105,19,46,220,32,93,53,10,178,58,33,226,169,63,182,235,206,18,107,198,236,39,157,205,1,127,252,177,72,191,122,42,143,199,12,218,119,35,108,54,159,23,240,219,0,143,100,177,36,166,243,15,173,224,123,19,183,49,82,15,244,141,3,217,81,185,250,142,73,106,246,124,137,99,156,240,86,202,10,135,35,170,143,69,182,27,87,109,66,147,30,115,53,150,174,221,76,164,241,57,156,248,173,226,214,99,120,60,43,247,67,16,110,51,144,89,200,56,246,94,208,146,105,179,205,94,190,128,65,170,7,122,229,22,193,162,218,15,196,46,123,29,159,73,217,84,255,13,53,130,244,174,230,43,220,202,86,245,22,93,131,33,114,95,190,2,84,140,40,9,146,179,194,130,210,80,191,219,25,119,41,139,163,11,70,239,219,124,57,162,44,228,152,97,56,209,156,180,66,42,85,253,71,143,103,224,248,113,178,44,124,224,104,150,216,23,81,185,101,137,6,111,210,52,229,180,17,213,45,131,236,63,188,206,81,232,93,28,163,121,253,152,70,237,187,80,215,116,43,169,6,34,77,253,12,113,29,239,199,38,83,131,3,232,112,27,167,214,1,188,53,96,148,4,196,161,75,189,7,119,58,159,17,234,67,185,158,11,193,65,247,144,72,204,26,122,105,255,158,52,12,223,141,40,6,92,207,172,1,31,102,252,142,191,91,234,197,135,182,87,211,138,16,116,248,98,212,146,201,182,59,131,82,153,17,207,241,63,91,238,32,205,96,144,250,198,126,169,39,254,98,139,121,86,170,107,160,92,183,168,15,70,33,117,174,106,62,233,183,55,132,107,158,230,198,59,23,128,64,111,151,21,222,53,166,74,177,191,62,30,172,52,121,92,238,38,246,171,69,34,128,184,23,117,49,168,67,222,34,88,51,214,78,29,57,206,233,40,21,221,7,250,54,228,152,198,133,215,245,75,204,169,101,22,244,44,66,124,88,180,226,157,212,175,47,102,68,127,246,106,46,226,158,136,242,77,9,155,19,105,198,118,225,142,105,229,153,215,138,246,17,130,176,229,3,116,148,129,173,6,75,153,199,59,117,34,138,80,43,242,87,20,186,149,9,128,81,220,194,140,213,16,148,49,8,81,32,249,0,231,205,155,27,4,147,88,12,109,219,41,186,228,208,138,49,21,190,85,167,14,56,80,101,187,42,111,74,156,103,240,195,90,225,111,244,178,127,238,190,210,100,218,2,112,165,56,98,35,48,249,156,114,34,177,78,250,166,110,241,99,199,123,143,88,172,39,194,217,125,255,204,24,194,96,128,61,164,77,234,97,59,212,42,243,201,175,0,230,150,210,192,25,61,180,16,69,35,144,50,99,28,88,70,151,173,125,65,181,140,200,232,119,214,191,18,68,236,7,97,200,39,219,184,138,55,72,187,16,115,79,236,99,66,181,79,57,166,148,251,31,114,7,176,149,253,9,133,71,114,31,126,64,88,12,247,142,220,45,208,249,158,189,216,15,137,164,47,10,22,193,235,31,222,14,70,163,142,60,91,168,146,121,57,133,19,65,119,13,230,161,213,241,58,137,177,51,160,33,134,240,118,1,71,216,90,189,221,32,121,162,184,94,226,157,252,204,166,53,98,122,82,164,134,118,0,82,63,202,253,185,228,109,246,91,146,48,103,128,84,242,1,108,227,201,45,216,187,238,154,90,207,174,44,25,95,36,153,223,6,119,210,16,222,92,175,50,197,139,243,45,131,70,106,204,22,144,195,47,106,22,137,217,35,173,231,28,95,236,175,224,125,103,39,76,215,132,57,201,77,159,253,209,28,175,188,37,132,254,26,85,107,164,30,247,76,147,107,252,132,202,109,22,249,88,193,149,107,40,231,211,23,105,154,18,166,237,51,82,246,61,6,86,179,77,240,112,185,68,10,193,55,108,43,23,167,148,8,118,154,27,168,38,121,178,6,62,154,95,223,54,76,153,176,4,70,222,51,128,190,2,218,81,169,65,184,75,166,45,233,71,186,11,158,76,124,181,62,84,193,2,215,175,36,219,130,237,149,40,192,3,131,249,153,205,143,213,73,198,243,85,230,179,65,96,209,240,19,219,111,195,43,135,117,208,12,101,124,233,141,201,15,101,231,60,117,195,48,12,125,206,101,139,25,127,245,54,141,98,247,35,227,208,96,118,137,153,100,114,165,207,15,223,60,161,90,47,104,79,18,255,156,135,57,31,204,48,248,1,187,136,69,90,143,233,79,248,21,164,243,184,59,194,34,114,172,151,40,180,23,156,235,224,146,244,35,220,62,174,86,115,206,191,5,169,52,142,251,29,64,233,9,190,49,69,122,102,142,200,235,29,225,126,180,93,4,120,97,187,111,137,162,78,104,226,46,165,30,183,10,203,66,145,83,217,44,159,93,252,65,208,85,243,140,99,30,89,57,1,160,113,199,7,214,163,20,66,221,129,112,11,160,180,44,198,76,255,92,27,175,245,83,19,116,168,188,61,36,165,50,223,173,12,218,21,233,125,151,14,199,251,57,102,125,171,48,110,31,134,16,238,78,8,132,226,19,124,72,205,171,115,191,80,180,93,251,151,37,236,46,94,148,79,237,201,71,90,221,126,18,157,136,231,187,37,210,54,71,216,9,147,231,69,193,240,76,147,60,90,193,37,55,177,114,131,214,157,224,92,239,196,229,98,206,119,177,215,49,96,166,197,5,255,44,135,239,216,23,131,50,103,77,123,178,254,26,187,39,103,20,242,147,105,171,209,58,111,11,162,124,150,252,134,99,206,112,141,17,33,207,127,252,169,72,212,245,92,26,82,3,71,39,18,150,181,1,167,69,143,24,155,188,35,146,55,109,220,65,19,152,39,70,233,189,15,227,136,196,109,161,215,59,170,132,189,54,33,82,227,40,145,74,195,93,0,178,42,83,25,246,125,89,107,157,45,100,29,121,5,158,203,235,145,188,244,208,116,78,61,129,46,249,192,57,105,246,116,235,178,82,158,185,98,202,122,173,145,61,166,205,28,55,0,85,121,140,231,210,3,118,249,200,8,98,246,215,50,234,220,107,199,158,56,175,41,212,235,177,7,200,227,185,106,134,65,44,167,108,54,175,140,255,23,220,90,113,36,231,83,2,70,200,15,31,126,230,9,84,250,107,10,213,115,90,156,72,223,242,14,32,75,45,87,158,176,68,133,190,168,116,20,132,33,64,241,13,226,188,2,148,61,82,136,239,53,149,82,220,17,99,226,31,126,8,193,100,160,204,185,16,148,209,127,172,219,136,93,242,143,52,214,164,47,197,32,78,247,41,235,144,102,173,205,183,152,99,238,216,17,108,151,28,86,61,181,154,78,171,143,116,95,75,167,221,192,20,115,68,165,13,40,253,176,196,76,154,237,87,44,230,30,136,76,239,164,95,47,22,157,61,43,206,181,71,118,25,140,94,224,179,132,7,184,200,126,48,64,249,112,195,26,127,56,234,42,219,239,5,207,250,91,189,27,211,134,253,103,121,48,248,182,95,217,129,192,58,117,138,22,202,60,169,216,68,109,52,122,5,64,195,227,183,102,250,113,167,6,103,244,192,64,237,150,54,162,97,67,20,34,163,90,134,6,168,69,142,182,201,78,124,162,142,104,39,123,12,233,49,66,32,144,14,90,160,36,205,24,109,232,92,159,0,245,111,94,130,16,183,153,247,176,222,141,31,74,133,10,212,28,147,81,222,38,174,124,2,111,21,209,121,221,253,110,214,17,229,53,220,37,254,93,1,171,100,50,71,192,223,56,202,109,162,182,198,238,209,227,64,140,243,153,74,172,33,212,49,179,219,38,250,144,205,9,84,211,44,106,254,118,233,86,191,67,236,197,133,15,156,86,217,74,245,194,44,84,171,143,188,77,150,117,203,81,159,120,30,212,247,14,232,26,134,168,148,74,245,8,83,53,26,170,126,3,84,50,201,9,241,132,85,69,149,25,191,77,117,35,163,96,20,150,181,56,167,40,155,122,48,95,58,254,203,46,185,167,35,137,154,10,56,235,99,40,246,178,102,13,189,228,60,135,186,154,113,177,83,6,228,41,93,154,130,180,73,98,196,111,230,184,123,62,146,106,188,231,123,165,54,103,223,63,242,129,198,79,8,203,25,138,221,0,181,164,24,114,100,144,234,61,106,91,226,181,72,131,1,210,60,22,138,240,47,107,148,75,38,89,209,62,255,99,120,214,20,206,114,37,223,147,254,43,19,166,97,222,20,207,41,10,97,211,14,236,172,140,189,52,230,160,217,92,110,239,73,103,247,214,141,229,72,8,28,130,207,13,250,112,198,30,162,121,194,91,156,68,215,9,200,237,19,225,127,46,198,32,186,136,173,63,248,160,190,11,58,135,217,151,33,248,79,174,157,254,65,196,130,42,87,26,1,109,69,30,123,246,60,172,197,131,20,64,35,188,170,216,155,241,79,172,26,50,150,222,242,80,171,226,34,129,164,88,175,123,101,168,2,142,161,239,70,50,234,104,0,92,120,79,174,199,89,70,118,191,136,55,115,30,141,81,245,155,184,120,210,252,177,143,46,185,149,16,38,89,159,205,82,125,44,89,117,54,193,146,124,212,87,103,44,141,17,51,252,112,187,27,248,42,67,195,243,80,108,14,151,87,29,196,140,46,211,232,25,106,245,13,49,232,5,94,201,222,181,4,107,217,72,233,149,39,85,101,227,4,81,211,229,53,179,112,237,18,197,250,179,3,98,39,237,63,168,6,185,68,209,100,200,2,78,222,55,139,155,217,31,58,176,205,218,126,165,225,68,18,243,155,128,37,209,183,154,212,169,73,238,45,122,163,55,34,17,97,59,165,192,22,204,134,164,106,121,143,244,4,153,98,139,66,32,224,204,73,187,138,23,249,110,228,130,152,174,63,144,119,204,8,111,183,92,121,230,23,98,6,252,111,182,145,99,52,72,168,139,60,101,128,28,110,149,20,89,230,193,145,175,203,129,11,218,116,237,54,68,255,28,190,74,40,217,56,228,163,113,133,159,107,11,219,120,201,156,36,12,87,231,43,243,160,89,234,74,24,251,149,41,136,192,78,56,38,204,171,6,194,223,113,2,227,80,41,251,186,59,172,210,68,132,247,80,110,239,47,75,157,91,36,199,176,11,222,94,169,129,184,11,78,240,19,55,254,174,91,50,76,178,58,244,122,24,192,102,35,18,189,171,132,51,201,167,64,243,180,157,130,82,28,117,252,88,178,23,242,161,200,11,220,135,242,7,103,42,26,220,3,183,138,249,174,14,127,149,100,47,137,62,208,24,105,201,45,176,212,85,36,148,230,26,132,96,217,187,71,211,135,168,218,125,64,210,98,14,225,84,105,33,119,11,239,216,232,134,59,34,144,206,95,120,67,145,83,99,34,156,202,117,167,62,155,93,30,64,107,213,186,241,81,231,160,119,251,85,233,145,124,96,152,195,116,66,207,161,238,2,142,164,46,110,8,78,52,250,146,39,240,160,116,4,210,229,140,196,94,66,43,184,162,215,77,50,190,32,234,180,48,125,189,77,255,141,88,236,210,122,199,150,225,24,56,1,206,111,26,196,5,152,37,68,220,0,29,243,138,8,186,41,107,197,30,88,255,151,180,230,94,197,5,108,76,185,58,145,172,72,22,51,165,107,147,200,8,100,245,127,154,9,109,166,22,217,232,14,55,181,19,190,51,13,231,42,83,120,142,70,169,38,182,77,54,177,114,192,249,59,183,75,225,100,126,83,248,55,118,225,18,62,202,31,118,157,176,221,139,29,195,253,43,91,184,247,207,14,125,71,237,115,21,174,60,221,253,88,199,66,112,173,128,224,36,110,78,134,176,102,190,163,252,95,219,127,245,139,215,237,91,16,166,132,108,157,50,16,216,169,151,73,176,207,129,101,240,137,68,21,84,48,236,94,123,17,216,132,153,114,81,224,27,92,151,45,225,194,138,75,39,129,157,4,144,43,95,72,239,146,165,251,62,5,237,32,202,48,153,9,62,99,13,161,128,48,80,213,36,232,176,200,63,25,228,7,137,36,81,169,0,45,185,247,211,129,10,203,68,166,104,231,1,62,37,179,255,56,209,168,86,3,101,211,182,54,235,102,245,214,195,158,0,202,96,27,213,154,74,133,16,108,188,87,227,198,110,32,203,228,148,190,7,92,115,253,145,97,193,109,184,246,51,218,192,148,228,104,164,61,151,175,245,50,79,31,189,239,139,161,7,192,130,33,67,249,122,15,148,25,206,79,32,169,20,120,63,219,45,126,194,113,90,222,178,67,234,27,173,149,51,254,71,20,102,244,65,139,26,80,37,131,47,238,14,93,159,112,74,123,89,33,15,115,227,37,110,143,208,158,121,87,214,104,228,112,176,234,142,162,198,230,91,172,117,188,133,50,87,249,139,174,84,241,11,52,170,38,246,143,117,206,41,123,84,167,138,182,120,42,170,197,156,236,209,163,70,213,146,60,230,25,11,210,56,179,206,75,191,88,5,182,224,57,11,199,45,73,149,82,18,97,49,27,111,58,41,247,69,10,220,151,107,200,12,35,106,181,226,147,207,124,2,54,161,76,13,237,189,222,2,58,208,86,224,126,52,1,181,117,21,85,172,124,201,136,253,167,234,131,147,250,47,136,236,20,128,94,251,171,133,25,203,55,218,188,241,75,180,221,158,140,97,239,61,180,228,75,234,155,59,134,72,19,101,186,85,213,97,250,136,62,25,96,113,241,152,30,14,249,94,67,104,226,195,250,32,103,43,187,65,100,42,3,85,23,160,100,197,73,168,39,113,66,184,235,164,116,0,126,151,209,18,84,123,3,194,163,18,125,41,24,186,118,208,253,31,163,238,65,230,22,194,179,108,215,159,202,37,175,133,73,185,111,217,167,18,138,56,153,4,223,78,161,29,150,199,119,184,222,62,212,119,29,244,145,218,17,100,35,138,252,69,171,40,103,135,252,33,214,48,112,204,93,145,167,97,48,5,193,92,116,46,140,155,37,129,49,5,146,74,127,52,90,231,211,161,44,147,201,232,41,91,129,179,205,244,116,89,219,242,71,105,238,36,176,153,53,204,77,191,157,242,86,215,23,192,90,228,12,202,170,70,182,235,80,30,254,213,65,243,221,141,77,171,218,197,7,105,171,226,89,241,33,229,180,248,21,105,4,60,84,130,32,76,186,238,110,68,50,139,24,174,8,135,53,169,13,134,88,1,229,105,131,8,51,124,61,179,108,48,144,244,64,115,51,145,101,129,154,57,175,2,84,128,159,109,16,57,244,127,80,251,203,70,118,165,191,102,15,67,166,196,142,242,190,10,251,120,158,9,216,166,14,98,234,61,188,38,209,151,196,113,255,67,186,24,91,173,227,200,12,234,159,211,122,30,163,86,196,219,22,9,225,188,136,115,196,19,36,237,184,152,40,27,181,59,15,150,25,55,80,137,209,153,221,124,38,113,225,100,175,63,208,83,29,255,194,152,204,123,81,251,95,21,76,47,218,144,163,240,211,41,110,151,79,39,98,8,75,223,187,5,239,42,161,247,74,95,41,233,52,170,204,63,96,213,135,112,208,96,138,223,178,216,251,7,116,49,86,26,75,170,53,213,21,149,46,103,142,119,37,73,227,17,108,159,216,125,233,181,99,38,118,58,137,71,251,29,133]);const n=new Uint8Array(12288);for(let e=0;e<4096;e++)n[3*e]=t[e],n[3*e+1]=n[3*e+2]=0;const e=new El(n,64,64,wt,Mt);return e.wrapS=U,e.wrapT=U,e}}var Fg,Bg={fromCubeTexture:function(e){for(var t,n=0,r=new vt,i=new vt,a=new mt,o=[0,0,0,0,0,0,0,0,0],s=new Kd,l=s.coefficients,c=0;c<6;c++)for(var u=e.image[c],d=u.width,h=u.height,p=document.createElement("canvas"),p=(p.width=d,p.height=h,p.getContext("2d")),u=(p.drawImage(u,0,0,d,h),p.getImageData(0,0,d,h)),f=u.data,m=u.width,v=2/m,g=0,_=f.length;g<_;g+=4){a.set(f[g]/255,f[g+1]/255,f[g+2]/255,f[g+3]/255),zg(a,e.encoding);var x=g/4,y=(x%m+.5)*v-1,b=1-(Math.floor(x/m)+.5)*v;switch(c){case 0:r.set(-1,b,-y);break;case 1:r.set(1,b,y);break;case 2:r.set(-y,1,-b);break;case 3:r.set(-y,-1,b);break;case 4:r.set(-y,b,1);break;case 5:r.set(y,b,-1)}x=r.lengthSq(),n+=t=4/(Math.sqrt(x)*x),i.copy(r).normalize(),Kd.getBasisAt(i,o);for(var M=0;M<9;M++)l[M].x+=o[M]*a.x*t,l[M].y+=o[M]*a.y*t,l[M].z+=o[M]*a.z*t}for(var A=4*Math.PI/n,M=0;M<9;M++)l[M].x*=A,l[M].y*=A,l[M].z*=A;return new Jd(s)},fromCubeRenderTarget:function(e,t){for(var n,r=0,i=new vt,a=new vt,o=new mt,s=[0,0,0,0,0,0,0,0,0],l=new Kd,c=l.coefficients,u=0;u<6;u++)for(var d=t.width,h=new Uint8Array(d*d*4),p=(e.readRenderTargetPixels(t,0,0,d,d,h,u),2/d),f=0,m=h.length;f<m;f+=4){o.set(h[f]/255,h[f+1]/255,h[f+2]/255,h[f+3]/255),zg(o,t.texture.encoding);var v=f/4,g=(v%d+.5)*p-1,_=1-(Math.floor(v/d)+.5)*p;switch(u){case 0:i.set(1,_,-g);break;case 1:i.set(-1,_,g);break;case 2:i.set(g,1,-_);break;case 3:i.set(g,-1,_);break;case 4:i.set(g,_,1);break;case 5:i.set(-g,_,-1)}v=i.lengthSq(),r+=n=4/(Math.sqrt(v)*v),a.copy(i).normalize(),Kd.getBasisAt(a,s);for(var x=0;x<9;x++)c[x].x+=s[x]*o.x*n,c[x].y+=s[x]*o.y*n,c[x].z+=s[x]*o.z*n}for(var y=4*Math.PI/r,x=0;x<9;x++)c[x].x*=y,c[x].y*=y,c[x].z*=y;return new Jd(l)}},zg=(Fg=new _t,function(e,t){switch(t){case on:Vg(e,Fg),Fg.convertSRGBToLinear(),Ug(Fg,e);break;case sn:Vg(e,Fg),Fg.convertRGBEToLinear(e.w),Ug(Fg,e),e.w=1;break;case an:break;default:console.warn("WARNING: LightProbeGenerator convertColorToLinear() encountered an unsupported encoding.")}return e});function Vg(e,t){t.setRGB(e.x,e.y,e.z)}function Ug(e,t){t.setX(e.r).setY(e.g).setZ(e.b)}function Gg(e,t,n,r,i){this._domElement=e,this._keyCode=t,this._callback=n,this._repeats=r,this._period=i,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*i)),++this._counter>=r&&(this._timer&&(window.clearTimeout(this._timer),this._timer=null),this._counter=0,this._callback()))}.bind(this),this._domElement.addEventListener("keydown",this._keydownCb,!1)}function kg(e){this.data=void 0!==e?e:null,this.useHDR=!1}Object.assign(Gg.prototype,{dispose:function(){this._domElement.removeEventListener("keydown",this._keydownCb,!1),this._timer&&window.clearTimeout(this._timer)}}),Object.assign(kg.prototype,{isSceneBackground:!0,clone:function(){return(new this.constructor).copy(this)},copy:function(e){null===e.data?this.data=null:e.data.isColor?this.data=e.data.clone():e.data.isCubeTexture||e.data.isTexture?(this.data=e.data.clone(),this.data.needsUpdate=!0):e.data.isWebGLCubeRenderTarget?(this.data=e.data.clone(),this.data.texture.needsUpdate=!0):this.data=e.data,this.useHDR=e.useHDR},toJSON:function(e){const t={metadata:{version:4.5,type:"SceneBackground",generator:"SceneBackground.toJSON"}};return null!==this.data&&(t.data=this.data.toJSON(e)),t}});const Wg={createMultiMaterialObject:function(n,r){const i=new Us;for(let e=0,t=r.length;e<t;e++)i.add(new ee(n,r[e]));return i},detach:function(e,t,n){e.applyMatrix(t.matrixWorld),t.remove(e),n.add(e)},attach:function(e,t,n){e.applyMatrix((new gt).copy(n.matrixWorld).invert()),t.remove(e),n.add(e)},getMaterialByName:function(e,t){e=this.getMaterialsByName(e,t);return e.length?e[0]:null},getMaterialsByName:function(e,t){const n=[];return null!==e.scene&&(e.scene.traverse(function(e){e.material&&e.material.name===t&&-1===n.indexOf(e.material)&&n.push(e.material)}),null!==(e=e.scene.worldMaterial)&&e.name===t&&-1===n.indexOf(e)&&n.push(e)),n},getAnimationActionByName:function(t,n){for(let e=0;e<t.actions.length;e++){const r=t.actions[e];if(r.getClip().name==n)return r}return null},checkActionIsUsed:function(n,e){return Boolean(e._propertyBindings.find(function(e){const t=e.binding.node;return t&&t.findRoot()===n}))},createEnvironmentMaterial:function(e,t,n){const r=new Iu.DiGraph(6),i={};if(r.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},r.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},i[cd.nodeTexUniName("TEX_ENVIRONMENT_BL",0)]=t,n instanceof _t){const a=[0,0,0,0];a[0]=n.r,a[1]=n.g,a[2]=n.b,a[3]=1,r.node(2).originData={name:"Background Color",type:"RGB_BL",inputs:[],outputs:[a],is_active_output:!1}}else r.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},i[cd.nodeTexUniName("TEX_ENVIRONMENT_BL",1)]=n;return r.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},r.node(4).originData={name:"Background",type:"BACKGROUND_BL",inputs:[[0,0,0,0],1],outputs:[[0,0,0,0]],is_active_output:!1},r.node(5).originData={name:"Output",type:"OUTPUT_WORLD_BL",inputs:[[0,0,0,0],[0,0,0,0]],outputs:[],is_active_output:!0},bt(r,0,0,3,0),bt(r,1,0,3,1),bt(r,2,0,3,2),bt(r,3,0,4,0),bt(r,4,0,5,0),new cd({name:e,nodeGraph:r,nodeTextures:i})},calcSceneBox:function(e){const t=new g;return t.expandByObject(e),t},createDefaultCamera:function(e,t){var n=new vt,r=2*e.getSize(n).length();const i=new da(45,t,r/1e4,r);return i.position.copy(e.max).multiplyScalar(2),i.lookAt(e.getCenter(n)),i},assignDefaultControls:function(e,t){var n=new he;t.getCenter(n.position),e.controls=new lg,e.controls.orbitMinDistance=e.near,e.controls.orbitMaxDistance=e.far,e.controls.orbitTarget=n}};function Hg(){var n=0,r=document.createElement("div");function e(e){return r.appendChild(e.dom),e}function t(e){for(var t=0;t<r.children.length;t++)r.children[t].style.display=t===e?"block":"none";n=e}r.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",r.addEventListener("click",function(e){e.preventDefault(),t(++n%r.children.length)},!1);var i,a=(performance||Date).now(),o=a,s=0,l=e(new Hg.Panel("FPS","#0ff","#002")),c=e(new Hg.Panel("MS","#0f0","#020"));return self.performance&&self.performance.memory&&(i=e(new Hg.Panel("MB","#f08","#201"))),t(0),{REVISION:16,dom:r,addPanel:e,showPanel:t,begin:function(){a=(performance||Date).now()},end:function(){s++;var e,t=(performance||Date).now();return c.update(t-a,200),o+1e3<=t&&(l.update(1e3*s/(t-o),100),o=t,s=0,i&&(e=performance.memory,i.update(e.usedJSHeapSize/1048576,e.jsHeapSizeLimit/1048576))),t},update:function(){a=this.end()},domElement:r,setMode:t}}Hg.Panel=function(n,r,i){var a=1/0,o=0,s=Math.round,l=s(window.devicePixelRatio||1),c=80*l,e=48*l,u=3*l,d=2*l,h=3*l,p=15*l,f=74*l,m=30*l,v=document.createElement("canvas"),g=(v.width=c,v.height=e,v.style.cssText="width:80px;height:48px",v.getContext("2d"));return g.font="bold "+9*l+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=i,g.fillRect(0,0,c,e),g.fillStyle=r,g.fillText(n,u,d),g.fillRect(h,p,f,m),g.fillStyle=i,g.globalAlpha=.9,g.fillRect(h,p,f,m),{dom:v,update:function(e,t){a=Math.min(a,e),o=Math.max(o,e),g.fillStyle=i,g.globalAlpha=1,g.fillRect(0,0,c,p),g.fillStyle=r,g.fillText(s(e)+" "+n+" ("+s(a)+"-"+s(o)+")",u,d),g.drawImage(v,h+l,p,f-l,m,h,p,f-l,m),g.fillRect(h+f-l,p,l,m),g.fillStyle=i,g.globalAlpha=.9,g.fillRect(h+f-l,p,l,s((1-e/t)*m))}}};const Xg=["toneMapping","toneMappingMidTones","toneMappingPhysicalScale","toneMappingBrightness","toneMappingContrast","toneMappingChromaticAdaptation","toneMappingWhiteColor","toneMappingColorDifferentiation","toneMappingExteriorDaylight","toneMappingWhiteBalance","toneMappingHighlights","toneMappingShadows","toneMappingSaturation","toneMappingAperture","toneMappingShutter","toneMappingISO","toneMappingVignetting"];function jg(e,t,n){return 2*An*Math.atan(Math.tan(Mn*e/2)*t/n)}class Yg extends n{constructor(e,t,n){super(),this.container=e instanceof HTMLElement?e:document.getElementById(e),ma.checkWebGL()?(this.scene=null,this.camera=null,this.clock=new _h,this.mixer=null,this.renderCallbacks=[],this.compileCallbacks=[],this.elapsed=0,this.frame=0,this.preloader=n,this.worldCubemapRes=1024,this._pmremMaxTileSize=256,this._lightProbeCubemapRes=64,this.xrSession=null,this.xrControllers=[],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),ma.isSafariWithMultisamplingBug()&&(console.warn("v3d.App: disabling buggy context AA on Safari 15.4/15.5"),t.antialias=!1),this.renderer=new i(t),X1.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=on,this.container.appendChild(this.renderer.domElement),this.container.classList.add("v3d-container"),this.renderer.domElement.classList.add("v3d-canvas"),this.container.setAttribute("translate","no"),this.loader=new ug,S.prototype.computeBoundsTree=N0,S.prototype.disposeBoundsTree=D0,ee.prototype.raycast=I0,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,H1.drawWatermark(this),H1.addToAppList(this),this.worldMaterial=null):ma.showWebGLErrorMessage(this.container)}_updateRendererFromGLTF(t){const e=this;var n=ma.checkHalfFloatTex(this.renderer,!0);if(t.renderer.shadowMap?(this.renderer.shadowMap.enabled=t.renderer.shadowMap.enabled,this.renderer.shadowMap.type=t.renderer.shadowMap.type,n||this.renderer.shadowMap.type!==oe||(this.renderer.shadowMap.type=ie,t.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 Hd).copy(e.shadow),e.shadow.camera.updateProjectionMatrix()))}))):(this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=ie),t.renderer.physicallyCorrectLights&&(this.renderer.physicallyCorrectLights=!0),this.aaMethod=t.renderer.aaMethod||"AUTO",this.useHDR=Boolean(t.renderer.useHDR&&n),this.renderer.unitsScaleFactor=t.renderer.unitsScaleFactor,t.renderer.toneMapping)for(let e=0;e<Xg.length;e++){var r=Xg[e];xt(t.renderer[r])&&(this.renderer[r]=t.renderer[r])}void 0!==t.renderer.pmremMaxTileSize&&(this._pmremMaxTileSize=t.renderer.pmremMaxTileSize),void 0!==t.renderer.iblEnvironmentMode&&(this._envIBLMode=t.renderer.iblEnvironmentMode),void 0!==t.renderer.esmDistanceScale&&(this.renderer.shadowMap.esmDistanceScale=t.renderer.esmDistanceScale),t.scene.traverse(function(t){t.hidpiCompositing&&(t.traverse(e=>{t.isMesh&&e.layers.set(7)}),e.useHiDPIRenderPass=!0,e.renderer.setPixelRatio(window.devicePixelRatio))}),e.useHiDPIRenderPass&&t.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=>{var t;e.isCubeReflectionProbe?this._prepareEnvMapProbe(e):e.isPlaneReflectionProbe&&0<(t=this._checkMSAA(this.renderer,4))&&e.makeMultisampleRenderTarget(t)})}_prepareEnvMapProbe(e){switch(e.setSize(this._pmremMaxTileSize),this._envIBLMode){case 0:e.onUpdate=e=>this.generateRTargetPMREM(e);break;case 1:break;case 2:e.onUpdate=()=>null}}_prepareReflProbesEncoding(e,t){e.traverse(e=>{(e.isCubeReflectionProbe||e.isPlaneReflectionProbe)&&e.setEncoding(t)})}_prepareEnvMapProbeWorld(){const e=new Js,t=(e.worldMaterial=this.scene.worldMaterial,null===this.scene.worldEnvMapProbe&&(this.scene.worldEnvMapProbe=new $1(this._pmremMaxTileSize),this.scene.worldEnvMapProbe.influenceType=0,this.scene.worldEnvMapProbe.parallaxType=0),this.scene.worldEnvMapProbe);switch(this._envIBLMode){case 0:t.onUpdate=e=>this.generateRTargetPMREM(e);break;case 1:case 2:t.onUpdate=e=>{const t=e.clone(),n=(t.setSize(this._lightProbeCubemapRes,this._lightProbeCubemapRes),t.texture.type=Mt,t.texture.format=pt,t.texture.encoding=sn,new v1(e.texture));return n.render(this.renderer,t),n.dispose(),this._disposeEnvLightProbe(),this._envLightProbe=Bg.fromCubeRenderTarget(this.renderer,t),this.scene.add(this._envLightProbe),t.dispose(),1===this._envIBLMode?e:null}}t.update(e,this.renderer),this.renderer.compatSettings.useSpecEnvBlenderApprox=0===this._envIBLMode}_updateMaterialsFromGLTF(e){const n=this;e.scene&&e.scene.traverse(function(e){const t=e.material;t&&n.useHDR&&(t.useHDR=!0,t.useFloatTex=ma.checkFloatTex(n.renderer,!0),t.isMeshNodeMaterial&&t.updateNodeGraph())})}_updateAnimationsFromGLTF(e,r){const i=this;!i.mixer&&e.animations&&e.animations.length&&(i.mixer=new Uh(i.scene)),(e.animations||[]).forEach(function(t){var n=r.getObjectById(t.nodeId);if(n){let e;(e=n.id==r.id||""!==n.name&&"root"!==n.name&&"."!==n.name&&n.name!==r.name&&n.name!==r.uuid?i.mixer.clipAction(t.clip,r):i.mixer.clipAction(t.clip,n)).setLoop(t.loop,t.repetitions),e.startAt(t.startAt+i.mixer.time),e.clampWhenFinished=!0,t.auto?e.play():(e.stop(),e.paused=!0),i.actions.push(e)}})}_traverseSceneForTexUniforms(e,n){e.traverse(function(t){if(t.material){const e=Array.isArray(t.material)?t.material:[t.material];e.forEach(function(e){void 0!==e.program&&n(t,e,e.program.getTexUniformCount())})}})}_checkMSAA(e,t){return Math.min(t,e.capabilities.maxSamples)}_precompileSceneAsync(e,t,n,r){const i=this,a=i.compileCallbacks;for(let e=0;e<a.length;e++)a[e](i);const o=i.renderer.getRenderTarget();i.renderer.setRenderTarget(n),i.renderer.compileAsync(e,t,function(e){1<=e&&i.renderer.setRenderTarget(o),r&&r(100*e)})}_handleAlphaToCoverage(n){this.scene.traverse(function(e){const t=e.material;t&&t.alphaToCoverage&&(0<n?(t.transparent=!1,t.premultipliedAlpha=!1,t.blending=ce):t.alphaToCoverage=!1)})}assignClippingPlanes(e){let n=[],r=[],i=[],a=-1e3;e.traverse(function(t){t.isClippingPlaneObject&&(n.push(t),r.push(t.plane),e.traverse(function(e){t.needsClippingPlane(e)&&t.assignToObject(e,a++)}),i.push(a++))});for(let e=0;e<n.length;e++){const t=n[e];t.crossSection&&t.createCrossSectionPlane(r,i[e])}n.length&&(this.renderer.localClippingEnabled=!0,this.postprocessing&&this.postprocessing.composer.setStencil(!0))}updateConstraints(e){const r=this;e.traverse(function(t){for(let e=0;e<t.constraints.length;e++){const n=t.constraints[e];n.isCanvasBreakpointsConstraint&&(n.appInstance=r)}})}load(e,t,n,r){console.warn("v3d.App.load has been deprecated. Use v3d.App.loadScene instead.");const i=this;i.loadScene(e,function(e){t(e),r&&i.run()},null,n)}loadScene(e,i,a,t){const o=this;o.renderer?(o._loadSceneURL=e,o._loadingTime=performance.now(),o.preloader&&o.preloader.onUpdate(0),this.loader.load(e,function(t){o.scene=t.scene||new Js;let e=null;t.cameras&&t.cameras.length?o.camera=t.cameras[0]:(e=Wg.calcSceneBox(o.scene),o.camera=Wg.createDefaultCamera(e,o.container.offsetWidth/o.container.offsetHeight),o.scene.add(o.camera)),o.camera.controls||(e=e||Wg.calcSceneBox(o.scene),Wg.assignDefaultControls(o.camera,Wg.calcSceneBox(o.scene)),o.camera.viewportFit.type=1),o._updateRendererFromGLTF(t),o._prepareReflProbesFromGLTF(t),o._updateMaterialsFromGLTF(t),o._updateAnimationsFromGLTF(t,o.scene);var n=t.world.material;n&&(o.scene.background=new kg,o.scene.worldMaterial=n,o.updateEnvironment(n),o.worldMaterial=n),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;function r(){o.scene&&o._traverseSceneForTexUniforms(o.scene,function(e,t,n){8<n&&console.warn(`v3d.App: Material "${t.name}" on object `+`"${e.name}" exceeds iOS limit of `+"8 textures "+`(has ${n}).`)}),o.removeEventListener("firstFrameRendered",r)}n=o.postprocessing?o.postprocessing.composer.renderTarget1:null;o._precompileSceneAsync(o.scene,o.camera,n,function(e){e=60+.4*e;a&&a(e),o.preloader&&o.preloader.onUpdate(e),100<=e&&(o._updateMeshesRaycastFromGLTF(t),o.addEventListener("firstFrameRendered",r),i&&setTimeout(function(){o.scene.visible=!0,o.scene.disableChildRendering=!1,o.updateReflectionProbes(o.scene),o._loadingTime=performance.now()-o._loadingTime,o.dispatchEvent({type:"loadSceneEnd"}),i(o.scene)},16))}),o.clearBkgOnLoad&&(o.scene.background=null),o._tripleP=new Gg(window,pe.P,function(){H1.printPerformanceInfo(o,1)},3,1),o._tripleF=new Gg(window,pe.F,function(){o.stats?o.hideFPS():o.showFPS()},3,1),o._tripleH=new Gg(window,pe.H,function(){o.enableRender?o.disableRendering():o.enableRendering()},3,1)},function(e){e*=.6;a&&a(e),o.preloader&&o.preloader.onUpdate(e)},function(e){console.error(e),t&&t(e)}),window.removeEventListener("resize",this._resizeCb,!1),this._resizeCb=function(){o.onResize&&o.onResize()},window.addEventListener("resize",this._resizeCb,!1)):t&&t("WebGL not found")}appendScene(e,a,o,t,s,l){const c=this;c.renderer?(void 0===s&&(s=!0),void 0===l&&(l=!0),c.preloader&&c.preloader.onUpdate(0),this.loader.load(e,function(t){const n=t.scene||new Js,r=[];n.traverse(function(e){(e.isCamera&&!s||e.isLight&&!l)&&r.push(e)}),r.forEach(function(e){c.unload(e)}),c.scene&&(c.scene.add(n),c._prepareReflProbesFromGLTF(t),c._updateMaterialsFromGLTF(t),c._updateAnimationsFromGLTF(t,n),c.scene.updateMatrixWorld());var e=c.postprocessing?c.postprocessing.composer.renderTarget1:null,i=c.scene||n;c.assignClippingPlanes(i),c.updateConstraints(i),n.visible=!1,n.disableChildRendering=!0,c._precompileSceneAsync(i,c.camera||new ua,e,function(e){e=60+.4*e;o&&o(e),c.preloader&&c.preloader.onUpdate(e),100<=e&&(c._updateMeshesRaycastFromGLTF(t),c._traverseSceneForTexUniforms(n,function(e,t,n){8<n&&console.warn(`v3d.App: Material "${t.name}" on object `+`"${e.name}" exceeds iOS limit of `+"8 textures "+`(has ${n}).`)}),a&&setTimeout(function(){n.visible=!0,n.disableChildRendering=!1,c.updateReflectionProbes(c.scene),a(n)},16))})},function(e){e*=.6;o&&o(e),c.preloader&&c.preloader.onUpdate(e)},function(e){console.error(e),t&&t(e)})):t&&t("WebGL not found")}unload(e){const t=this;function r(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)r(e.controls.orbitTarget);else if(e.isScene){const t=e.worldMaterial;null!==t&&(F0.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 n=e.material;F0.disposeTextures(n),n.dispose()}}if((e=e||t.scene)===t.scene){if(t.scene&&(t.scene.traverse(r),t.disposeEnvironment()),t.scene=null,t.controls&&t.controls.dispose&&t.controls.dispose(),t.controls=null,t.camera=null,t.mixer&&(t.mixer.stopAllAction(),t.actions.forEach(function(e){t.mixer.uncacheAction(e.getClip(),e.getRoot())})),t.mixer=null,t.actions=[],t.postprocessing){if(t.postprocessing.composer)for(var n in t.postprocessing){const i=t.postprocessing[n];(i instanceof _1||i instanceof ev)&&i.dispose()}t.disablePostprocessing()}t.postprocessing=null,b1.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(r),e.parent&&e.parent.remove(e)),t.mixer)for(let e=t.actions.length-1;0<=e;e--){const a=t.actions[e];Wg.checkActionIsUsed(t.scene,a)||(a.stop(),t.mixer.uncacheAction(a.getClip(),a.getRoot()),t.actions.splice(e,1))}}dispose(){this.scene&&this.unload(),this.renderer&&(this.renderer.forceContextLoss(),this.renderer.dispose(),this.renderer.domElement.parentElement===this.container&&this.container.removeChild(this.renderer.domElement)),this.renderer=null,window.removeEventListener("resize",this._resizeCb,!1),H1.removeFromAppList(this),Md.clear(),this.dispatchEvent({type:"dispose"})}getWidth(){return this.container.offsetWidth}getHeight(){return this.container.offsetHeight}onResize(){this.enableRender&&!this.ssaaOnPause||(this.enableRendering(),this.disableRendering(1));const t=this.getWidth(),n=this.getHeight();if(this.renderer.setSize(t,n),this.postprocessing&&(this.postprocessing.gtaoGenerator&&this.postprocessing.gtaoGenerator.setSize(t,n),this.postprocessing.composer.setSize(t,n)),this.scene){this.scene.traverse(e=>{e.isPlaneReflectionProbe&&e.setSize(t,n)});var r=t/n;const s=this.camera;if(s.isPerspectiveCamera){var e=s.aspect<s.viewportFit.initialAspect,i=r<s.viewportFit.initialAspect;switch(s.viewportFit.type){case 1:s.aspect=r;break;case 2:s.fov=jg(s.fov,s.aspect,r),s.aspect=r;break;case 3:e&&i?s.fov=jg(s.fov,s.aspect,r):e&&!i?s.fov=jg(s.fov,s.aspect,s.viewportFit.initialAspect):!e&&i&&(s.fov=jg(s.fov,s.viewportFit.initialAspect,r)),s.aspect=r;break;case 5:e&&i?s.fov=jg(s.fov,s.aspect,r):e&&!i?s.fov=jg(s.fov,s.viewportFit.initialAspect,r):!e&&i&&(s.fov=jg(s.fov,s.aspect,r)),s.aspect=r;break;case 4:e||i?(e&&!i||!e&&i)&&(s.fov=jg(s.fov,s.aspect,s.viewportFit.initialAspect)):s.fov=jg(s.fov,s.aspect,r),s.aspect=r}}else if(s.isOrthographicCamera){let e,t;switch(s.viewportFit.type){case 1:e=s.top*r,s.left=-e,s.right=e;break;case 2:t=s.right/r,s.bottom=-t,s.top=t;break;case 3:var a=(s.right-s.left)/(s.top-s.bottom)<s.viewportFit.initialAspect,o=r<s.viewportFit.initialAspect;e=a&&o?s.right:a&&!o?s.right*r/s.viewportFit.initialAspect:!a&&o?s.top*s.viewportFit.initialAspect:s.top*r,s.left=-e,s.right=e,s.bottom=-e/r,s.top=e/r;break;case 4:t=s.right/r,s.bottom=-t,s.top=t;break;case 5:e=s.top*r,s.left=-e,s.right=e}}s.updateProjectionMatrix()}}run(){this.preloader&&(this.preloader.onFinish(),this.preloader=null),this.animate()}animate(){const r=this;r.renderer.setAnimationLoop(function(){r.stats&&r.stats.begin();var t=r.clock.getDelta();r.elapsed=t,r.mixer&&r.mixer.update(t),r.controls&&!r.xrSession&&r.controls.update(t);const n=r.renderCallbacks;for(let e=0;e<n.length;e++)n[e](t,r.clock.elapsedTime);r.frame%r.frameRateDivider==0&&r.enableRender&&(r.render(),0===r.frame&&r.dispatchEvent({type:"firstFrameRendered"})),r.frame++,r.disableRenderTrigger&&0==--r.disableRenderTrigger&&(r.enableRender=!1),r.stats&&r.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)}setFrameRateDivider(e){this.frameRateDivider=e}render(){this.dispatchEvent({type:"onBeforeRender"});var e,t,n=!!this.scene&&!!this.camera;if(n&&this.scene.traverse(e=>{e.isPlaneReflectionProbe&&e.update(this.scene,this.camera,this.renderer)}),this.postprocessing){const r=this.postprocessing.gtaoGenerator,i=(r&&r.render(this.renderer),this.postprocessing.composer);i.render(this.elapsed)}else n&&this.renderer.render(this.scene,this.camera);n&&this.useHiDPIRenderPass&&(n=this.camera.layers.mask,e=this.scene.background,t=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=n,this.scene.background=e,this.renderer.autoClear=t),this.dispatchEvent({type:"onAfterRender"})}enableControls(e){const n=this.camera;if(n.controls){switch(n.controls.type){case"ORBIT":this.controls=new m1(n,e||this.renderer.domElement);break;case"FLYING":this.controls=new f1(n,this.renderer.domElement);break;case"FIRST_PERSON":this.controls=new p1(n,this.renderer.domElement),this.controls.collisionMeshes=[];const r=this;this.scene.traverse(function(e){var t=e.material;t&&n.controls.collisionMaterial&&t.name==n.controls.collisionMaterial.name&&r.controls.collisionMeshes.push(e)});break;default:this.controls=null}this.controls&&(n.controls.assignToControls(this.controls),this.controls.update())}}setCamera(t){if(this.camera=t,this.postprocessing){const n=this.postprocessing.composer.passes;for(let e=0;e<n.length;e++)n[e].setCamera(t);this.postprocessing.renderPass&&this.postprocessing.renderPass.setCamera(t),this.postprocessing.ssaaRenderPass&&this.postprocessing.ssaaRenderPass.setCamera(t),this.postprocessing.gtaoGenerator&&this.postprocessing.gtaoGenerator.setCamera(t)}this.controls&&this.controls.dispose(),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}cleanup(){if(console.warn("v3d.App.cleanup has been deprecated. Use v3d.App.unload or v3d.App.dispose instead."),this.container)for(;this.container.firstChild;)this.container.removeChild(this.container.firstChild);this.loader&&this.mixer&&this.mixer.stopAllAction()}initPostprocessing(){this.scene.postprocessing&&this.scene.postprocessing.length||this.useHDR||this.useHiDPIRenderPass||"AUTO"!=this.aaMethod?this.enablePostprocessing(this.scene.postprocessing||[]):this._handleAlphaToCoverage(this.renderer.getContextAttributes().antialias?4:0)}enablePostprocessing(t){const c={format:pt,stencilBuffer:!1};this.useHDR?(c.type=je,c.encoding=an):(c.type=Mt,c.encoding=on),this._prepareReflProbesEncoding(this.scene,c.encoding);let u;if(this.postprocessing)u=this.postprocessing.composer;else{this.postprocessing={};var n=new V1(this.scene,this.camera);this.postprocessing.renderPass=n;let e=0;switch(this.aaMethod){case"AUTO":case"MSAA4":e=this._checkMSAA(this.renderer,4);break;case"MSAA8":e=this._checkMSAA(this.renderer,8);break;case"MSAA16":e=this._checkMSAA(this.renderer,16)}ma.checkSwiftShader(this.renderer)&&(console.warn("v3d.App: disabling buggy multisampling on SwiftShader renderer"),e=0),ma.isSafariWithMultisamplingBug()&&(console.warn("v3d.App: disabling buggy multisampling on Safari 15.4/15.5"),e=0);let t;e?(t=new Yn(this.getWidth(),this.getHeight(),c)).samples=e:t=new ze(this.getWidth(),this.getHeight(),c),t.texture.name="EffectComposer.rt1",(u=new ev(this.renderer,t)).addPass(n),this.postprocessing.composer=u;var n=this.renderer.getContextAttributes().alpha,r=0==e&&"NONE"!=this.aaMethod;if(this.useHDR){const i=new k1;r&&!n&&(i.material.defines.ALPHA_AS_LUMA=1),u.addPass(i),this.postprocessing.toneMapPass=i}if(r){const a=new C1(this.scene,this.camera);this.useHDR&&!n&&(a.material.defines.FXAA_GREEN_AS_LUMA=0),u.addPass(a),this.postprocessing.fxaaPass=a}this._handleAlphaToCoverage(e)}t.length&&this.postprocessing.copyPass&&(u.passes.splice(u.passes.indexOf(this.postprocessing.copyPass),1),this.postprocessing.copyPass=null);for(let e=0;e<t.length;e++){var d,h=t[e];let l=u.passes.length-1;switch(u.passes[l]instanceof C1||l++,this.useHDR&&l--,h.type){case"afterimage":var p=h.damp;let e;this.postprocessing.afterimagePass?(e=this.postprocessing.afterimagePass).damp=p:(e=new M1(new Be(this.getWidth(),this.getHeight()),p,c),u.insertPass(e,l),this.postprocessing.afterimagePass=e);break;case"bloom":var p=h.strength,f=h.radius,m=h.threshold;let t;this.postprocessing.bloomPass?((t=this.postprocessing.bloomPass).strength=p,t.radius=f,t.threshold=m):(t=new A1(new Be(this.getWidth(),this.getHeight()),p,f,m,c),u.insertPass(t,l),this.postprocessing.bloomPass=t);break;case"brightnessContrast":let n;this.postprocessing.brightnessContrastPass?n=this.postprocessing.brightnessContrastPass:(n=new T1,u.insertPass(n,l),this.postprocessing.brightnessContrastPass=n),n.brightness=h.brightness,n.contrast=h.contrast;break;case"dof":let r;this.postprocessing.bokehPass?r=this.postprocessing.bokehPass:(r=new w1(this.scene,this.camera,{width:this.getWidth(),height:this.getHeight()}),u.insertPass(r,l),this.postprocessing.bokehPass=r),r.focus=h.focus,r.aperture=h.aperture,r.maxblur=h.maxblur,r.depthLeakThreshold=h.depthLeakThreshold;break;case"grayscale":this.postprocessing.grayscalePass||(f=new E1,u.insertPass(f,l),this.postprocessing.grayscalePass=f);break;case"gtao":case"ao":if(!ma.checkDepthTex(this.renderer)){console.warn("v3d.App: disabling GTAO since your hardware does not support depth textures");break}let i=this.postprocessing.gtaoGenerator;if(!i){i=this.postprocessing.gtaoGenerator=new Og(this.scene,this.camera,this.getWidth(),this.getHeight());const v=e=>{i.removeEventListener("dispose",v),this.renderer.disposeGTAO()};i.addEventListener("dispose",v),this.renderer.gtaoMap=i.renderTarget.texture}i.distance=h.distance,i.factor=h.factor,i.precision=h.precision,i.bentNormals=null!=(m=h.bentNormals)&&m,i.bounceApprox=h.bounceApprox;break;case"outline":let a;this.postprocessing.outlinePass?a=this.postprocessing.outlinePass:(a=new z1(new Be(this.getWidth(),this.getHeight()),this.scene,this.camera),u.insertPass(a,l),this.postprocessing.outlinePass=a),a.edgeStrength=h.edgeStrength,a.edgeGlow=h.edgeGlow,a.edgeThickness=h.edgeThickness,a.pulsePeriod=h.pulsePeriod,a.visibleEdgeColor.fromArray(h.visibleEdgeColor),a.hiddenEdgeColor.fromArray(h.hiddenEdgeColor),void 0===h.renderHiddenEdge?(d=0===h.hiddenEdgeColor[0]&&0===h.hiddenEdgeColor[1]&&0===h.hiddenEdgeColor[2],a.hiddenEdgeColor.setW(Number(!d))):a.hiddenEdgeColor.setW(Number(h.renderHiddenEdge));break;case"ssr":if(!ma.checkHalfFloatTex(this.renderer,!1)){console.warn("v3d.App: disabling SSR since your hardware does not support half float textures");break}let o=!1,s;((o=xt(h.useRefract)?h.useRefract:o)?this.postprocessing.ssrPassRefract:this.postprocessing.ssrPassReflect)?s=o?this.postprocessing.ssrPassRefract:this.postprocessing.ssrPassReflect:(s=new G1(this.scene,this.camera),u.insertPassAfter(s,[this.postprocessing.renderPass,this.postprocessing.ssrPassRefract,this.postprocessing.ssrPassReflect]),o?this.postprocessing.ssrPassRefract=s:this.postprocessing.ssrPassReflect=s),s.useRefract=o,xt(h.objects)&&(s.objects=h.objects),xt(h.intensity)&&(s.intensity=h.intensity),xt(h.steps)&&(s.steps=h.steps),xt(h.stride)&&(s.stride=h.stride),xt(h.binarySearchSteps)&&(s.binarySearchSteps=h.binarySearchSteps),xt(h.renderTargetScale)&&(s.renderTargetScale=h.renderTargetScale),xt(h.thickness)&&(s.thickness=h.thickness),xt(h.maxDistance)&&(s.maxDistance=h.maxDistance),xt(h.jitter)&&(s.jitter=h.jitter),xt(h.renderAfter)&&(s.renderAfter=h.renderAfter),xt(h.simpleRefraction)&&(s.simpleRefraction=h.simpleRefraction),this.onResize&&this.onResize();break;default:console.error(`v3d.App: wrong postprocessing effect "${h.type}"`)}}1==u.passes.length&&(r=new S1(E.copy),u.passes.push(r),this.postprocessing.copyPass=r)}disablePostprocessing(e,t){if(this.postprocessing){const r=this.postprocessing.gtaoGenerator,i=(!t&&r&&(r.dispose(),this.postprocessing.gtaoGenerator=null),["afterimagePass","bloomPass","brightnessContrastPass","bokehPass","grayscalePass","ssrPassReflect","ssrPassRefract"]),a=(e||i.push("outlinePass"),this.postprocessing.composer);for(let e=0;e<i.length;e++){var n=i[e];this.postprocessing[n]&&(a.passes.splice(a.passes.indexOf(this.postprocessing[n]),1),this.postprocessing[n].dispose(),this.postprocessing[n]=null)}"AUTO"!=this.aaMethod||1!=a.passes.length||this.postprocessing.gtaoGenerator?1==a.passes.length&&(t=new S1(E.copy),a.passes.push(t),this.postprocessing.copyPass=t):(this.postprocessing.renderPass.dispose(),this.postprocessing.composer.dispose(),this.postprocessing=null)}}enableSSAA(t,n){if(this.postprocessing||this.enablePostprocessing([]),!(0<t&&(this.postprocessing.ssrPassRefract||this.postprocessing.ssrPassReflect))){const r=this,i=(this.scene.traverse(function(e){e.isAnnotationControl&&(e.update(r.camera),e.doUpdate=!Boolean(t))}),this.postprocessing.composer);if(0<t&&i.passes[0]instanceof V1){let e;this.postprocessing.ssaaRenderPass?e=this.postprocessing.ssaaRenderPass:(e=new U1(this.scene,this.camera),this.postprocessing.ssaaRenderPass=e,n&&e.addEventListener("iteration",function(e){e.frame==t*t-1&&(i.enableAllPasses(),i.renderToScreen=!0,i.passes[i.passes.length-1].renderToScreen=!0,r.disableRenderTrigger=1)})),e.sampleLevel=t||4,i.passes[0]=e,this.postprocessing.fxaaPass&&i.passes.splice(i.passes.length-1,1),n&&(e.iterative=!0,e.iterativeFrame=0,i.disableAllPasses(),i.renderToScreen=!1,e.enabled=!0)}else 0<t?(i.passes[0].sampleLevel=t||4,n&&(ssaaRenderPass.iterative=!0,ssaaRenderPass.iterativeFrame=0,i.disableAllPasses(),i.renderToScreen=!1,ssaaRenderPass.enabled=!0)):0==t&&i.passes[0]instanceof U1&&(i.passes[0]=this.postprocessing.renderPass,this.postprocessing.fxaaPass&&i.passes.push(this.postprocessing.fxaaPass),i.enableAllPasses(),i.renderToScreen=!0)}}updateEnvironment(e){var t=this.renderer.xr.enabled;this.renderer.xr.enabled=!1,this.disposeEnvironment(),e.useHDR=!0,null!==this.scene.background&&this.scene.background.isSceneBackground&&(this.scene.background.data=Y1.renderWorldNodeMatToCubemap(this.renderer,e,this.worldCubemapRes,{encoding:on,format:pt,generateMipmaps:!0,minFilter:He,type:je}),this.scene.background.useHDR=this.useHDR),0===this._envIBLMode&&new Up(this.renderer,this._pmremMaxTileSize,!0).compileCubemapShader(),this._prepareEnvMapProbeWorld(),this.renderer.xr.enabled=t}disposeEnvironment(){this._disposeEnvLightProbe();let e=this.scene.background;(e=e&&(e.isSceneBackground?e.data:e))&&(e.isTexture||e.isWebGLRenderTarget)&&e.dispose()}_disposeEnvLightProbe(){null!==this._envLightProbe&&(this.scene.remove(this._envLightProbe),this._envLightProbe=null)}updateReflectionProbes(e){e.traverse(e=>{e.isCubeReflectionProbe&&e.update(this.scene,this.renderer)})}updateObjectMaterialEnv(e){console.warn("v3d.App.updateObjectMaterialEnv has been deprecated: not needed anymore")}generateRTargetPMREM(e){if(!e.isWebGLCubeRenderTarget)return null;const t=new Up(this.renderer,this._pmremMaxTileSize,!0);t.flipCubemapX=!1;e=t.fromCubeRenderTarget(e,{encoding:an});return t.dispose(),e}initWebXR(r,i,a,e,n,o){a=a||function(){},e=e||function(){},n=n||function(){},o=o||{};const s=this;function l(e){s.xrSession.removeEventListener("end",l),s.renderer.xr.setSession(null),n();for(let e=0;e<s.xrControllers.length;e++){var t=s.xrControllers[e];s.scene.remove(t)}s.xrControllers=[],s.xrSession=null,s._backgroundSave&&(s.scene.background=s._backgroundSave,s._backgroundSave=null),s.postprocessing=s._postprocessingSave,s._postprocessingSave=null,s.onResize()}function c(e){var t=e.data;const n=e.target;if("tracked-pointer"==t.targetRayMode){e=(new S).setFromPoints([new vt(0,0,0),new vt(0,0,-1)]);const r=new Wl(e);r.name=n.name+"_RAY",r.scale.z=5,n.add(r)}else if("gaze"==t.targetRayMode){e=(new Pd).load("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="),e=new nl({map:e,sizeAttenuation:!1});const i=new vl(e);i.name=n.name+"_RETICLE",i.scale.multiplyScalar(.1),i.position.z=-5,n.add(i)}n.userData.v3d.inputSource=t}function u(e){const t=e.target;for(let e=t.children.length-1;0<=e;e--){const n=t.children[e];-1<n.name.indexOf(t.name)&&(n.geometry.dispose(),n.material.dispose(),t.remove(n))}}const t={optionalFeatures:[i]};"immersive-ar"==r&&(t.optionalFeatures.push("hit-test"),o.domOverlay&&(t.optionalFeatures.push("dom-overlay"),t.domOverlay={root:s.container})),navigator.xr.requestSession(r,t).then(function(e){s._postprocessingSave=s.postprocessing,s.postprocessing=null,s.renderer.xr.setReferenceSpaceType(i),(s.xrSession=e).addEventListener("end",l);var t="immersive-vr"==r?2:1;for(let e=0;e<t;e++){const n=s.renderer.xr.getController(e);s.scene.add(n),s.xrControllers.push(n),n.addEventListener("connected",c),n.addEventListener("disconnected",u)}"immersive-vr"!=r&&(s._backgroundSave=s.scene.background,s.scene.background=null),s.renderer.xr.enabled=!0,s.renderer.xr.setSession(e),o.domOverlay&&s.renderer.xr.addEventListener("sessionstart",function(){setTimeout(function(){s.renderer.domElement.style.width=s.getWidth()+"px",s.renderer.domElement.style.height=s.getHeight()+"px"},300)}),a()}).catch(e)}endWebXR(){this.xrSession&&this.xrSession.end()}printPerformanceInfo(e){H1.printPerformanceInfo(this,e)}showFPS(){if(this.container){this.hideFPS();const e=new Hg;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)}}var Zg,qg,Qg,Ih={computeTangents:function(e){var t=e.index,n=e.attributes;if(null===t||void 0===n.position||void 0===n.normal||void 0===n.uv)console.warn("v3d.BufferGeometry: Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");else{for(var r=t.array,i=n.position.array,a=n.normal.array,o=n.uv.array,s=i.length/3,l=(void 0===n.tangent&&e.setAttribute("tangent",new re(new Float32Array(4*s),4)),n.tangent.array),c=[],u=[],d=0;d<s;d++)c[d]=new vt,u[d]=new vt;for(var h,p,f,m,v=new vt,g=new vt,_=new vt,x=new Be,y=new Be,b=new Be,M=new vt,A=new vt,w=e.groups,d=0,S=(w=0===w.length?[{start:0,count:r.length}]:w).length;d<S;++d)for(var T=D=(N=w[d]).start,C=D+N.count;T<C;T+=3)h=r[T+0],p=r[T+1],f=r[T+2],m=void 0,v.fromArray(i,3*h),g.fromArray(i,3*p),_.fromArray(i,3*f),x.fromArray(o,2*h),y.fromArray(o,2*p),b.fromArray(o,2*f),g.sub(v),_.sub(v),y.sub(x),b.sub(x),m=1/(y.x*b.y-b.x*y.y),isFinite(m)&&(M.copy(g).multiplyScalar(b.y).addScaledVector(_,-y.y).multiplyScalar(m),A.copy(_).multiplyScalar(y.x).addScaledVector(g,-b.x).multiplyScalar(m),c[h].add(M),c[p].add(M),c[f].add(M),u[h].add(A),u[p].add(A),u[f].add(A));for(var E,L=new vt,R=new vt,P=new vt,I=new vt,d=0,S=w.length;d<S;++d)for(var N,D,T=D=(N=w[d]).start,C=D+N.count;T<C;T+=3)O(r[T+0]),O(r[T+1]),O(r[T+2])}function O(e){P.fromArray(a,3*e),I.copy(P),E=c[e],L.copy(E),L.sub(P.multiplyScalar(P.dot(E))).normalize(),R.crossVectors(I,E),E=R.dot(u[e]),E=E<0?-1:1,l[4*e]=L.x,l[4*e+1]=L.y,l[4*e+2]=L.z,l[4*e+3]=E}},mergeBufferGeometries:function(e,t){for(var n=null!==e[0].index,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=e[0].morphTargetsRelative,l=new S,c=0,u=0;u<e.length;++u){var d,h,p=e[u];if(n!=(null!==p.index))return null;for(d in p.attributes){if(!r.has(d))return null;void 0===a[d]&&(a[d]=[]),a[d].push(p.attributes[d])}if(s!==p.morphTargetsRelative)return null;for(d in p.morphAttributes){if(!i.has(d))return null;void 0===o[d]&&(o[d]=[]),o[d].push(p.morphAttributes[d])}if(l.userData.mergedUserData=l.userData.mergedUserData||[],l.userData.mergedUserData.push(p.userData),t){if(n)h=p.index.count;else{if(void 0===p.attributes.position)return null;h=p.attributes.position.count}l.addGroup(c,h,u),c+=h}}if(n){for(var f=0,m=[],u=0;u<e.length;++u){for(var v=e[u].index,g=0;g<v.count;++g)m.push(v.getX(g)+f);f+=e[u].attributes.position.count}l.setIndex(m)}for(d in a){var _=this.mergeBufferAttributes(a[d]);if(!_)return null;l.setAttribute(d,_)}for(d in o){var x=o[d][0].length;if(0===x)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[d]=[];for(u=0;u<x;++u){for(var y=[],g=0;g<o[d].length;++g)y.push(o[d][g][u]);var b=this.mergeBufferAttributes(y);if(!b)return null;l.morphAttributes[d].push(b)}}return l},mergeBufferAttributes:function(e){for(var t,n,r,i=0,a=0;a<e.length;++a){var o=e[a];if(o.isInterleavedBufferAttribute)return null;if((t=void 0===t?o.array.constructor:t)!==o.array.constructor)return null;if((n=void 0===n?o.itemSize:n)!==o.itemSize)return null;if((r=void 0===r?o.normalized:r)!==o.normalized)return null;i+=o.array.length}for(var s=new t(i),l=0,a=0;a<e.length;++a)s.set(e[a].array,l),l+=e[a].array.length;return new re(s,n,r)},interleaveAttributes:function(e){for(var t,n=0,r=0,i=0,a=e.length;i<a;++i){var o=e[i];if((t=void 0===t?o.array.constructor:t)!==o.array.constructor)return console.warn("AttributeBuffers of different types cannot be interleaved"),null;n+=o.array.length,r+=o.itemSize}for(var s=new $s(new t(n),r),l=0,c=[],u=["getX","getY","getZ","getW"],d=["setX","setY","setZ","setW"],h=0,a=e.length;h<a;h++){var p=(o=e[h]).itemSize,f=o.count,m=new tl(s,p,l,o.normalized);c.push(m),l+=p;for(var v=0;v<f;v++)for(var g=0;g<p;g++)m[d[g]](v,o[u[g]](v))}return c},estimateBytesUsed:function(e){var t,n=0;for(t in e.attributes){var r=e.getAttribute(t);n+=r.count*r.itemSize*r.array.BYTES_PER_ELEMENT}var i=e.getIndex();return n+=i?i.count*i.itemSize*i.array.BYTES_PER_ELEMENT:0},mergeVertices:function(e,t=1e-4){t=Math.max(t,Number.EPSILON);for(var n={},r=e.getIndex(),i=e.getAttribute("position"),a=(r||i).count,o=0,s=Object.keys(e.attributes),l={},c={},u=[],d=["getX","getY","getZ","getW"],h=0,p=s.length;h<p;h++)l[_=s[h]]=[],(M=e.morphAttributes[_])&&(c[_]=new Array(M.length).fill().map(()=>[]));for(var i=Math.log10(1/t),f=Math.pow(10,i),h=0;h<a;h++){for(var m=r?r.getX(h):h,v="",g=0,p=s.length;g<p;g++)for(var _=s[g],x=(b=e.getAttribute(_)).itemSize,y=0;y<x;y++)v+=~~(b[d[y]](m)*f)+",";if(v in n)u.push(n[v]);else{for(g=0,p=s.length;g<p;g++)for(var _=s[g],b=e.getAttribute(_),M=e.morphAttributes[_],x=b.itemSize,A=l[_],w=c[_],y=0;y<x;y++){var S=d[y];if(A.push(b[S](m)),M)for(var T=0,C=M.length;T<C;T++)w[T].push(M[T][S](m))}n[v]=o,u.push(o),o++}}const E=e.clone();for(h=0,p=s.length;h<p;h++){var _=s[h],L=e.getAttribute(_),R=new L.array.constructor(l[_]),b=new re(R,L.itemSize,L.normalized);if(E.setAttribute(_,b),_ in c)for(g=0;g<c[_].length;g++){var P=e.morphAttributes[_][g],R=new P.array.constructor(c[_][g]),P=new re(R,P.itemSize,P.normalized);E.morphAttributes[_][g]=P}}return E.setIndex(u),E},toTrianglesDrawMode:function(e,t){if(0===t)return console.warn("v3d.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(2!==t&&1!==t)return console.error("v3d.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e;var n=e.getIndex();if(null===n){var r=[],i=e.getAttribute("position");if(void 0===i)return console.error("v3d.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(var a=0;a<i.count;a++)r.push(a);e.setIndex(r),n=e.getIndex()}var o=n.count-2,s=[];if(2===t)for(a=1;a<=o;a++)s.push(n.getX(0)),s.push(n.getX(a)),s.push(n.getX(a+1));else for(a=0;a<o;a++)a%2==0?(s.push(n.getX(a)),s.push(n.getX(a+1)),s.push(n.getX(a+2))):(s.push(n.getX(a+2)),s.push(n.getX(a+1)),s.push(n.getX(a)));s.length/3!=o&&console.error("v3d.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");t=e.clone();return t.setIndex(s),t.clearGroups(),t},batchMeshes:function(n,e){const r={};for(let t=0;t<n.length;t++){var i=n[t],a=i.geometry,o=i.material;let e=[];e.push(o.name),e.push(i.visible),e.push(i.disableChildRendering),e.push(i.castShadow),e.push(i.receiveShadow),e.push(i.renderOrder),e=e.concat(i.groupNames);o=Object.keys(a.attributes),o=(e=e.concat(o),Object.keys(a.morphAttributes));e=(e=e.concat(o)).join(),r[e]=r[e]||[],-1==r[e].indexOf(i)&&r[e].push(i)}for(var s in r){const n=r[s];if(!(n.length<2)){const u=[];let t=!0;for(let e=0;e<n.length;e++){const h=n[e],p=h.geometry;h.updateMatrixWorld(),u.push(p.clone().applyMatrix4(h.matrixWorld)),p.boundsTree||(t=!1)}var s=n[0],l=s.material,c=`${l.name}_x${n.length}_batch`;const d=this.mergeBufferGeometries(u);if(d){const f=new ee(d,l);f.name=c,f.visible=s.visible,f.disableChildRendering=s.disableChildRendering,f.castShadow=s.castShadow,f.receiveShadow=s.receiveShadow,f.renderOrder=s.renderOrder,f.groupNames=s.groupNames;for(let e=0;e<n.length;e++){const m=n[e];m.parent.remove(m)}t&&d.computeBoundsTree({verbose:!1}),console.log("Adding batch object:",c),e.add(f)}else console.warn("Failed to create batch object:",c)}}}},Kg={calcCameraZoomToObjectsParams:(qg=new g,Qg=new fr,function(e,t,n,r){var i=qg.makeEmpty(),t=(t.forEach(function(e){i.expandByObject(e)}),i.getBoundingSphere(Qg));Kg.calcCameraZoomToSphereParams(e,t,n,r)}),calcCameraZoomToSphereParams:(Zg=new vt,function(e,t,n,r){var i=En(e.fov/2),i=(e.aspect<1&&(i=Math.atan(e.aspect*Math.tan(i))),t.radius/Math.sin(i)),e=e.getWorldDirection(Zg);n.copy(t.center).addScaledVector(e,-i),r.copy(t.center)})},Jg={normalizeDialectOptions:function(e){var t,n={delimiter:",",doublequote:!0,lineterminator:"\n",quotechar:'"',skipinitialspace:!0,skipinitialrows:0};for(t in e)n[t.toLowerCase()]=e[t];return n},parse:function(e,t){t&&t.lineterminator||(e=Jg.normalizeLineTerminator(e,t));for(var n,r=Jg.normalizeDialectOptions(t),i=(e=Jg.chomp(e,r.lineterminator),!1),a=!1,o="",s=[],l=[],c=function(e){var t=String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")};return!0!==a&&(""===e?e=null:!0===r.skipinitialspace&&(e=t(e)),/^\d+$/.test(e)?e=parseInt(e,10):/^\d*\.\d+$|^\d+\.\d*$/.test(e)&&(e=parseFloat(e,10))),e},u=0;u<e.length;u+=1)n=e.charAt(u),!1!==i||n!==r.delimiter&&n!==r.lineterminator?n!==r.quotechar?o+=n:i?e.charAt(u+1)===r.quotechar?(o+=r.quotechar,u+=1):i=!1:a=i=!0:(o=c(o),s.push(o),n===r.lineterminator&&(l.push(s),s=[]),o="",a=!1);return o=c(o),s.push(o),l.push(s),l=r.skipinitialrows?l.slice(r.skipinitialrows):l},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 $g=new vt(1,0,0),e2=new vt,t2=new vt,n2=new de;class r2 extends ee{constructor(e,t){e=void 0!==e?e:new _t(1,0,0),t=void 0!==t?t:2;const n=new P1;n.setGeometry([0,0,0,$g.x,$g.y,$g.z]);e=new B1({color:e,lineWidth:t,sizeAttenuation:0});super(n.geometry,e),this.elemHTML=null,this.offset=5}onBeforeRender(n,e,r,t,i,a){if(super.onBeforeRender(),this.elemHTML){var o=n.domElement.offsetHeight,n=n.domElement.offsetWidth,s=this.elemHTML.getBoundingClientRect(),l=(s.left+s.right)/2,c=(s.top+s.bottom)/2,u=this.getWorldPosition(e2).project(r),d=(u.x+1)/2*n,u=(1-u.y)/2*o,h=(c-u)/(l-d),p=(s.height+2*this.offset)/(s.width+2*this.offset);let e,t;Math.abs(h)>p?(t=c<u?Math.min(s.bottom+this.offset,u):Math.max(s.top-this.offset,u),e=(t-u)/h+d):(e=d<l?Math.max(s.left-this.offset,d):Math.min(s.right+this.offset,d),t=(e-d)*h+u);p=2*e/n-1,c=1-2*t/o;const f=t2.set(p,c,-1);f.unproject(r),this.parent&&this.parent.worldToLocal(f);l=f.length(),s=(this.scale.setScalar(l),f.normalize(),n2.setFromUnitVectors($g,f));this.setRotationFromQuaternion(s),this.updateMatrixWorld()}}}function i2(){}function a2(e){for(var t in i2.call(this),e){var n=e[t];"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("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiCiAgIGlkPSJzdmcyNzc1IgogICB2ZXJzaW9uPSIxLjEiCiAgIHZpZXdCb3g9IjAgMCAyOS4xMDQxNjYgMzEuNzUwMDAxIgogICBoZWlnaHQ9IjEyMCIKICAgd2lkdGg9IjExMCI+CiAgPGRlZnMKICAgICBpZD0iZGVmczI3NjkiPgogICAgPGxpbmVhckdyYWRpZW50CiAgICAgICBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIKICAgICAgIHkyPSI1My44MDY2MTgiCiAgICAgICB4Mj0iMTkzLjc4NDciCiAgICAgICB5MT0iNzguNjg5NDA3IgogICAgICAgeDE9IjE3Mi45MTMzNiIKICAgICAgIGlkPSJsaW5lYXJHcmFkaWVudDMwNzktOCIKICAgICAgIHhsaW5rOmhyZWY9IiNsaW5lYXJHcmFkaWVudDMwNzciCiAgICAgICBncmFkaWVudFRyYW5zZm9ybT0ibWF0cml4KDEuMTY0NzU5NCwwLDAsMS4xNTgzOTgyLC0xOTcuMTUzMTksMjAzLjUxNjUxKSIgLz4KICAgIDxsaW5lYXJHcmFkaWVudAogICAgICAgaWQ9ImxpbmVhckdyYWRpZW50MzA3NyI+CiAgICAgIDxzdG9wCiAgICAgICAgIGlkPSJzdG9wMzA3MyIKICAgICAgICAgb2Zmc2V0PSIwIgogICAgICAgICBzdHlsZT0ic3RvcC1jb2xvcjojMDA0OGE1O3N0b3Atb3BhY2l0eToxIiAvPgogICAgICA8c3RvcAogICAgICAgICBpZD0ic3RvcDMwNzUiCiAgICAgICAgIG9mZnNldD0iMSIKICAgICAgICAgc3R5bGU9InN0b3AtY29sb3I6IzRiODZkMTtzdG9wLW9wYWNpdHk6MSIgLz4KICAgIDwvbGluZWFyR3JhZGllbnQ+CiAgPC9kZWZzPgogIDxtZXRhZGF0YQogICAgIGlkPSJtZXRhZGF0YTI3NzIiPgogICAgPHJkZjpSREY+CiAgICAgIDxjYzpXb3JrCiAgICAgICAgIHJkZjphYm91dD0iIj4KICAgICAgICA8ZGM6Zm9ybWF0PmltYWdlL3N2Zyt4bWw8L2RjOmZvcm1hdD4KICAgICAgICA8ZGM6dHlwZQogICAgICAgICAgIHJkZjpyZXNvdXJjZT0iaHR0cDovL3B1cmwub3JnL2RjL2RjbWl0eXBlL1N0aWxsSW1hZ2UiIC8+CiAgICAgICAgPGRjOnRpdGxlPjwvZGM6dGl0bGU+CiAgICAgIDwvY2M6V29yaz4KICAgIDwvcmRmOlJERj4KICA8L21ldGFkYXRhPgogIDxnCiAgICAgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMCwtMjY1LjI0OTk2KSIKICAgICBpZD0ibGF5ZXIxIj4KICAgIDxwYXRoCiAgICAgICBzdHlsZT0iZGlzcGxheTppbmxpbmU7ZmlsbDp1cmwoI2xpbmVhckdyYWRpZW50MzA3OS04KTtmaWxsLW9wYWNpdHk6MTtzdHJva2U6bm9uZTtzdHJva2Utd2lkdGg6MC45MjA0NTI2NTtzdHJva2UtbWl0ZXJsaW1pdDo0O3N0cm9rZS1kYXNoYXJyYXk6bm9uZTtzdHJva2Utb3BhY2l0eToxIgogICAgICAgZD0ibSAxNC42MjI3OTMsMjY1LjI1MDA0IGMgLTEuNjgyMTUsLTAuMDA3IC0zLjM2OTMsMS4xMDUxMSAtNy4yODAyNDk3LDMuMzI3ODYgLTcuODIxOTEwMDcsNC40NDU1IC03LjI4MTA3MDA3LDMuNTIzMzggLTcuMzIwOTcwMDcsMTIuNDgzMDkgLTAuMDM5OSw4Ljk1OTcxIC0wLjU3MjQ3LDguMDMyODUgNy4yMDk1NTAwNywxMi41NDcwNyA3Ljc4MTk4OTcsNC41MTQyNCA2LjcwODYwOTcsNC41MDk1IDE0LjUzMDQ5OTcsMC4wNjM5IDcuODIxOTEsLTQuNDQ1NDkgNy4yODEwNjIsLTMuNTIzMzcgNy4zMjA5NzEsLTEyLjQ4MzA5IDAuMDM5OSwtOC45NTk3MSAwLjU3MjQ1OCwtOC4wMzI4NSAtNy4yMDk1NTEsLTEyLjU0NzA3IC0zLjg5MSwtMi4yNTcxMiAtNS41NjgxMiwtMy4zODQ0NSAtNy4yNTAyNSwtMy4zOTE4NiB6IG0gLTAuMDEzMywyLjg1MTY3IGMgMS42OTU5NCwwLjAwNyAzLjM4ODMzLDAuODEyODEgNi4xNjAxNiwyLjQyMDY5IDUuNTQzNjIsMy4yMTU3OCA2LjE1MTkzMSw0LjI3NDM4IDYuMTIzNDkxLDEwLjY1Njk2IC0wLjAyODQsNi4zODI2IC0wLjY0NjEwMSw3LjQzNTc2IC02LjIxODE1MSwxMC42MDI1OCAtNS41NzIwMywzLjE2NjgxIC02Ljc5OCwzLjE2MTM5IC0xMi4zNDE2Mzk3LC0wLjA1NDMgLTUuNTQzNjEsLTMuMjE1NzcgLTYuMTUxODksLTQuMjc0MzcgLTYuMTIzNDksLTEwLjY1Njk2IDAuMDI4NiwtNi4zODI1OCAwLjY0NjEsLTcuNDM1NzUgNi4yMTgxNiwtMTAuNjAyNTggMi43ODYwMjk3LC0xLjU4MzQgNC40ODU1Mzk3LC0yLjM3Mzc3IDYuMTgxNDY5NywtMi4zNjYzIHogbSAtMC4xNTUzNywxLjYxNzY5IGMgLTIuNzEzOTEsMC4wMzQxIC01LjcyNDk5OTcsMy4wNzAwOCAtNy4yODkzNTk3LDYuMDc1NDkgLTEuNTg5MjEsMy4wNTMxMSAtMi40OTg1Miw1Ljk0NDU2IC0yLjEyNDA1LDkuNjU3NTEgMC4xNjMwNywxLjYxNjU0IDEuNzEwODIsMy42Nzk4NCAzLjU2Mzc2LDQuNzE0MjYgLTAuMzkzODIsLTMuMjA2MiAtMC4xNzIsLTYuMzQzMDUgMC41NDM5NjEsLTguOTQ2OTIgMC43MTU5NTksLTIuNjAzODcgMi44NTI5Nzg3LC02LjgyODgxIDUuMzc2MjQ4NywtNi44MjMxNiAyLjUyMzMxLDAuMDA2IDQuNjYwMjcsNC4yMjcwNCA1LjM3NjIyLDYuODMwODkgMC43MTU5MywyLjYwMzg4IDAuOTM3NzcsNS43NDA3NSAwLjU0Mzk0LDguOTQ2OTQgMS44NTI5NCwtMS4wMzQ0MyAzLjQwMDcxLC0zLjA5Nzc4IDMuNTYzNzcsLTQuNzE0MzEgMC4zNzQ0OCwtMy43MTI5OCAtMC41MzQ3MSwtNi42MDQyNyAtMi4xMjM5MywtOS42NTc0IC0xLjU1ODkzLC0yLjk5NDk4IC00LjU1NDY1LC02LjAxOTg4IC03LjMwMTU1LC02LjA4MjY2IC0wLjA0MzEsLTkuOGUtNCAtMC4wODYsLTkuOGUtNCAtMC4xMjg5NywtNi4xZS00IHogbSAwLjEzMjY3LDguOTE4NDEgYSAyLjQ5MTI2MzEsMi40Nzc2NTczIDAgMCAwIC0xLjE5NzM0LDAuMjkxNTIgMi40OTEyNjMxLDIuNDc3NjU3MyAwIDAgMCAtMS4wMjUzNCwzLjM1MjI5IDIuNDkxMjYzMSwyLjQ3NzY1NzMgMCAwIDAgMy4zNzA2OSwxLjAxOTcxIDIuNDkxMjYzMSwyLjQ3NzY1NzMgMCAwIDAgMS4wMjUzNCwtMy4zNTIyOCAyLjQ5MTI2MzEsMi40Nzc2NTczIDAgMCAwIC0yLjE3MzM1LC0xLjMxMTI0IHoiCiAgICAgICBpZD0icGF0aDYwNDctMiIgLz4KICA8L2c+Cjwvc3ZnPgo=");'),this.clock=new _h}r2.prototype.isLineHTML=!0,Object.assign(i2.prototype,{onUpdate:function(e){},onFinish:function(){}}),a2.prototype=Object.assign(Object.create(i2.prototype),{constructor:a2,onUpdate:function(e){e=Math.round(e),this.bar.style.width=e+"%"},onFinish:function(){this.container.removeChild(this.background)}});function o2(){}function s2(e){ee.call(this),this.type="CubeTextureHelper",this.geometry=new oa(2,2,2,1,1,1),this.geometry.computeBoundingSphere(),this.material=new fi,this.material.envMap=e}Object.assign(o2.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:function(n){const r=this;return new Promise(function(e,t){H1.loadScript(n,document.body,function(){e()},function(){t(r._logicFileLoadError("Unable to load the logic file: '"+n+"'."))})})},_getEditorPromise:function(n,e){const r=this;return new Promise(function(e,t){H1.loadScript(n,document.body,function(){e()},function(){t(r._editorLoadError("Unable to load the Puzzles Editor: '"+n+"'."))})})},_getLogicViaEditorPromise:function(a,o){const s=this;return new Promise(function(t,n){const e=Pi();if(e.v3d&&e.v3d.PE){const r=o.split("."),i=(r[r.length-1]="xml",r.join("."));e.v3d.PE.init(a,i,function(e){e?t():n(s._logicFileLoadError("Unable to load the Puzzles Editor's XML logic file: '"+i+"'."))})}else n(s._editorLoadError("Unable to load Puzzles' logic. The Puzzles Editor isn't loaded."))})},_getAmmoJSPromise:function(){return"function"==typeof window.Ammo?new Promise(function(e,t){window.Ammo().then(function(){window.Ammo=Ammo,e()})}):Promise.resolve()},loadLogic:function(e,t,n){const r=this;this._getLogicPromise(e).then(function(){return r._getAmmoJSPromise()}).then(function(){t&&t()},function(e){console.error(e),n&&n(e)})},loadEditorWithLogic:function(e,t,n,r){const i=this;i._getEditorPromise(e+"puzzles.min.js").then(function(){return i._getLogicViaEditorPromise(e,t)}).catch(function(e){return"LogicFileLoadError"===e.name?Promise.resolve():Promise.reject(e)}).then(function(){return i._getAmmoJSPromise()}).then(function(){n&&n()}).catch(function(e){console.error(e),r&&r(e)})}}),(s2.prototype=Object.create(ee.prototype)).constructor=s2;class l2 extends he{constructor(e){super(),this.doUpdate=!0,this.projected=new vt,this.container=e,this.updatedCallback=null}clone(){return new this.constructor(this.container).copy(this)}update(e){var t,n,r,i;this.doUpdate&&(t=this.projected,this.getWorldPosition(t).project(e),e=this.container.offsetWidth,n=this.container.offsetHeight,i=(.5+t.x/2)*e,r=(.5-t.y/2)*n,t.x=i,t.y=r,i=t.z<=1&&0<=i&&i<=e&&0<=r&&r<=n,this.visible=i,this.updatedCallback&&this.updatedCallback(t.x,t.y,i))}}l2.prototype.isAnnotationControl=!0;var c2=new Ws,u2=new vt,d2=new vt,h2=new vt;class p2 extends l2{constructor(e,t,n){super(e),this.type="Annotation",this.character=t,this.dialogContents=n,this.annotation=document.createElement("div"),this.annotation.innerHTML=t,this.annotation.className="v3d-annotation",this.container.appendChild(this.annotation),this.annotationDialogVisible=!1,this.annotationDialog=document.createElement("div"),this.annotationDialog.innerHTML=n,this.annotationDialog.className="v3d-annotation-dialog",this.annotation.appendChild(this.annotationDialog),this.fadeObscured=!0,this.obscured=!1,this.text=this.dialogContents,this.annotationText=this.annotationDialog;var r=!1,i=this;function a(e){e.target!=i.annotation?-1<e.target.className.indexOf("v3d-annotation")&&(i.annotationDialogVisible=!1,i.annotationDialog.style.visibility="hidden",i.annotation.style.zIndex=i.obscured?"auto":"1"):0==i.annotationDialog.innerHTML.length||i.obscured||(i.annotationDialogVisible=!i.annotationDialogVisible,i.annotationDialog.style.visibility=i.annotationDialogVisible?"visible":"hidden",i.annotationDialogVisible?i.annotation.style.zIndex="2":i.annotation.style.zIndex="1")}this._touchstartCb=function(e){a(e),r=!0},document.body.addEventListener("touchstart",this._touchstartCb,!1),this._mousedownCb=function(e){r||a(e),r=!1},document.body.addEventListener("mousedown",this._mousedownCb,!1)}raycast(){}clone(){return new this.constructor(this.container,this.character,this.dialogContents).copy(this)}update(e){super.update(e);var t=this.projected,n=this.annotation;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(u2),this.getWorldPositionNU(d2),h2.copy(d2).sub(u2).normalize(),c2.set(u2,h2),c2.far=u2.distanceTo(d2),1<(t=c2.intersectObject(this.findRoot(),!0)).length||1==t.length&&t[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)}}p2.prototype.isAnnotation=!0;var f2,m2,Dh={translateVRCamera:function(){var i=new vt;new gt;return function(e,t,n){var r=e.parent;r&&!r.isScene&&(i.copy(t).applyQuaternion(e.quaternion).applyQuaternion(r.quaternion),r.position.add(i.multiplyScalar(n)))}}(),rotateVRCamera:(f2=new de,m2=new de,function(e,t,n){var r=e.parent;r&&!r.isScene&&(f2.setFromAxisAngle(t,n),f2.premultiply(e.quaternion),f2.premultiply(r.quaternion),r.quaternion.multiplyQuaternions(f2,m2.copy(e.quaternion).invert()))})},Oh=function(){function p(){this.pluginCallbacks=[],this.register(function(e){return new A(e)}),this.register(function(e){return new w(e)}),this.register(function(e){return new S(e)})}p.prototype={constructor:p,register:function(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this},unregister:function(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this},parse:function(e,t,n){for(var r=new h,i=[],a=0,o=this.pluginCallbacks.length;a<o;a++)i.push(this.pluginCallbacks[a](r));r.setPlugins(i),r.write(e,t,n)}};var O=0,F=1,B=2,z=3,V=4,f=5121,m=5123,v=5126,g=5125,_=34962,c=34963,e=9728,t=9729,n=9984,r=9985,i=9986,a=9987,o=33071,s=33648,l=10497,u={},x=(u[dt]=e,u[W]=n,u[H]=i,u[ht]=t,u[We]=r,u[He]=a,u[ut]=o,u[U]=l,u[G]=s,{scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"});function y(e,n){return e.length===n.length&&e.every(function(e,t){return e===n[t]})}function b(e){return 4*Math.ceil(e/4)}function d(e,t){t=t||0;var n=b(e.byteLength);if(n===e.byteLength)return e;var r=new Uint8Array(n);if(r.set(new Uint8Array(e)),0!==t)for(var i=e.byteLength;i<n;i++)r[i]=t;return r.buffer}var M=null;function h(){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:"Verge3D Runtime Exporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}function A(e){this.writer=e,this.name="KHR_lights_punctual"}function w(e){this.writer=e,this.name="KHR_materials_unlit"}function S(e){this.writer=e,this.name="KHR_materials_pbrSpecularGlossiness"}return h.prototype={constructor:h,setPlugins:function(e){this.plugins=e},write:function(e,u,t){this.options=Object.assign({},{binary:!1,trs:!1,onlyVisible:!0,truncateDrawRange:!0,embedImages:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},t),0<this.options.animations.length&&(this.options.trs=!0),this.processInput(e);var r=this;Promise.all(this.pending).then(function(){var l,e=r.buffers,c=r.json,t=r.options,n=r.extensionsUsed,e=new Blob(e,{type:"application/octet-stream"}),n=Object.keys(n);0<n.length&&(c.extensionsUsed=n),c.buffers&&0<c.buffers.length&&(c.buffers[0].byteLength=e.size),!0===t.binary?((l=new window.FileReader).readAsArrayBuffer(e),l.onloadend=function(){var e=d(l.result),t=new DataView(new ArrayBuffer(8)),n=(t.setUint32(0,e.byteLength,!0),t.setUint32(4,5130562,!0),d(function(e){if(void 0!==window.TextEncoder)return(new TextEncoder).encode(e).buffer;for(var t=new Uint8Array(new ArrayBuffer(e.length)),n=0,r=e.length;n<r;n++){var i=e.charCodeAt(n);t[n]=255<i?32:i}return t.buffer}(JSON.stringify(c)),32)),r=new DataView(new ArrayBuffer(8)),i=(r.setUint32(0,n.byteLength,!0),r.setUint32(4,1313821514,!0),new ArrayBuffer(12)),a=new DataView(i),o=(a.setUint32(0,1179937895,!0),a.setUint32(4,2,!0),12+r.byteLength+n.byteLength+t.byteLength+e.byteLength),a=(a.setUint32(8,o,!0),new Blob([i,r,n,t,e],{type:"application/octet-stream"})),s=new window.FileReader;s.readAsArrayBuffer(a),s.onloadend=function(){u(s.result)}}):c.buffers&&0<c.buffers.length?((l=new window.FileReader).readAsDataURL(e),l.onloadend=function(){var e=l.result;c.buffers[0].uri=e,u(c)}):u(c)})},serializeUserData:function(t,e){if(0!==Object.keys(t.userData).length){var n=this.options,r=this.extensionsUsed;try{var i=JSON.parse(JSON.stringify(t.userData));if(n.includeCustomExtensions&&i.gltfExtensions){for(var a in void 0===e.extensions&&(e.extensions={}),i.gltfExtensions)e.extensions[a]=i.gltfExtensions[a],r[a]=!0;delete i.gltfExtensions}0<Object.keys(i).length&&(e.extras=i)}catch(e){console.warn("v3d.GLTFExporter: userData of '"+t.name+"' won't be serialized because of JSON.stringify error - "+e.message)}}},getUID:function(e){return this.uids.has(e)||this.uids.set(e,this.uid++),this.uids.get(e)},isNormalizedNormalAttribute:function(e){if(this.cache.attributesNormalized.has(e))return!1;for(var t=new vt,n=0,r=e.count;n<r;n++)if(5e-4<Math.abs(t.fromBufferAttribute(e,n).length()-1))return!1;return!0},createNormalizedNormalAttribute:function(e){var t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);for(var n=e.clone(),r=new vt,i=0,a=n.count;i<a;i++)r.fromBufferAttribute(n,i),0===r.x&&0===r.y&&0===r.z?r.setX(1):r.normalize(),n.setXYZ(i,r.x,r.y,r.z);return t.attributesNormalized.set(e,n),n},applyTextureTransform:function(e,t){var n=!1,r={};0===t.offset.x&&0===t.offset.y||(r.offset=t.offset.toArray(),n=!0),0!==t.rotation&&(r.rotation=t.rotation,n=!0),1===t.repeat.x&&1===t.repeat.y||(r.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)},processBuffer:function(e){var t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0},processBufferView:function(e,t,n,r,i){for(var a,o=this.json,s=(o.bufferViews||(o.bufferViews=[]),a=t===f?1:t===m?2:4,b(r*e.itemSize*a)),l=new DataView(new ArrayBuffer(s)),c=0,u=n;u<n+r;u++)for(var d,h=0;h<e.itemSize;h++)4<e.itemSize?d=e.array[u*e.itemSize+h]:0===h?d=e.getX(u):1===h?d=e.getY(u):2===h?d=e.getZ(u):3===h&&(d=e.getW(u)),t===v?l.setFloat32(c,d,!0):t===g?l.setUint32(c,d,!0):t===m?l.setUint16(c,d,!0):t===f&&l.setUint8(c,d),c+=a;var p={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:s};return void 0!==i&&(p.target=i),i===_&&(p.byteStride=e.itemSize*a),this.byteOffset+=s,o.bufferViews.push(p),{id:o.bufferViews.length-1,byteLength:0}},processBufferViewImage:function(e){var i=this,a=i.json;return a.bufferViews||(a.bufferViews=[]),new Promise(function(n){var r=new window.FileReader;r.readAsArrayBuffer(e),r.onloadend=function(){var e=d(r.result),t={buffer:i.processBuffer(e),byteOffset:i.byteOffset,byteLength:e.byteLength};i.byteOffset+=e.byteLength,n(a.bufferViews.push(t)-1)}})},processAccessor:function(e,t,n,r){var i,a=this.options,o=this.json;if(e.array.constructor===Float32Array)i=v;else if(e.array.constructor===Uint32Array)i=g;else if(e.array.constructor===Uint16Array)i=m;else{if(e.array.constructor!==Uint8Array)throw new Error("v3d.GLTFExporter: Unsupported bufferAttribute component type.");i=f}if(void 0===n&&(n=0),void 0===r&&(r=e.count),a.truncateDrawRange&&void 0!==t&&null===t.index&&(a=n+r,l=t.drawRange.count===1/0?e.count:t.drawRange.start+t.drawRange.count,n=Math.max(n,t.drawRange.start),(r=Math.min(a,l)-n)<0&&(r=0)),0===r)return null;var s,a=function(e,t,n){for(var r={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)},i=t;i<t+n;i++)for(var a,o=0;o<e.itemSize;o++)4<e.itemSize?a=e.array[i*e.itemSize+o]:0===o?a=e.getX(i):1===o?a=e.getY(i):2===o?a=e.getZ(i):3===o&&(a=e.getW(i)),r.min[o]=Math.min(r.min[o],a),r.max[o]=Math.max(r.max[o],a);return r}(e,n,r),l=(void 0!==t&&(s=e===t.index?c:_),this.processBufferView(e,i,n,r,s)),t={bufferView:l.id,byteOffset:l.byteOffset,componentType:i,count:r,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(t.normalized=!0),o.accessors||(o.accessors=[]),o.accessors.push(t)-1},processImage:function(e,t,n){var r=this,i=r.cache,a=r.json,o=r.options,s=r.pending,i=(i.images.has(e)||i.images.set(e,{}),i.images.get(e)),l=t===pt?"image/png":"image/jpeg",c=l+":flipY/"+n.toString();if(void 0!==i[c])return i[c];a.images||(a.images=[]);var u={mimeType:l};if(o.embedImages){var d=M=M||document.createElement("canvas"),h=(d.width=Math.min(e.width,o.maxTextureSize),d.height=Math.min(e.height,o.maxTextureSize),d.getContext("2d"));if(!0===n&&(h.translate(0,d.height),h.scale(1,-1)),"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap)h.drawImage(e,0,0,d.width,d.height);else{t!==pt&&t!==wt&&console.error("GLTFExporter: Only RGB and RGBA formats are supported."),(e.width>o.maxTextureSize||e.height>o.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);var p=e.data;if(t===wt)for(var p=new Uint8ClampedArray(e.height*e.width*4),f=0,m=0;f<p.length;f+=4,m+=3)p[f+0]=e.data[m+0],p[f+1]=e.data[m+1],p[f+2]=e.data[m+2],p[f+3]=255;h.putImageData(new ImageData(p,e.width,e.height),0,0)}!0===o.binary?s.push(new Promise(function(t){d.toBlob(function(e){r.processBufferViewImage(e).then(function(e){u.bufferView=e,t()})},l)})):u.uri=d.toDataURL(l)}else u.uri=e.src;n=a.images.push(u)-1;return i[c]=n},processSampler:function(e){var t=this.json,e=(t.samplers||(t.samplers=[]),{magFilter:u[e.magFilter],minFilter:u[e.minFilter],wrapS:u[e.wrapS],wrapT:u[e.wrapT]});return t.samplers.push(e)-1},processTexture:function(t){var e=this.cache,n=this.json;if(e.textures.has(t))return e.textures.get(t);n.textures||(n.textures=[]);var r={sampler:this.processSampler(t),source:this.processImage(t.image,t.format,t.flipY)},n=(t.name&&(r.name=t.name),this._invokeAll(function(e){e.writeTexture&&e.writeTexture(t,r)}),n.textures.push(r)-1);return e.textures.set(t,n),n},processMaterial:function(t){var e=this.cache,n=this.json;if(e.materials.has(t))return e.materials.get(t);if(t.isShaderMaterial)return console.warn("GLTFExporter: v3d.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);var r={pbrMetallicRoughness:{}},i=(!0!==t.isMeshStandardMaterial&&!0!==t.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results."),t.color.toArray().concat([t.opacity])),i=(y(i,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=i),t.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=t.metalness,r.pbrMetallicRoughness.roughnessFactor=t.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5),(t.metalnessMap||t.roughnessMap)&&(t.metalnessMap===t.roughnessMap?(i={index:this.processTexture(t.metalnessMap)},this.applyTextureTransform(i,t.metalnessMap),r.pbrMetallicRoughness.metallicRoughnessTexture=i):console.warn("v3d.GLTFExporter: Ignoring metalnessMap and roughnessMap because they are not the same Texture.")),t.map&&(i={index:this.processTexture(t.map)},this.applyTextureTransform(i,t.map),r.pbrMetallicRoughness.baseColorTexture=i),t.emissive&&(y(i=t.emissive.clone().multiplyScalar(t.emissiveIntensity).toArray(),[0,0,0])||(r.emissiveFactor=i),t.emissiveMap&&(i={index:this.processTexture(t.emissiveMap)},this.applyTextureTransform(i,t.emissiveMap),r.emissiveTexture=i)),t.normalMap&&(i={index:this.processTexture(t.normalMap)},t.normalScale&&-1!==t.normalScale.x&&(t.normalScale.x!==t.normalScale.y&&console.warn("v3d.GLTFExporter: Normal scale components are different, ignoring Y and exporting X."),i.scale=t.normalScale.x),this.applyTextureTransform(i,t.normalMap),r.normalTexture=i),t.aoMap&&(i={index:this.processTexture(t.aoMap),texCoord:1},1!==t.aoMapIntensity&&(i.strength=t.aoMapIntensity),this.applyTextureTransform(i,t.aoMap),r.occlusionTexture=i),t.transparent?r.alphaMode="BLEND":0<t.alphaTest&&(r.alphaMode="MASK",r.alphaCutoff=t.alphaTest),t.side===Ue&&(r.doubleSided=!0),""!==t.name&&(r.name=t.name),this.serializeUserData(t,r),this._invokeAll(function(e){e.writeMaterial&&e.writeMaterial(t,r)}),n.materials.push(r)-1);return e.materials.set(t,i),i},processMesh:function(t){var e=this.cache,n=this.json,r=[t.geometry.uuid];if(Array.isArray(t.material))for(var i=0,a=t.material.length;i<a;i++)r.push(t.material[i].uuid);else r.push(t.material.uuid);var o=r.join(":");if(e.meshes.has(o))return e.meshes.get(o);var s=t.geometry,l=t.isLineSegments?F:t.isLineLoop?B:t.isLine?z:t.isPoints?O:t.material.wireframe?F:V;if(!0!==s.isBufferGeometry)throw new Error("v3d.GLTFExporter: Geometry is not of type v3d.BufferGeometry.");var c,u={},d={},h=[],p=[],f={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},m=s.getAttribute("normal"),v=(void 0===m||this.isNormalizedNormalAttribute(m)||(console.warn("v3d.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),s.setAttribute("normal",this.createNormalizedNormalAttribute(m))),null);for(b in s.attributes)"morph"!==b.substr(0,5)&&(w=s.attributes[b],b=f[b]||b.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(b)||(b="_"+b),e.attributes.has(this.getUID(w))?d[b]=e.attributes.get(this.getUID(w)):(v=null,c=w.array,"JOINTS_0"!==b||c instanceof Uint16Array||c instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),v=new re(new Uint16Array(c),w.itemSize,w.normalized)),null!==(c=this.processAccessor(v||w,s))&&(d[b]=c,e.attributes.set(this.getUID(w),c))));if(void 0!==m&&s.setAttribute("normal",m),0===Object.keys(d).length)return null;if(void 0!==t.morphTargetInfluences&&0<t.morphTargetInfluences.length){var g=[],_=[],x={};if(void 0!==t.morphTargetDictionary)for(var y in t.morphTargetDictionary)x[t.morphTargetDictionary[y]]=y;for(i=0;i<t.morphTargetInfluences.length;++i){var b,M={},A=!1;for(b in s.morphAttributes)if("position"!==b&&"normal"!==b)A||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),A=!0);else{var w=s.morphAttributes[b][i],S=b.toUpperCase(),T=s.attributes[b];if(e.attributes.has(this.getUID(w)))M[S]=e.attributes.get(this.getUID(w));else{var C=w.clone();if(!s.morphTargetsRelative)for(var E=0,L=w.count;E<L;E++)C.setXYZ(E,w.getX(E)-T.getX(E),w.getY(E)-T.getY(E),w.getZ(E)-T.getZ(E));M[S]=this.processAccessor(C,s),e.attributes.set(this.getUID(T),M[S])}}p.push(M),g.push(t.morphTargetInfluences[i]),void 0!==t.morphTargetDictionary&&_.push(x[i])}u.weights=g,0<_.length&&(u.extras={},u.extras.targetNames=_)}m=Array.isArray(t.material);if(m&&0===s.groups.length)return null;for(var R=m?t.material:[t.material],P=m?s.groups:[{materialIndex:0,start:void 0,count:void 0}],i=0,I=P.length;i<I;i++){var N={mode:l,attributes:d},D=(this.serializeUserData(s,N),0<p.length&&(N.targets=p),null!==s.index&&(D=this.getUID(s.index),void 0===P[i].start&&void 0===P[i].count||(D+=":"+P[i].start+":"+P[i].count),e.attributes.has(D)?N.indices=e.attributes.get(D):(N.indices=this.processAccessor(s.index,s,P[i].start,P[i].count),e.attributes.set(D,N.indices)),null===N.indices&&delete N.indices),this.processMaterial(R[P[i].materialIndex]));null!==D&&(N.material=D),h.push(N)}u.primitives=h,n.meshes||(n.meshes=[]),this._invokeAll(function(e){e.writeMesh&&e.writeMesh(t,u)});m=n.meshes.push(u)-1;return e.meshes.set(o,m),m},processCamera:function(e){var t=this.json,n=(t.cameras||(t.cameras=[]),e.isOrthographicCamera),r={type:n?"orthographic":"perspective"};return n?r.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:En(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(r.name=e.type),t.cameras.push(r)-1},processAnimation:function(e,t){for(var n=this.json,r=this.nodeMap,i=(n.animations||(n.animations=[]),(e=p.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks),a=[],o=[],s=0;s<i.length;++s){var l=i[s],c=C.parseTrackName(l.name),u=C.findNode(t,c.nodeName),d=x[c.propertyName];if(!(u="bones"===c.objectName?!0===u.isSkinnedMesh?u.skeleton.getBoneByName(c.objectIndex):void 0:u)||!d)return console.warn('v3d.GLTFExporter: Could not export animation track "%s".',l.name),null;var h,c=l.values.length/l.times.length;d===x.morphTargetInfluences&&(c/=u.morphTargetInfluences.length),!0===l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(h="CUBICSPLINE",c/=3):h=l.getInterpolation()===Jt?"STEP":"LINEAR",o.push({input:this.processAccessor(new re(l.times,1)),output:this.processAccessor(new re(l.values,c)),interpolation:h}),a.push({sampler:o.length-1,target:{node:r.get(u),path:d}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:o,channels:a}),n.animations.length-1},processSkin:function(e){var t=this.json,n=this.nodeMap,r=t.nodes[n.get(e)],i=e.skeleton;if(void 0===i)return null;var a=e.skeleton.bones[0];if(void 0===a)return null;for(var o=[],s=new Float32Array(16*i.bones.length),l=new gt,c=0;c<i.bones.length;++c)o.push(n.get(i.bones[c])),l.copy(i.boneInverses[c]),l.multiply(e.bindMatrix).toArray(s,16*c);return void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new re(s,16)),joints:o,skeleton:n.get(a)}),r.skin=t.skins.length-1},processNode:function(t){var e=this.json,n=this.options,r=this.nodeMap,i=!1;if(n.onlyVisible&&!t.visible&&(t.traverse(function(e){e.visible&&(i=!0)}),!i))return null;e.nodes||(e.nodes=[]);var a,o,s={};if(n.trs?(n=t.quaternion.toArray(),a=t.position.toArray(),o=t.scale.toArray(),y(n,[0,0,0,1])||(s.rotation=n),y(a,[0,0,0])||(s.translation=a),y(o,[1,1,1])||(s.scale=o)):(t.matrixAutoUpdate&&t.updateMatrix(),!1===y(t.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(s.matrix=t.matrix.elements)),""!==t.name&&(s.name=String(t.name)),this.serializeUserData(t,s),(t.isMesh||t.isLine||t.isPoints)&&!i?null!==(n=this.processMesh(t))&&(s.mesh=n):t.isCamera&&!i&&(s.camera=this.processCamera(t)),t.isSkinnedMesh&&!i&&this.skins.push(t),0<t.children.length){for(var l=[],c=0,u=t.children.length;c<u;c++){var d=t.children[c];null!==(h=this.processNode(d))&&l.push(h)}0<l.length&&(s.children=l)}this._invokeAll(function(e){e.writeNode&&e.writeNode(t,s)});var h=e.nodes.push(s)-1;return r.set(t,h),h},processScene:function(e){for(var t=this.json,n=this.options,r=(t.scenes||(t.scenes=[],t.scene=0),{}),i=(""!==e.name&&(r.name=e.name),t.scenes.push(r),[]),a=0,o=e.children.length;a<o;a++){var s=e.children[a];!s.visible&&!1!==n.onlyVisible||null!==(s=this.processNode(s))&&i.push(s)}0<i.length&&(r.nodes=i),this.serializeUserData(e,r)},processObjects:function(e){var t=new Js;t.name="AuxScene";for(var n=0;n<e.length;n++)t.children.push(e[n]);this.processScene(t)},processInput:function(t){for(var e=this.options,n=(t=t instanceof Array?t:[t],this._invokeAll(function(e){e.beforeParse&&e.beforeParse(t)}),[]),r=0;r<t.length;r++)t[r]instanceof Js?this.processScene(t[r]):n.push(t[r]);0<n.length&&this.processObjects(n);for(r=0;r<this.skins.length;++r)this.processSkin(this.skins[r]);for(r=0;r<e.animations.length;++r)this.processAnimation(e.animations[r],t[0]);this._invokeAll(function(e){e.afterParse&&e.afterParse(t)})},_invokeAll:function(e){for(var t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}},A.prototype={constructor:A,writeNode:function(e,t){var n,r,i;e.isLight&&(e.isDirectionalLight||e.isPointLight||e.isSpotLight?(n=(i=this.writer).json,i=i.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",0<e.distance&&(r.range=e.distance)):e.isSpotLight&&(r.type="spot",0<e.distance&&(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."),i[this.name]||(n.extensions=n.extensions||{},n.extensions[this.name]={lights:[]},i[this.name]=!0),(i=n.extensions[this.name].lights).push(r),t.extensions=t.extensions||{},t.extensions[this.name]={light:i.length-1}):console.warn("v3d.GLTFExporter: Only directional, point, and spot lights are supported.",e))}},w.prototype={constructor:w,writeMaterial:function(e,t){e.isMeshBasicMaterial&&(e=this.writer.extensionsUsed,t.extensions=t.extensions||{},t.extensions[this.name]={},e[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9)}},S.prototype={constructor:S,writeMaterial:function(e,t){var n,r,i,a;e.isGLTFSpecularGlossinessMaterial&&(r=(n=this.writer).extensionsUsed,i={},t.pbrMetallicRoughness.baseColorFactor&&(i.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor),e.specular.toArray(a=[1,1,1],0),i.specularFactor=a,i.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(i.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap&&(a={index:n.processTexture(e.specularMap)},n.applyTextureTransform(a,e.specularMap),i.specularGlossinessTexture=a),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0)}},p.Utils={insertKeyframe:function(e,t){var n,r=e.getValueSize(),i=new e.TimeBufferType(e.times.length+1),a=new e.ValueBufferType(e.values.length+r),o=e.createInterpolant(new e.ValueBufferType(r));if(0===e.times.length){i[0]=t;for(var s=0;s<r;s++)a[s]=0;n=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<.001)return 0;i[0]=t,i.set(e.times,1),a.set(o.evaluate(t),0),a.set(e.values,r),n=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<.001)return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),a.set(e.values,0),a.set(o.evaluate(t),e.values.length),n=i.length-1}else for(s=0;s<e.times.length;s++){if(Math.abs(e.times[s]-t)<.001)return s;if(e.times[s]<t&&e.times[s+1]>t){i.set(e.times.slice(0,s+1),0),i[s+1]=t,i.set(e.times.slice(s+1),s+2),a.set(e.values.slice(0,(s+1)*r),0),a.set(o.evaluate(t),(s+1)*r),a.set(e.values.slice((s+1)*r),(s+2)*r),n=s+1;break}}return e.times=i,e.values=a,n},mergeMorphTargetTracks:function(e,t){for(var n=[],r={},i=e.tracks,a=0;a<i.length;++a){var o=i[a],s=C.parseTrackName(o.name),l=C.findNode(t,s.nodeName);if("morphTargetInfluences"!==s.propertyName||void 0===s.propertyIndex)n.push(o);else{if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.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."),(o=o.clone()).setInterpolation($t)}var c=l.morphTargetInfluences.length,u=l.morphTargetDictionary[s.propertyIndex];if(void 0===u)throw new Error("v3d.GLTFExporter: Morph target name not found: "+s.propertyIndex);if(void 0===r[l.uuid]){for(var d,h=new(d=o.clone()).ValueBufferType(c*d.times.length),p=0;p<d.times.length;p++)h[p*c+u]=d.values[p];d.name=(s.nodeName||"")+".morphTargetInfluences",d.values=h,r[l.uuid]=d,n.push(d)}else{var f=o.createInterpolant(new o.ValueBufferType(1));d=r[l.uuid];for(p=0;p<d.times.length;p++)d.values[p*c+u]=f.evaluate(d.times[p]);for(p=0;p<o.times.length;p++){var m=this.insertKeyframe(d,o.times[p]);d.values[m*c+u]=o.values[p]}}}}return e.tracks=n,e}},p}();"undefined"!=typeof __V3D_DEVTOOLS__&&__V3D_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:o}})),"undefined"!=typeof window&&(window.__V3D__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__V3D__=o);const v2=Pi();if(v2.v3d&&(v2.THREE=v2.v3d),"undefined"!=typeof document){const g2=document.createElement("style");g2.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-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(g2,document.head.firstChild)}e.ACESFilmicToneMapping=4,e.AVERAGE=1,e.AddEquation=$,e.AddOperation=2,e.AdditiveAnimationBlendMode=2501,e.AdditiveBlending=q,e.AlphaFormat=f,e.AlwaysDepth=Re,e.AlwaysStencilFunc=519,e.AmbientLight=Zd,e.AmbientLightProbe=mh,e.AnimationClip=bd,e.AnimationLoader=class extends Sd{constructor(e){super(e)}load(t,n,e,r){const i=this,a=new Cd(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(e){try{n(i.parse(JSON.parse(e)))}catch(e){r?r(e):console.error(e),i.manager.itemError(t)}},e,r)}parse(t){const n=[];for(let e=0;e<t.length;e++){var r=bd.parse(t[e]);n.push(r)}return n}},e.AnimationMixer=Uh,e.AnimationObjectGroup=zh,e.AnimationUtils=y,e.Annotation=p2,e.AnnotationControl=l2,e.App=Yg,e.AppUtils=H1,e.ArcCurve=gc,e.ArrayCamera=Vs,e.ArrowHelper=bp,e.Audio=Sh,e.AudioAnalyser=Rh,e.AudioContext=hh,e.AudioListener=wh,e.AudioLoader=ph,e.AxesHelper=Mp,e.AxisHelper=function(e){return console.warn("v3d.AxisHelper has been renamed to v3d.AxesHelper."),new Mp(e)},e.BackSide=Fe,e.BasicDepthPacking=3200,e.BasicShadowMap=te,e.BilinearShadowMap=le,e.BinaryTextureLoader=function(e){return console.warn("v3d.BinaryTextureLoader has been renamed to v3d.DataTextureLoader."),new Rd(e)},e.BlenderTextBufferGeometry=vu,e.BlenderTextGeometry=vu,e.BloomPass=A1,e.BokehPass=w1,e.Bone=Cl,e.BooleanKeyframeTrack=fd,e.BoundingBoxHelper=function(e,t){return console.warn("v3d.BoundingBoxHelper has been deprecated. Creating a v3d.BoxHelper instead."),new vp(e,t)},e.Box2=Xh,e.Box3=g,e.Box3Helper=gp,e.BoxBufferGeometry=oa,e.BoxGeometry=oa,e.BoxHelper=vp,e.BrightnessContrastPass=T1,e.BufferAttribute=re,e.BufferGeometry=S,e.BufferGeometryLoader=rh,e.BufferGeometryUtils=Ih,e.ByteType=l,e.CENTER=0,e.CSVParser=Jg,e.Cache=Md,e.Camera=ua,e.CameraHelper=class extends jl{constructor(e){const t=new S;var n=new Bl({color:16777215,vertexColors:!0,toneMapped:!1});const r=[],i=[],a={};var o=new _t(16755200),s=new _t(16711680),l=new _t(43775),c=new _t(16777215),u=new _t(3355443);function d(e,t,n){h(e,n),h(t,n)}function h(e,t){r.push(0,0,0),i.push(t.r,t.g,t.b),void 0===a[e]&&(a[e]=[]),a[e].push(r.length/3-1)}d("n1","n2",o),d("n2","n4",o),d("n4","n3",o),d("n3","n1",o),d("f1","f2",o),d("f2","f4",o),d("f4","f3",o),d("f3","f1",o),d("n1","f1",o),d("n2","f2",o),d("n3","f3",o),d("n4","f4",o),d("p","n1",s),d("p","n2",s),d("p","n3",s),d("p","n4",s),d("u1","u2",l),d("u2","u3",l),d("u3","u1",l),d("c","t",c),d("p","c",u),d("cn1","cn2",u),d("cn3","cn4",u),d("cf1","cf2",u),d("cf3","cf4",u),t.setAttribute("position",new k(r,3)),t.setAttribute("color",new k(i,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=a,this.update()}update(){const e=this.geometry;var t=this.pointMap;pp.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),fp("c",t,e,pp,0,0,-1),fp("t",t,e,pp,0,0,1),fp("n1",t,e,pp,-1,-1,-1),fp("n2",t,e,pp,1,-1,-1),fp("n3",t,e,pp,-1,1,-1),fp("n4",t,e,pp,1,1,-1),fp("f1",t,e,pp,-1,-1,1),fp("f2",t,e,pp,1,-1,1),fp("f3",t,e,pp,-1,1,1),fp("f4",t,e,pp,1,1,1),fp("u1",t,e,pp,.7,1.1,-1),fp("u2",t,e,pp,-.7,1.1,-1),fp("u3",t,e,pp,0,2,-1),fp("cf1",t,e,pp,-1,0,1),fp("cf2",t,e,pp,1,0,1),fp("cf3",t,e,pp,0,-1,1),fp("cf4",t,e,pp,0,1,1),fp("cn1",t,e,pp,-1,0,-1),fp("cn2",t,e,pp,1,0,-1),fp("cn3",t,e,pp,0,-1,-1),fp("cn4",t,e,pp,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},e.CameraUtils=Kg,e.CanvasBreakpointsConstraint=s1,e.CanvasFitConstraint=o1,e.CanvasRenderer=function(){console.error("v3d.CanvasRenderer has been removed")},e.CanvasTexture=rc,e.CatmullRomCurve3=Ac,e.ChildOfConstraint=G0,e.CineonToneMapping=3,e.CircleBufferGeometry=ac,e.CircleGeometry=ac,e.ClampToEdgeWrapping=ut,e.ClearMaskPass=R1,e.Clock=_h,e.Color=_t,e.ColorKeyframeTrack=md,e.Compat=X1,e.CompressedTexture=nc,e.CompressedTextureLoader=class extends Sd{constructor(e){super(e)}load(n,i,r,a){const o=this,s=[],l=new nc,c=new Cd(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(o.withCredentials);let u=0;if(Array.isArray(n))for(let e=0,t=n.length;e<t;++e)!function(t){c.load(n[t],function(e){e=o.parse(e,!0);s[t]={width:e.width,height:e.height,format:e.format,mipmaps:e.mipmaps},6===(u+=1)&&(1===e.mipmapCount&&(l.minFilter=ht),l.image=s,l.format=e.format,l.needsUpdate=!0,i&&i(l))},r,a)}(e);else c.load(n,function(e){var n=o.parse(e,!0);if(n.isCubemap){var r=n.mipmaps.length/n.mipmapCount;for(let t=0;t<r;t++){s[t]={mipmaps:[]};for(let e=0;e<n.mipmapCount;e++)s[t].mipmaps.push(n.mipmaps[t*n.mipmapCount+e]),s[t].format=n.format,s[t].width=n.width,s[t].height=n.height}l.image=s}else l.image.width=n.width,l.image.height=n.height,l.mipmaps=n.mipmaps;1===n.mipmapCount&&(l.minFilter=ht),l.format=n.format,l.needsUpdate=!0,i&&i(l)},r,a);return l}},e.ConeBufferGeometry=sc,e.ConeGeometry=sc,e.Constraint=B0,e.CopyLocationConstraint=X0,e.CopyRotationConstraint=Q0,e.CopyScaleConstraint=$0,e.CopyTransformsConstraint=am,e.CubeCamera=ha,e.CubeCopy=v1,e.CubeReflectionMapping=L,e.CubeReflectionProbe=$1,e.CubeRefractionMapping=R,e.CubeTexture=pa,e.CubeTextureHelper=s2,e.CubeTextureLoader=Ld,e.CubeUVReflectionMapping=N,e.CubeUVRefractionMapping=D,e.CubicBezierCurve=Cc,e.CubicBezierCurve3=Ec,e.CubicInterpolant=hd,e.CullFaceBack=j,e.CullFaceFront=Y,e.CullFaceFrontBack=3,e.CullFaceNone=X,e.Curve=mc,e.CurvePath=Id,e.CustomBlending=J,e.CustomToneMapping=5,e.CylinderBufferGeometry=oc,e.CylinderGeometry=oc,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=vm,e.DataTexture=El,e.DataTexture2DArray=Va,e.DataTexture3D=Ua,e.DataTextureLoader=Rd,e.DataUtils=Sp,e.DecrementStencilOp=7683,e.DecrementWrapStencilOp=fn,e.DefaultLoadingManager=wd,e.DepthFormat=Ze,e.DepthStencilFormat=qe,e.DepthTexture=ic,e.Detector=ma,e.DirectionalLight=Yd,e.DirectionalLightHelper=dp,e.DiscreteInterpolant=Pu,e.DodecahedronBufferGeometry=cc,e.DodecahedronGeometry=cc,e.DoubleSide=Ue,e.DstAlphaFactor=we,e.DstColorFactor=Te,e.DynamicBufferAttribute=function(e,t){return console.warn("v3d.DynamicBufferAttribute has been removed. Use new v3d.BufferAttribute().setUsage(v3d.DynamicDrawUsage) instead."),new re(e,t).setUsage(vn)},e.DynamicCopyUsage=35050,e.DynamicDrawUsage=vn,e.DynamicReadUsage=35049,e.ESMDistancePacking=un,e.ESMShadowMap=oe,e.EdgesGeometry=fc,e.EdgesHelper=function(e,t){return console.warn("v3d.EdgesHelper has been removed. Use v3d.EdgesGeometry instead."),new jl(new fc(e.geometry),new Bl({color:void 0!==t?t:16777215}))},e.EffectComposer=ev,e.EllipseCurve=vc,e.EqualDepth=Ne,e.EqualStencilFunc=514,e.EquiCube=g1,e.EquirectangularReflectionMapping=P,e.EquirectangularRefractionMapping=I,e.Euler=Ir,e.EventDispatcher=n,e.ExtrudeBufferGeometry=tu,e.ExtrudeGeometry=tu,e.FXAAPass=C1,e.FaceColors=1,e.FileLoader=Cd,e.FilmicBlenderToneMapping=8,e.FirstPersonControls=p1,e.FixOrthoZoomConstraint=e1,e.FlatShading=1,e.Float16BufferAttribute=Ai,e.Float32Attribute=function(e,t){return console.warn("v3d.Float32Attribute has been removed. Use new v3d.Float32BufferAttribute() instead."),new k(e,t)},e.Float32BufferAttribute=k,e.Float64Attribute=function(e,t){return console.warn("v3d.Float64Attribute has been removed. Use new v3d.Float64BufferAttribute() instead."),new wi(e,t)},e.Float64BufferAttribute=wi,e.FloatType=At,e.FloorConstraint=bm,e.FlyingControls=f1,e.Fog=Ks,e.FogExp2=Qs,e.Font=ch,e.FontLoader=class extends Sd{constructor(e){super(e)}load(e,r,t,n){const i=this,a=new Cd(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(t){let n;try{n=JSON.parse(t)}catch(e){console.warn("v3d.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),n=JSON.parse(t.substring(65,t.length-2))}t=i.parse(n);r&&r(t)},t,n)}parse(e){return new ch(e)}},e.FrontSide=Ve,e.Frustum=Ma,e.GLBufferAttribute=Wh,e.GLSL1="100",e.GLSL3=gn,e.GLTFExporter=Oh,e.GLTFLoader=ug,e.GTAOMapGenerator=Og,e.GammaEncoding=3007,e.GraphUtils=Iu,e.GrayscalePass=E1,e.GreaterDepth=Oe,e.GreaterEqualDepth=De,e.GreaterEqualStencilFunc=518,e.GreaterStencilFunc=516,e.GridHelper=sp,e.Group=Us,e.HalfFloatType=je,e.HemisphereLight=Fd,e.HemisphereLightHelper=op,e.HemisphereLightProbe=fh,e.IBLEnvironmentPMREM=0,e.IBLEnvironmentProbe=2,e.IBLEnvironmentProbeCubemap=1,e.IcosahedronBufferGeometry=ru,e.IcosahedronGeometry=ru,e.ImageBitmapLoader=sh,e.ImageLoader=Ed,e.ImageUtils=kn,e.ImmediateRenderObject=qh,e.IncrementStencilOp=7682,e.IncrementWrapStencilOp=pn,e.InstancedBufferAttribute=nh,e.InstancedBufferGeometry=th,e.InstancedInterleavedBuffer=kh,e.InstancedMesh=Fl,e.Int16Attribute=function(e,t){return console.warn("v3d.Int16Attribute has been removed. Use new v3d.Int16BufferAttribute() instead."),new xi(e,t)},e.Int16BufferAttribute=xi,e.Int32Attribute=function(e,t){return console.warn("v3d.Int32Attribute has been removed. Use new v3d.Int32BufferAttribute() instead."),new bi(e,t)},e.Int32BufferAttribute=bi,e.Int8Attribute=function(e,t){return console.warn("v3d.Int8Attribute has been removed. Use new v3d.Int8BufferAttribute() instead."),new vi(e,t)},e.Int8BufferAttribute=vi,e.IntType=u,e.InterleavedBuffer=$s,e.InterleavedBufferAttribute=tl,e.Interpolant=Ru,e.InterpolateDiscrete=Jt,e.InterpolateLinear=$t,e.InterpolateSmooth=en,e.InvertStencilOp=5386,e.JSONLoader=function(){console.error("v3d.JSONLoader has been removed.")},e.KeepStencilOp=7680,e.KeyframeTrack=pd,e.Keys=pe,e.LOD=yl,e.LatheBufferGeometry=iu,e.LatheGeometry=iu,e.Layers=Nr,e.LensFlare=function(){console.error("v3d.LensFlare has been moved to /examples/jsm/objects/Lensflare.js")},e.LessDepth=Pe,e.LessEqualDepth=Ie,e.LessEqualStencilFunc=515,e.LessStencilFunc=513,e.Light=Od,e.LightProbe=Jd,e.LightProbeGenerator=Bg,e.LimitDistanceConstraint=Tm,e.LimitLocationConstraint=Cm,e.LimitRotationConstraint=Lm,e.LimitScaleConstraint=Rm,e.Line=Wl,e.Line3=Zh,e.LineBasicMaterial=Bl,e.LineCurve=Lc,e.LineCurve3=Rc,e.LineDashedMaterial=Eu,e.LineHTML=r2,e.LineLoop=Yl,e.LinePieces=1,e.LineSegments=jl,e.LineStrip=0,e.LinearDepthPacking=3202,e.LinearEncoding=an,e.LinearFilter=ht,e.LinearInterpolant=Ju,e.LinearMipMapLinearFilter=1008,e.LinearMipMapNearestFilter=1007,e.LinearMipmapLinearFilter=He,e.LinearMipmapNearestFilter=We,e.LinearToneMapping=1,e.Loader=Sd,e.LoaderUtils=eh,e.LoadingManager=Ad,e.LockedTrackConstraint=Gm,e.LogLuvEncoding=3003,e.LogarithmicMaxToneMapping=6,e.LoopOnce=2200,e.LoopPingPong=2202,e.LoopRepeat=2201,e.LuminanceAlphaFormat=v,e.LuminanceFormat=m,e.MOD_SUITE=_n,e.MOUSE=fe,e.MaskPass=L1,e.Material=pi,e.MaterialLoader=$d,e.MaterialUtils=F0,e.Math=Vn,e.MathUtils=Vn,e.Matrix3=Un,e.Matrix4=gt,e.MaxEquation=ge,e.Mesh=ee,e.MeshBVH=A0,e.MeshBasicMaterial=fi,e.MeshDepthMaterial=gs,e.MeshDistanceMaterial=_s,e.MeshFaceMaterial=function(e){return console.warn("v3d.MeshFaceMaterial has been removed. Use an Array instead."),e},e.MeshLambertMaterial=Tu,e.MeshLine=P1,e.MeshLineIndexed=O1,e.MeshLineMaterial=B1,e.MeshMaskMaterial=Lu,e.MeshMatcapMaterial=Cu,e.MeshNodeMaterial=cd,e.MeshNormalMaterial=Su,e.MeshPhongMaterial=Au,e.MeshPhysicalMaterial=Mu,e.MeshStandardMaterial=bu,e.MeshToonMaterial=wu,e.MinEquation=ve,e.MirroredRepeatWrapping=G,e.MixOperation=1,e.MultiMaterial=function(e=[]){return console.warn("v3d.MultiMaterial has been removed. Use an Array instead."),e.isMultiMaterial=!0,(e.materials=e).clone=function(){return e.slice()},e},e.MultiplyBlending=K,e.MultiplyOperation=0,e.NearestFilter=dt,e.NearestMipMapLinearFilter=1005,e.NearestMipMapNearestFilter=1004,e.NearestMipmapLinearFilter=H,e.NearestMipmapNearestFilter=W,e.NeverDepth=Le,e.NeverStencilFunc=512,e.NoBlending=ce,e.NoColors=0,e.NoToneMapping=ke,e.NormalAnimationBlendMode=2500,e.NormalBlending=Z,e.NotEqualDepth=Ge,e.NotEqualStencilFunc=517,e.NumberKeyframeTrack=vd,e.Object3D=he,e.ObjectLoader=class extends Sd{constructor(e){super(e)}load(r,i,e,a){const o=this;var t=""===this.path?eh.extractUrlBase(r):this.path;this.resourcePath=this.resourcePath||t;const n=new Cd(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(r,function(e){let t=null;try{t=JSON.parse(e)}catch(e){return void 0!==a&&a(e),void console.error("v3d:ObjectLoader: Can't parse "+r+".",e.message)}const n=t.metadata;void 0===n||void 0===n.type||"geometry"===n.type.toLowerCase()?console.error("v3d.ObjectLoader: Can't load "+r):o.parse(t,i)},e,a)}async loadAsync(e,t){var n=""===this.path?eh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;const r=new Cd(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);n=await r.loadAsync(e,t),t=JSON.parse(n);const i=t.metadata;if(void 0===i||void 0===i.type||"geometry"===i.type.toLowerCase())throw new Error("v3d.ObjectLoader: Can't load "+e);return this.parseAsync(t)}parse(e,t){var n=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,r),i=this.parseImages(e.images,function(){void 0!==t&&t(s)}),a=this.parseTextures(e.textures,i),o=this.parseMaterials(e.materials,a);const s=this.parseObject(e.object,r,o,a,n);r=this.parseSkeletons(e.skeletons,s);if(this.bindSkeletons(s,r),void 0!==t){let e=!1;for(const l in i)if(i[l]instanceof HTMLImageElement){e=!0;break}!1===e&&t(s)}return s}async parseAsync(e){var t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),n=this.parseGeometries(e.geometries,n),r=await this.parseImagesAsync(e.images),r=this.parseTextures(e.textures,r),i=this.parseMaterials(e.materials,r),n=this.parseObject(e.object,n,i,r,t),i=this.parseSkeletons(e.skeletons,n);return this.bindSkeletons(n,i),n}parseShapes(n){const r={};if(void 0!==n)for(let e=0,t=n.length;e<t;e++){var i=(new Dd).fromJSON(n[e]);r[i.uuid]=i}return r}parseSkeletons(n,e){const r={},i={};if(e.traverse(function(e){e.isBone&&(i[e.uuid]=e)}),void 0!==n)for(let e=0,t=n.length;e<t;e++){var a=(new Pl).fromJSON(n[e],i);r[a.uuid]=a}return r}parseGeometries(n,r){const i={};if(void 0!==n){const o=new rh;for(let t=0,e=n.length;t<e;t++){let e;var a=n[t];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":e=o.parse(a);break;case"Geometry":console.error("v3d.ObjectLoader: The legacy Geometry type is no longer supported.");break;default:a.type in _u?e=_u[a.type].fromJSON(a,r):console.warn(`v3d.ObjectLoader: Unsupported geometry type "${a.type}"`)}e.uuid=a.uuid,void 0!==a.name&&(e.name=a.name),!0===e.isBufferGeometry&&void 0!==a.userData&&(e.userData=a.userData),i[a.uuid]=e}}return i}parseMaterials(n,e){const r={},i={};if(void 0!==n){const s=new $d;s.setTextures(e);for(let e=0,t=n.length;e<t;e++){var a=n[e];if("MultiMaterial"===a.type){const l=[];for(let e=0;e<a.materials.length;e++){var o=a.materials[e];void 0===r[o.uuid]&&(r[o.uuid]=s.parse(o)),l.push(r[o.uuid])}i[a.uuid]=l}else void 0===r[a.uuid]&&(r[a.uuid]=s.parse(a)),i[a.uuid]=r[a.uuid]}}return i}parseAnimations(t){const n={};if(void 0!==t)for(let e=0;e<t.length;e++){var r=t[e],r=bd.parse(r);n[r.uuid]=r}return n}parseImages(n,e){const r=this,i={};let a;function o(e){var t,n;return"string"==typeof e?(t=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t=e)?t:r.resourcePath+t,n=t,r.manager.itemStart(n),a.load(n,function(){r.manager.itemEnd(n)},void 0,function(){r.manager.itemError(n),r.manager.itemEnd(n)})):e.data?{data:Ci(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==n&&0<n.length){e=new Ad(e);(a=new Ed(e)).setCrossOrigin(this.crossOrigin);for(let e=0,t=n.length;e<t;e++){var s=n[e],l=s.url;if(Array.isArray(l)){i[s.uuid]=[];for(let e=0,t=l.length;e<t;e++){var c=o(l[e]);null!==c&&(c instanceof HTMLImageElement?i[s.uuid].push(c):i[s.uuid].push(new El(c.data,c.width,c.height)))}}else{var u=o(s.url);null!==u&&(i[s.uuid]=u)}}}return i}async parseImagesAsync(n){const r=this,i={};let a;async function o(e){var t;return"string"==typeof e?(t=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t=e)?t:r.resourcePath+t,a.loadAsync(t)):e.data?{data:Ci(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==n&&0<n.length){(a=new Ed(this.manager)).setCrossOrigin(this.crossOrigin);for(let e=0,t=n.length;e<t;e++){var s=n[e],l=s.url;if(Array.isArray(l)){i[s.uuid]=[];for(let e=0,t=l.length;e<t;e++){var c=await o(l[e]);null!==c&&(c instanceof HTMLImageElement?i[s.uuid].push(c):i[s.uuid].push(new El(c.data,c.width,c.height)))}}else{var u=await o(s.url);null!==u&&(i[s.uuid]=u)}}}return i}parseTextures(n,r){function i(e,t){return"number"==typeof e?e:(console.warn("v3d.ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}const a={};if(void 0!==n)for(let t=0,e=n.length;t<e;t++){var o=n[t];void 0===o.image&&console.warn('v3d.ObjectLoader: No "image" specified for',o.uuid),void 0===r[o.image]&&console.warn("v3d.ObjectLoader: Undefined image",o.image);let e;var s=r[o.image];Array.isArray(s)?(e=new pa(s),6===s.length&&(e.needsUpdate=!0)):(e=s&&s.data?new El(s.data,s.width,s.height):new Hn(s),s&&(e.needsUpdate=!0)),e.uuid=o.uuid,void 0!==o.name&&(e.name=o.name),void 0!==o.mapping&&(e.mapping=i(o.mapping,ih)),void 0!==o.offset&&e.offset.fromArray(o.offset),void 0!==o.repeat&&e.repeat.fromArray(o.repeat),void 0!==o.center&&e.center.fromArray(o.center),void 0!==o.rotation&&(e.rotation=o.rotation),void 0!==o.wrap&&(e.wrapS=i(o.wrap[0],ah),e.wrapT=i(o.wrap[1],ah)),void 0!==o.format&&(e.format=o.format),void 0!==o.type&&(e.type=o.type),void 0!==o.encoding&&(e.encoding=o.encoding),void 0!==o.minFilter&&(e.minFilter=i(o.minFilter,oh)),void 0!==o.magFilter&&(e.magFilter=i(o.magFilter,oh)),void 0!==o.anisotropy&&(e.anisotropy=o.anisotropy),void 0!==o.flipY&&(e.flipY=o.flipY),void 0!==o.premultiplyAlpha&&(e.premultiplyAlpha=o.premultiplyAlpha),void 0!==o.unpackAlignment&&(e.unpackAlignment=o.unpackAlignment),a[o.uuid]=e}return a}parseObject(e,t,a,n,r){let i;function o(e){return void 0===t[e]&&console.warn("v3d.ObjectLoader: Undefined geometry",e),t[e]}function s(n){if(void 0!==n){if(Array.isArray(n)){const i=[];for(let e=0,t=n.length;e<t;e++){var r=n[e];void 0===a[r]&&console.warn("v3d.ObjectLoader: Undefined material",r),i.push(a[r])}return i}return void 0===a[n]&&console.warn("v3d.ObjectLoader: Undefined material",n),a[n]}}function l(e){return void 0===n[e]&&console.warn("v3d.ObjectLoader: Undefined texture",e),n[e]}let c,u;switch(e.type){case"Scene":i=new Js,void 0!==e.background&&(Number.isInteger(e.background)?i.background=new _t(e.background):i.background=l(e.background)),void 0!==e.environment&&(i.environment=l(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?i.fog=new Ks(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(i.fog=new Qs(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":i=new da(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(i.focus=e.focus),void 0!==e.zoom&&(i.zoom=e.zoom),void 0!==e.filmGauge&&(i.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(i.filmOffset=e.filmOffset),void 0!==e.view&&(i.view=Object.assign({},e.view));break;case"OrthographicCamera":i=new Rs(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(i.zoom=e.zoom),void 0!==e.view&&(i.view=Object.assign({},e.view));break;case"AmbientLight":i=new Zd(e.color,e.intensity);break;case"DirectionalLight":i=new Yd(e.color,e.intensity);break;case"PointLight":i=new Wd(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":i=new Qd(e.color,e.intensity,e.width,e.height);break;case"SpotLight":i=new zd(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":i=new Fd(e.color,e.groundColor,e.intensity);break;case"LightProbe":i=(new Jd).fromJSON(e);break;case"SkinnedMesh":c=o(e.geometry),u=s(e.material),i=new Tl(c,u),void 0!==e.bindMode&&(i.bindMode=e.bindMode),void 0!==e.bindMatrix&&i.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(i.skeleton=e.skeleton);break;case"Mesh":c=o(e.geometry),u=s(e.material),i=new ee(c,u);break;case"InstancedMesh":c=o(e.geometry),u=s(e.material);var d=e.count,h=e.instanceMatrix,p=e.instanceColor;(i=new Fl(c,u,d)).instanceMatrix=new re(new Float32Array(h.array),16),void 0!==p&&(i.instanceColor=new re(new Float32Array(p.array),p.itemSize));break;case"LOD":i=new yl;break;case"Line":i=new Wl(o(e.geometry),s(e.material));break;case"LineLoop":i=new Yl(o(e.geometry),s(e.material));break;case"LineSegments":i=new jl(o(e.geometry),s(e.material));break;case"PointCloud":case"Points":i=new $l(o(e.geometry),s(e.material));break;case"Sprite":i=new vl(s(e.material));break;case"Group":i=new Us;break;case"Bone":i=new Cl;break;default:i=new he}if(i.uuid=e.uuid,void 0!==e.name&&(i.name=e.name),void 0!==e.matrix?(i.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(i.matrixAutoUpdate=e.matrixAutoUpdate),i.matrixAutoUpdate&&i.matrix.decompose(i.position,i.quaternion,i.scale)):(void 0!==e.position&&i.position.fromArray(e.position),void 0!==e.rotation&&i.rotation.fromArray(e.rotation),void 0!==e.quaternion&&i.quaternion.fromArray(e.quaternion),void 0!==e.scale&&i.scale.fromArray(e.scale)),void 0!==e.castShadow&&(i.castShadow=e.castShadow),void 0!==e.receiveShadow&&(i.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(i.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(i.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(i.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&i.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(i.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(i.visible=e.visible),void 0!==e.frustumCulled&&(i.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(i.renderOrder=e.renderOrder),void 0!==e.userData&&(i.userData=e.userData),void 0!==e.layers&&(i.layers.mask=e.layers),void 0!==e.children){var f=e.children;for(let e=0;e<f.length;e++)i.add(this.parseObject(f[e],t,a,n,r))}if(void 0!==e.animations){var m=e.animations;for(let e=0;e<m.length;e++){var v=m[e];i.animations.push(r[v])}}if("LOD"===e.type){void 0!==e.autoUpdate&&(i.autoUpdate=e.autoUpdate);var g=e.levels;for(let e=0;e<g.length;e++){var _=g[e],x=i.getObjectByProperty("uuid",_.object);void 0!==x&&i.addLevel(x,_.distance)}}return i}bindSkeletons(e,n){0!==Object.keys(n).length&&e.traverse(function(e){var t;!0===e.isSkinnedMesh&&void 0!==e.skeleton&&(void 0===(t=n[e.skeleton])?console.warn("v3d.ObjectLoader: No skeleton found with UUID:",e.skeleton):e.bind(t,e.bindMatrix))})}setTexturePath(e){return console.warn("v3d.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(e)}},e.ObjectSpaceNormalMap=hn,e.OctahedronBufferGeometry=au,e.OctahedronGeometry=au,e.OneFactor=xe,e.OneMinusDstAlphaFactor=Se,e.OneMinusDstColorFactor=Ce,e.OneMinusSrcAlphaFactor=Ae,e.OneMinusSrcColorFactor=be,e.OrbitControls=m1,e.OrthographicCamera=Rs,e.OutlinePass=z1,e.PCFShadowMap=ne,e.PCFShadowMapPoissonDisk=se,e.PCFSoftShadowMap=ie,e.PMREMGenerator=Up,e.ParametricBufferGeometry=ou,e.ParametricGeometry=ou,e.Particle=function(e){return console.warn("v3d.Particle has been renamed to v3d.Sprite."),new vl(e)},e.ParticleBasicMaterial=function(e){return console.warn("v3d.ParticleBasicMaterial has been renamed to v3d.PointsMaterial."),new Zl(e)},e.ParticleSystem=function(e,t){return console.warn("v3d.ParticleSystem has been renamed to v3d.Points."),new $l(e,t)},e.ParticleSystemMaterial=function(e){return console.warn("v3d.ParticleSystemMaterial has been renamed to v3d.PointsMaterial."),new Zl(e)},e.Pass=_1,e.Path=Nd,e.PerspectiveCamera=da,e.PhysicalMaxToneMapping=7,e.Plane=xa,e.PlaneBufferGeometry=Sa,e.PlaneGeometry=Sa,e.PlaneHelper=class extends Wl{constructor(e,t=1,n=16776960){const r=new S;r.setAttribute("position",new k([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,0,1,0,0,0],3)),r.computeBoundingSphere(),super(r,new Bl({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const i=new S;i.setAttribute("position",new k([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3)),i.computeBoundingSphere(),this.add(new ee(i,new fi({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){let t=-this.plane.constant;Math.abs(t)<1e-8&&(t=1e-8),this.scale.set(.5*this.size,.5*this.size,t),this.children[0].material.side=t<0?Fe:Ve,this.lookAt(this.plane.normal),super.updateMatrixWorld(e)}},e.PointCloud=function(e,t){return console.warn("v3d.PointCloud has been renamed to v3d.Points."),new $l(e,t)},e.PointCloudMaterial=function(e){return console.warn("v3d.PointCloudMaterial has been renamed to v3d.PointsMaterial."),new Zl(e)},e.PointLight=Wd,e.PointLightHelper=np,e.Points=$l,e.PointsMaterial=Zl,e.PolarGridHelper=class extends jl{constructor(t=10,n=16,r=8,i=64,a=4473924,o=8947848){a=new _t(a),o=new _t(o);const s=[],l=[];for(let e=0;e<=n;e++){var c=e/n*(2*Math.PI),u=Math.sin(c)*t,c=Math.cos(c)*t,u=(s.push(0,0,0),s.push(u,0,c),1&e?a:o);l.push(u.r,u.g,u.b),l.push(u.r,u.g,u.b)}for(let e=0;e<=r;e++){var d=1&e?a:o,h=t-t/r*e;for(let e=0;e<i;e++){var p=e/i*(2*Math.PI),f=Math.sin(p)*h,m=Math.cos(p)*h;s.push(f,0,m),l.push(d.r,d.g,d.b),p=(e+1)/i*(2*Math.PI),f=Math.sin(p)*h,m=Math.cos(p)*h,s.push(f,0,m),l.push(d.r,d.g,d.b)}}const e=new S;e.setAttribute("position",new k(s,3)),e.setAttribute("color",new k(l,3));var v=new Bl({vertexColors:!0,toneMapped:!1});super(e,v),this.type="PolarGridHelper"}},e.PolyhedronBufferGeometry=lc,e.PolyhedronGeometry=lc,e.PositionalAudio=class extends Sh{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(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){this.matrixWorld.decompose(Th,Ch,Eh),Lh.set(0,0,1).applyQuaternion(Ch);const t=this.panner;t.positionX?(e=this.context.currentTime+this.listener.timeDelta,t.positionX.linearRampToValueAtTime(Th.x,e),t.positionY.linearRampToValueAtTime(Th.y,e),t.positionZ.linearRampToValueAtTime(Th.z,e),t.orientationX.linearRampToValueAtTime(Lh.x,e),t.orientationY.linearRampToValueAtTime(Lh.y,e),t.orientationZ.linearRampToValueAtTime(Lh.z,e)):(t.setPosition(Th.x,Th.y,Th.z),t.setOrientation(Lh.x,Lh.y,Lh.z))}}},e.Preloader=i2,e.PropertyBinding=C,e.PropertyMixer=Ph,e.PuzzlesLoader=o2,e.QuadraticBezierCurve=Pc,e.QuadraticBezierCurve3=Ic,e.Quaternion=de,e.QuaternionKeyframeTrack=_d,e.QuaternionLinearInterpolant=gd,e.REVISION=o,e.RGBADepthPacking=ln,e.RGBADistancePacking=cn,e.RGBAFormat=pt,e.RGBAIntegerFormat=z,e.RGBA_ASTC_10x10_Format=Dt,e.RGBA_ASTC_10x5_Format=Pt,e.RGBA_ASTC_10x6_Format=It,e.RGBA_ASTC_10x8_Format=Nt,e.RGBA_ASTC_12x10_Format=Ot,e.RGBA_ASTC_12x12_Format=Ft,e.RGBA_ASTC_4x4_Format=lt,e.RGBA_ASTC_5x4_Format=ct,e.RGBA_ASTC_5x5_Format=St,e.RGBA_ASTC_6x5_Format=Tt,e.RGBA_ASTC_6x6_Format=Ct,e.RGBA_ASTC_8x5_Format=Et,e.RGBA_ASTC_8x6_Format=Lt,e.RGBA_ASTC_8x8_Format=Rt,e.RGBA_BPTC_Format=Bt,e.RGBA_ETC2_EAC_Format=st,e.RGBA_PVRTC_2BPPV1_Format=it,e.RGBA_PVRTC_4BPPV1_Format=rt,e.RGBA_S3TC_DXT1_Format=Je,e.RGBA_S3TC_DXT3_Format=$e,e.RGBA_S3TC_DXT5_Format=et,e.RGBDEncoding=3006,e.RGBEEncoding=sn,e.RGBEFormat=F,e.RGBELoader=Kv,e.RGBFormat=wt,e.RGBIntegerFormat=B,e.RGBM16Encoding=3005,e.RGBM7Encoding=3004,e.RGB_ETC1_Format=at,e.RGB_ETC2_Format=ot,e.RGB_PVRTC_2BPPV1_Format=nt,e.RGB_PVRTC_4BPPV1_Format=tt,e.RGB_S3TC_DXT1_Format=Ke,e.RGFormat=A,e.RGIntegerFormat=w,e.RawShaderMaterial=yu,e.Ray=Mr,e.Raycaster=Ws,e.RectAreaLight=Qd,e.RectAreaLightUniformsLib=ig,e.RedFormat=Qe,e.RedIntegerFormat=M,e.ReflectionProbeTypeBox=2,e.ReflectionProbeTypeInfinite=0,e.ReflectionProbeTypeSphere=1,e.ReinhardToneMapping=2,e.RenderPass=V1,e.RenderUtils=Y1,e.RepeatWrapping=U,e.ReplaceStencilOp=7681,e.ReverseSubtractEquation=me,e.RingBufferGeometry=su,e.RingGeometry=su,e.SAH=2,e.SRGB8_ALPHA8_ASTC_10x10_Format=qt,e.SRGB8_ALPHA8_ASTC_10x5_Format=jt,e.SRGB8_ALPHA8_ASTC_10x6_Format=Yt,e.SRGB8_ALPHA8_ASTC_10x8_Format=Zt,e.SRGB8_ALPHA8_ASTC_12x10_Format=Qt,e.SRGB8_ALPHA8_ASTC_12x12_Format=Kt,e.SRGB8_ALPHA8_ASTC_4x4_Format=zt,e.SRGB8_ALPHA8_ASTC_5x4_Format=Vt,e.SRGB8_ALPHA8_ASTC_5x5_Format=Ut,e.SRGB8_ALPHA8_ASTC_6x5_Format=Gt,e.SRGB8_ALPHA8_ASTC_6x6_Format=kt,e.SRGB8_ALPHA8_ASTC_8x5_Format=Wt,e.SRGB8_ALPHA8_ASTC_8x6_Format=Ht,e.SRGB8_ALPHA8_ASTC_8x8_Format=Xt,e.SSAARenderPass=U1,e.SSAOPass=function(){console.error("v3d.SSAOPass has been removed, use v3d.GTAOMapGenerator instead")},e.Scene=Js,e.SceneBackground=kg,e.SceneUtils=Wg,e.ShaderChunk=yt,e.ShaderLib=E,e.ShaderMaterial=T,e.ShaderPass=S1,e.ShadowMaterial=xu,e.Shape=Dd,e.ShapeBufferGeometry=lu,e.ShapeGeometry=lu,e.ShapePath=lh,e.ShapeUtils=Jc,e.ShortType=c,e.SimplePreloader=a2,e.Skeleton=Pl,e.SkeletonHelper=tp,e.SkinnedMesh=Tl,e.SmoothShading=2,e.Sphere=fr,e.SphereBufferGeometry=cu,e.SphereGeometry=cu,e.Spherical=ad,e.SphericalHarmonics3=Kd,e.SplineCurve=Nc,e.SpotLight=zd,e.SpotLightHelper=Kh,e.Sprite=vl,e.SpriteMaterial=nl,e.SrcAlphaFactor=Me,e.SrcAlphaSaturateFactor=Ee,e.SrcColorFactor=ye,e.StaticCopyUsage=35046,e.StaticDrawUsage=mn,e.StaticReadUsage=35045,e.Stats=Hg,e.StereoCamera=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new da,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new da,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;const o=e.projectionMatrix.clone();var n,r=t.eyeSep/2,i=r*t.near/t.focus,a=t.near*Math.tan(Mn*t.fov*.5)/t.zoom;gh.elements[12]=-r,vh.elements[12]=r,r=-a*t.aspect+i,n=a*t.aspect+i,o.elements[0]=2*t.near/(n-r),o.elements[8]=(n+r)/(n-r),this.cameraL.projectionMatrix.copy(o),r=-a*t.aspect-i,n=a*t.aspect-i,o.elements[0]=2*t.near/(n-r),o.elements[8]=(n+r)/(n-r),this.cameraR.projectionMatrix.copy(o)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(gh),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(vh)}},e.StreamCopyUsage=35042,e.StreamDrawUsage=35040,e.StreamReadUsage=35041,e.StringKeyframeTrack=xd,e.SubtractEquation=ue,e.SubtractiveBlending=Q,e.TOUCH={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},e.TTFLoader=Qv,e.TangentSpaceNormalMap=dn,e.TargetConstraint=z0,e.TeapotBufferGeometry=gu,e.TeapotGeometry=gu,e.TetrahedronBufferGeometry=uu,e.TetrahedronGeometry=uu,e.TextBufferGeometry=du,e.TextGeometry=du,e.Texture=Hn,e.TextureLoader=Pd,e.ToneMapPass=k1,e.TorusBufferGeometry=hu,e.TorusGeometry=hu,e.TorusKnotBufferGeometry=pu,e.TorusKnotGeometry=pu,e.TrackToConstraint=$m,e.Triangle=ui,e.TriangleFanDrawMode=2,e.TriangleStripDrawMode=1,e.TrianglesDrawMode=0,e.TubeBufferGeometry=fu,e.TubeGeometry=fu,e.TweenCameraController=h1,e.TweenLinear=0,e.TweenSpherical=1,e.UVMapping=s,e.Uint16Attribute=function(e,t){return console.warn("v3d.Uint16Attribute has been removed. Use new v3d.Uint16BufferAttribute() instead."),new yi(e,t)},e.Uint16BufferAttribute=yi,e.Uint32Attribute=function(e,t){return console.warn("v3d.Uint32Attribute has been removed. Use new v3d.Uint32BufferAttribute() instead."),new Mi(e,t)},e.Uint32BufferAttribute=Mi,e.Uint8Attribute=function(e,t){return console.warn("v3d.Uint8Attribute has been removed. Use new v3d.Uint8BufferAttribute() instead."),new gi(e,t)},e.Uint8BufferAttribute=gi,e.Uint8ClampedAttribute=function(e,t){return console.warn("v3d.Uint8ClampedAttribute has been removed. Use new v3d.Uint8ClampedBufferAttribute() instead."),new _i(e,t)},e.Uint8ClampedBufferAttribute=_i,e.Uniform=Gh,e.UniformsLib=O,e.UniformsUtils=ca,e.UnsignedByteType=Mt,e.UnsignedInt248Type=Ye,e.UnsignedIntType=Xe,e.UnsignedShort4444Type=d,e.UnsignedShort5551Type=h,e.UnsignedShort565Type=p,e.UnsignedShortType=V,e.V3DL=xn,e.VSMShadowMap=ae,e.Vector2=Be,e.Vector3=vt,e.Vector4=mt,e.VectorKeyframeTrack=yd,e.Vertex=function(e,t,n){return console.warn("v3d.Vertex has been removed. Use v3d.Vector3 instead."),new vt(e,t,n)},e.VertexColors=2,e.VideoTexture=tc,e.ViewportFitAuto=3,e.ViewportFitFill=4,e.ViewportFitHorizontal=2,e.ViewportFitNone=0,e.ViewportFitOverscan=5,e.ViewportFitVertical=1,e.Visualizer=E0,e.WebGL1Renderer=qs,e.WebGLCubeRenderTarget=fa,e.WebGLMultipleRenderTargets=jn,e.WebGLMultisampleRenderTarget=Yn,e.WebGLRenderTarget=ze,e.WebGLRenderTargetCube=function(e,t,n){return console.warn("v3d.WebGLRenderTargetCube(width, height, options) is now WebGLCubeRenderTarget(size, options)."),new fa(e,n)},e.WebGLRenderer=i,e.WebGLUtils=zs,e.WebXRUtils=Dh,e.WireframeGeometry=mu,e.WireframeHelper=function(e,t){return console.warn("v3d.WireframeHelper has been removed. Use v3d.WireframeGeometry instead."),new jl(new mu(e.geometry),new Bl({color:void 0!==t?t:16777215}))},e.WrapAroundEnding=rn,e.XHRLoader=function(e){return console.warn("v3d.XHRLoader has been renamed to v3d.FileLoader."),new Cd(e)},e.XZ=_,e.XZLoader=qv,e.ZeroCurvatureEnding=tn,e.ZeroFactor=_e,e.ZeroSlopeEnding=nn,e.ZeroStencilOp=0,e.acceleratedRaycast=I0,e.arrayMax=Si,e.arrayMin=function(n){if(0===n.length)return 1/0;let r=n[0];for(let e=1,t=n.length;e<t;++e)n[e]<r&&(r=n[e]);return r},e.clampArray=Ei,e.computeBoundsTree=N0,e.disposeBoundsTree=D0,e.getGlobalScope=Pi,e.isDef=xt,e.loadModule=Ni,e.sRGBEncoding=on,e.shaderFloatStr=Ri,Object.defineProperty(e,"__esModule",{value:!0})});
|