var Ec=Object.defineProperty;var Lc=(e,t,i)=>t in e?Ec(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var wi=(e,t,i)=>(Lc(e,typeof t!="symbol"?t+"":t,i),i);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(n){if(n.ep)return;n.ep=!0;const r=t(n);fetch(n.href,r)}})();const ca="125",Pc=0,ha=1,Rc=2,ua=1,da=2,$n=3,Gt=0,Ze=1,on=2,pa=1,er=0,Bi=1,ko=2,fa=3,ma=4,Cc=5,sn=100,Nc=101,Ic=102,ga=103,va=104,Fc=200,Oc=201,Dc=202,Uc=203,_a=204,xa=205,zc=206,kc=207,Hc=208,Bc=209,Gc=210,Vc=0,Wc=1,jc=2,Ho=3,Xc=4,Yc=5,qc=6,Qc=7,Or=0,Zc=1,Jc=2,tr=0,Kc=1,$c=2,eh=3,th=4,ih=5,ya=300,Bo=301,Go=302,ba=303,wa=304,Vo=306,Wo=307,Mi=1e3,ut=1001,Dr=1002,rt=1003,jo=1004,Xo=1005,qe=1006,Ma=1007,an=1008,Ta=1008,Ur=1009,nh=1010,rh=1011,zr=1012,oh=1013,ir=1014,li=1015,kr=1016,sh=1017,ah=1018,lh=1019,nr=1020,ch=1021,Ti=1022,wt=1023,hh=1024,uh=1025,Gi=1026,rr=1027,dh=1028,ph=1029,fh=1030,mh=1031,gh=1032,vh=1033,Aa=33776,Sa=33777,Ea=33778,La=33779,Pa=35840,Ra=35841,Ca=35842,Na=35843,_h=36196,Ia=37492,Fa=37496,xh=37808,yh=37809,bh=37810,wh=37811,Mh=37812,Th=37813,Ah=37814,Sh=37815,Eh=37816,Lh=37817,Ph=37818,Rh=37819,Ch=37820,Nh=37821,Ih=36492,Fh=37840,Oh=37841,Dh=37842,Uh=37843,zh=37844,kh=37845,Hh=37846,Bh=37847,Gh=37848,Vh=37849,Wh=37850,jh=37851,Xh=37852,Yh=37853,Yo=2200,qh=2201,Qh=2202,or=2300,ln=2301,qo=2302,cn=2400,hn=2401,Hr=2402,Qo=2500,Oa=2501,Zh=0,Jh=1,Da=2,sr=3e3,Vi=3001,Kh=3007,$h=3002,eu=3003,tu=3004,iu=3005,nu=3006,ru=3200,ou=3201,Wi=0,su=1,Zo=7680,au=519,Br=35044,ar=35048,Ua="300 es";function ci(){}Object.assign(ci.prototype,{addEventListener:function(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)},hasEventListener:function(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1},removeEventListener:function(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const n=i.indexOf(t);n!==-1&&i.splice(n,1)}},dispatchEvent:function(e){if(this._listeners===void 0)return;const t=this._listeners[e.type];if(t!==void 0){e.target=this;const i=t.slice(0);for(let n=0,r=i.length;n>8&255]+at[e>>16&255]+at[e>>24&255]+"-"+at[t&255]+at[t>>8&255]+"-"+at[t>>16&15|64]+at[t>>24&255]+"-"+at[i&63|128]+at[i>>8&255]+"-"+at[i>>16&255]+at[i>>24&255]+at[n&255]+at[n>>8&255]+at[n>>16&255]+at[n>>24&255]).toUpperCase()},clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,i,n,r){return n+(e-t)*(r-n)/(i-t)},lerp:function(e,t,i){return(1-i)*e+i*t},damp:function(e,t,i,n){return Se.lerp(e,t,1-Math.exp(-i*n))},pingpong:function(e,t=1){return t-Math.abs(Se.euclideanModulo(e,t*2)-t)},smoothstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t),e*e*(3-2*e))},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t),e*e*e*(e*(e*6-15)+10))},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 e!==void 0&&(Gr=e%2147483647),Gr=Gr*16807%2147483647,(Gr-1)/2147483646},degToRad:function(e){return e*Se.DEG2RAD},radToDeg:function(e){return e*Se.RAD2DEG},isPowerOfTwo:function(e){return(e&e-1)===0&&e!==0},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,i,n,r){const o=Math.cos,s=Math.sin,a=o(i/2),l=s(i/2),c=o((t+n)/2),h=s((t+n)/2),u=o((t-n)/2),d=s((t-n)/2),f=o((n-t)/2),m=s((n-t)/2);switch(r){case"XYX":e.set(a*h,l*u,l*d,a*c);break;case"YZY":e.set(l*d,a*h,l*u,a*c);break;case"ZXZ":e.set(l*u,l*d,a*h,a*c);break;case"XZX":e.set(a*h,l*m,l*f,a*c);break;case"YXY":e.set(l*f,a*h,l*m,a*c);break;case"ZYZ":e.set(l*m,l*f,a*h,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}};class le{constructor(t=0,i=0){Object.defineProperty(this,"isVector2",{value:!0}),this.x=t,this.y=i}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,i){return this.x=t,this.y=i,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t,i){return i!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,i)):(this.x+=t.x,this.y+=t.y,this)}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this}sub(t,i){return i!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,i)):(this.x-=t.x,this.y-=t.y,this)}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const i=this.x,n=this.y,r=t.elements;return this.x=r[0]*i+r[3]*n+r[6],this.y=r[1]*i+r[4]*n+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,i){return this.x=Math.max(t.x,Math.min(i.x,this.x)),this.y=Math.max(t.y,Math.min(i.y,this.y)),this}clampScalar(t,i){return this.x=Math.max(t,Math.min(i,this.x)),this.y=Math.max(t,Math.min(i,this.y)),this}clampLength(t,i){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(i,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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const i=this.x-t.x,n=this.y-t.y;return i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this}lerpVectors(t,i,n){return this.x=t.x+(i.x-t.x)*n,this.y=t.y+(i.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t}fromBufferAttribute(t,i,n){return n!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(i),this.y=t.getY(i),this}rotateAround(t,i){const n=Math.cos(i),r=Math.sin(i),o=this.x-t.x,s=this.y-t.y;return this.x=o*n-s*r+t.x,this.y=o*r+s*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}class Ft{constructor(){Object.defineProperty(this,"isMatrix3",{value:!0}),this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(t,i,n,r,o,s,a,l,c){const h=this.elements;return h[0]=t,h[1]=r,h[2]=a,h[3]=i,h[4]=o,h[5]=l,h[6]=n,h[7]=s,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}clone(){return new this.constructor().fromArray(this.elements)}copy(t){const i=this.elements,n=t.elements;return i[0]=n[0],i[1]=n[1],i[2]=n[2],i[3]=n[3],i[4]=n[4],i[5]=n[5],i[6]=n[6],i[7]=n[7],i[8]=n[8],this}extractBasis(t,i,n){return t.setFromMatrix3Column(this,0),i.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const i=t.elements;return this.set(i[0],i[4],i[8],i[1],i[5],i[9],i[2],i[6],i[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){const n=t.elements,r=i.elements,o=this.elements,s=n[0],a=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],m=n[8],v=r[0],_=r[3],g=r[6],p=r[1],E=r[4],S=r[7],T=r[2],x=r[5],L=r[8];return o[0]=s*v+a*p+l*T,o[3]=s*_+a*E+l*x,o[6]=s*g+a*S+l*L,o[1]=c*v+h*p+u*T,o[4]=c*_+h*E+u*x,o[7]=c*g+h*S+u*L,o[2]=d*v+f*p+m*T,o[5]=d*_+f*E+m*x,o[8]=d*g+f*S+m*L,this}multiplyScalar(t){const i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=t,i[4]*=t,i[7]*=t,i[2]*=t,i[5]*=t,i[8]*=t,this}determinant(){const t=this.elements,i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return i*s*h-i*a*c-n*o*h+n*a*l+r*o*c-r*s*l}invert(){const t=this.elements,i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=h*s-a*c,d=a*l-h*o,f=c*o-s*l,m=i*u+n*d+r*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return t[0]=u*v,t[1]=(r*c-h*n)*v,t[2]=(a*n-r*s)*v,t[3]=d*v,t[4]=(h*i-r*l)*v,t[5]=(r*o-a*i)*v,t[6]=f*v,t[7]=(n*l-c*i)*v,t[8]=(s*i-n*o)*v,this}transpose(){let t;const i=this.elements;return t=i[1],i[1]=i[3],i[3]=t,t=i[2],i[2]=i[6],i[6]=t,t=i[5],i[5]=i[7],i[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).copy(this).invert().transpose()}transposeIntoArray(t){const i=this.elements;return t[0]=i[0],t[1]=i[3],t[2]=i[6],t[3]=i[1],t[4]=i[4],t[5]=i[7],t[6]=i[2],t[7]=i[5],t[8]=i[8],this}setUvTransform(t,i,n,r,o,s,a){const l=Math.cos(o),c=Math.sin(o);return this.set(n*l,n*c,-n*(l*s+c*a)+s+t,-r*c,r*l,-r*(-c*s+l*a)+a+i,0,0,1),this}scale(t,i){const n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=i,n[4]*=i,n[7]*=i,this}rotate(t){const i=Math.cos(t),n=Math.sin(t),r=this.elements,o=r[0],s=r[3],a=r[6],l=r[1],c=r[4],h=r[7];return r[0]=i*o+n*l,r[3]=i*s+n*c,r[6]=i*a+n*h,r[1]=-n*o+i*l,r[4]=-n*s+i*c,r[7]=-n*a+i*h,this}translate(t,i){const n=this.elements;return n[0]+=t*n[2],n[3]+=t*n[5],n[6]+=t*n[8],n[1]+=i*n[2],n[4]+=i*n[5],n[7]+=i*n[8],this}equals(t){const i=this.elements,n=t.elements;for(let r=0;r<9;r++)if(i[r]!==n[r])return!1;return!0}fromArray(t,i=0){for(let n=0;n<9;n++)this.elements[n]=t[n+i];return this}toArray(t=[],i=0){const n=this.elements;return t[i]=n[0],t[i+1]=n[1],t[i+2]=n[2],t[i+3]=n[3],t[i+4]=n[4],t[i+5]=n[5],t[i+6]=n[6],t[i+7]=n[7],t[i+8]=n[8],t}}let un;const dn={getDataURL:function(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{un===void 0&&(un=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),un.width=e.width,un.height=e.height;const i=un.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=un}return t.width>2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}};let lu=0;function He(e=He.DEFAULT_IMAGE,t=He.DEFAULT_MAPPING,i=ut,n=ut,r=qe,o=an,s=wt,a=Ur,l=1,c=sr){Object.defineProperty(this,"id",{value:lu++}),this.uuid=Se.generateUUID(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=a,this.offset=new le(0,0),this.repeat=new le(1,1),this.center=new le(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ft,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.version=0,this.onUpdate=null}He.DEFAULT_IMAGE=void 0,He.DEFAULT_MAPPING=ya,He.prototype=Object.assign(Object.create(ci.prototype),{constructor:He,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return new this.constructor().copy(this)},copy:function(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:function(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={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(this.image!==void 0){const n=this.image;if(n.uuid===void 0&&(n.uuid=Se.generateUUID()),!t&&e.images[n.uuid]===void 0){let r;if(Array.isArray(n)){r=[];for(let o=0,s=n.length;o1)switch(this.wrapS){case Mi:e.x=e.x-Math.floor(e.x);break;case ut:e.x=e.x<0?0:1;break;case Dr:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Mi:e.y=e.y-Math.floor(e.y);break;case ut:e.y=e.y<0?0:1;break;case Dr:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}}),Object.defineProperty(He.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}});function Jo(e){return typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap?dn.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}class ke{constructor(t=0,i=0,n=0,r=1){Object.defineProperty(this,"isVector4",{value:!0}),this.x=t,this.y=i,this.z=n,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,i,n,r){return this.x=t,this.y=i,this.z=n,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;case 3:this.w=i;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t,i){return i!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,i)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this.w=t.w+i.w,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this.w+=t.w*i,this}sub(t,i){return i!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,i)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this.w=t.w-i.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const i=this.x,n=this.y,r=this.z,o=this.w,s=t.elements;return this.x=s[0]*i+s[4]*n+s[8]*r+s[12]*o,this.y=s[1]*i+s[5]*n+s[9]*r+s[13]*o,this.z=s[2]*i+s[6]*n+s[10]*r+s[14]*o,this.w=s[3]*i+s[7]*n+s[11]*r+s[15]*o,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const i=Math.sqrt(1-t.w*t.w);return i<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/i,this.y=t.y/i,this.z=t.z/i),this}setAxisAngleFromRotationMatrix(t){let i,n,r,o;const s=t.elements,a=s[0],l=s[4],c=s[8],h=s[1],u=s[5],d=s[9],f=s[2],m=s[6],v=s[10];if(Math.abs(l-h)<.01&&Math.abs(c-f)<.01&&Math.abs(d-m)<.01){if(Math.abs(l+h)<.1&&Math.abs(c+f)<.1&&Math.abs(d+m)<.1&&Math.abs(a+u+v-3)<.1)return this.set(1,0,0,0),this;i=Math.PI;const g=(a+1)/2,p=(u+1)/2,E=(v+1)/2,S=(l+h)/4,T=(c+f)/4,x=(d+m)/4;return g>p&&g>E?g<.01?(n=0,r=.707106781,o=.707106781):(n=Math.sqrt(g),r=S/n,o=T/n):p>E?p<.01?(n=.707106781,r=0,o=.707106781):(r=Math.sqrt(p),n=S/r,o=x/r):E<.01?(n=.707106781,r=.707106781,o=0):(o=Math.sqrt(E),n=T/o,r=x/o),this.set(n,r,o,i),this}let _=Math.sqrt((m-d)*(m-d)+(c-f)*(c-f)+(h-l)*(h-l));return Math.abs(_)<.001&&(_=1),this.x=(m-d)/_,this.y=(c-f)/_,this.z=(h-l)/_,this.w=Math.acos((a+u+v-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,i){return this.x=Math.max(t.x,Math.min(i.x,this.x)),this.y=Math.max(t.y,Math.min(i.y,this.y)),this.z=Math.max(t.z,Math.min(i.z,this.z)),this.w=Math.max(t.w,Math.min(i.w,this.w)),this}clampScalar(t,i){return this.x=Math.max(t,Math.min(i,this.x)),this.y=Math.max(t,Math.min(i,this.y)),this.z=Math.max(t,Math.min(i,this.z)),this.w=Math.max(t,Math.min(i,this.w)),this}clampLength(t,i){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(i,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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this.w+=(t.w-this.w)*i,this}lerpVectors(t,i,n){return this.x=t.x+(i.x-t.x)*n,this.y=t.y+(i.y-t.y)*n,this.z=t.z+(i.z-t.z)*n,this.w=t.w+(i.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this.z=t[i+2],this.w=t[i+3],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t[i+3]=this.w,t}fromBufferAttribute(t,i,n){return n!==void 0&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(i),this.y=t.getY(i),this.z=t.getZ(i),this.w=t.getW(i),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}}class ji extends ci{constructor(t,i,n){super(),Object.defineProperty(this,"isWebGLRenderTarget",{value:!0}),this.width=t,this.height=i,this.scissor=new ke(0,0,t,i),this.scissorTest=!1,this.viewport=new ke(0,0,t,i),n=n||{},this.texture=new He(void 0,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=i,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:qe,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null}setSize(t,i){(this.width!==t||this.height!==i)&&(this.width=t,this.height=i,this.texture.image.width=t,this.texture.image.height=i,this.dispose()),this.viewport.set(0,0,t,i),this.scissor.set(0,0,t,i)}clone(){return new this.constructor().copy(this)}copy(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class tt{constructor(t=0,i=0,n=0,r=1){Object.defineProperty(this,"isQuaternion",{value:!0}),this._x=t,this._y=i,this._z=n,this._w=r}static slerp(t,i,n,r){return n.copy(t).slerp(i,r)}static slerpFlat(t,i,n,r,o,s,a){let l=n[r+0],c=n[r+1],h=n[r+2],u=n[r+3];const d=o[s+0],f=o[s+1],m=o[s+2],v=o[s+3];if(u!==v||l!==d||c!==f||h!==m){let _=1-a;const g=l*d+c*f+h*m+u*v,p=g>=0?1:-1,E=1-g*g;if(E>Number.EPSILON){const T=Math.sqrt(E),x=Math.atan2(T,g*p);_=Math.sin(_*x)/T,a=Math.sin(a*x)/T}const S=a*p;if(l=l*_+d*S,c=c*_+f*S,h=h*_+m*S,u=u*_+v*S,_===1-a){const T=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=T,c*=T,h*=T,u*=T}}t[i]=l,t[i+1]=c,t[i+2]=h,t[i+3]=u}static multiplyQuaternionsFlat(t,i,n,r,o,s){const a=n[r],l=n[r+1],c=n[r+2],h=n[r+3],u=o[s],d=o[s+1],f=o[s+2],m=o[s+3];return t[i]=a*m+h*u+l*f-c*d,t[i+1]=l*m+h*d+c*u-a*f,t[i+2]=c*m+h*f+a*d-l*u,t[i+3]=h*m-a*u-l*d-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,i,n,r){return this._x=t,this._y=i,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,i){if(!(t&&t.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=t._x,r=t._y,o=t._z,s=t._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(r/2),u=a(o/2),d=l(n/2),f=l(r/2),m=l(o/2);switch(s){case"XYZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"YXZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"ZXY":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"ZYX":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"YZX":this._x=d*h*u+c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u-d*f*m;break;case"XZY":this._x=d*h*u-c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u+d*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return i!==!1&&this._onChangeCallback(),this}setFromAxisAngle(t,i){const n=i/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const i=t.elements,n=i[0],r=i[4],o=i[8],s=i[1],a=i[5],l=i[9],c=i[2],h=i[6],u=i[10],d=n+a+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(o-c)*f,this._z=(s-r)*f}else if(n>a&&n>u){const f=2*Math.sqrt(1+n-a-u);this._w=(h-l)/f,this._x=.25*f,this._y=(r+s)/f,this._z=(o+c)/f}else if(a>u){const f=2*Math.sqrt(1+a-n-u);this._w=(o-c)/f,this._x=(r+s)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-a);this._w=(s-r)/f,this._x=(o+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,i){let n=t.dot(i)+1;return n<1e-6?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*i.z-t.z*i.y,this._y=t.z*i.x-t.x*i.z,this._z=t.x*i.y-t.y*i.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Se.clamp(this.dot(t),-1,1)))}rotateTowards(t,i){const n=this.angleTo(t);if(n===0)return this;const r=Math.min(1,i/n);return this.slerp(t,r),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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t,i){return i!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,i)):this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,i){const n=t._x,r=t._y,o=t._z,s=t._w,a=i._x,l=i._y,c=i._z,h=i._w;return this._x=n*h+s*a+r*c-o*l,this._y=r*h+s*l+o*a-n*c,this._z=o*h+s*c+n*l-r*a,this._w=s*h-n*a-r*l-o*c,this._onChangeCallback(),this}slerp(t,i){if(i===0)return this;if(i===1)return this.copy(t);const n=this._x,r=this._y,o=this._z,s=this._w;let a=s*t._w+n*t._x+r*t._y+o*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=n,this._y=r,this._z=o,this;const l=1-a*a;if(l<=Number.EPSILON){const f=1-i;return this._w=f*s+i*this._w,this._x=f*n+i*this._x,this._y=f*r+i*this._y,this._z=f*o+i*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),h=Math.atan2(c,a),u=Math.sin((1-i)*h)/c,d=Math.sin(i*h)/c;return this._w=s*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=o*u+this._z*d,this._onChangeCallback(),this}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,i=0){return this._x=t[i],this._y=t[i+1],this._z=t[i+2],this._w=t[i+3],this._onChangeCallback(),this}toArray(t=[],i=0){return t[i]=this._x,t[i+1]=this._y,t[i+2]=this._z,t[i+3]=this._w,t}fromBufferAttribute(t,i){return this._x=t.getX(i),this._y=t.getY(i),this._z=t.getZ(i),this._w=t.getW(i),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}class A{constructor(t=0,i=0,n=0){Object.defineProperty(this,"isVector3",{value:!0}),this.x=t,this.y=i,this.z=n}set(t,i,n){return n===void 0&&(n=this.z),this.x=t,this.y=i,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t,i){return i!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,i)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this}sub(t,i){return i!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,i)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this}multiply(t,i){return i!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,i)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,i){return this.x=t.x*i.x,this.y=t.y*i.y,this.z=t.z*i.z,this}applyEuler(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(za.setFromEuler(t))}applyAxisAngle(t,i){return this.applyQuaternion(za.setFromAxisAngle(t,i))}applyMatrix3(t){const i=this.x,n=this.y,r=this.z,o=t.elements;return this.x=o[0]*i+o[3]*n+o[6]*r,this.y=o[1]*i+o[4]*n+o[7]*r,this.z=o[2]*i+o[5]*n+o[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const i=this.x,n=this.y,r=this.z,o=t.elements,s=1/(o[3]*i+o[7]*n+o[11]*r+o[15]);return this.x=(o[0]*i+o[4]*n+o[8]*r+o[12])*s,this.y=(o[1]*i+o[5]*n+o[9]*r+o[13])*s,this.z=(o[2]*i+o[6]*n+o[10]*r+o[14])*s,this}applyQuaternion(t){const i=this.x,n=this.y,r=this.z,o=t.x,s=t.y,a=t.z,l=t.w,c=l*i+s*r-a*n,h=l*n+a*i-o*r,u=l*r+o*n-s*i,d=-o*i-s*n-a*r;return this.x=c*l+d*-o+h*-a-u*-s,this.y=h*l+d*-s+u*-o-c*-a,this.z=u*l+d*-a+c*-s-h*-o,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const i=this.x,n=this.y,r=this.z,o=t.elements;return this.x=o[0]*i+o[4]*n+o[8]*r,this.y=o[1]*i+o[5]*n+o[9]*r,this.z=o[2]*i+o[6]*n+o[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,i){return this.x=Math.max(t.x,Math.min(i.x,this.x)),this.y=Math.max(t.y,Math.min(i.y,this.y)),this.z=Math.max(t.z,Math.min(i.z,this.z)),this}clampScalar(t,i){return this.x=Math.max(t,Math.min(i,this.x)),this.y=Math.max(t,Math.min(i,this.y)),this.z=Math.max(t,Math.min(i,this.z)),this}clampLength(t,i){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(i,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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this}lerpVectors(t,i,n){return this.x=t.x+(i.x-t.x)*n,this.y=t.y+(i.y-t.y)*n,this.z=t.z+(i.z-t.z)*n,this}cross(t,i){return i!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,i)):this.crossVectors(this,t)}crossVectors(t,i){const n=t.x,r=t.y,o=t.z,s=i.x,a=i.y,l=i.z;return this.x=r*l-o*a,this.y=o*s-n*l,this.z=n*a-r*s,this}projectOnVector(t){const i=t.lengthSq();if(i===0)return this.set(0,0,0);const n=t.dot(this)/i;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Ko.copy(this).projectOnVector(t),this.sub(Ko)}reflect(t){return this.sub(Ko.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const i=Math.sqrt(this.lengthSq()*t.lengthSq());if(i===0)return Math.PI/2;const n=this.dot(t)/i;return Math.acos(Se.clamp(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const i=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return i*i+n*n+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,i,n){const r=Math.sin(i)*t;return this.x=r*Math.sin(n),this.y=Math.cos(i)*t,this.z=r*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,i,n){return this.x=t*Math.sin(i),this.y=n,this.z=t*Math.cos(i),this}setFromMatrixPosition(t){const i=t.elements;return this.x=i[12],this.y=i[13],this.z=i[14],this}setFromMatrixScale(t){const i=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=i,this.y=n,this.z=r,this}setFromMatrixColumn(t,i){return this.fromArray(t.elements,i*4)}setFromMatrix3Column(t,i){return this.fromArray(t.elements,i*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this.z=t[i+2],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t}fromBufferAttribute(t,i,n){return n!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(i),this.y=t.getY(i),this.z=t.getZ(i),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}const Ko=new A,za=new tt;class dt{constructor(t,i){Object.defineProperty(this,"isBox3",{value:!0}),this.min=t!==void 0?t:new A(1/0,1/0,1/0),this.max=i!==void 0?i:new A(-1/0,-1/0,-1/0)}set(t,i){return this.min.copy(t),this.max.copy(i),this}setFromArray(t){let i=1/0,n=1/0,r=1/0,o=-1/0,s=-1/0,a=-1/0;for(let l=0,c=t.length;lo&&(o=h),u>s&&(s=u),d>a&&(a=d)}return this.min.set(i,n,r),this.max.set(o,s,a),this}setFromBufferAttribute(t){let i=1/0,n=1/0,r=1/0,o=-1/0,s=-1/0,a=-1/0;for(let l=0,c=t.count;lo&&(o=h),u>s&&(s=u),d>a&&(a=d)}return this.min.set(i,n,r),this.max.set(o,s,a),this}setFromPoints(t){this.makeEmpty();for(let i=0,n=t.length;ithis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,i){return i===void 0&&(console.warn("THREE.Box3: .getParameter() target is now required"),i=new A),i.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,lr),lr.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let i,n;return t.normal.x>0?(i=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(i=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(i+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(i+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(i+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(i+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),i<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(cr),Vr.subVectors(this.max,cr),pn.subVectors(t.a,cr),fn.subVectors(t.b,cr),mn.subVectors(t.c,cr),Ai.subVectors(fn,pn),Si.subVectors(mn,fn),Xi.subVectors(pn,mn);let i=[0,-Ai.z,Ai.y,0,-Si.z,Si.y,0,-Xi.z,Xi.y,Ai.z,0,-Ai.x,Si.z,0,-Si.x,Xi.z,0,-Xi.x,-Ai.y,Ai.x,0,-Si.y,Si.x,0,-Xi.y,Xi.x,0];return!$o(i,pn,fn,mn,Vr)||(i=[1,0,0,0,1,0,0,0,1],!$o(i,pn,fn,mn,Vr))?!1:(Wr.crossVectors(Ai,Si),i=[Wr.x,Wr.y,Wr.z],$o(i,pn,fn,mn,Vr))}clampPoint(t,i){return i===void 0&&(console.warn("THREE.Box3: .clampPoint() target is now required"),i=new A),i.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return lr.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return t===void 0&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=this.getSize(lr).length()*.5,t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(hi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),hi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),hi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),hi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),hi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),hi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),hi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),hi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(hi),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}function $o(e,t,i,n,r){for(let o=0,s=e.length-3;o<=s;o+=3){Yi.fromArray(e,o);const a=r.x*Math.abs(Yi.x)+r.y*Math.abs(Yi.y)+r.z*Math.abs(Yi.z),l=t.dot(Yi),c=i.dot(Yi),h=n.dot(Yi);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const hi=[new A,new A,new A,new A,new A,new A,new A,new A],lr=new A,es=new dt,pn=new A,fn=new A,mn=new A,Ai=new A,Si=new A,Xi=new A,cr=new A,Vr=new A,Wr=new A,Yi=new A,cu=new dt;class Zt{constructor(t,i){this.center=t!==void 0?t:new A,this.radius=i!==void 0?i:-1}set(t,i){return this.center.copy(t),this.radius=i,this}setFromPoints(t,i){const n=this.center;i!==void 0?n.copy(i):cu.setFromPoints(t).getCenter(n);let r=0;for(let o=0,s=t.length;othis.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i}getBoundingBox(t){return t===void 0&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new dt),this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}}const ui=new A,ts=new A,jr=new A,Ei=new A,is=new A,Xr=new A,ns=new A;class qi{constructor(t,i){this.origin=t!==void 0?t:new A,this.direction=i!==void 0?i:new A(0,0,-1)}set(t,i){return this.origin.copy(t),this.direction.copy(i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,i){return i===void 0&&(console.warn("THREE.Ray: .at() target is now required"),i=new A),i.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,ui)),this}closestPointToPoint(t,i){i===void 0&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),i=new A),i.subVectors(t,this.origin);const n=i.dot(this.direction);return n<0?i.copy(this.origin):i.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const i=ui.subVectors(t,this.origin).dot(this.direction);return i<0?this.origin.distanceToSquared(t):(ui.copy(this.direction).multiplyScalar(i).add(this.origin),ui.distanceToSquared(t))}distanceSqToSegment(t,i,n,r){ts.copy(t).add(i).multiplyScalar(.5),jr.copy(i).sub(t).normalize(),Ei.copy(this.origin).sub(ts);const o=t.distanceTo(i)*.5,s=-this.direction.dot(jr),a=Ei.dot(this.direction),l=-Ei.dot(jr),c=Ei.lengthSq(),h=Math.abs(1-s*s);let u,d,f,m;if(h>0)if(u=s*l-a,d=s*a-l,m=o*h,u>=0)if(d>=-m)if(d<=m){const v=1/h;u*=v,d*=v,f=u*(u+s*d+2*a)+d*(s*u+d+2*l)+c}else d=o,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*l)+c;else d=-o,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*l)+c;else d<=-m?(u=Math.max(0,-(-s*o+a)),d=u>0?-o:Math.min(Math.max(-o,-l),o),f=-u*u+d*(d+2*l)+c):d<=m?(u=0,d=Math.min(Math.max(-o,-l),o),f=d*(d+2*l)+c):(u=Math.max(0,-(s*o+a)),d=u>0?o:Math.min(Math.max(-o,-l),o),f=-u*u+d*(d+2*l)+c);else d=s>0?-o:o,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),r&&r.copy(jr).multiplyScalar(d).add(ts),f}intersectSphere(t,i){ui.subVectors(t.center,this.origin);const n=ui.dot(this.direction),r=ui.dot(ui)-n*n,o=t.radius*t.radius;if(r>o)return null;const s=Math.sqrt(o-r),a=n-s,l=n+s;return a<0&&l<0?null:a<0?this.at(l,i):this.at(a,i)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const i=t.normal.dot(this.direction);if(i===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/i;return n>=0?n:null}intersectPlane(t,i){const n=this.distanceToPlane(t);return n===null?null:this.at(n,i)}intersectsPlane(t){const i=t.distanceToPoint(this.origin);return i===0||t.normal.dot(this.direction)*i<0}intersectBox(t,i){let n,r,o,s,a,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,r=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,r=(t.min.x-d.x)*c),h>=0?(o=(t.min.y-d.y)*h,s=(t.max.y-d.y)*h):(o=(t.max.y-d.y)*h,s=(t.min.y-d.y)*h),n>s||o>r||((o>n||n!==n)&&(n=o),(s=0?(a=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(a=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||a>r)||((a>n||n!==n)&&(n=a),(l=0?n:r,i)}intersectsBox(t){return this.intersectBox(t,ui)!==null}intersectTriangle(t,i,n,r,o){is.subVectors(i,t),Xr.subVectors(n,t),ns.crossVectors(is,Xr);let s=this.direction.dot(ns),a;if(s>0){if(r)return null;a=1}else if(s<0)a=-1,s=-s;else return null;Ei.subVectors(this.origin,t);const l=a*this.direction.dot(Xr.crossVectors(Ei,Xr));if(l<0)return null;const c=a*this.direction.dot(is.cross(Ei));if(c<0||l+c>s)return null;const h=-a*Ei.dot(ns);return h<0?null:this.at(h/s,o)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}}class Re{constructor(){Object.defineProperty(this,"isMatrix4",{value:!0}),this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(t,i,n,r,o,s,a,l,c,h,u,d,f,m,v,_){const g=this.elements;return g[0]=t,g[4]=i,g[8]=n,g[12]=r,g[1]=o,g[5]=s,g[9]=a,g[13]=l,g[2]=c,g[6]=h,g[10]=u,g[14]=d,g[3]=f,g[7]=m,g[11]=v,g[15]=_,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 Re().fromArray(this.elements)}copy(t){const i=this.elements,n=t.elements;return i[0]=n[0],i[1]=n[1],i[2]=n[2],i[3]=n[3],i[4]=n[4],i[5]=n[5],i[6]=n[6],i[7]=n[7],i[8]=n[8],i[9]=n[9],i[10]=n[10],i[11]=n[11],i[12]=n[12],i[13]=n[13],i[14]=n[14],i[15]=n[15],this}copyPosition(t){const i=this.elements,n=t.elements;return i[12]=n[12],i[13]=n[13],i[14]=n[14],this}setFromMatrix3(t){const i=t.elements;return this.set(i[0],i[3],i[6],0,i[1],i[4],i[7],0,i[2],i[5],i[8],0,0,0,0,1),this}extractBasis(t,i,n){return t.setFromMatrixColumn(this,0),i.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,i,n){return this.set(t.x,i.x,n.x,0,t.y,i.y,n.y,0,t.z,i.z,n.z,0,0,0,0,1),this}extractRotation(t){const i=this.elements,n=t.elements,r=1/gn.setFromMatrixColumn(t,0).length(),o=1/gn.setFromMatrixColumn(t,1).length(),s=1/gn.setFromMatrixColumn(t,2).length();return i[0]=n[0]*r,i[1]=n[1]*r,i[2]=n[2]*r,i[3]=0,i[4]=n[4]*o,i[5]=n[5]*o,i[6]=n[6]*o,i[7]=0,i[8]=n[8]*s,i[9]=n[9]*s,i[10]=n[10]*s,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const i=this.elements,n=t.x,r=t.y,o=t.z,s=Math.cos(n),a=Math.sin(n),l=Math.cos(r),c=Math.sin(r),h=Math.cos(o),u=Math.sin(o);if(t.order==="XYZ"){const d=s*h,f=s*u,m=a*h,v=a*u;i[0]=l*h,i[4]=-l*u,i[8]=c,i[1]=f+m*c,i[5]=d-v*c,i[9]=-a*l,i[2]=v-d*c,i[6]=m+f*c,i[10]=s*l}else if(t.order==="YXZ"){const d=l*h,f=l*u,m=c*h,v=c*u;i[0]=d+v*a,i[4]=m*a-f,i[8]=s*c,i[1]=s*u,i[5]=s*h,i[9]=-a,i[2]=f*a-m,i[6]=v+d*a,i[10]=s*l}else if(t.order==="ZXY"){const d=l*h,f=l*u,m=c*h,v=c*u;i[0]=d-v*a,i[4]=-s*u,i[8]=m+f*a,i[1]=f+m*a,i[5]=s*h,i[9]=v-d*a,i[2]=-s*c,i[6]=a,i[10]=s*l}else if(t.order==="ZYX"){const d=s*h,f=s*u,m=a*h,v=a*u;i[0]=l*h,i[4]=m*c-f,i[8]=d*c+v,i[1]=l*u,i[5]=v*c+d,i[9]=f*c-m,i[2]=-c,i[6]=a*l,i[10]=s*l}else if(t.order==="YZX"){const d=s*l,f=s*c,m=a*l,v=a*c;i[0]=l*h,i[4]=v-d*u,i[8]=m*u+f,i[1]=u,i[5]=s*h,i[9]=-a*h,i[2]=-c*h,i[6]=f*u+m,i[10]=d-v*u}else if(t.order==="XZY"){const d=s*l,f=s*c,m=a*l,v=a*c;i[0]=l*h,i[4]=-u,i[8]=c*h,i[1]=d*u+v,i[5]=s*h,i[9]=f*u-m,i[2]=m*u-f,i[6]=a*h,i[10]=v*u+d}return i[3]=0,i[7]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromQuaternion(t){return this.compose(hu,t,uu)}lookAt(t,i,n){const r=this.elements;return St.subVectors(t,i),St.lengthSq()===0&&(St.z=1),St.normalize(),Li.crossVectors(n,St),Li.lengthSq()===0&&(Math.abs(n.z)===1?St.x+=1e-4:St.z+=1e-4,St.normalize(),Li.crossVectors(n,St)),Li.normalize(),Yr.crossVectors(St,Li),r[0]=Li.x,r[4]=Yr.x,r[8]=St.x,r[1]=Li.y,r[5]=Yr.y,r[9]=St.y,r[2]=Li.z,r[6]=Yr.z,r[10]=St.z,this}multiply(t,i){return i!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,i)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){const n=t.elements,r=i.elements,o=this.elements,s=n[0],a=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],m=n[2],v=n[6],_=n[10],g=n[14],p=n[3],E=n[7],S=n[11],T=n[15],x=r[0],L=r[4],W=r[8],U=r[12],B=r[1],H=r[5],j=r[9],G=r[13],D=r[2],k=r[6],Y=r[10],Z=r[14],$=r[3],ne=r[7],ae=r[11],de=r[15];return o[0]=s*x+a*B+l*D+c*$,o[4]=s*L+a*H+l*k+c*ne,o[8]=s*W+a*j+l*Y+c*ae,o[12]=s*U+a*G+l*Z+c*de,o[1]=h*x+u*B+d*D+f*$,o[5]=h*L+u*H+d*k+f*ne,o[9]=h*W+u*j+d*Y+f*ae,o[13]=h*U+u*G+d*Z+f*de,o[2]=m*x+v*B+_*D+g*$,o[6]=m*L+v*H+_*k+g*ne,o[10]=m*W+v*j+_*Y+g*ae,o[14]=m*U+v*G+_*Z+g*de,o[3]=p*x+E*B+S*D+T*$,o[7]=p*L+E*H+S*k+T*ne,o[11]=p*W+E*j+S*Y+T*ae,o[15]=p*U+E*G+S*Z+T*de,this}multiplyScalar(t){const i=this.elements;return i[0]*=t,i[4]*=t,i[8]*=t,i[12]*=t,i[1]*=t,i[5]*=t,i[9]*=t,i[13]*=t,i[2]*=t,i[6]*=t,i[10]*=t,i[14]*=t,i[3]*=t,i[7]*=t,i[11]*=t,i[15]*=t,this}determinant(){const t=this.elements,i=t[0],n=t[4],r=t[8],o=t[12],s=t[1],a=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],f=t[14],m=t[3],v=t[7],_=t[11],g=t[15];return m*(+o*l*u-r*c*u-o*a*d+n*c*d+r*a*f-n*l*f)+v*(+i*l*f-i*c*d+o*s*d-r*s*f+r*c*h-o*l*h)+_*(+i*c*u-i*a*f-o*s*u+n*s*f+o*a*h-n*c*h)+g*(-r*a*h-i*l*u+i*a*d+r*s*u-n*s*d+n*l*h)}transpose(){const t=this.elements;let i;return i=t[1],t[1]=t[4],t[4]=i,i=t[2],t[2]=t[8],t[8]=i,i=t[6],t[6]=t[9],t[9]=i,i=t[3],t[3]=t[12],t[12]=i,i=t[7],t[7]=t[13],t[13]=i,i=t[11],t[11]=t[14],t[14]=i,this}setPosition(t,i,n){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=i,r[14]=n),this}invert(){const t=this.elements,i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],m=t[12],v=t[13],_=t[14],g=t[15],p=u*_*c-v*d*c+v*l*f-a*_*f-u*l*g+a*d*g,E=m*d*c-h*_*c-m*l*f+s*_*f+h*l*g-s*d*g,S=h*v*c-m*u*c+m*a*f-s*v*f-h*a*g+s*u*g,T=m*u*l-h*v*l-m*a*d+s*v*d+h*a*_-s*u*_,x=i*p+n*E+r*S+o*T;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const L=1/x;return t[0]=p*L,t[1]=(v*d*o-u*_*o-v*r*f+n*_*f+u*r*g-n*d*g)*L,t[2]=(a*_*o-v*l*o+v*r*c-n*_*c-a*r*g+n*l*g)*L,t[3]=(u*l*o-a*d*o-u*r*c+n*d*c+a*r*f-n*l*f)*L,t[4]=E*L,t[5]=(h*_*o-m*d*o+m*r*f-i*_*f-h*r*g+i*d*g)*L,t[6]=(m*l*o-s*_*o-m*r*c+i*_*c+s*r*g-i*l*g)*L,t[7]=(s*d*o-h*l*o+h*r*c-i*d*c-s*r*f+i*l*f)*L,t[8]=S*L,t[9]=(m*u*o-h*v*o-m*n*f+i*v*f+h*n*g-i*u*g)*L,t[10]=(s*v*o-m*a*o+m*n*c-i*v*c-s*n*g+i*a*g)*L,t[11]=(h*a*o-s*u*o-h*n*c+i*u*c+s*n*f-i*a*f)*L,t[12]=T*L,t[13]=(h*v*r-m*u*r+m*n*d-i*v*d-h*n*_+i*u*_)*L,t[14]=(m*a*r-s*v*r-m*n*l+i*v*l+s*n*_-i*a*_)*L,t[15]=(s*u*r-h*a*r+h*n*l-i*u*l-s*n*d+i*a*d)*L,this}scale(t){const i=this.elements,n=t.x,r=t.y,o=t.z;return i[0]*=n,i[4]*=r,i[8]*=o,i[1]*=n,i[5]*=r,i[9]*=o,i[2]*=n,i[6]*=r,i[10]*=o,i[3]*=n,i[7]*=r,i[11]*=o,this}getMaxScaleOnAxis(){const t=this.elements,i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(i,n,r))}makeTranslation(t,i,n){return this.set(1,0,0,t,0,1,0,i,0,0,1,n,0,0,0,1),this}makeRotationX(t){const i=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,i,-n,0,0,n,i,0,0,0,0,1),this}makeRotationY(t){const i=Math.cos(t),n=Math.sin(t);return this.set(i,0,n,0,0,1,0,0,-n,0,i,0,0,0,0,1),this}makeRotationZ(t){const i=Math.cos(t),n=Math.sin(t);return this.set(i,-n,0,0,n,i,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,i){const n=Math.cos(i),r=Math.sin(i),o=1-n,s=t.x,a=t.y,l=t.z,c=o*s,h=o*a;return this.set(c*s+n,c*a-r*l,c*l+r*a,0,c*a+r*l,h*a+n,h*l-r*s,0,c*l-r*a,h*l+r*s,o*l*l+n,0,0,0,0,1),this}makeScale(t,i,n){return this.set(t,0,0,0,0,i,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,i,n){return this.set(1,i,n,0,t,1,n,0,t,i,1,0,0,0,0,1),this}compose(t,i,n){const r=this.elements,o=i._x,s=i._y,a=i._z,l=i._w,c=o+o,h=s+s,u=a+a,d=o*c,f=o*h,m=o*u,v=s*h,_=s*u,g=a*u,p=l*c,E=l*h,S=l*u,T=n.x,x=n.y,L=n.z;return r[0]=(1-(v+g))*T,r[1]=(f+S)*T,r[2]=(m-E)*T,r[3]=0,r[4]=(f-S)*x,r[5]=(1-(d+g))*x,r[6]=(_+p)*x,r[7]=0,r[8]=(m+E)*L,r[9]=(_-p)*L,r[10]=(1-(d+v))*L,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,i,n){const r=this.elements;let o=gn.set(r[0],r[1],r[2]).length();const s=gn.set(r[4],r[5],r[6]).length(),a=gn.set(r[8],r[9],r[10]).length();this.determinant()<0&&(o=-o),t.x=r[12],t.y=r[13],t.z=r[14],Vt.copy(this);const l=1/o,c=1/s,h=1/a;return Vt.elements[0]*=l,Vt.elements[1]*=l,Vt.elements[2]*=l,Vt.elements[4]*=c,Vt.elements[5]*=c,Vt.elements[6]*=c,Vt.elements[8]*=h,Vt.elements[9]*=h,Vt.elements[10]*=h,i.setFromRotationMatrix(Vt),n.x=o,n.y=s,n.z=a,this}makePerspective(t,i,n,r,o,s){s===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const a=this.elements,l=2*o/(i-t),c=2*o/(n-r),h=(i+t)/(i-t),u=(n+r)/(n-r),d=-(s+o)/(s-o),f=-2*s*o/(s-o);return a[0]=l,a[4]=0,a[8]=h,a[12]=0,a[1]=0,a[5]=c,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,i,n,r,o,s){const a=this.elements,l=1/(i-t),c=1/(n-r),h=1/(s-o),u=(i+t)*l,d=(n+r)*c,f=(s+o)*h;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*h,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const i=this.elements,n=t.elements;for(let r=0;r<16;r++)if(i[r]!==n[r])return!1;return!0}fromArray(t,i=0){for(let n=0;n<16;n++)this.elements[n]=t[n+i];return this}toArray(t=[],i=0){const n=this.elements;return t[i]=n[0],t[i+1]=n[1],t[i+2]=n[2],t[i+3]=n[3],t[i+4]=n[4],t[i+5]=n[5],t[i+6]=n[6],t[i+7]=n[7],t[i+8]=n[8],t[i+9]=n[9],t[i+10]=n[10],t[i+11]=n[11],t[i+12]=n[12],t[i+13]=n[13],t[i+14]=n[14],t[i+15]=n[15],t}}const gn=new A,Vt=new Re,hu=new A(0,0,0),uu=new A(1,1,1),Li=new A,Yr=new A,St=new A;class Qn{constructor(t=0,i=0,n=0,r=Qn.DefaultOrder){Object.defineProperty(this,"isEuler",{value:!0}),this._x=t,this._y=i,this._z=n,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,i,n,r){return this._x=t,this._y=i,this._z=n,this._order=r||this._order,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,i,n){const r=Se.clamp,o=t.elements,s=o[0],a=o[4],l=o[8],c=o[1],h=o[5],u=o[9],d=o[2],f=o[6],m=o[10];switch(i=i||this._order,i){case"XYZ":this._y=Math.asin(r(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(f,h),this._z=0);break;case"YXZ":this._x=Math.asin(-r(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(l,m),this._z=Math.atan2(c,h)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(r(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-d,m),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-r(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(f,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(r(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,h),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-r(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,h),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+i)}return this._order=i,n!==!1&&this._onChangeCallback(),this}setFromQuaternion(t,i,n){return ka.makeRotationFromQuaternion(t),this.setFromRotationMatrix(ka,i,n)}setFromVector3(t,i){return this.set(t.x,t.y,t.z,i||this._order)}reorder(t){return Ha.setFromEuler(this),this.setFromQuaternion(Ha,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],i=0){return t[i]=this._x,t[i+1]=this._y,t[i+2]=this._z,t[i+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new A(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}Qn.DefaultOrder="XYZ",Qn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];const ka=new Re,Ha=new tt;class Ba{constructor(){this.mask=1}set(t){this.mask=1<1){for(let t=0;t1){for(let i=0;i0){n.children=[];for(let s=0;s0){n.animations=[];for(let s=0;s0&&(i.geometries=s),a.length>0&&(i.materials=a),l.length>0&&(i.textures=l),c.length>0&&(i.images=c),h.length>0&&(i.shapes=h),u.length>0&&(i.skeletons=u),d.length>0&&(i.animations=d)}return i.object=n,i;function o(s){const a=[];for(const l in s){const c=s[l];delete c.metadata,a.push(c)}return a}},clone:function(e){return new this.constructor().copy(this,e)},copy:function(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i1))return i.copy(n).multiplyScalar(o).add(t.start)}intersectsLine(t){const i=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return i<0&&n>0||n<0&&i>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t===void 0&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new A),t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,i){const n=i||vu.getNormalMatrix(t),r=this.coplanarPoint(rs).applyMatrix4(t),o=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(o),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}}const Wt=new A,fi=new A,os=new A,mi=new A,_n=new A,xn=new A,Ya=new A,ss=new A,as=new A,ls=new A;class xt{constructor(t,i,n){this.a=t!==void 0?t:new A,this.b=i!==void 0?i:new A,this.c=n!==void 0?n:new A}static getNormal(t,i,n,r){r===void 0&&(console.warn("THREE.Triangle: .getNormal() target is now required"),r=new A),r.subVectors(n,i),Wt.subVectors(t,i),r.cross(Wt);const o=r.lengthSq();return o>0?r.multiplyScalar(1/Math.sqrt(o)):r.set(0,0,0)}static getBarycoord(t,i,n,r,o){Wt.subVectors(r,i),fi.subVectors(n,i),os.subVectors(t,i);const s=Wt.dot(Wt),a=Wt.dot(fi),l=Wt.dot(os),c=fi.dot(fi),h=fi.dot(os),u=s*c-a*a;if(o===void 0&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),o=new A),u===0)return o.set(-2,-1,-1);const d=1/u,f=(c*l-a*h)*d,m=(s*h-a*l)*d;return o.set(1-f-m,m,f)}static containsPoint(t,i,n,r){return this.getBarycoord(t,i,n,r,mi),mi.x>=0&&mi.y>=0&&mi.x+mi.y<=1}static getUV(t,i,n,r,o,s,a,l){return this.getBarycoord(t,i,n,r,mi),l.set(0,0),l.addScaledVector(o,mi.x),l.addScaledVector(s,mi.y),l.addScaledVector(a,mi.z),l}static isFrontFacing(t,i,n,r){return Wt.subVectors(n,i),fi.subVectors(t,i),Wt.cross(fi).dot(r)<0}set(t,i,n){return this.a.copy(t),this.b.copy(i),this.c.copy(n),this}setFromPointsAndIndices(t,i,n,r){return this.a.copy(t[i]),this.b.copy(t[n]),this.c.copy(t[r]),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Wt.subVectors(this.c,this.b),fi.subVectors(this.a,this.b),Wt.cross(fi).length()*.5}getMidpoint(t){return t===void 0&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new A),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return xt.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t===void 0&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new pi),t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,i){return xt.getBarycoord(t,this.a,this.b,this.c,i)}getUV(t,i,n,r,o){return xt.getUV(t,this.a,this.b,this.c,i,n,r,o)}containsPoint(t){return xt.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return xt.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,i){i===void 0&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),i=new A);const n=this.a,r=this.b,o=this.c;let s,a;_n.subVectors(r,n),xn.subVectors(o,n),ss.subVectors(t,n);const l=_n.dot(ss),c=xn.dot(ss);if(l<=0&&c<=0)return i.copy(n);as.subVectors(t,r);const h=_n.dot(as),u=xn.dot(as);if(h>=0&&u<=h)return i.copy(r);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return s=l/(l-h),i.copy(n).addScaledVector(_n,s);ls.subVectors(t,o);const f=_n.dot(ls),m=xn.dot(ls);if(m>=0&&f<=m)return i.copy(o);const v=f*c-l*m;if(v<=0&&c>=0&&m<=0)return a=c/(c-m),i.copy(n).addScaledVector(xn,a);const _=h*m-f*u;if(_<=0&&u-h>=0&&f-m>=0)return Ya.subVectors(o,r),a=(u-h)/(u-h+(f-m)),i.copy(r).addScaledVector(Ya,a);const g=1/(_+v+d);return s=v*g,a=d*g,i.copy(n).addScaledVector(_n,s).addScaledVector(xn,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const qa={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},jt={h:0,s:0,l:0},Qr={h:0,s:0,l:0};function cs(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+(t-e)*6*i:i<1/2?t:i<2/3?e+(t-e)*6*(2/3-i):e}function hs(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function us(e){return e<.0031308?e*12.92:1.055*Math.pow(e,.41666)-.055}class he{constructor(t,i,n){return Object.defineProperty(this,"isColor",{value:!0}),i===void 0&&n===void 0?this.set(t):this.setRGB(t,i,n)}set(t){return t&&t.isColor?this.copy(t):typeof t=="number"?this.setHex(t):typeof t=="string"&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,this}setRGB(t,i,n){return this.r=t,this.g=i,this.b=n,this}setHSL(t,i,n){if(t=Se.euclideanModulo(t,1),i=Se.clamp(i,0,1),n=Se.clamp(n,0,1),i===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+i):n+i-n*i,o=2*n-r;this.r=cs(o,r,t+1/3),this.g=cs(o,r,t),this.b=cs(o,r,t-1/3)}return this}setStyle(t){function i(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let r;const o=n[1],s=n[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,i(r[4]),this;if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,i(r[4]),this;break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s)){const a=parseFloat(r[1])/360,l=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return i(r[4]),this.setHSL(a,l,c)}break}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=n[1],o=r.length;if(o===3)return this.r=parseInt(r.charAt(0)+r.charAt(0),16)/255,this.g=parseInt(r.charAt(1)+r.charAt(1),16)/255,this.b=parseInt(r.charAt(2)+r.charAt(2),16)/255,this;if(o===6)return this.r=parseInt(r.charAt(0)+r.charAt(1),16)/255,this.g=parseInt(r.charAt(2)+r.charAt(3),16)/255,this.b=parseInt(r.charAt(4)+r.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this}setColorName(t){const i=qa[t];return i!==void 0?this.setHex(i):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copyGammaToLinear(t,i=2){return this.r=Math.pow(t.r,i),this.g=Math.pow(t.g,i),this.b=Math.pow(t.b,i),this}copyLinearToGamma(t,i=2){const n=i>0?1/i:1;return this.r=Math.pow(t.r,n),this.g=Math.pow(t.g,n),this.b=Math.pow(t.b,n),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.r=hs(t.r),this.g=hs(t.g),this.b=hs(t.b),this}copyLinearToSRGB(t){return this.r=us(t.r),this.g=us(t.g),this.b=us(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return this.r*255<<16^this.g*255<<8^this.b*255<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(t){t===void 0&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});const i=this.r,n=this.g,r=this.b,o=Math.max(i,n,r),s=Math.min(i,n,r);let a,l;const c=(s+o)/2;if(s===o)a=0,l=0;else{const h=o-s;switch(l=c<=.5?h/(o+s):h/(2-o-s),o){case i:a=(n-r)/h+(n0&&(i.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.morphTargets===!0&&(i.morphTargets=!0),this.morphNormals===!0&&(i.morphNormals=!0),this.skinning===!0&&(i.skinning=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),JSON.stringify(this.userData)!=="{}"&&(i.userData=this.userData);function n(r){const o=[];for(const s in r){const a=r[s];delete a.metadata,o.push(a)}return o}if(t){const r=n(e.textures),o=n(e.images);r.length>0&&(i.textures=r),o.length>0&&(i.images=o)}return i},clone:function(){return new this.constructor().copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,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 i=null;if(t!==null){const n=t.length;i=new Array(n);for(let r=0;r!==n;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,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.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(Me.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}});function vt(e){Me.call(this),this.type="MeshBasicMaterial",this.color=new he(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=Or,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(e)}vt.prototype=Object.create(Me.prototype),vt.prototype.constructor=vt,vt.prototype.isMeshBasicMaterial=!0,vt.prototype.copy=function(e){return Me.prototype.copy.call(this,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.skinning=e.skinning,this.morphTargets=e.morphTargets,this};const Be=new A,Zr=new le;function Le(e,t,i){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i===!0,this.usage=Br,this.updateRange={offset:0,count:-1},this.version=0}Object.defineProperty(Le.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(Le.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(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:function(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,r=this.itemSize;nt&&(t=e[i]);return t}const yu={Int8Array,Uint8Array,Uint8ClampedArray:typeof Uint8ClampedArray<"u"?Uint8ClampedArray:Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Kr(e,t){return new yu[e](t)}let bu=0;const Jt=new Re,_s=new we,yn=new A,Et=new dt,pr=new dt,ot=new A;function De(){Object.defineProperty(this,"id",{value:bu++}),this.uuid=Se.generateUUID(),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={}}De.prototype=Object.assign(Object.create(ci.prototype),{constructor:De,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(e){return Array.isArray(e)?this.index=new(Qa(e)>65535?dr:ur)(e,1):this.index=e,this},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,t){return this.attributes[e]=t,this},deleteAttribute:function(e){return delete this.attributes[e],this},hasAttribute:function(e){return this.attributes[e]!==void 0},addGroup:function(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix4:function(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new Ft().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this},rotateX:function(e){return Jt.makeRotationX(e),this.applyMatrix4(Jt),this},rotateY:function(e){return Jt.makeRotationY(e),this.applyMatrix4(Jt),this},rotateZ:function(e){return Jt.makeRotationZ(e),this.applyMatrix4(Jt),this},translate:function(e,t,i){return Jt.makeTranslation(e,t,i),this.applyMatrix4(Jt),this},scale:function(e,t,i){return Jt.makeScale(e,t,i),this.applyMatrix4(Jt),this},lookAt:function(e){return _s.lookAt(e),_s.updateMatrix(),this.applyMatrix4(_s.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(yn).negate(),this.translate(yn.x,yn.y,yn.z),this},setFromPoints:function(e){const t=[];for(let i=0,n=e.length;i0&&(e.userData=this.userData),this.parameters!==void 0){const a=this.parameters;for(const l in a)a[l]!==void 0&&(e[l]=a[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const a in i){const l=i[a],c=l.toJSON(e.data);l.name!==""&&(c.name=l.name),e.data.attributes[a]=c}const n={};let r=!1;for(const a in this.morphAttributes){const l=this.morphAttributes[a],c=[];for(let h=0,u=l.length;h0&&(n[a]=c,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const s=this.boundingSphere;return s!==null&&(e.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),e},clone:function(){return new De().copy(this)},copy:function(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(t));const n=e.attributes;for(const l in n){const c=n[l];this.setAttribute(l,c.clone(t))}const r=e.morphAttributes;for(const l in r){const c=[],h=r[l];for(let u=0,d=h.length;u0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(e,t){const i=this.geometry,n=this.material,r=this.matrixWorld;if(n===void 0||(i.boundingSphere===null&&i.computeBoundingSphere(),xs.copy(i.boundingSphere),xs.applyMatrix4(r),e.ray.intersectsSphere(xs)===!1)||(Za.copy(r).invert(),bn.copy(e.ray).applyMatrix4(Za),i.boundingBox!==null&&bn.intersectsBox(i.boundingBox)===!1))return;let o;if(i.isBufferGeometry){const s=i.index,a=i.attributes.position,l=i.morphAttributes.position,c=i.morphTargetsRelative,h=i.attributes.uv,u=i.attributes.uv2,d=i.groups,f=i.drawRange;if(s!==null)if(Array.isArray(n))for(let m=0,v=d.length;mi.far?null:{distance:c,point:oo.clone(),object:e}}function so(e,t,i,n,r,o,s,a,l,c,h,u){Pi.fromBufferAttribute(r,c),Ri.fromBufferAttribute(r,h),Ci.fromBufferAttribute(r,u);const d=e.morphTargetInfluences;if(t.morphTargets&&o&&d){$r.set(0,0,0),eo.set(0,0,0),to.set(0,0,0);for(let m=0,v=o.length;m0?1:-1,h.push(ne.x,ne.y,ne.z),u.push(ce/L),u.push(1-ae/W),Z+=1}}for(let ae=0;ae0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const i={};for(const n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(t.extensions=i),t};function Ni(){we.call(this),this.type="Camera",this.matrixWorldInverse=new Re,this.projectionMatrix=new Re,this.projectionMatrixInverse=new Re}Ni.prototype=Object.assign(Object.create(we.prototype),{constructor:Ni,isCamera:!0,copy:function(e,t){return we.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this},getWorldDirection:function(e){e===void 0&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),e=new A),this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){we.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()},updateWorldMatrix:function(e,t){we.prototype.updateWorldMatrix.call(this,e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()},clone:function(){return new this.constructor().copy(this)}});function $e(e=50,t=1,i=.1,n=2e3){Ni.call(this),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}$e.prototype=Object.assign(Object.create(Ni.prototype),{constructor:$e,isPerspectiveCamera:!0,copy:function(e,t){return Ni.prototype.copy.call(this,e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){const t=.5*this.getFilmHeight()/e;this.fov=Se.RAD2DEG*2*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){const e=Math.tan(Se.DEG2RAD*.5*this.fov);return .5*this.getFilmHeight()/e},getEffectiveFOV:function(){return Se.RAD2DEG*2*Math.atan(Math.tan(Se.DEG2RAD*.5*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,t,i,n,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){const e=this.near;let t=e*Math.tan(Se.DEG2RAD*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n;const o=this.view;if(this.view!==null&&this.view.enabled){const a=o.fullWidth,l=o.fullHeight;r+=o.offsetX*n/a,t-=o.offsetY*i/l,n*=o.width/a,i*=o.height/l}const s=this.filmOffset;s!==0&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,t,t-i,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(e){const t=we.prototype.toJSON.call(this,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,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}});const Mn=90,Tn=1;function An(e,t,i){if(we.call(this),this.type="CubeCamera",i.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=i;const n=new $e(Mn,Tn,e,t);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new A(1,0,0)),this.add(n);const r=new $e(Mn,Tn,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new A(-1,0,0)),this.add(r);const o=new $e(Mn,Tn,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new A(0,1,0)),this.add(o);const s=new $e(Mn,Tn,e,t);s.layers=this.layers,s.up.set(0,0,-1),s.lookAt(new A(0,-1,0)),this.add(s);const a=new $e(Mn,Tn,e,t);a.layers=this.layers,a.up.set(0,-1,0),a.lookAt(new A(0,0,1)),this.add(a);const l=new $e(Mn,Tn,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new A(0,0,-1)),this.add(l),this.update=function(c,h){this.parent===null&&this.updateMatrixWorld();const u=c.xr.enabled,d=c.getRenderTarget();c.xr.enabled=!1;const f=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,c.setRenderTarget(i,0),c.render(h,n),c.setRenderTarget(i,1),c.render(h,r),c.setRenderTarget(i,2),c.render(h,o),c.setRenderTarget(i,3),c.render(h,s),c.setRenderTarget(i,4),c.render(h,a),i.texture.generateMipmaps=f,c.setRenderTarget(i,5),c.render(h,l),c.setRenderTarget(d),c.xr.enabled=u}}An.prototype=Object.create(we.prototype),An.prototype.constructor=An;function Ii(e,t,i,n,r,o,s,a,l,c){e=e!==void 0?e:[],t=t!==void 0?t:Bo,s=s!==void 0?s:Ti,He.call(this,e,t,i,n,r,o,s,a,l,c),this.flipY=!1,this._needsFlipEnvMap=!0}Ii.prototype=Object.create(He.prototype),Ii.prototype.constructor=Ii,Ii.prototype.isCubeTexture=!0,Object.defineProperty(Ii.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}});class Au extends ji{constructor(t,i,n){Number.isInteger(i)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),i=n),super(t,t,i),Object.defineProperty(this,"isWebGLCubeRenderTarget",{value:!0}),i=i||{},this.texture=new Ii(void 0,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(t,i){this.texture.type=i.type,this.texture.format=wt,this.texture.encoding=i.encoding,this.texture.generateMipmaps=i.generateMipmaps,this.texture.minFilter=i.minFilter,this.texture.magFilter=i.magFilter;const 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 #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},r=new gi(5,5,5),o=new Qe({name:"CubemapFromEquirect",uniforms:wn(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ze,blending:er});o.uniforms.tEquirect.value=i;const s=new Oe(r,o),a=i.minFilter;return i.minFilter===an&&(i.minFilter=qe),new An(1,10,this).update(t,s),i.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(t,i,n,r){const o=t.getRenderTarget();for(let s=0;s<6;s++)t.setRenderTarget(this,s),t.clear(i,n,r);t.setRenderTarget(o)}}function Sn(e,t,i,n,r,o,s,a,l,c,h,u){He.call(this,null,o,s,a,l,c,n,r,h,u),this.image={data:e||null,width:t||1,height:i||1},this.magFilter=l!==void 0?l:rt,this.minFilter=c!==void 0?c:rt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}Sn.prototype=Object.create(He.prototype),Sn.prototype.constructor=Sn,Sn.prototype.isDataTexture=!0;const En=new Zt,ao=new A;class lo{constructor(t,i,n,r,o,s){this.planes=[t!==void 0?t:new pi,i!==void 0?i:new pi,n!==void 0?n:new pi,r!==void 0?r:new pi,o!==void 0?o:new pi,s!==void 0?s:new pi]}set(t,i,n,r,o,s){const a=this.planes;return a[0].copy(t),a[1].copy(i),a[2].copy(n),a[3].copy(r),a[4].copy(o),a[5].copy(s),this}clone(){return new this.constructor().copy(this)}copy(t){const i=this.planes;for(let n=0;n<6;n++)i[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t){const i=this.planes,n=t.elements,r=n[0],o=n[1],s=n[2],a=n[3],l=n[4],c=n[5],h=n[6],u=n[7],d=n[8],f=n[9],m=n[10],v=n[11],_=n[12],g=n[13],p=n[14],E=n[15];return i[0].setComponents(a-r,u-l,v-d,E-_).normalize(),i[1].setComponents(a+r,u+l,v+d,E+_).normalize(),i[2].setComponents(a+o,u+c,v+f,E+g).normalize(),i[3].setComponents(a-o,u-c,v-f,E-g).normalize(),i[4].setComponents(a-s,u-h,v-m,E-p).normalize(),i[5].setComponents(a+s,u+h,v+m,E+p).normalize(),this}intersectsObject(t){const i=t.geometry;return i.boundingSphere===null&&i.computeBoundingSphere(),En.copy(i.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(En)}intersectsSprite(t){return En.center.set(0,0,0),En.radius=.7071067811865476,En.applyMatrix4(t.matrixWorld),this.intersectsSphere(En)}intersectsSphere(t){const i=this.planes,n=t.center,r=-t.radius;for(let o=0;o<6;o++)if(i[o].distanceToPoint(n)0?t.max.x:t.min.x,ao.y=r.normal.y>0?t.max.y:t.min.y,ao.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(ao)<0)return!1}return!0}containsPoint(t){const i=this.planes;for(let n=0;n<6;n++)if(i[n].distanceToPoint(t)<0)return!1;return!0}}function Ka(){let e=null,t=!1,i=null,n=null;function r(o,s){i(o,s),n=e.requestAnimationFrame(r)}return{start:function(){t!==!0&&i!==null&&(n=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(o){i=o},setContext:function(o){e=o}}}function Su(e,t){const i=t.isWebGL2,n=new WeakMap;function r(c,h){const u=c.array,d=c.usage,f=e.createBuffer();e.bindBuffer(h,f),e.bufferData(h,u,d),c.onUploadCallback();let m=5126;return u instanceof Float32Array?m=5126:u instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):u instanceof Uint16Array?c.isFloat16BufferAttribute?i?m=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):m=5123:u instanceof Int16Array?m=5122:u instanceof Uint32Array?m=5125:u instanceof Int32Array?m=5124:u instanceof Int8Array?m=5120:u instanceof Uint8Array&&(m=5121),{buffer:f,type:m,bytesPerElement:u.BYTES_PER_ELEMENT,version:c.version}}function o(c,h,u){const d=h.array,f=h.updateRange;e.bindBuffer(u,c),f.count===-1?e.bufferSubData(u,0,d):(i?e.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):e.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1)}function s(c){return c.isInterleavedBufferAttribute&&(c=c.data),n.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);const h=n.get(c);h&&(e.deleteBuffer(h.buffer),n.delete(c))}function l(c,h){if(c.isGLBufferAttribute){const d=n.get(c);(!d||d.version 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; #else if( cutoffDistance > 0.0 && decayExponent > 0.0 ) { return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent ); } return 1.0; #endif } vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) { float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH ); return ( 1.0 - specularColor ) * fresnel + specularColor; } vec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) { float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV ); vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0; return Fr * fresnel + F0; } float G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); return 1.0 / ( gl * gv ); } float G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) { float alpha = pow2( roughness ); vec3 halfDir = normalize( incidentLight.direction + viewDir ); float dotNL = saturate( dot( normal, incidentLight.direction ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotLH = saturate( dot( incidentLight.direction, halfDir ) ); vec3 F = F_Schlick( specularColor, dotLH ); float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( G * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } vec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); vec2 brdf = integrateSpecularBRDF( dotNV, roughness ); return specularColor * brdf.x + brdf.y; } void BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) ); vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness ); vec2 brdf = integrateSpecularBRDF( dotNV, roughness ); vec3 FssEss = F * brdf.x + brdf.y; float Ess = brdf.x + brdf.y; float Ems = 1.0 - Ess; vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } float G_BlinnPhong_Implicit( ) { return 0.25; } float D_BlinnPhong( const in float shininess, const in float dotNH ) { return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); } vec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) { vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir ); float dotNH = saturate( dot( geometry.normal, halfDir ) ); float dotLH = saturate( dot( incidentLight.direction, halfDir ) ); vec3 F = F_Schlick( specularColor, dotLH ); float G = G_BlinnPhong_Implicit( ); float D = D_BlinnPhong( shininess, dotNH ); return F * ( G * D ); } float GGXRoughnessToBlinnExponent( const in float ggxRoughness ) { return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 ); } float BlinnExponentToGGXRoughness( const in float blinnExponent ) { return sqrt( 2.0 / ( blinnExponent + 2.0 ) ); } #if defined( USE_SHEEN ) float D_Charlie(float roughness, float NoH) { float invAlpha = 1.0 / roughness; float cos2h = NoH * NoH; float sin2h = max(1.0 - cos2h, 0.0078125); return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI); } float V_Neubelt(float NoV, float NoL) { return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV))); } vec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) { vec3 N = geometry.normal; vec3 V = geometry.viewDir; vec3 H = normalize( V + L ); float dotNH = saturate( dot( N, H ) ); return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) ); } #endif`,Ou=`#ifdef USE_BUMPMAP uniform sampler2D bumpMap; uniform float bumpScale; vec2 dHdxy_fwd() { vec2 dSTdx = dFdx( vUv ); vec2 dSTdy = dFdy( vUv ); float Hll = bumpScale * texture2D( bumpMap, vUv ).x; float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll; float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll; return vec2( dBx, dBy ); } vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) { vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) ); vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) ); vec3 vN = surf_norm; vec3 R1 = cross( vSigmaY, vN ); vec3 R2 = cross( vN, vSigmaX ); float fDet = dot( vSigmaX, R1 ); fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 ); vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * surf_norm - vGrad ); } #endif`,Du=`#if NUM_CLIPPING_PLANES > 0 vec4 plane; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES bool clipped = true; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; } #pragma unroll_loop_end if ( clipped ) discard; #endif #endif`,Uu=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,zu=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,ku=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,Hu=`#ifdef USE_COLOR diffuseColor.rgb *= vColor; #endif`,Bu=`#ifdef USE_COLOR varying vec3 vColor; #endif`,Gu=`#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; #endif`,Vu=`#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor.xyz *= color.xyz; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif`,Wu=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate(a) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement(a) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract(sin(sn) * c); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); } float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; struct GeometricContext { vec3 position; vec3 normal; vec3 viewDir; #ifdef CLEARCOAT vec3 clearcoatNormal; #endif }; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) { float distance = dot( planeNormal, point - pointOnPlane ); return - distance * planeNormal + point; } float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) { return sign( dot( point - pointOnPlane, planeNormal ) ); } vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) { return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine; } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } float linearToRelativeLuminance( const in vec3 color ) { vec3 weights = vec3( 0.2126, 0.7152, 0.0722 ); return dot( weights, color.rgb ); } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); }`,ju=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_maxMipLevel 8.0 #define cubeUV_minMipLevel 4.0 #define cubeUV_maxTileSize 256.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { vec3 absDirection = abs( direction ); float face = - 1.0; if ( absDirection.x > absDirection.z ) { if ( absDirection.x > absDirection.y ) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if ( absDirection.z > absDirection.y ) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; } vec2 getUV( vec3 direction, float face ) { vec2 uv; if ( face == 0.0 ) { uv = vec2( direction.z, direction.y ) / abs( direction.x ); } else if ( face == 1.0 ) { uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); } else if ( face == 2.0 ) { uv = vec2( - direction.x, direction.y ) / abs( direction.z ); } else if ( face == 3.0 ) { uv = vec2( - direction.z, direction.y ) / abs( direction.x ); } else if ( face == 4.0 ) { uv = vec2( - direction.x, direction.z ) / abs( direction.y ); } else { uv = vec2( direction.x, direction.y ) / abs( direction.z ); } return 0.5 * ( uv + 1.0 ); } vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { float face = getFace( direction ); float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); mipInt = max( mipInt, cubeUV_minMipLevel ); float faceSize = exp2( mipInt ); float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize ); vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ); vec2 f = fract( uv ); uv += 0.5 - f; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; if ( mipInt < cubeUV_maxMipLevel ) { uv.y += 2.0 * cubeUV_maxTileSize; } uv.y += filterInt * 2.0 * cubeUV_minTileSize; uv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize ); uv *= texelSize; vec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb; uv.x += texelSize; vec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb; uv.y += texelSize; vec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb; uv.x -= texelSize; vec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb; vec3 tm = mix( tl, tr, f.x ); vec3 bm = mix( bl, br, f.x ); return mix( tm, bm, f.y ); } #define r0 1.0 #define v0 0.339 #define m0 - 2.0 #define r1 0.8 #define v1 0.276 #define m1 - 1.0 #define r4 0.4 #define v4 0.046 #define m4 2.0 #define r5 0.305 #define v5 0.016 #define m5 3.0 #define r6 0.21 #define v6 0.0038 #define m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= r1 ) { mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0; } else if ( roughness >= r4 ) { mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1; } else if ( roughness >= r5 ) { mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4; } else if ( roughness >= r6 ) { mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel ); float mipF = fract( mip ); float mipInt = floor( mip ); vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); if ( mipF == 0.0 ) { return vec4( color0, 1.0 ); } else { vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); return vec4( mix( color0, color1, mipF ), 1.0 ); } } #endif`,Xu=`vec3 transformedNormal = objectNormal; #ifdef USE_INSTANCING mat3 m = mat3( instanceMatrix ); transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); transformedNormal = m * transformedNormal; #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`,Yu=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,qu=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); #endif`,Qu=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vUv ); emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb; totalEmissiveRadiance *= emissiveColor.rgb; #endif`,Zu=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,Ju="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ku=` vec4 LinearToLinear( in vec4 value ) { return value; } vec4 GammaToLinear( in vec4 value, in float gammaFactor ) { return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a ); } vec4 LinearToGamma( in vec4 value, in float gammaFactor ) { return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a ); } vec4 sRGBToLinear( in vec4 value ) { return 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 ); } vec4 LinearTosRGB( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); } vec4 RGBEToLinear( in vec4 value ) { return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 ); } vec4 LinearToRGBE( in vec4 value ) { float maxComponent = max( max( value.r, value.g ), value.b ); float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 ); return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 ); } vec4 RGBMToLinear( in vec4 value, in float maxRange ) { return vec4( value.rgb * value.a * maxRange, 1.0 ); } vec4 LinearToRGBM( in vec4 value, in float maxRange ) { float maxRGB = max( value.r, max( value.g, value.b ) ); float M = clamp( maxRGB / maxRange, 0.0, 1.0 ); M = ceil( M * 255.0 ) / 255.0; return vec4( value.rgb / ( M * maxRange ), M ); } vec4 RGBDToLinear( in vec4 value, in float maxRange ) { return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 ); } vec4 LinearToRGBD( in vec4 value, in float maxRange ) { float maxRGB = max( value.r, max( value.g, value.b ) ); float D = max( maxRange / maxRGB, 1.0 ); D = clamp( floor( D ) / 255.0, 0.0, 1.0 ); return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D ); } const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 ); vec4 LinearToLogLuv( in vec4 value ) { vec3 Xp_Y_XYZp = cLogLuvM * value.rgb; Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) ); vec4 vResult; vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z; float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0; vResult.w = fract( Le ); vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0; return vResult; } const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 ); vec4 LogLuvToLinear( in vec4 value ) { float Le = value.z * 255.0 + value.w; vec3 Xp_Y_XYZp; Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 ); Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y; Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z; vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb; return vec4( max( vRGB, 0.0 ), 1.0 ); }`,$u=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 ); #else vec4 envColor = vec4( 0.0 ); #endif #ifndef ENVMAP_TYPE_CUBE_UV envColor = envMapTexelToLinear( envColor ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`,ed=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; uniform int maxMipLevel; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,td=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,id=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`,nd=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else vec3 cameraToVertex; if ( isOrthographic ) { cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`,rd=`#ifdef USE_FOG fogDepth = - mvPosition.z; #endif`,od=`#ifdef USE_FOG varying float fogDepth; #endif`,sd=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, fogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`,ad=`#ifdef USE_FOG uniform vec3 fogColor; varying float fogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,ld=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { float dotNL = dot( normal, lightDirection ); vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); #ifdef USE_GRADIENTMAP return texture2D( gradientMap, coord ).rgb; #else return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 ); #endif }`,cd=`#ifdef USE_LIGHTMAP vec4 lightMapTexel= texture2D( lightMap, vUv2 ); reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; #endif`,hd=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,ud=`vec3 diffuse = vec3( 1.0 ); GeometricContext geometry; geometry.position = mvPosition.xyz; geometry.normal = normalize( transformedNormal ); geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz ); GeometricContext backGeometry; backGeometry.position = geometry.position; backGeometry.normal = -geometry.normal; backGeometry.viewDir = geometry.viewDir; vLightFront = vec3( 0.0 ); vIndirectFront = vec3( 0.0 ); #ifdef DOUBLE_SIDED vLightBack = vec3( 0.0 ); vIndirectBack = vec3( 0.0 ); #endif IncidentLight directLight; float dotNL; vec3 directLightColor_Diffuse; vIndirectFront += getAmbientLightIrradiance( ambientLightColor ); vIndirectFront += getLightProbeIrradiance( lightProbe, geometry ); #ifdef DOUBLE_SIDED vIndirectBack += getAmbientLightIrradiance( ambientLightColor ); vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry ); #endif #if NUM_POINT_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = PI * directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = PI * directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #pragma unroll_loop_end #endif #if NUM_DIR_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = PI * directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #pragma unroll_loop_end #endif #if NUM_HEMI_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry ); #ifdef DOUBLE_SIDED vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry ); #endif } #pragma unroll_loop_end #endif`,dd=`uniform bool receiveShadow; uniform vec3 ambientLightColor; uniform vec3 lightProbe[ 9 ]; vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { float x = normal.x, y = normal.y, z = normal.z; vec3 result = shCoefficients[ 0 ] * 0.886227; result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); return result; } vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) { vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif return irradiance; } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) { directLight.color = directionalLight.color; directLight.direction = directionalLight.direction; directLight.visible = true; } #endif #if NUM_POINT_LIGHTS > 0 struct PointLight { vec3 position; vec3 color; float distance; float decay; }; uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) { vec3 lVector = pointLight.position - geometry.position; directLight.direction = normalize( lVector ); float lightDistance = length( lVector ); directLight.color = pointLight.color; directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay ); directLight.visible = ( directLight.color != vec3( 0.0 ) ); } #endif #if NUM_SPOT_LIGHTS > 0 struct SpotLight { vec3 position; vec3 direction; vec3 color; float distance; float decay; float coneCos; float penumbraCos; }; uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) { vec3 lVector = spotLight.position - geometry.position; directLight.direction = normalize( lVector ); float lightDistance = length( lVector ); float angleCos = dot( directLight.direction, spotLight.direction ); if ( angleCos > spotLight.coneCos ) { float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos ); directLight.color = spotLight.color; directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay ); directLight.visible = true; } else { directLight.color = vec3( 0.0 ); directLight.visible = false; } } #endif #if NUM_RECT_AREA_LIGHTS > 0 struct RectAreaLight { vec3 color; vec3 position; vec3 halfWidth; vec3 halfHeight; }; uniform sampler2D ltc_1; uniform sampler2D ltc_2; uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; #endif #if NUM_HEMI_LIGHTS > 0 struct HemisphereLight { vec3 direction; vec3 skyColor; vec3 groundColor; }; uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) { float dotNL = dot( geometry.normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif return irradiance; } #endif`,pd=`#if defined( USE_ENVMAP ) #ifdef ENVMAP_MODE_REFRACTION uniform float refractionRatio; #endif vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) { vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix ); #ifdef ENVMAP_TYPE_CUBE vec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz ); #ifdef TEXTURE_LOD_EXT vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) ); #else vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) ); #endif envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb; #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); #else vec4 envMapColor = vec4( 0.0 ); #endif return PI * envMapColor.rgb * envMapIntensity; } float getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) { float maxMIPLevelScalar = float( maxMIPLevel ); float sigma = PI * roughness * roughness / ( 1.0 + roughness ); float desiredMIPLevel = maxMIPLevelScalar + log2( sigma ); return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar ); } vec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) { #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( -viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); #else vec3 reflectVec = refract( -viewDir, normal, refractionRatio ); #endif reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); float specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel ); #ifdef ENVMAP_TYPE_CUBE vec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz ); #ifdef TEXTURE_LOD_EXT vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel ); #else vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel ); #endif envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb; #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); #endif return envMapColor.rgb * envMapIntensity; } #endif`,fd=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,md=`varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon #define Material_LightProbeLOD( material ) (0)`,gd=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,vd=`varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong #define Material_LightProbeLOD( material ) (0)`,_d=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness; material.specularRoughness = min( material.specularRoughness, 1.0 ); #ifdef REFLECTIVITY material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor ); #endif #ifdef CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_SHEEN material.sheenColor = sheen; #endif`,xd=`struct PhysicalMaterial { vec3 diffuseColor; float specularRoughness; vec3 specularColor; #ifdef CLEARCOAT float clearcoat; float clearcoatRoughness; #endif #ifdef USE_SHEEN vec3 sheenColor; #endif }; #define MAXIMUM_SPECULAR_COEFFICIENT 0.16 #define DEFAULT_SPECULAR_COEFFICIENT 0.04 float clearcoatDHRApprox( const in float roughness, const in float dotNL ) { return DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) ); } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometry.normal; vec3 viewDir = geometry.viewDir; vec3 position = geometry.position; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.specularRoughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif #ifdef CLEARCOAT float ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = ccDotNL * directLight.color; #ifndef PHYSICALLY_CORRECT_LIGHTS ccIrradiance *= PI; #endif float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL ); reflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness ); #else float clearcoatDHR = 0.0; #endif #ifdef USE_SHEEN reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen( material.specularRoughness, directLight.direction, geometry, material.sheenColor ); #else reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness); #endif reflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef CLEARCOAT float ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); reflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness ); float ccDotNL = ccDotNV; float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL ); #else float clearcoatDHR = 0.0; #endif float clearcoatInv = 1.0 - clearcoatDHR; vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering ); vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) ); reflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,yd=` GeometricContext geometry; geometry.position = - vViewPosition; geometry.normal = normal; geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); #ifdef CLEARCOAT geometry.clearcoatNormal = clearcoatNormal; #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointDirectLightIrradiance( pointLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotDirectLightIrradiance( spotLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); irradiance += getLightProbeIrradiance( lightProbe, geometry ); #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,bd=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel= texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; #ifndef PHYSICALLY_CORRECT_LIGHTS lightMapIrradiance *= PI; #endif irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel ); #ifdef CLEARCOAT clearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel ); #endif #endif`,wd=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); #endif`,Md=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,Td=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,Ad=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`,Sd=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #else if ( isPerspectiveMatrix( projectionMatrix ) ) { gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; gl_Position.z *= gl_Position.w; } #endif #endif`,Ed=`#ifdef USE_MAP vec4 texelColor = texture2D( map, vUv ); texelColor = mapTexelToLinear( texelColor ); diffuseColor *= texelColor; #endif`,Ld=`#ifdef USE_MAP uniform sampler2D map; #endif`,Pd=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #ifdef USE_MAP vec4 mapTexel = texture2D( map, uv ); diffuseColor *= mapTexelToLinear( mapTexel ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,Rd=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,Cd=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vUv ); metalnessFactor *= texelMetalness.b; #endif`,Nd=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,Id=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif`,Fd=`#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifndef USE_MORPHNORMALS uniform float morphTargetInfluences[ 8 ]; #else uniform float morphTargetInfluences[ 4 ]; #endif #endif`,Od=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; transformed += morphTarget0 * morphTargetInfluences[ 0 ]; transformed += morphTarget1 * morphTargetInfluences[ 1 ]; transformed += morphTarget2 * morphTargetInfluences[ 2 ]; transformed += morphTarget3 * morphTargetInfluences[ 3 ]; #ifndef USE_MORPHNORMALS transformed += morphTarget4 * morphTargetInfluences[ 4 ]; transformed += morphTarget5 * morphTargetInfluences[ 5 ]; transformed += morphTarget6 * morphTargetInfluences[ 6 ]; transformed += morphTarget7 * morphTargetInfluences[ 7 ]; #endif #endif`,Dd=`#ifdef FLAT_SHADED vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) ); vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 ); #endif #ifdef USE_TANGENT vec3 tangent = normalize( vTangent ); vec3 bitangent = normalize( vBitangent ); #ifdef DOUBLE_SIDED tangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 ); bitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 ); #endif #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) mat3 vTBN = mat3( tangent, bitangent, normal ); #endif #endif #endif vec3 geometryNormal = normal;`,Ud=`#ifdef OBJECTSPACE_NORMALMAP normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 ); #endif normal = normalize( normalMatrix * normal ); #elif defined( TANGENTSPACE_NORMALMAP ) vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; #ifdef USE_TANGENT normal = normalize( vTBN * mapN ); #else normal = perturbNormal2Arb( -vViewPosition, normal, mapN ); #endif #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() ); #endif`,zd=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef OBJECTSPACE_NORMALMAP uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) ) vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) { vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) ); vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) ); vec2 st0 = dFdx( vUv.st ); vec2 st1 = dFdy( vUv.st ); float scale = sign( st1.t * st0.s - st0.t * st1.s ); vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale ); vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale ); vec3 N = normalize( surf_norm ); mat3 tsn = mat3( S, T, N ); mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 ); return normalize( tsn * mapN ); } #endif`,kd=`#ifdef CLEARCOAT vec3 clearcoatNormal = geometryNormal; #endif`,Hd=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; #ifdef USE_TANGENT clearcoatNormal = normalize( vTBN * clearcoatMapN ); #else clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN ); #endif #endif`,Bd=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif`,Gd=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); const float ShiftRight8 = 1. / 256.; vec4 packDepthToRGBA( const in float v ) { vec4 r = vec4( fract( v * PackFactors ), v ); r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors ); } vec4 pack2HalfToRGBA( vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 )); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w); } vec2 unpackRGBATo2Half( vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) { return linearClipZ * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return (( near + viewZ ) * far ) / (( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * invClipZ - far ); }`,Vd=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,Wd=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,jd=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,Xd=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } #endif`,Yd=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vUv ); roughnessFactor *= texelRoughness.g; #endif`,qd=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,Qd=`#ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 ); bool inFrustum = all( inFrustumVec ); bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 ); bool frustumTest = all( frustumTestVec ); if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return shadow; } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); vec3 lightToPosition = shadowCoord.xyz; float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; return ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } #endif`,Zd=`#ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ]; varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,Jd=`#ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 ); vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif`,Kd=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,$d=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,ep=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; #ifdef BONE_TEXTURE uniform highp sampler2D boneTexture; uniform int boneTextureSize; mat4 getBoneMatrix( const in float i ) { float j = i * 4.0; float x = mod( j, float( boneTextureSize ) ); float y = floor( j / float( boneTextureSize ) ); float dx = 1.0 / float( boneTextureSize ); float dy = 1.0 / float( boneTextureSize ); y = dy * ( y + 0.5 ); vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); mat4 bone = mat4( v1, v2, v3, v4 ); return bone; } #else uniform mat4 boneMatrices[ MAX_BONES ]; mat4 getBoneMatrix( const in float i ) { mat4 bone = boneMatrices[ int(i) ]; return bone; } #endif #endif`,tp=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; skinned += boneMatY * skinVertex * skinWeight.y; skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; #endif`,ip=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; skinMatrix += skinWeight.z * boneMatZ; skinMatrix += skinWeight.w * boneMatW; skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif #endif`,np=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,rp=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,op=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,sp=`#ifndef saturate #define saturate(a) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return toneMappingExposure * color; } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } vec3 OptimizedCineonToneMapping( vec3 color ) { color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } vec3 RRTAndODTFit( vec3 v ) { vec3 a = v * ( v + 0.0245786 ) - 0.000090537; vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; return a / b; } vec3 ACESFilmicToneMapping( vec3 color ) { const mat3 ACESInputMat = mat3( vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), vec3( 0.04823, 0.01566, 0.83777 ) ); const mat3 ACESOutputMat = mat3( vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), vec3( -0.07367, -0.00605, 1.07602 ) ); color *= toneMappingExposure / 0.6; color = ACESInputMat * color; color = RRTAndODTFit( color ); color = ACESOutputMat * color; return saturate( color ); } vec3 CustomToneMapping( vec3 color ) { return color; }`,ap=`#ifdef USE_TRANSMISSIONMAP totalTransmission *= texture2D( transmissionMap, vUv ).r; #endif`,lp=`#ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif`,cp=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) varying vec2 vUv; #endif`,hp=`#ifdef USE_UV #ifdef UVS_VERTEX_ONLY vec2 vUv; #else varying vec2 vUv; #endif uniform mat3 uvTransform; #endif`,up=`#ifdef USE_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif`,dp=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) varying vec2 vUv2; #endif`,pp=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) attribute vec2 uv2; varying vec2 vUv2; uniform mat3 uv2Transform; #endif`,fp=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; #endif`,mp=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`,gp=`uniform sampler2D t2D; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); gl_FragColor = mapTexelToLinear( texColor ); #include #include }`,vp=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,_p=`#include uniform float opacity; varying vec3 vWorldDirection; #include void main() { vec3 vReflect = vWorldDirection; #include gl_FragColor = envColor; gl_FragColor.a *= opacity; #include #include }`,xp=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,yp=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include vec4 diffuseColor = vec4( 1.0 ); #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #endif }`,bp=`#include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,wp=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include void main () { #include vec4 diffuseColor = vec4( 1.0 ); #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,Mp=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,Tp=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); vec4 texColor = texture2D( tEquirect, sampleUV ); gl_FragColor = mapTexelToLinear( texColor ); #include #include }`,Ap=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,Sp=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include void main() { #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include outgoingLight = diffuseColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include }`,Ep=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include }`,Lp=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel= texture2D( lightMap, vUv2 ); reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,Pp=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_ENVMAP #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,Rp=`uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; varying vec3 vLightFront; varying vec3 vIndirectFront; #ifdef DOUBLE_SIDED varying vec3 vLightBack; varying vec3 vIndirectBack; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #ifdef DOUBLE_SIDED reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack; #else reflectedLight.indirectDiffuse += vIndirectFront; #endif #include reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ); #ifdef DOUBLE_SIDED reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack; #else reflectedLight.directDiffuse = vLightFront; #endif reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask(); #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,Cp=`#define LAMBERT varying vec3 vLightFront; varying vec3 vIndirectFront; #ifdef DOUBLE_SIDED varying vec3 vLightBack; varying vec3 vIndirectBack; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,Np=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); matcapColor = matcapTexelToLinear( matcapColor ); #else vec4 matcapColor = vec4( 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,Ip=`#define MATCAP varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #endif #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,Fp=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,Op=`#define TOON varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #endif #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,Dp=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,Up=`#define PHONG varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #endif #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,zp=`#define STANDARD #ifdef PHYSICAL #define REFLECTIVITY #define CLEARCOAT #define TRANSMISSION #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef TRANSMISSION uniform float transmission; #endif #ifdef REFLECTIVITY uniform float reflectivity; #endif #ifdef CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_SHEEN uniform vec3 sheen; #endif varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #ifdef TRANSMISSION float totalTransmission = transmission; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #ifdef TRANSMISSION diffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness ); #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,kp=`#define STANDARD varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,Hp=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif #include #include #include #include #include #include void main() { #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); }`,Bp=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) vViewPosition = - mvPosition.xyz; #endif }`,Gp=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include }`,Vp=`uniform float size; uniform float scale; #include #include #include #include #include #include void main() { #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,Wp=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,jp=`#include #include #include void main() { #include #include #include #include #include #include #include #include #include #include }`,Xp=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include }`,Yp=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); vec2 scale; scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); #ifndef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; #endif vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include #include #include }`;const Ie={alphamap_fragment:Eu,alphamap_pars_fragment:Lu,alphatest_fragment:Pu,aomap_fragment:Ru,aomap_pars_fragment:Cu,begin_vertex:Nu,beginnormal_vertex:Iu,bsdfs:Fu,bumpmap_pars_fragment:Ou,clipping_planes_fragment:Du,clipping_planes_pars_fragment:Uu,clipping_planes_pars_vertex:zu,clipping_planes_vertex:ku,color_fragment:Hu,color_pars_fragment:Bu,color_pars_vertex:Gu,color_vertex:Vu,common:Wu,cube_uv_reflection_fragment:ju,defaultnormal_vertex:Xu,displacementmap_pars_vertex:Yu,displacementmap_vertex:qu,emissivemap_fragment:Qu,emissivemap_pars_fragment:Zu,encodings_fragment:Ju,encodings_pars_fragment:Ku,envmap_fragment:$u,envmap_common_pars_fragment:ed,envmap_pars_fragment:td,envmap_pars_vertex:id,envmap_physical_pars_fragment:pd,envmap_vertex:nd,fog_vertex:rd,fog_pars_vertex:od,fog_fragment:sd,fog_pars_fragment:ad,gradientmap_pars_fragment:ld,lightmap_fragment:cd,lightmap_pars_fragment:hd,lights_lambert_vertex:ud,lights_pars_begin:dd,lights_toon_fragment:fd,lights_toon_pars_fragment:md,lights_phong_fragment:gd,lights_phong_pars_fragment:vd,lights_physical_fragment:_d,lights_physical_pars_fragment:xd,lights_fragment_begin:yd,lights_fragment_maps:bd,lights_fragment_end:wd,logdepthbuf_fragment:Md,logdepthbuf_pars_fragment:Td,logdepthbuf_pars_vertex:Ad,logdepthbuf_vertex:Sd,map_fragment:Ed,map_pars_fragment:Ld,map_particle_fragment:Pd,map_particle_pars_fragment:Rd,metalnessmap_fragment:Cd,metalnessmap_pars_fragment:Nd,morphnormal_vertex:Id,morphtarget_pars_vertex:Fd,morphtarget_vertex:Od,normal_fragment_begin:Dd,normal_fragment_maps:Ud,normalmap_pars_fragment:zd,clearcoat_normal_fragment_begin:kd,clearcoat_normal_fragment_maps:Hd,clearcoat_pars_fragment:Bd,packing:Gd,premultiplied_alpha_fragment:Vd,project_vertex:Wd,dithering_fragment:jd,dithering_pars_fragment:Xd,roughnessmap_fragment:Yd,roughnessmap_pars_fragment:qd,shadowmap_pars_fragment:Qd,shadowmap_pars_vertex:Zd,shadowmap_vertex:Jd,shadowmask_pars_fragment:Kd,skinbase_vertex:$d,skinning_pars_vertex:ep,skinning_vertex:tp,skinnormal_vertex:ip,specularmap_fragment:np,specularmap_pars_fragment:rp,tonemapping_fragment:op,tonemapping_pars_fragment:sp,transmissionmap_fragment:ap,transmissionmap_pars_fragment:lp,uv_pars_fragment:cp,uv_pars_vertex:hp,uv_vertex:up,uv2_pars_fragment:dp,uv2_pars_vertex:pp,uv2_vertex:fp,worldpos_vertex:mp,background_frag:gp,background_vert:vp,cube_frag:_p,cube_vert:xp,depth_frag:yp,depth_vert:bp,distanceRGBA_frag:wp,distanceRGBA_vert:Mp,equirect_frag:Tp,equirect_vert:Ap,linedashed_frag:Sp,linedashed_vert:Ep,meshbasic_frag:Lp,meshbasic_vert:Pp,meshlambert_frag:Rp,meshlambert_vert:Cp,meshmatcap_frag:Np,meshmatcap_vert:Ip,meshtoon_frag:Fp,meshtoon_vert:Op,meshphong_frag:Dp,meshphong_vert:Up,meshphysical_frag:zp,meshphysical_vert:kp,normal_frag:Hp,normal_vert:Bp,points_frag:Gp,points_vert:Vp,shadow_frag:Wp,shadow_vert:jp,sprite_frag:Xp,sprite_vert:Yp},me={common:{diffuse:{value:new he(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Ft},uv2Transform:{value:new Ft},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 le(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 he(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new he(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Ft}},sprite:{diffuse:{value:new he(15658734)},opacity:{value:1},center:{value:new le(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Ft}}},$t={basic:{uniforms:pt([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.fog]),vertexShader:Ie.meshbasic_vert,fragmentShader:Ie.meshbasic_frag},lambert:{uniforms:pt([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.fog,me.lights,{emissive:{value:new he(0)}}]),vertexShader:Ie.meshlambert_vert,fragmentShader:Ie.meshlambert_frag},phong:{uniforms:pt([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new he(0)},specular:{value:new he(1118481)},shininess:{value:30}}]),vertexShader:Ie.meshphong_vert,fragmentShader:Ie.meshphong_frag},standard:{uniforms:pt([me.common,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.roughnessmap,me.metalnessmap,me.fog,me.lights,{emissive:{value:new he(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ie.meshphysical_vert,fragmentShader:Ie.meshphysical_frag},toon:{uniforms:pt([me.common,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.gradientmap,me.fog,me.lights,{emissive:{value:new he(0)}}]),vertexShader:Ie.meshtoon_vert,fragmentShader:Ie.meshtoon_frag},matcap:{uniforms:pt([me.common,me.bumpmap,me.normalmap,me.displacementmap,me.fog,{matcap:{value:null}}]),vertexShader:Ie.meshmatcap_vert,fragmentShader:Ie.meshmatcap_frag},points:{uniforms:pt([me.points,me.fog]),vertexShader:Ie.points_vert,fragmentShader:Ie.points_frag},dashed:{uniforms:pt([me.common,me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ie.linedashed_vert,fragmentShader:Ie.linedashed_frag},depth:{uniforms:pt([me.common,me.displacementmap]),vertexShader:Ie.depth_vert,fragmentShader:Ie.depth_frag},normal:{uniforms:pt([me.common,me.bumpmap,me.normalmap,me.displacementmap,{opacity:{value:1}}]),vertexShader:Ie.normal_vert,fragmentShader:Ie.normal_frag},sprite:{uniforms:pt([me.sprite,me.fog]),vertexShader:Ie.sprite_vert,fragmentShader:Ie.sprite_frag},background:{uniforms:{uvTransform:{value:new Ft},t2D:{value:null}},vertexShader:Ie.background_vert,fragmentShader:Ie.background_frag},cube:{uniforms:pt([me.envmap,{opacity:{value:1}}]),vertexShader:Ie.cube_vert,fragmentShader:Ie.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ie.equirect_vert,fragmentShader:Ie.equirect_frag},distanceRGBA:{uniforms:pt([me.common,me.displacementmap,{referencePosition:{value:new A},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ie.distanceRGBA_vert,fragmentShader:Ie.distanceRGBA_frag},shadow:{uniforms:pt([me.lights,me.fog,{color:{value:new he(0)},opacity:{value:1}}]),vertexShader:Ie.shadow_vert,fragmentShader:Ie.shadow_frag}};$t.physical={uniforms:pt([$t.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new le(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new he(0)},transmission:{value:0},transmissionMap:{value:null}}]),vertexShader:Ie.meshphysical_vert,fragmentShader:Ie.meshphysical_frag};function qp(e,t,i,n,r){const o=new he(0);let s=0,a,l,c=null,h=0,u=null;function d(m,v,_,g){let p=v.isScene===!0?v.background:null;p&&p.isTexture&&(p=t.get(p));const E=e.xr,S=E.getSession&&E.getSession();S&&S.environmentBlendMode==="additive"&&(p=null),p===null?f(o,s):p&&p.isColor&&(f(p,1),g=!0),(e.autoClear||g)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),p&&(p.isCubeTexture||p.isWebGLCubeRenderTarget||p.mapping===Vo)?(l===void 0&&(l=new Oe(new gi(1,1,1),new Qe({name:"BackgroundCubeMaterial",uniforms:wn($t.cube.uniforms),vertexShader:$t.cube.vertexShader,fragmentShader:$t.cube.fragmentShader,side:Ze,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(T,x,L){this.matrixWorld.copyPosition(L.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),p.isWebGLCubeRenderTarget&&(p=p.texture),l.material.uniforms.envMap.value=p,l.material.uniforms.flipEnvMap.value=p.isCubeTexture&&p._needsFlipEnvMap?-1:1,(c!==p||h!==p.version||u!==e.toneMapping)&&(l.material.needsUpdate=!0,c=p,h=p.version,u=e.toneMapping),m.unshift(l,l.geometry,l.material,0,0,null)):p&&p.isTexture&&(a===void 0&&(a=new Oe(new Kt(2,2),new Qe({name:"BackgroundMaterial",uniforms:wn($t.background.uniforms),vertexShader:$t.background.vertexShader,fragmentShader:$t.background.fragmentShader,side:Gt,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(a)),a.material.uniforms.t2D.value=p,p.matrixAutoUpdate===!0&&p.updateMatrix(),a.material.uniforms.uvTransform.value.copy(p.matrix),(c!==p||h!==p.version||u!==e.toneMapping)&&(a.material.needsUpdate=!0,c=p,h=p.version,u=e.toneMapping),m.unshift(a,a.geometry,a.material,0,0,null))}function f(m,v){i.buffers.color.setClear(m.r,m.g,m.b,v,r)}return{getClearColor:function(){return o},setClearColor:function(m,v=1){o.set(m),s=v,f(o,s)},getClearAlpha:function(){return s},setClearAlpha:function(m){s=m,f(o,s)},render:d}}function Qp(e,t,i,n){const r=e.getParameter(34921),o=n.isWebGL2?null:t.get("OES_vertex_array_object"),s=n.isWebGL2||o!==null,a={},l=v(null);let c=l;function h(G,D,k,Y,Z){let $=!1;if(s){const ne=m(Y,k,D);c!==ne&&(c=ne,d(c.object)),$=_(Y,Z),$&&g(Y,Z)}else{const ne=D.wireframe===!0;(c.geometry!==Y.id||c.program!==k.id||c.wireframe!==ne)&&(c.geometry=Y.id,c.program=k.id,c.wireframe=ne,$=!0)}G.isInstancedMesh===!0&&($=!0),Z!==null&&i.update(Z,34963),$&&(L(G,D,k,Y),Z!==null&&e.bindBuffer(34963,i.get(Z).buffer))}function u(){return n.isWebGL2?e.createVertexArray():o.createVertexArrayOES()}function d(G){return n.isWebGL2?e.bindVertexArray(G):o.bindVertexArrayOES(G)}function f(G){return n.isWebGL2?e.deleteVertexArray(G):o.deleteVertexArrayOES(G)}function m(G,D,k){const Y=k.wireframe===!0;let Z=a[G.id];Z===void 0&&(Z={},a[G.id]=Z);let $=Z[D.id];$===void 0&&($={},Z[D.id]=$);let ne=$[Y];return ne===void 0&&(ne=v(u()),$[Y]=ne),ne}function v(G){const D=[],k=[],Y=[];for(let Z=0;Z=0){const ce=Z[ae];if(ce!==void 0){const ye=ce.normalized,Ne=ce.itemSize,ie=i.get(ce);if(ie===void 0)continue;const M=ie.buffer,w=ie.type,O=ie.bytesPerElement;if(ce.isInterleavedBufferAttribute){const P=ce.data,F=P.stride,R=ce.offset;P&&P.isInstancedInterleavedBuffer?(S(de,P.meshPerAttribute),Y._maxInstanceCount===void 0&&(Y._maxInstanceCount=P.meshPerAttribute*P.count)):E(de),e.bindBuffer(34962,M),x(de,Ne,w,ye,F*O,R*O)}else ce.isInstancedBufferAttribute?(S(de,ce.meshPerAttribute),Y._maxInstanceCount===void 0&&(Y._maxInstanceCount=ce.meshPerAttribute*ce.count)):E(de),e.bindBuffer(34962,M),x(de,Ne,w,ye,0,0)}else if(ae==="instanceMatrix"){const ye=i.get(G.instanceMatrix);if(ye===void 0)continue;const Ne=ye.buffer,ie=ye.type;S(de+0,1),S(de+1,1),S(de+2,1),S(de+3,1),e.bindBuffer(34962,Ne),e.vertexAttribPointer(de+0,4,ie,!1,64,0),e.vertexAttribPointer(de+1,4,ie,!1,64,16),e.vertexAttribPointer(de+2,4,ie,!1,64,32),e.vertexAttribPointer(de+3,4,ie,!1,64,48)}else if(ae==="instanceColor"){const ye=i.get(G.instanceColor);if(ye===void 0)continue;const Ne=ye.buffer,ie=ye.type;S(de,1),e.bindBuffer(34962,Ne),e.vertexAttribPointer(de,3,ie,!1,12,0)}else if(ne!==void 0){const ye=ne[ae];if(ye!==void 0)switch(ye.length){case 2:e.vertexAttrib2fv(de,ye);break;case 3:e.vertexAttrib3fv(de,ye);break;case 4:e.vertexAttrib4fv(de,ye);break;default:e.vertexAttrib1fv(de,ye)}}}}T()}function W(){H();for(const G in a){const D=a[G];for(const k in D){const Y=D[k];for(const Z in Y)f(Y[Z].object),delete Y[Z];delete D[k]}delete a[G]}}function U(G){if(a[G.id]===void 0)return;const D=a[G.id];for(const k in D){const Y=D[k];for(const Z in Y)f(Y[Z].object),delete Y[Z];delete D[k]}delete a[G.id]}function B(G){for(const D in a){const k=a[D];if(k[G.id]===void 0)continue;const Y=k[G.id];for(const Z in Y)f(Y[Z].object),delete Y[Z];delete k[G.id]}}function H(){j(),c!==l&&(c=l,d(c.object))}function j(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:h,reset:H,resetDefaultState:j,dispose:W,releaseStatesOfGeometry:U,releaseStatesOfProgram:B,initAttributes:p,enableAttribute:E,disableUnusedAttributes:T}}function Zp(e,t,i,n){const r=n.isWebGL2;let o;function s(c){o=c}function a(c,h){e.drawArrays(o,c,h),i.update(h,o,1)}function l(c,h,u){if(u===0)return;let d,f;if(r)d=e,f="drawArraysInstanced";else if(d=t.get("ANGLE_instanced_arrays"),f="drawArraysInstancedANGLE",d===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[f](o,c,h,u),i.update(h,o,u)}this.setMode=s,this.render=a,this.renderInstances=l}function Jp(e,t,i){let n;function r(){if(n!==void 0)return n;const x=t.get("EXT_texture_filter_anisotropic");return x!==null?n=e.getParameter(x.MAX_TEXTURE_MAX_ANISOTROPY_EXT):n=0,n}function o(x){if(x==="highp"){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";x="mediump"}return x==="mediump"&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const s=typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&e instanceof WebGL2ComputeRenderingContext;let a=i.precision!==void 0?i.precision:"highp";const l=o(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const c=i.logarithmicDepthBuffer===!0,h=e.getParameter(34930),u=e.getParameter(35660),d=e.getParameter(3379),f=e.getParameter(34076),m=e.getParameter(34921),v=e.getParameter(36347),_=e.getParameter(36348),g=e.getParameter(36349),p=u>0,E=s||!!t.get("OES_texture_float"),S=p&&E,T=s?e.getParameter(36183):0;return{isWebGL2:s,getMaxAnisotropy:r,getMaxPrecision:o,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:f,maxAttributes:m,maxVertexUniforms:v,maxVaryings:_,maxFragmentUniforms:g,vertexTextures:p,floatFragmentTextures:E,floatVertexTextures:S,maxSamples:T}}function Kp(e){const t=this;let i=null,n=0,r=!1,o=!1;const s=new pi,a=new Ft,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d,f){const m=u.length!==0||d||n!==0||r;return r=d,i=h(u,f,0),n=u.length,m},this.beginShadows=function(){o=!0,h(null)},this.endShadows=function(){o=!1,c()},this.setState=function(u,d,f){const m=u.clippingPlanes,v=u.clipIntersection,_=u.clipShadows,g=e.get(u);if(!r||m===null||m.length===0||o&&!_)o?h(null):c();else{const p=o?0:n,E=p*4;let S=g.clippingState||null;l.value=S,S=h(m,d,E,f);for(let T=0;T!==E;++T)S[T]=i[T];g.clippingState=S,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=p}};function c(){l.value!==i&&(l.value=i,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,m){const v=u!==null?u.length:0;let _=null;if(v!==0){if(_=l.value,m!==!0||_===null){const g=f+v*4,p=d.matrixWorldInverse;a.getNormalMatrix(p),(_===null||_.length0){const c=e.getRenderList(),h=e.getRenderTarget(),u=new Au(l.height/2);return u.fromEquirectangularTexture(e,s),t.set(s,u),e.setRenderTarget(h),e.setRenderList(c),s.addEventListener("dispose",r),i(u.texture,s.mapping)}else return null}}return s}function r(s){const a=s.target;a.removeEventListener("dispose",r);const l=t.get(a);l!==void 0&&(t.delete(a),l.dispose())}function o(){t=new WeakMap}return{get:n,dispose:o}}function ef(e){const t={};function i(n){if(t[n]!==void 0)return t[n];let r;switch(n){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(n)}return t[n]=r,r}return{has:function(n){return i(n)!==null},init:function(n){n.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(n){const r=i(n);return r===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function tf(e,t,i,n){const r={},o=new WeakMap;function s(u){const d=u.target;d.index!==null&&t.remove(d.index);for(const m in d.attributes)t.remove(d.attributes[m]);d.removeEventListener("dispose",s),delete r[d.id];const f=o.get(d);f&&(t.remove(f),o.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,i.memory.geometries--}function a(u,d){return r[d.id]===!0||(d.addEventListener("dispose",s),r[d.id]=!0,i.memory.geometries++),d}function l(u){const d=u.attributes;for(const m in d)t.update(d[m],34962);const f=u.morphAttributes;for(const m in f){const v=f[m];for(let _=0,g=v.length;_65535?dr:ur)(d,1);_.version=v;const g=o.get(u);g&&t.remove(g),o.set(u,_)}function h(u){const d=o.get(u);if(d){const f=u.index;f!==null&&d.version0)return e;const r=t*i;let o=tl[r];if(o===void 0&&(o=new Float32Array(r),tl[r]=o),t!==0){n.toArray(o,0);for(let s=1,a=0;s!==t;++s)a+=i,e[s].toArray(o,a)}return o}function Ot(e,t){if(e.length!==t.length)return!1;for(let i=0,n=e.length;i/gm;function As(e){return e.replace(Jf,Kf)}function Kf(e,t){const i=Ie[t];if(i===void 0)throw new Error("Can not resolve #include <"+t+">");return As(i)}const $f=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,em=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function ml(e){return e.replace(em,gl).replace($f,tm)}function tm(e,t,i,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),gl(e,t,i,n)}function gl(e,t,i,n){let r="";for(let o=parseInt(t);o0?e.gammaFactor:1,f=i.isWebGL2?"":qf(i),m=Qf(o),v=r.createProgram();let _,g,p=i.glslVersion?"#version "+i.glslVersion+` `:"";i.isRawShaderMaterial?(_=[m].filter(gr).join(` `),_.length>0&&(_+=` `),g=[f,m].filter(gr).join(` `),g.length>0&&(g+=` `)):(_=[vl(i),"#define SHADER_NAME "+i.shaderName,m,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+d,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+h:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.useVertexTexture?"#define BONE_TEXTURE":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&i.flatShading===!1?"#define USE_MORPHNORMALS":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#ifdef USE_COLOR"," attribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(gr).join(` `),g=[f,vl(i),"#define SHADER_NAME "+i.shaderName,m,i.alphaTest?"#define ALPHATEST "+i.alphaTest+(i.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+d,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.envMap?"#define "+h:"",i.envMap?"#define "+u:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.sheen?"#define USE_SHEEN":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(i.extensionShaderTextureLOD||i.envMap)&&i.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==tr?"#define TONE_MAPPING":"",i.toneMapping!==tr?Ie.tonemapping_pars_fragment:"",i.toneMapping!==tr?Yf("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",Ie.encodings_pars_fragment,i.map?mr("mapTexelToLinear",i.mapEncoding):"",i.matcap?mr("matcapTexelToLinear",i.matcapEncoding):"",i.envMap?mr("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMap?mr("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.lightMap?mr("lightMapTexelToLinear",i.lightMapEncoding):"",Xf("linearToOutputTexel",i.outputEncoding),i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"",` `].filter(gr).join(` `)),s=As(s),s=pl(s,i),s=fl(s,i),a=As(a),a=pl(a,i),a=fl(a,i),s=ml(s),a=ml(a),i.isWebGL2&&i.isRawShaderMaterial!==!0&&(p=`#version 300 es `,_=["#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+_,g=["#define varying in",i.glslVersion===Ua?"":"out highp vec4 pc_fragColor;",i.glslVersion===Ua?"":"#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(` `)+` `+g);const E=p+_+s,S=p+g+a,T=hl(r,35633,E),x=hl(r,35632,S);if(r.attachShader(v,T),r.attachShader(v,x),i.index0AttributeName!==void 0?r.bindAttribLocation(v,0,i.index0AttributeName):i.morphTargets===!0&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v),e.debug.checkShaderErrors){const U=r.getProgramInfoLog(v).trim(),B=r.getShaderInfoLog(T).trim(),H=r.getShaderInfoLog(x).trim();let j=!0,G=!0;if(r.getProgramParameter(v,35714)===!1){j=!1;const D=dl(r,T,"vertex"),k=dl(r,x,"fragment");console.error("THREE.WebGLProgram: shader error: ",r.getError(),"35715",r.getProgramParameter(v,35715),"gl.getProgramInfoLog",U,D,k)}else U!==""?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",U):(B===""||H==="")&&(G=!1);G&&(this.diagnostics={runnable:j,programLog:U,vertexShader:{log:B,prefix:_},fragmentShader:{log:H,prefix:g}})}r.deleteShader(T),r.deleteShader(x);let L;this.getUniforms=function(){return L===void 0&&(L=new Fi(r,v)),L};let W;return this.getAttributes=function(){return W===void 0&&(W=Zf(r,v)),W},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.name=i.shaderName,this.id=Wf++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=T,this.fragmentShader=x,this}function am(e,t,i,n,r,o){const s=[],a=n.isWebGL2,l=n.logarithmicDepthBuffer,c=n.floatVertexTextures,h=n.maxVertexUniforms,u=n.vertexTextures;let d=n.precision;const f={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"},m=["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","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen","transmissionMap"];function v(x){const L=x.skeleton.bones;if(c)return 1024;{const W=Math.floor((h-20)/4),U=Math.min(W,L.length);return U0,maxBones:k,useVertexTexture:c,morphTargets:x.morphTargets,morphNormals:x.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:L.directional.length,numPointLights:L.point.length,numSpotLights:L.spot.length,numRectAreaLights:L.rectArea.length,numHemiLights:L.hemi.length,numDirLightShadows:L.directionalShadowMap.length,numPointLightShadows:L.pointShadowMap.length,numSpotLightShadows:L.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:x.dithering,shadowMapEnabled:e.shadowMap.enabled&&W.length>0,shadowMapType:e.shadowMap.type,toneMapping:x.toneMapped?e.toneMapping:tr,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:x.premultipliedAlpha,alphaTest:x.alphaTest,doubleSided:x.side===on,flipSided:x.side===Ze,depthPacking:x.depthPacking!==void 0?x.depthPacking:!1,index0AttributeName:x.index0AttributeName,extensionDerivatives:x.extensions&&x.extensions.derivatives,extensionFragDepth:x.extensions&&x.extensions.fragDepth,extensionDrawBuffers:x.extensions&&x.extensions.drawBuffers,extensionShaderTextureLOD:x.extensions&&x.extensions.shaderTextureLOD,rendererExtensionFragDepth:a||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:a||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:a||i.has("EXT_shader_texture_lod"),customProgramCacheKey:x.customProgramCacheKey()}}function p(x){const L=[];if(x.shaderID?L.push(x.shaderID):(L.push(x.fragmentShader),L.push(x.vertexShader)),x.defines!==void 0)for(const W in x.defines)L.push(W),L.push(x.defines[W]);if(x.isRawShaderMaterial===!1){for(let W=0;W1&&n.sort(d||cm),r.length>1&&r.sort(f||hm)}function u(){for(let d=i,f=t.length;d0&&(t.isWebGL2||e.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=me.LTC_FLOAT_1,r.rectAreaLTC2=me.LTC_FLOAT_2):e.has("OES_texture_half_float_linear")===!0?(r.rectAreaLTC1=me.LTC_HALF_1,r.rectAreaLTC2=me.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=u,r.ambient[1]=d,r.ambient[2]=f;const x=r.hash;(x.directionalLength!==m||x.pointLength!==v||x.spotLength!==_||x.rectAreaLength!==g||x.hemiLength!==p||x.numDirectionalShadows!==E||x.numPointShadows!==S||x.numSpotShadows!==T)&&(r.directional.length=m,r.spot.length=_,r.rectArea.length=g,r.point.length=v,r.hemi.length=p,r.directionalShadow.length=E,r.directionalShadowMap.length=E,r.pointShadow.length=S,r.pointShadowMap.length=S,r.spotShadow.length=T,r.spotShadowMap.length=T,r.directionalShadowMatrix.length=E,r.pointShadowMatrix.length=S,r.spotShadowMatrix.length=T,x.directionalLength=m,x.pointLength=v,x.spotLength=_,x.rectAreaLength=g,x.hemiLength=p,x.numDirectionalShadows=E,x.numPointShadows=S,x.numSpotShadows=T,r.version=fm++)}function c(h,u){let d=0,f=0,m=0,v=0,_=0;const g=u.matrixWorldInverse;for(let p=0,E=h.length;p=i.get(o).length?(a=new xl(e,t),i.get(o).push(a)):a=i.get(o)[s],a}function r(){i=new WeakMap}return{get:n,dispose:r}}function Qi(e){Me.call(this),this.type="MeshDepthMaterial",this.depthPacking=ru,this.skinning=!1,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)}Qi.prototype=Object.create(Me.prototype),Qi.prototype.constructor=Qi,Qi.prototype.isMeshDepthMaterial=!0,Qi.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,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};function Zi(e){Me.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new A,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}Zi.prototype=Object.create(Me.prototype),Zi.prototype.constructor=Zi,Zi.prototype.isMeshDistanceMaterial=!0,Zi.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.skinning=e.skinning,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};var _m=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { float mean = 0.0; float squared_mean = 0.0; float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) ); for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) { #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean * HALF_SAMPLE_RATE; squared_mean = squared_mean * HALF_SAMPLE_RATE; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`,xm=`void main() { gl_Position = vec4( position, 1.0 ); }`;function yl(e,t,i){let n=new lo;const r=new le,o=new le,s=new ke,a=[],l=[],c={},h={0:Ze,1:Gt,2:on},u=new Qe({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new le},radius:{value:4}},vertexShader:xm,fragmentShader:_m}),d=u.clone();d.defines.HORIZONTAL_PASS=1;const f=new De;f.setAttribute("position",new Le(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Oe(f,u),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ua,this.render=function(T,x,L){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||T.length===0)return;const W=e.getRenderTarget(),U=e.getActiveCubeFace(),B=e.getActiveMipmapLevel(),H=e.state;H.setBlending(er),H.buffers.color.setClear(1,1,1,1),H.buffers.depth.setTest(!0),H.setScissorTest(!1);for(let j=0,G=T.length;ji||r.y>i)&&(r.x>i&&(o.x=Math.floor(i/Y.x),r.x=o.x*Y.x,k.mapSize.x=o.x),r.y>i&&(o.y=Math.floor(i/Y.y),r.y=o.y*Y.y,k.mapSize.y=o.y)),k.map===null&&!k.isPointLightShadow&&this.type===$n){const $={minFilter:qe,magFilter:qe,format:wt};k.map=new ji(r.x,r.y,$),k.map.texture.name=D.name+".shadowMap",k.mapPass=new ji(r.x,r.y,$),k.camera.updateProjectionMatrix()}if(k.map===null){const $={minFilter:rt,magFilter:rt,format:wt};k.map=new ji(r.x,r.y,$),k.map.texture.name=D.name+".shadowMap",k.camera.updateProjectionMatrix()}e.setRenderTarget(k.map),e.clear();const Z=k.getViewportCount();for(let $=0;$0);let Y=!1;T.isSkinnedMesh===!0&&(L.skinning===!0?Y=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",T));const Z=T.isInstancedMesh===!0;j=G(k,Y,Z)}else j=D;if(e.localClippingEnabled&&L.clipShadows===!0&&L.clippingPlanes.length!==0){const k=j.uuid,Y=L.uuid;let Z=c[k];Z===void 0&&(Z={},c[k]=Z);let $=Z[Y];$===void 0&&($=j.clone(),Z[Y]=$),j=$}return j.visible=L.visible,j.wireframe=L.wireframe,H===$n?j.side=L.shadowSide!==null?L.shadowSide:L.side:j.side=L.shadowSide!==null?L.shadowSide:h[L.side],j.clipShadows=L.clipShadows,j.clippingPlanes=L.clippingPlanes,j.clipIntersection=L.clipIntersection,j.wireframeLinewidth=L.wireframeLinewidth,j.linewidth=L.linewidth,W.isPointLight===!0&&j.isMeshDistanceMaterial===!0&&(j.referencePosition.setFromMatrixPosition(W.matrixWorld),j.nearDistance=U,j.farDistance=B),j}function S(T,x,L,W,U){if(T.visible===!1)return;if(T.layers.test(x.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&U===$n)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(L.matrixWorldInverse,T.matrixWorld);const H=t.update(T),j=T.material;if(Array.isArray(j)){const G=H.groups;for(let D=0,k=G.length;D=1):G.indexOf("OpenGL ES")!==-1&&(j=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),H=j>=2);let D=null,k={};const Y=new ke,Z=new ke;function $(z,te,re){const ue=new Uint8Array(4),se=e.createTexture();e.bindTexture(z,se),e.texParameteri(z,10241,9728),e.texParameteri(z,10240,9728);for(let ge=0;geq||b.height>q)&&(z=q/Math.max(b.width,b.height)),z<1||y===!0)if(typeof HTMLImageElement<"u"&&b instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&b instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&b instanceof ImageBitmap){const te=y?Se.floorPowerOfTwo:Math.floor,re=te(z*b.width),ue=te(z*b.height);f===void 0&&(f=v(re,ue));const se=J?v(re,ue):f;return se.width=re,se.height=ue,se.getContext("2d").drawImage(b,0,0,re,ue),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+b.width+"x"+b.height+") to ("+re+"x"+ue+")."),se}else return"data"in b&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+b.width+"x"+b.height+")."),b;return b}function g(b){return Se.isPowerOfTwo(b.width)&&Se.isPowerOfTwo(b.height)}function p(b){return a?!1:b.wrapS!==ut||b.wrapT!==ut||b.minFilter!==rt&&b.minFilter!==qe}function E(b,y){return b.generateMipmaps&&y&&b.minFilter!==rt&&b.minFilter!==qe}function S(b,y,J,q){e.generateMipmap(b);const z=n.get(y);z.__maxMipLevel=Math.log(Math.max(J,q))*Math.LOG2E}function T(b,y,J){if(a===!1)return y;if(b!==null){if(e[b]!==void 0)return e[b];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+b+"'")}let q=y;return y===6403&&(J===5126&&(q=33326),J===5131&&(q=33325),J===5121&&(q=33321)),y===6407&&(J===5126&&(q=34837),J===5131&&(q=34843),J===5121&&(q=32849)),y===6408&&(J===5126&&(q=34836),J===5131&&(q=34842),J===5121&&(q=32856)),(q===33325||q===33326||q===34842||q===34836)&&t.get("EXT_color_buffer_float"),q}function x(b){return b===rt||b===jo||b===Xo?9728:9729}function L(b){const y=b.target;y.removeEventListener("dispose",L),U(y),y.isVideoTexture&&d.delete(y),s.memory.textures--}function W(b){const y=b.target;y.removeEventListener("dispose",W),B(y),s.memory.textures--}function U(b){const y=n.get(b);y.__webglInit!==void 0&&(e.deleteTexture(y.__webglTexture),n.remove(b))}function B(b){const y=n.get(b),J=n.get(b.texture);if(b){if(J.__webglTexture!==void 0&&e.deleteTexture(J.__webglTexture),b.depthTexture&&b.depthTexture.dispose(),b.isWebGLCubeRenderTarget)for(let q=0;q<6;q++)e.deleteFramebuffer(y.__webglFramebuffer[q]),y.__webglDepthbuffer&&e.deleteRenderbuffer(y.__webglDepthbuffer[q]);else e.deleteFramebuffer(y.__webglFramebuffer),y.__webglDepthbuffer&&e.deleteRenderbuffer(y.__webglDepthbuffer),y.__webglMultisampledFramebuffer&&e.deleteFramebuffer(y.__webglMultisampledFramebuffer),y.__webglColorRenderbuffer&&e.deleteRenderbuffer(y.__webglColorRenderbuffer),y.__webglDepthRenderbuffer&&e.deleteRenderbuffer(y.__webglDepthRenderbuffer);n.remove(b.texture),n.remove(b)}}let H=0;function j(){H=0}function G(){const b=H;return b>=l&&console.warn("THREE.WebGLTextures: Trying to use "+b+" texture units while this GPU supports only "+l),H+=1,b}function D(b,y){const J=n.get(b);if(b.isVideoTexture&&N(b),b.version>0&&J.__version!==b.version){const q=b.image;if(q===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(q.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ce(J,b,y);return}}i.activeTexture(33984+y),i.bindTexture(3553,J.__webglTexture)}function k(b,y){const J=n.get(b);if(b.version>0&&J.__version!==b.version){ce(J,b,y);return}i.activeTexture(33984+y),i.bindTexture(35866,J.__webglTexture)}function Y(b,y){const J=n.get(b);if(b.version>0&&J.__version!==b.version){ce(J,b,y);return}i.activeTexture(33984+y),i.bindTexture(32879,J.__webglTexture)}function Z(b,y){const J=n.get(b);if(b.version>0&&J.__version!==b.version){ye(J,b,y);return}i.activeTexture(33984+y),i.bindTexture(34067,J.__webglTexture)}const $={[Mi]:10497,[ut]:33071,[Dr]:33648},ne={[rt]:9728,[jo]:9984,[Xo]:9986,[qe]:9729,[Ma]:9985,[an]:9987};function ae(b,y,J){J?(e.texParameteri(b,10242,$[y.wrapS]),e.texParameteri(b,10243,$[y.wrapT]),(b===32879||b===35866)&&e.texParameteri(b,32882,$[y.wrapR]),e.texParameteri(b,10240,ne[y.magFilter]),e.texParameteri(b,10241,ne[y.minFilter])):(e.texParameteri(b,10242,33071),e.texParameteri(b,10243,33071),(b===32879||b===35866)&&e.texParameteri(b,32882,33071),(y.wrapS!==ut||y.wrapT!==ut)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(b,10240,x(y.magFilter)),e.texParameteri(b,10241,x(y.minFilter)),y.minFilter!==rt&&y.minFilter!==qe&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));const q=t.get("EXT_texture_filter_anisotropic");if(q){if(y.type===li&&t.get("OES_texture_float_linear")===null||y.type===kr&&(a||t.get("OES_texture_half_float_linear"))===null)return;(y.anisotropy>1||n.get(y).__currentAnisotropy)&&(e.texParameterf(b,q.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,r.getMaxAnisotropy())),n.get(y).__currentAnisotropy=y.anisotropy)}}function de(b,y){b.__webglInit===void 0&&(b.__webglInit=!0,y.addEventListener("dispose",L),b.__webglTexture=e.createTexture(),s.memory.textures++)}function ce(b,y,J){let q=3553;y.isDataTexture2DArray&&(q=35866),y.isDataTexture3D&&(q=32879),de(b,y),i.activeTexture(33984+J),i.bindTexture(q,b.__webglTexture),e.pixelStorei(37440,y.flipY),e.pixelStorei(37441,y.premultiplyAlpha),e.pixelStorei(3317,y.unpackAlignment);const z=p(y)&&g(y.image)===!1,te=_(y.image,z,!1,h),re=g(te)||a,ue=o.convert(y.format);let se=o.convert(y.type),ge=T(y.internalFormat,ue,se);ae(q,y,re);let ve;const be=y.mipmaps;if(y.isDepthTexture)ge=6402,a?y.type===li?ge=36012:y.type===ir?ge=33190:y.type===nr?ge=35056:ge=33189:y.type===li&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),y.format===Gi&&ge===6402&&y.type!==zr&&y.type!==ir&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),y.type=zr,se=o.convert(y.type)),y.format===rr&&ge===6402&&(ge=34041,y.type!==nr&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),y.type=nr,se=o.convert(y.type))),i.texImage2D(3553,0,ge,te.width,te.height,0,ue,se,null);else if(y.isDataTexture)if(be.length>0&&re){for(let pe=0,_e=be.length;pe<_e;pe++)ve=be[pe],i.texImage2D(3553,pe,ge,ve.width,ve.height,0,ue,se,ve.data);y.generateMipmaps=!1,b.__maxMipLevel=be.length-1}else i.texImage2D(3553,0,ge,te.width,te.height,0,ue,se,te.data),b.__maxMipLevel=0;else if(y.isCompressedTexture){for(let pe=0,_e=be.length;pe<_e;pe++)ve=be[pe],y.format!==wt&&y.format!==Ti?ue!==null?i.compressedTexImage2D(3553,pe,ge,ve.width,ve.height,0,ve.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(3553,pe,ge,ve.width,ve.height,0,ue,se,ve.data);b.__maxMipLevel=be.length-1}else if(y.isDataTexture2DArray)i.texImage3D(35866,0,ge,te.width,te.height,te.depth,0,ue,se,te.data),b.__maxMipLevel=0;else if(y.isDataTexture3D)i.texImage3D(32879,0,ge,te.width,te.height,te.depth,0,ue,se,te.data),b.__maxMipLevel=0;else if(be.length>0&&re){for(let pe=0,_e=be.length;pe<_e;pe++)ve=be[pe],i.texImage2D(3553,pe,ge,ue,se,ve);y.generateMipmaps=!1,b.__maxMipLevel=be.length-1}else i.texImage2D(3553,0,ge,ue,se,te),b.__maxMipLevel=0;E(y,re)&&S(q,y,te.width,te.height),b.__version=y.version,y.onUpdate&&y.onUpdate(y)}function ye(b,y,J){if(y.image.length!==6)return;de(b,y),i.activeTexture(33984+J),i.bindTexture(34067,b.__webglTexture),e.pixelStorei(37440,y.flipY),e.pixelStorei(37441,y.premultiplyAlpha),e.pixelStorei(3317,y.unpackAlignment);const q=y&&(y.isCompressedTexture||y.image[0].isCompressedTexture),z=y.image[0]&&y.image[0].isDataTexture,te=[];for(let pe=0;pe<6;pe++)!q&&!z?te[pe]=_(y.image[pe],!1,!0,c):te[pe]=z?y.image[pe].image:y.image[pe];const re=te[0],ue=g(re)||a,se=o.convert(y.format),ge=o.convert(y.type),ve=T(y.internalFormat,se,ge);ae(34067,y,ue);let be;if(q){for(let pe=0;pe<6;pe++){be=te[pe].mipmaps;for(let _e=0;_ed+f?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&u<=d-f&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else s!==null&&(n=t.getPose(e.targetRaySpace,i),n!==null&&(s.matrix.fromArray(n.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale))),a!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale)));return s!==null&&(s.visible=n!==null),a!==null&&(a.visible=r!==null),l!==null&&(l.visible=o!==null),this}});function bl(e,t){const i=this;let n=null,r=1,o=null,s="local-floor",a=null;const l=[],c=new Map,h=new $e;h.layers.enable(1),h.viewport=new ke;const u=new $e;u.layers.enable(2),u.viewport=new ke;const d=[h,u],f=new Ss;f.layers.enable(1),f.layers.enable(2);let m=null,v=null;this.enabled=!1,this.isPresenting=!1,this.getController=function(B){let H=l[B];return H===void 0&&(H=new vr,l[B]=H),H.getTargetRaySpace()},this.getControllerGrip=function(B){let H=l[B];return H===void 0&&(H=new vr,l[B]=H),H.getGripSpace()},this.getHand=function(B){let H=l[B];return H===void 0&&(H=new vr,l[B]=H),H.getHandSpace()};function _(B){const H=c.get(B.inputSource);H&&H.dispatchEvent({type:B.type,data:B.inputSource})}function g(){c.forEach(function(B,H){B.disconnect(H)}),c.clear(),m=null,v=null,e.setFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),U.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(B){r=B,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(B){s=B,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return o},this.getSession=function(){return n},this.setSession=async function(B){if(n=B,n!==null){n.addEventListener("select",_),n.addEventListener("selectstart",_),n.addEventListener("selectend",_),n.addEventListener("squeeze",_),n.addEventListener("squeezestart",_),n.addEventListener("squeezeend",_),n.addEventListener("end",g),n.addEventListener("inputsourceschange",p);const H=t.getContextAttributes();H.xrCompatible!==!0&&await t.makeXRCompatible();const j={antialias:H.antialias,alpha:H.alpha,depth:H.depth,stencil:H.stencil,framebufferScaleFactor:r},G=new XRWebGLLayer(n,t,j);n.updateRenderState({baseLayer:G}),o=await n.requestReferenceSpace(s),U.setContext(n),U.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function p(B){const H=n.inputSources;for(let j=0;j0&&yt(Ae,C,ee),Ce.length>0&&yt(Ce,C,ee),C.isScene===!0&&C.onAfterRender(m,C,ee),E!==null&&(N.updateRenderTargetMipmap(E),N.updateMultisampleRenderTarget(E)),P.buffers.depth.setTest(!0),P.buffers.depth.setMask(!0),P.buffers.color.setMask(!0),P.setPolygonOffset(!1),f.pop(),f.length>0?d=f[f.length-1]:d=null,u=null};function st(C,ee,K,oe){if(C.visible===!1)return;if(C.layers.test(ee.layers)){if(C.isGroup)K=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(ee);else if(C.isLight)d.pushLight(C),C.castShadow&&d.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||$.intersectsSprite(C)){oe&&ce.setFromMatrixPosition(C.matrixWorld).applyMatrix4(de);const Ae=Q.update(C),Ce=C.material;Ce.visible&&u.push(C,Ae,Ce,K,ce.z,null)}}else if(C.isImmediateRenderObject)oe&&ce.setFromMatrixPosition(C.matrixWorld).applyMatrix4(de),u.push(C,null,C.material,K,ce.z,null);else if((C.isMesh||C.isLine||C.isPoints)&&(C.isSkinnedMesh&&C.skeleton.frame!==F.render.frame&&(C.skeleton.update(),C.skeleton.frame=F.render.frame),!C.frustumCulled||$.intersectsObject(C))){oe&&ce.setFromMatrixPosition(C.matrixWorld).applyMatrix4(de);const Ae=Q.update(C),Ce=C.material;if(Array.isArray(Ce)){const ze=Ae.groups;for(let Pe=0,it=ze.length;Pe=0&&ee<=C.width-oe&&K>=0&&K<=C.height-fe&&ie.readPixels(ee,K,oe,fe,ge.convert(Ye),ge.convert(Ee),Ae):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{Pe&&ie.bindFramebuffer(36160,S)}}},this.copyFramebufferToTexture=function(C,ee,K=0){const oe=Math.pow(2,-K),fe=Math.floor(ee.image.width*oe),Ae=Math.floor(ee.image.height*oe),Ce=ge.convert(ee.format);N.setTexture2D(ee,0),ie.copyTexImage2D(3553,K,Ce,C.x,C.y,fe,Ae,0),P.unbindTexture()},this.copyTextureToTexture=function(C,ee,K,oe=0){const fe=ee.image.width,Ae=ee.image.height,Ce=ge.convert(K.format),ze=ge.convert(K.type);N.setTexture2D(K,0),ie.pixelStorei(37440,K.flipY),ie.pixelStorei(37441,K.premultiplyAlpha),ie.pixelStorei(3317,K.unpackAlignment),ee.isDataTexture?ie.texSubImage2D(3553,oe,C.x,C.y,fe,Ae,Ce,ze,ee.image.data):ee.isCompressedTexture?ie.compressedTexSubImage2D(3553,oe,C.x,C.y,ee.mipmaps[0].width,ee.mipmaps[0].height,Ce,ee.mipmaps[0].data):ie.texSubImage2D(3553,oe,C.x,C.y,Ce,ze,ee.image),oe===0&&K.generateMipmaps&&ie.generateMipmap(3553),P.unbindTexture()},this.initTexture=function(C){N.setTexture2D(C,0),P.unbindTexture()},this.resetState=function(){P.reset(),ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function wl(e){_r.call(this,e)}wl.prototype=Object.assign(Object.create(_r.prototype),{constructor:wl,isWebGL1Renderer:!0});class Es extends we{constructor(){super(),Object.defineProperty(this,"isScene",{value:!0}),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,i){return super.copy(t,i),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const i=super.toJSON(t);return this.background!==null&&(i.object.background=this.background.toJSON(t)),this.environment!==null&&(i.object.environment=this.environment.toJSON(t)),this.fog!==null&&(i.object.fog=this.fog.toJSON()),i}}function Pt(e,t){this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Br,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Se.generateUUID()}Object.defineProperty(Pt.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(Pt.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this},copyAt:function(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,r=this.stride;ne.far||t.push({distance:a,point:xr.clone(),uv:xt.getUV(xr,co,br,ho,Tl,Ls,Al,new le),face:null,object:this})},copy:function(e){return we.prototype.copy.call(this,e),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}});function uo(e,t,i,n,r,o){In.subVectors(e,i).addScalar(.5).multiply(n),r!==void 0?(yr.x=o*In.x-r*In.y,yr.y=r*In.x+o*In.y):yr.copy(In),e.copy(t),e.x+=yr.x,e.y+=yr.y,e.applyMatrix4(Ml)}const po=new A,El=new A;function Ps(){we.call(this),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}Ps.prototype=Object.assign(Object.create(we.prototype),{constructor:Ps,isLOD:!0,copy:function(e){we.prototype.copy.call(this,e,!1);const t=e.levels;for(let i=0,n=t.length;i0){let i,n;for(i=1,n=t.length;i0){po.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(po);this.getObjectForDistance(i).raycast(e,t)}},update:function(e){const t=this.levels;if(t.length>1){po.setFromMatrixPosition(e.matrixWorld),El.setFromMatrixPosition(this.matrixWorld);const i=po.distanceTo(El)/e.zoom;t[0].object.visible=!0;let n,r;for(n=1,r=t.length;n=t[n].distance;n++)t[n-1].object.visible=!1,t[n].object.visible=!0;for(this._currentLevel=n-1;ns)continue;h.applyMatrix4(this.matrixWorld);const E=e.ray.origin.distanceTo(h);Ee.far||t.push({distance:E,point:c.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else for(let m=0,v=f.count-1;ms)continue;h.applyMatrix4(this.matrixWorld);const _=e.ray.origin.distanceTo(h);_e.far||t.push({distance:_,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}else i.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},updateMorphTargets:function(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});const kl=new A,Hl=new A;function Mr(e,t){$i.call(this,e,t),this.type="LineSegments"}Mr.prototype=Object.assign(Object.create($i.prototype),{constructor:Mr,isLineSegments:!0,computeLineDistances:function(){const e=this.geometry;if(e.isBufferGeometry)if(e.index===null){const t=e.attributes.position,i=[];for(let n=0,r=t.count;n0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});function Gl(e,t,i,n,r,o,s){const a=Ns.distanceSqToPoint(e);if(ar.far)return;o.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:t,face:null,object:s})}}function Vl(e,t,i,n,r,o,s,a,l){He.call(this,e,t,i,n,r,o,s,a,l),this.format=s!==void 0?s:Ti,this.minFilter=o!==void 0?o:qe,this.magFilter=r!==void 0?r:qe,this.generateMipmaps=!1;const c=this;function h(){c.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}Vl.prototype=Object.assign(Object.create(He.prototype),{constructor:Vl,clone:function(){return new this.constructor(this.image).copy(this)},isVideoTexture:!0,update:function(){const e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});function Tr(e,t,i,n,r,o,s,a,l,c,h,u){He.call(this,null,o,s,a,l,c,n,r,h,u),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}Tr.prototype=Object.create(He.prototype),Tr.prototype.constructor=Tr,Tr.prototype.isCompressedTexture=!0;function Ar(e,t,i,n,r,o,s,a,l){He.call(this,e,t,i,n,r,o,s,a,l),this.needsUpdate=!0}Ar.prototype=Object.create(He.prototype),Ar.prototype.constructor=Ar,Ar.prototype.isCanvasTexture=!0;function Sr(e,t,i,n,r,o,s,a,l,c){if(c=c!==void 0?c:Gi,c!==Gi&&c!==rr)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&c===Gi&&(i=zr),i===void 0&&c===rr&&(i=nr),He.call(this,null,n,r,o,s,a,c,i,l),this.image={width:e,height:t},this.magFilter=s!==void 0?s:rt,this.minFilter=a!==void 0?a:rt,this.flipY=!1,this.generateMipmaps=!1}Sr.prototype=Object.create(He.prototype),Sr.prototype.constructor=Sr,Sr.prototype.isDepthTexture=!0,new A,new A,new A,new xt;const Em={triangulate:function(e,t,i){i=i||2;const n=t&&t.length,r=n?t[0]*i:e.length;let o=Wl(e,0,r,i,!0);const s=[];if(!o||o.next===o.prev)return s;let a,l,c,h,u,d,f;if(n&&(o=Nm(e,t,o,i)),e.length>80*i){a=c=e[0],l=h=e[1];for(let m=i;mc&&(c=u),d>h&&(h=d);f=Math.max(c-a,h-l),f=f!==0?1/f:0}return Er(o,s,i,a,l,f),s}};function Wl(e,t,i,n,r){let o,s;if(r===Vm(e,t,i,n)>0)for(o=t;o=t;o-=n)s=Yl(o,e[o],e[o+1],s);return s&&bo(s,s.next)&&(Pr(s),s=s.next),s}function Ui(e,t){if(!e)return e;t||(t=e);let i=e,n;do if(n=!1,!i.steiner&&(bo(i,i.next)||Xe(i.prev,i,i.next)===0)){if(Pr(i),i=t=i.prev,i===i.next)break;n=!0}else i=i.next;while(n||i!==t);return t}function Er(e,t,i,n,r,o,s){if(!e)return;!s&&o&&Um(e,n,r,o);let a=e,l,c;for(;e.prev!==e.next;){if(l=e.prev,c=e.next,o?Pm(e,n,r,o):Lm(e)){t.push(l.i/i),t.push(e.i/i),t.push(c.i/i),Pr(e),e=c.next,a=c.next;continue}if(e=c,e===a){s?s===1?(e=Rm(Ui(e),t,i),Er(e,t,i,n,r,o,2)):s===2&&Cm(e,t,i,n,r,o):Er(Ui(e),t,i,n,r,o,1);break}}}function Lm(e){const t=e.prev,i=e,n=e.next;if(Xe(t,i,n)>=0)return!1;let r=e.next.next;for(;r!==e.prev;){if(Fn(t.x,t.y,i.x,i.y,n.x,n.y,r.x,r.y)&&Xe(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Pm(e,t,i,n){const r=e.prev,o=e,s=e.next;if(Xe(r,o,s)>=0)return!1;const a=r.xo.x?r.x>s.x?r.x:s.x:o.x>s.x?o.x:s.x,h=r.y>o.y?r.y>s.y?r.y:s.y:o.y>s.y?o.y:s.y,u=Fs(a,l,t,i,n),d=Fs(c,h,t,i,n);let f=e.prevZ,m=e.nextZ;for(;f&&f.z>=u&&m&&m.z<=d;){if(f!==e.prev&&f!==e.next&&Fn(r.x,r.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Xe(f.prev,f,f.next)>=0||(f=f.prevZ,m!==e.prev&&m!==e.next&&Fn(r.x,r.y,o.x,o.y,s.x,s.y,m.x,m.y)&&Xe(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;f&&f.z>=u;){if(f!==e.prev&&f!==e.next&&Fn(r.x,r.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Xe(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;m&&m.z<=d;){if(m!==e.prev&&m!==e.next&&Fn(r.x,r.y,o.x,o.y,s.x,s.y,m.x,m.y)&&Xe(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function Rm(e,t,i){let n=e;do{const r=n.prev,o=n.next.next;!bo(r,o)&&jl(r,n,n.next,o)&&Lr(r,o)&&Lr(o,r)&&(t.push(r.i/i),t.push(n.i/i),t.push(o.i/i),Pr(n),Pr(n.next),n=e=o),n=n.next}while(n!==e);return Ui(n)}function Cm(e,t,i,n,r,o){let s=e;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&Hm(s,a)){let l=Xl(s,a);s=Ui(s,s.next),l=Ui(l,l.next),Er(s,t,i,n,r,o),Er(l,t,i,n,r,o);return}a=a.next}s=s.next}while(s!==e)}function Nm(e,t,i,n){const r=[];let o,s,a,l,c;for(o=0,s=t.length;o=i.next.y&&i.next.y!==i.y){const d=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(d<=n&&d>o){if(o=d,d===n){if(r===i.y)return i;if(r===i.next.y)return i.next}s=i.x=i.x&&i.x>=l&&n!==i.x&&Fn(rs.x||i.x===s.x&&Dm(s,i)))&&(s=i,h=u)),i=i.next;while(i!==a);return s}function Dm(e,t){return Xe(e.prev,e,t.prev)<0&&Xe(t.next,e,e.next)<0}function Um(e,t,i,n){let r=e;do r.z===null&&(r.z=Fs(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,zm(r)}function zm(e){let t,i,n,r,o,s,a,l,c=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,n=i,a=0,t=0;t0||l>0&&n;)a!==0&&(l===0||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;i=n}o.nextZ=null,c*=2}while(s>1);return e}function Fs(e,t,i,n,r){return e=32767*(e-i)*r,t=32767*(t-n)*r,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function km(e){let t=e,i=e;do(t.x=0&&(e-s)*(n-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(r-s)*(n-a)>=0}function Hm(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Bm(e,t)&&(Lr(e,t)&&Lr(t,e)&&Gm(e,t)&&(Xe(e.prev,e,t.prev)||Xe(e,t.prev,t))||bo(e,t)&&Xe(e.prev,e,e.next)>0&&Xe(t.prev,t,t.next)>0)}function Xe(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function bo(e,t){return e.x===t.x&&e.y===t.y}function jl(e,t,i,n){const r=Mo(Xe(e,t,i)),o=Mo(Xe(e,t,n)),s=Mo(Xe(i,n,e)),a=Mo(Xe(i,n,t));return!!(r!==o&&s!==a||r===0&&wo(e,i,t)||o===0&&wo(e,n,t)||s===0&&wo(i,e,n)||a===0&&wo(i,t,n))}function wo(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Mo(e){return e>0?1:e<0?-1:0}function Bm(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&jl(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Lr(e,t){return Xe(e.prev,e,e.next)<0?Xe(e,t,e.next)>=0&&Xe(e,e.prev,t)>=0:Xe(e,t,e.prev)<0||Xe(e,e.next,t)<0}function Gm(e,t){let i=e,n=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next;while(i!==e);return n}function Xl(e,t){const i=new Os(e.i,e.x,e.y),n=new Os(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function Yl(e,t,i,n){const r=new Os(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Pr(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 Os(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Vm(e,t,i,n){let r=0;for(let o=t,s=i-n;o2&&e[t-1].equals(e[0])&&e.pop()}function Ql(e,t){for(let i=0;iNumber.EPSILON){const re=Math.sqrt(z),ue=Math.sqrt(J*J+q*q),se=N.x-y/re,ge=N.y+b/re,ve=I.x-q/ue,be=I.y+J/ue,pe=((ve-se)*q-(be-ge)*J)/(b*q-y*J);V=se+b*pe-R.x,X=ge+y*pe-R.y;const _e=V*V+X*X;if(_e<=2)return new le(V,X);Q=Math.sqrt(_e/2)}else{let re=!1;b>Number.EPSILON?J>Number.EPSILON&&(re=!0):b<-Number.EPSILON?J<-Number.EPSILON&&(re=!0):Math.sign(y)===Math.sign(q)&&(re=!0),re?(V=-y,X=b,Q=Math.sqrt(z)):(V=b,X=y,Q=Math.sqrt(z/2))}return new le(V/Q,X/Q)}const $=[];for(let R=0,N=G.length,I=N-1,V=R+1;R=0;R--){const N=R/_,I=f*Math.cos(N*Math.PI/2),V=m*Math.sin(N*Math.PI/2)+v;for(let X=0,Q=G.length;X=0;){const V=I;let X=I-1;X<0&&(X=R.length-1);for(let Q=0,b=h+_*2;Q=0?(e(g-a,v,h),u.subVectors(c,h)):(e(g+a,v,h),u.subVectors(h,c)),v-a>=0?(e(g,v-a,h),d.subVectors(c,h)):(e(g,v+a,h),d.subVectors(h,c)),l.crossVectors(u,d).normalize(),o.push(l.x,l.y,l.z),s.push(g,v)}}for(let m=0;m0)&&f.push(E,S,x),(g!==n-1||l=n)){u.push(c.times[f]);for(let v=0;vo.tracks[l].times[0]&&(a=o.tracks[l].times[0]);for(let l=0;l=a.times[m]){const g=m*u+h,p=g+u-h;v=je.arraySlice(a.values,g,p)}else{const g=a.createInterpolant(),p=h,E=u-h;g.evaluate(o),v=je.arraySlice(g.resultBuffer,p,E)}l==="quaternion"&&new tt().fromArray(v).normalize().conjugate().toArray(v);const _=c.times.length;for(let g=0;g<_;++g){const p=g*f+d;if(l==="quaternion")tt.multiplyQuaternionsFlat(c.values,p,v,0,c.values,p);else{const E=f-d*2;for(let S=0;S=r)){const s=t[1];e=r)break t}o=i,i=0;break i}break e}for(;i>>1;et;)--o;if(++o,r!==0||o!==n){r>=o&&(o=Math.max(o,1),r=o-1);const s=this.getValueSize();this.times=je.arraySlice(i,r,o),this.values=je.arraySlice(this.values,r*s,o*s)}return this},validate:function(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,r=i.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let s=0;s!==r;s++){const a=i[s];if(typeof a=="number"&&isNaN(a)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,s,a),e=!1;break}if(o!==null&&o>a){console.error("THREE.KeyframeTrack: Out of order keys.",this,s,a,o),e=!1;break}o=a}if(n!==void 0&&je.isTypedArray(n))for(let s=0,a=n.length;s!==a;++s){const l=n[s];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,s,l),e=!1;break}}return e},optimize:function(){const e=je.arraySlice(this.times),t=je.arraySlice(this.values),i=this.getValueSize(),n=this.getInterpolation()===qo,r=e.length-1;let o=1;for(let s=1;s0){e[o]=e[r];for(let s=r*i,a=o*i,l=0;l!==i;++l)t[a+l]=t[s+l];++o}return o!==e.length?(this.times=je.arraySlice(e,0,o),this.values=je.arraySlice(t,0,o*i)):(this.times=e,this.values=t),this},clone:function(){const e=je.arraySlice(this.times,0),t=je.arraySlice(this.values,0),i=this.constructor,n=new i(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}});function ks(e,t,i){mt.call(this,e,t,i)}ks.prototype=Object.assign(Object.create(mt.prototype),{constructor:ks,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:or,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function Hs(e,t,i,n){mt.call(this,e,t,i,n)}Hs.prototype=Object.assign(Object.create(mt.prototype),{constructor:Hs,ValueTypeName:"color"});function Bn(e,t,i,n){mt.call(this,e,t,i,n)}Bn.prototype=Object.assign(Object.create(mt.prototype),{constructor:Bn,ValueTypeName:"number"});function Bs(e,t,i,n){Tt.call(this,e,t,i,n)}Bs.prototype=Object.assign(Object.create(Tt.prototype),{constructor:Bs,interpolate_:function(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=(i-t)/(n-t);let l=e*s;for(let c=l+s;l!==c;l+=4)tt.slerpFlat(r,0,o,l-s,o,l,a);return r}});function tn(e,t,i,n){mt.call(this,e,t,i,n)}tn.prototype=Object.assign(Object.create(mt.prototype),{constructor:tn,ValueTypeName:"quaternion",DefaultInterpolation:ln,InterpolantFactoryMethodLinear:function(e){return new Bs(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0});function Gs(e,t,i,n){mt.call(this,e,t,i,n)}Gs.prototype=Object.assign(Object.create(mt.prototype),{constructor:Gs,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:or,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function Gn(e,t,i,n){mt.call(this,e,t,i,n)}Gn.prototype=Object.assign(Object.create(mt.prototype),{constructor:Gn,ValueTypeName:"vector"});function At(e,t=-1,i,n=Qo){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=Se.generateUUID(),this.duration<0&&this.resetDuration()}function Zm(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Bn;case"vector":case"vector2":case"vector3":case"vector4":return Gn;case"color":return Hs;case"quaternion":return tn;case"bool":case"boolean":return ks;case"string":return Gs}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function Jm(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=Zm(e.type);if(e.times===void 0){const i=[],n=[];je.flattenJSON(e.keys,i,n,"value"),e.times=i,e.values=n}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}Object.assign(At,{parse:function(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let o=0,s=i.length;o!==s;++o)t.push(Jm(i[o]).scale(n));const r=new At(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r},toJSON:function(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,o=i.length;r!==o;++r)t.push(mt.toJSON(i[r]));return n},CreateFromMorphTargetSequence:function(e,t,i,n){const r=t.length,o=[];for(let s=0;s1){const h=c[1];let u=n[h];u||(n[h]=u=[]),u.push(l)}}const o=[];for(const s in n)o.push(At.CreateFromMorphTargetSequence(s,n[s],t,i));return o},parseAnimation:function(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(c,h,u,d,f){if(u.length!==0){const m=[],v=[];je.flattenJSON(u,m,v,d),m.length!==0&&f.push(new c(h,m,v))}},n=[],r=e.name||"default",o=e.fps||30,s=e.blendMode;let a=e.length||-1;const l=e.hierarchy||[];for(let c=0;c0||e.search(/^data\:image\/jpeg/)===0;r.format=a?Ti:wt,r.needsUpdate=!0,t!==void 0&&t(r)},i,n),r}});function xe(){this.type="Curve",this.arcLengthDivisions=200}Object.assign(xe.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)},getPoints:function(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t},getSpacedPoints:function(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t},getLength:function(){const e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(e===void 0&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,n=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),r+=i.distanceTo(n),t.push(r),n=i;return this.cacheArcLengths=t,t},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){const i=this.getLengths();let n=0;const r=i.length;let o;t?o=t:o=e*i[r-1];let s=0,a=r-1,l;for(;s<=a;)if(n=Math.floor(s+(a-s)/2),l=i[n]-o,l<0)s=n+1;else if(l>0)a=n-1;else{a=n;break}if(n=a,i[n]===o)return n/(r-1);const c=i[n],h=i[n+1]-c,u=(o-c)/h;return(n+u)/(r-1)},getTangent:function(e,t){let i=e-1e-4,n=e+1e-4;i<0&&(i=0),n>1&&(n=1);const r=this.getPoint(i),o=this.getPoint(n),s=t||(r.isVector2?new le:new A);return s.copy(o).sub(r).normalize(),s},getTangentAt:function(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)},computeFrenetFrames:function(e,t){const i=new A,n=[],r=[],o=[],s=new A,a=new Re;for(let d=0;d<=e;d++){const f=d/e;n[d]=this.getTangentAt(f,new A),n[d].normalize()}r[0]=new A,o[0]=new A;let l=Number.MAX_VALUE;const c=Math.abs(n[0].x),h=Math.abs(n[0].y),u=Math.abs(n[0].z);c<=l&&(l=c,i.set(1,0,0)),h<=l&&(l=h,i.set(0,1,0)),u<=l&&i.set(0,0,1),s.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],s),o[0].crossVectors(n[0],r[0]);for(let d=1;d<=e;d++){if(r[d]=r[d-1].clone(),o[d]=o[d-1].clone(),s.crossVectors(n[d-1],n[d]),s.length()>Number.EPSILON){s.normalize();const f=Math.acos(Se.clamp(n[d-1].dot(n[d]),-1,1));r[d].applyMatrix4(a.makeRotationAxis(s,f))}o[d].crossVectors(n[d],r[d])}if(t===!0){let d=Math.acos(Se.clamp(r[0].dot(r[e]),-1,1));d/=e,n[0].dot(s.crossVectors(r[0],r[e]))>0&&(d=-d);for(let f=1;f<=e;f++)r[f].applyMatrix4(a.makeRotationAxis(n[f],d*f)),o[f].crossVectors(n[f],r[f])}return{tangents:n,normals:r,binormals:o}},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}});function Dt(e,t,i,n,r,o,s,a){xe.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=t||0,this.xRadius=i||1,this.yRadius=n||1,this.aStartAngle=r||0,this.aEndAngle=o||2*Math.PI,this.aClockwise=s||!1,this.aRotation=a||0}Dt.prototype=Object.create(xe.prototype),Dt.prototype.constructor=Dt,Dt.prototype.isEllipseCurve=!0,Dt.prototype.getPoint=function(e,t){const i=t||new le,n=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)n;)r-=n;r0?0:(Math.floor(Math.abs(s)/r)+1)*r:a===0&&s===r-1&&(s=r-2,a=1);let l,c;this.closed||s>0?l=n[(s-1)%r]:(Eo.subVectors(n[0],n[1]).add(n[0]),l=Eo);const h=n[s%r],u=n[(s+1)%r];if(this.closed||s+2n.length-2?n.length-1:o+1],h=n[o>n.length-3?n.length-1:o+2];return i.set(tc(s,a.x,l.x,c.x,h.x),tc(s,a.y,l.y,c.y,h.y)),i},ni.prototype.copy=function(e){xe.prototype.copy.call(this,e),this.points=[];for(let t=0,i=e.points.length;t=t){const r=i[n]-t,o=this.curves[n],s=o.getLength(),a=s===0?0:1-r/s;return o.getPointAt(a)}n++}return null},getLength:function(){const e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,n=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t},copy:function(e){xe.prototype.copy.call(this,e),this.curves=[];for(let t=0,i=e.curves.length;t0){const h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this},copy:function(e){return nn.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){const e=nn.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return nn.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}});function jn(e){ri.call(this,e),this.uuid=Se.generateUUID(),this.type="Shape",this.holes=[]}jn.prototype=Object.assign(Object.create(ri.prototype),{constructor:jn,getPointsHoles:function(e){const t=[];for(let i=0,n=this.holes.length;i0:n.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const r in e.uniforms){const o=e.uniforms[r];switch(n.uniforms[r]={},o.type){case"t":n.uniforms[r].value=i(o.value);break;case"c":n.uniforms[r].value=new he().setHex(o.value);break;case"v2":n.uniforms[r].value=new le().fromArray(o.value);break;case"v3":n.uniforms[r].value=new A().fromArray(o.value);break;case"v4":n.uniforms[r].value=new ke().fromArray(o.value);break;case"m3":n.uniforms[r].value=new Ft().fromArray(o.value);break;case"m4":n.uniforms[r].value=new Re().fromArray(o.value);break;default:n.uniforms[r].value=o.value}}if(e.defines!==void 0&&(n.defines=e.defines),e.vertexShader!==void 0&&(n.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(n.fragmentShader=e.fragmentShader),e.extensions!==void 0)for(const r in e.extensions)n.extensions[r]=e.extensions[r];if(e.shading!==void 0&&(n.flatShading=e.shading===1),e.size!==void 0&&(n.size=e.size),e.sizeAttenuation!==void 0&&(n.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(n.map=i(e.map)),e.matcap!==void 0&&(n.matcap=i(e.matcap)),e.alphaMap!==void 0&&(n.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(n.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(n.bumpScale=e.bumpScale),e.normalMap!==void 0&&(n.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(n.normalMapType=e.normalMapType),e.normalScale!==void 0){let r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),n.normalScale=new le().fromArray(r)}return e.displacementMap!==void 0&&(n.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(n.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(n.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(n.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(n.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(n.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(n.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(n.specularMap=i(e.specularMap)),e.envMap!==void 0&&(n.envMap=i(e.envMap)),e.envMapIntensity!==void 0&&(n.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(n.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(n.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(n.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(n.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(n.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(n.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(n.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(n.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(n.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(n.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(n.clearcoatNormalScale=new le().fromArray(e.clearcoatNormalScale)),e.transmission!==void 0&&(n.transmission=e.transmission),e.transmissionMap!==void 0&&(n.transmissionMap=i(e.transmissionMap)),n},setTextures:function(e){return this.textures=e,this}});const Yn={decodeText:function(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,n=e.length;i"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),Ue.call(this,e),this.options={premultiplyAlpha:"none"}}ea.prototype=Object.assign(Object.create(Ue.prototype),{constructor:ea,isImageBitmapLoader:!0,setOptions:function(e){return this.options=e,this},load:function(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Vn.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;const s={};s.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",fetch(e,s).then(function(a){return a.blob()}).then(function(a){return createImageBitmap(a,r.options)}).then(function(a){Vn.add(e,a),t&&t(a),r.manager.itemEnd(e)}).catch(function(a){n&&n(a),r.manager.itemError(e),r.manager.itemEnd(e)}),r.manager.itemStart(e)}});function sc(){this.type="ShapePath",this.color=new he,this.subPaths=[],this.currentPath=null}Object.assign(sc.prototype,{moveTo:function(e,t){return this.currentPath=new ri,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this},lineTo:function(e,t){return this.currentPath.lineTo(e,t),this},quadraticCurveTo:function(e,t,i,n){return this.currentPath.quadraticCurveTo(e,t,i,n),this},bezierCurveTo:function(e,t,i,n,r,o){return this.currentPath.bezierCurveTo(e,t,i,n,r,o),this},splineThru:function(e){return this.currentPath.splineThru(e),this},toShapes:function(e,t){function i(g){const p=[];for(let E=0,S=g.length;ENumber.EPSILON){if(B<0&&(L=p[x],U=-U,W=p[T],B=-B),g.yW.y)continue;if(g.y===L.y){if(g.x===L.x)return!0}else{const H=B*(g.x-L.x)-U*(g.y-L.y);if(H===0)return!0;if(H<0)continue;S=!S}}else{if(g.y!==L.y)continue;if(W.x<=g.x&&g.x<=L.x||L.x<=g.x&&g.x<=W.x)return!0}}return S}const r=zi.isClockWise,o=this.subPaths;if(o.length===0)return[];if(t===!0)return i(o);let s,a,l;const c=[];if(o.length===1)return a=o[0],l=new jn,l.curves=a.curves,c.push(l),c;let h=!r(o[0].getPoints());h=e?!h:h;const u=[],d=[];let f=[],m=0,v;d[m]=void 0,f[m]=[];for(let g=0,p=o.length;g1){let g=!1;const p=[];for(let E=0,S=d.length;E0&&(g||(f=u))}let _;for(let g=0,p=d.length;g"u"?Date:performance).now()}function fc(e,t,i){this.binding=e,this.valueSize=i;let n,r,o;switch(t){case"quaternion":n=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:n=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}Object.assign(fc.prototype,{accumulate:function(e,t){const i=this.buffer,n=this.valueSize,r=e*n+n;let o=this.cumulativeWeight;if(o===0){for(let s=0;s!==n;++s)i[r+s]=i[s];o=t}else{o+=t;const s=t/o;this._mixBufferRegion(i,r,0,s,n)}this.cumulativeWeight=o},accumulateAdditive:function(e){const t=this.buffer,i=this.valueSize,n=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,n,0,e,i),this.cumulativeWeightAdditive+=e},apply:function(e){const t=this.valueSize,i=this.buffer,n=e*t+t,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,s=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const a=t*this._origIndex;this._mixBufferRegion(i,n,a,1-r,t)}o>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let a=t,l=t+t;a!==l;++a)if(i[a]!==i[a+t]){s.setValue(i,n);break}},saveOriginalState:function(){const e=this.binding,t=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(t,n);for(let r=i,o=n;r!==o;++r)t[r]=t[n+r%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0},restoreOriginalState:function(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)},_setAdditiveIdentityNumeric:function(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i=.5)for(let o=0;o!==r;++o)e[t+o]=e[i+o]},_slerp:function(e,t,i,n){tt.slerpFlat(e,t,e,t,e,i,n)},_slerpAdditive:function(e,t,i,n,r){const o=this._workIndex*r;tt.multiplyQuaternionsFlat(e,o,e,t,e,i),tt.slerpFlat(e,t,e,t,e,o,n)},_lerp:function(e,t,i,n,r){const o=1-n;for(let s=0;s!==r;++s){const a=t+s;e[a]=e[a]*o+e[i+s]*n}},_lerpAdditive:function(e,t,i,n,r){for(let o=0;o!==r;++o){const s=t+o;e[s]=e[s]+e[i+o]*n}}});const ta="\\[\\]\\.:\\/",fg=new RegExp("["+ta+"]","g"),ia="[^"+ta+"]",mg="[^"+ta.replace("\\.","")+"]",gg=/((?:WC+[\/:])*)/.source.replace("WC",ia),vg=/(WCOD+)?/.source.replace("WCOD",mg),_g=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ia),xg=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ia),yg=new RegExp("^"+gg+vg+_g+xg+"$"),bg=["material","materials","bones"];function mc(e,t,i){const n=i||gt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}Object.assign(mc.prototype,{getValue:function(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(e,t)},setValue:function(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(e,t)},bind:function(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()},unbind:function(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}});function gt(e,t,i){this.path=t,this.parsedPath=i||gt.parseTrackName(t),this.node=gt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}Object.assign(gt,{Composite:mc,create:function(e,t,i){return e&&e.isAnimationObjectGroup?new gt.Composite(e,t,i):new gt(e,t,i)},sanitizeNodeName:function(e){return e.replace(/\s/g,"_").replace(fg,"")},parseTrackName:function(e){const t=yg.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const r=i.nodeName.substring(n+1);bg.indexOf(r)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=r)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i},findNode:function(e,t){if(!t||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(r){for(let o=0;o=r){const h=r++,u=e[h];t[u.uuid]=c,e[c]=u,t[l]=h,e[h]=a;for(let d=0,f=n;d!==f;++d){const m=i[d],v=m[h],_=m[c];m[c]=v,m[h]=_}}}this.nCachedObjects_=r},uncache:function(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,o=e.length;for(let s=0,a=arguments.length;s!==a;++s){const l=arguments[s],c=l.uuid,h=t[c];if(h!==void 0)if(delete t[c],h0&&(t[d.uuid]=h),e[h]=d,e.pop();for(let f=0,m=n;f!==m;++f){const v=i[f];v[h]=v[u],v.pop()}}}this.nCachedObjects_=r},subscribe_:function(e,t){const i=this._bindingsIndicesByPath;let n=i[e];const r=this._bindings;if(n!==void 0)return r[n];const o=this._paths,s=this._parsedPaths,a=this._objects,l=a.length,c=this.nCachedObjects_,h=new Array(l);n=r.length,i[e]=n,o.push(e),s.push(t),r.push(h);for(let u=c,d=a.length;u!==d;++u){const f=a[u];h[u]=new gt(f,e,t)}return h},unsubscribe_:function(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const n=this._paths,r=this._parsedPaths,o=this._bindings,s=o.length-1,a=o[s],l=e[s];t[l]=i,o[i]=a,o.pop(),r[i]=r[s],r.pop(),n[i]=n[s],n.pop()}}});class Mg{constructor(t,i,n=null,r=i.blendMode){this._mixer=t,this._clip=i,this._localRoot=n,this.blendMode=r;const o=i.tracks,s=o.length,a=new Array(s),l={endingStart:cn,endingEnd:cn};for(let c=0;c!==s;++c){const h=o[c].createInterpolant(null);a[c]=h,h.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=qh,this._loopCount=-1,this._startTime=null,this.time=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.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,i){return this.loop=t,this.repetitions=i,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,i,n){if(t.fadeOut(i),this.fadeIn(i),n){const r=this._clip.duration,o=t._clip.duration,s=o/r,a=r/o;t.warp(1,s,i),this.warp(a,1,i)}return this}crossFadeTo(t,i,n){return t.crossFadeFrom(this,i,n)}stopFading(){const t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,i,n){const r=this._mixer,o=r.time,s=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);const l=a.parameterPositions,c=a.sampleValues;return l[0]=o,l[1]=o+n,c[0]=t/s,c[1]=i/s,this}stopWarping(){const t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,i,n,r){if(!this.enabled){this._updateWeight(t);return}const o=this._startTime;if(o!==null){const l=(t-o)*n;if(l<0||n===0)return;this._startTime=null,i=n*l}i*=this._updateTimeScale(t);const s=this._updateTime(i),a=this._updateWeight(t);if(a>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Oa:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(s),c[h].accumulateAdditive(a);break;case Qo:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(s),c[h].accumulate(r,a)}}}_updateWeight(t){let i=0;if(this.enabled){i=this.weight;const n=this._weightInterpolant;if(n!==null){const r=n.evaluate(t)[0];i*=r,t>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=i,i}_updateTimeScale(t){let i=0;if(!this.paused){i=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const r=n.evaluate(t)[0];i*=r,t>n.parameterPositions[1]&&(this.stopWarping(),i===0?this.paused=!0:this.timeScale=i)}}return this._effectiveTimeScale=i,i}_updateTime(t){const i=this._clip.duration,n=this.loop;let r=this.time+t,o=this._loopCount;const s=n===Qh;if(t===0)return o===-1?r:s&&(o&1)===1?i-r:r;if(n===Yo){o===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=i)r=i;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(o===-1&&(t>=0?(o=0,this._setEndings(!0,this.repetitions===0,s)):this._setEndings(this.repetitions===0,!0,s)),r>=i||r<0){const a=Math.floor(r/i);r-=i*a,o+=Math.abs(a);const l=this.repetitions-o;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=t>0?i:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){const c=t<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=o,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(s&&(o&1)===1)return i-r}return r}_setEndings(t,i,n){const r=this._interpolantSettings;n?(r.endingStart=hn,r.endingEnd=hn):(t?r.endingStart=this.zeroSlopeAtStart?hn:cn:r.endingStart=Hr,i?r.endingEnd=this.zeroSlopeAtEnd?hn:cn:r.endingEnd=Hr)}_scheduleFading(t,i,n){const r=this._mixer,o=r.time;let s=this._weightInterpolant;s===null&&(s=r._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,l=s.sampleValues;return a[0]=o,l[0]=i,a[1]=o+t,l[1]=n,this}}function Co(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}Co.prototype=Object.assign(Object.create(ci.prototype),{constructor:Co,_bindAction:function(e,t){const i=e._localRoot||this._root,n=e._clip.tracks,r=n.length,o=e._propertyBindings,s=e._interpolants,a=i.uuid,l=this._bindingsByRootAndName;let c=l[a];c===void 0&&(c={},l[a]=c);for(let h=0;h!==r;++h){const u=n[h],d=u.name;let f=c[d];if(f!==void 0)o[h]=f;else{if(f=o[h],f!==void 0){f._cacheIndex===null&&(++f.referenceCount,this._addInactiveBinding(f,a,d));continue}const m=t&&t._propertyBindings[h].binding.parsedPath;f=new fc(gt.create(i,d,m),u.ValueTypeName,u.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,a,d),o[h]=f}s[h].resultBuffer=f.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,i)}const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const r=t[i];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const r=t[i];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}},_initMemoryManager:function(){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:function(e){const t=e._cacheIndex;return t!==null&&t=0;--i)e[i].stop();return this},update:function(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,n=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(n,e,r,o);const s=this._bindings,a=this._nActiveBindings;for(let l=0;l!==a;++l)s[l].apply(o);return this},setTime:function(e){this.time=0;for(let t=0;tthis.max.x||t.ythis.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,i){return i===void 0&&(console.warn("THREE.Box2: .getParameter() target is now required"),i=new le),i.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)}clampPoint(t,i){return i===void 0&&(console.warn("THREE.Box2: .clampPoint() target is now required"),i=new le),i.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return yc.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}function No(e){we.call(this),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}No.prototype=Object.create(we.prototype),No.prototype.constructor=No,No.prototype.isImmediateRenderObject=!0;const ki=new A,Io=new Re,ra=new Re;class Ag extends Mr{constructor(t){const i=bc(t),n=new De,r=[],o=[],s=new he(0,0,1),a=new he(0,1,0);for(let c=0;c= edgeVert;"," FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;","/*--------------------------------------------------------------------------*/"," if(!horzSpan) lumaN = lumaW;"," if(!horzSpan) lumaS = lumaE;"," if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;"," FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;","/*--------------------------------------------------------------------------*/"," FxaaFloat gradientN = lumaN - lumaM;"," FxaaFloat gradientS = lumaS - lumaM;"," FxaaFloat lumaNN = lumaN + lumaM;"," FxaaFloat lumaSS = lumaS + lumaM;"," FxaaBool pairN = abs(gradientN) >= abs(gradientS);"," FxaaFloat gradient = max(abs(gradientN), abs(gradientS));"," if(pairN) lengthSign = -lengthSign;"," FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);","/*--------------------------------------------------------------------------*/"," FxaaFloat2 posB;"," posB.x = posM.x;"," posB.y = posM.y;"," FxaaFloat2 offNP;"," offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;"," offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;"," if(!horzSpan) posB.x += lengthSign * 0.5;"," if( horzSpan) posB.y += lengthSign * 0.5;","/*--------------------------------------------------------------------------*/"," FxaaFloat2 posN;"," posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;"," posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;"," FxaaFloat2 posP;"," posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;"," posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;"," FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;"," FxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));"," FxaaFloat subpixE = subpixC * subpixC;"," FxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));","/*--------------------------------------------------------------------------*/"," if(!pairN) lumaNN = lumaSS;"," FxaaFloat gradientScaled = gradient * 1.0/4.0;"," FxaaFloat lumaMM = lumaM - lumaNN * 0.5;"," FxaaFloat subpixF = subpixD * subpixE;"," FxaaBool lumaMLTZero = lumaMM < 0.0;","/*--------------------------------------------------------------------------*/"," lumaEndN -= lumaNN * 0.5;"," lumaEndP -= lumaNN * 0.5;"," FxaaBool doneN = abs(lumaEndN) >= gradientScaled;"," FxaaBool doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;"," FxaaBool doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;","/*--------------------------------------------------------------------------*/"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 3)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 4)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 5)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 6)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 7)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 8)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 9)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 10)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 11)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 12)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }","/*--------------------------------------------------------------------------*/"," FxaaFloat dstN = posM.x - posN.x;"," FxaaFloat dstP = posP.x - posM.x;"," if(!horzSpan) dstN = posM.y - posN.y;"," if(!horzSpan) dstP = posP.y - posM.y;","/*--------------------------------------------------------------------------*/"," FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;"," FxaaFloat spanLength = (dstP + dstN);"," FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;"," FxaaFloat spanLengthRcp = 1.0/spanLength;","/*--------------------------------------------------------------------------*/"," FxaaBool directionN = dstN < dstP;"," FxaaFloat dst = min(dstN, dstP);"," FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;"," FxaaFloat subpixG = subpixF * subpixF;"," FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;"," FxaaFloat subpixH = subpixG * fxaaQualitySubpix;","/*--------------------------------------------------------------------------*/"," FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;"," FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);"," if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;"," if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;"," #if (FXAA_DISCARD == 1)"," return FxaaTexTop(tex, posM);"," #else"," return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);"," #endif","}","/*==========================================================================*/","#endif","","void main() {"," gl_FragColor = FxaaPixelShader("," vUv,"," vec4(0.0),"," tDiffuse,"," tDiffuse,"," tDiffuse,"," resolution,"," vec4(0.0),"," vec4(0.0),"," vec4(0.0),"," 0.75,"," 0.166,"," 0.0833,"," 0.0,"," 0.0,"," 0.0,"," vec4(0.0)"," );",""," // TODO avoid querying texture twice for same texel"," gl_FragColor.a = texture2D(tDiffuse, vUv).a;","}"].join(` `)};const Ut=(()=>{class e{constructor(){this._name=null,this._components={},this._position=new A,this._rotation=new tt,this._handlers={},this.parent_=null,this.dead_=!1}Destroy(){for(let n in this._components)this._components[n].Destroy();this._components=null,this.parent_=null,this._handlers=null}_RegisterHandler(n,r){n in this._handlers||(this._handlers[n]=[]),this._handlers[n].push(r)}SetParent(n){this.parent_=n}SetName(n){this._name=n}get Name(){return this._name}get Manager(){return this.parent_}SetActive(n){this.parent_.SetActive(this,n)}SetDead(){this.dead_=!0}AddComponent(n){n.SetParent(this),this._components[n.NAME]=n,n.InitComponent()}InitEntity(){for(let n in this._components)this._components[n].InitEntity()}GetComponent(n){return this._components[n]}FindEntity(n){return this.parent_.Get(n)}Broadcast(n){if(n.topic in this._handlers)for(let r of this._handlers[n.topic])r(n)}SetPosition(n){this._position.copy(n),this.Broadcast({topic:"update.position",value:this._position})}SetQuaternion(n){this._rotation.copy(n),this.Broadcast({topic:"update.rotation",value:this._rotation})}get Position(){return this._position}get Quaternion(){return this._rotation}Update(n){for(let r in this._components)this._components[r].Update(n)}}class t{get NAME(){return console.error("Unnamed Component: "+this.constructor.name),"__UNNAMED__"}constructor(){this.parent_=null}Destroy(){}SetParent(n){this.parent_=n}InitComponent(){}InitEntity(){}GetComponent(n){return this.parent_.GetComponent(n)}get Manager(){return this.parent_.Manager}get Parent(){return this.parent_}FindEntity(n){return this.parent_.FindEntity(n)}Broadcast(n){this.parent_.Broadcast(n)}Update(n){}_RegisterHandler(n,r){this.parent_._RegisterHandler(n,r)}}return{Entity:e,Component:t}})(),Fr=(()=>({enabled:!1,foliageEnabled:!0,hardcodedFoliageEnabled:!1,introEnabled:!1,skipOceans:!1,skipClouds:!1,skipFoliageNoise:!1,skipPruning:!1,skipExteriorBlocks:!1,skipAO:!1,skipVariableLuminance:!1,skipGravity:!1,useFlatTerrain:!1,showTools:!0,fixedTerrainOrigin:!1,PLAYER_POS:[-1826.1306923527645,27.940844444445403,-220.6986696117536],PLAYER_ROT:[-.0380279893805328,.3364980691628503,.013601301436886065,.9408176901358577],CAMERA_POS:[0,0],CAMERA_DECCELERATION:[-10,0,-10],INTRO_RATE:5e-4,WORLD_BLOCK_SIZE:16,WORLD_SIZE:24}))(),_t=(()=>({FOG_RANGE:[100,300],UNDERWATER_RANGE:[0,50],FOG_COLOUR:new he(13491953).convertSRGBToLinear(),MOON_COLOUR:new he(8421504).convertSRGBToLinear(),UNDERWATER_COLOUR:new he(3829685).convertSRGBToLinear(),SKY_COLOUR:new he(8175606).convertSRGBToLinear(),PLAYER_POS:[255.311252087425,100,290.98564212457086],PLAYER_ROT:[.02753162419089479,-.7573631733845853,.031998988835540886,.6516280365237096]}))(),Cg=(()=>{const e=` varying vec3 vWorldPosition; void main() { vec4 worldPosition = modelMatrix * vec4( position, 1.0 ); vWorldPosition = worldPosition.xyz; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,t=` uniform vec3 topColor; uniform vec3 bottomColor; uniform vec3 playerPos; uniform float offset; uniform float exponent; uniform float whiteBlend; uniform float time; uniform samplerCube background; varying vec3 vWorldPosition; float sdPlane(vec3 p, vec3 n, float h) { // n must be normalized return dot(p, n) + h; } void main() { vec3 viewDirection = normalize(vWorldPosition - cameraPosition); vec3 stars = sRGBToLinear(textureCube(background, viewDirection)).xyz; float h = normalize(vWorldPosition + offset).y; float t = max(pow(max(h, 0.0), exponent), 0.0); float f = exp(min(0.0, -vWorldPosition.y * 0.0125)); float heightMix = clamp((playerPos.y - 500.0) / 1000.0, 0.0, 1.0); heightMix = smoothstep(0.0, 1.0, heightMix); heightMix = smoothstep(0.0, 1.0, heightMix); float wrapFactor = playerPos.y / 500.0; float normalMix = clamp((viewDirection.y + wrapFactor) / (1.0 + wrapFactor), 0.0, 1.0); normalMix = pow(normalMix, 0.250); vec3 topMix = mix(topColor, stars, heightMix * normalMix); // Normal vec3 sky = mix(topMix, bottomColor, f); // Moon // vec3 sky = mix(stars, bottomColor, f); float skyMix = clamp(whiteBlend, 0.0, 1.0); sky = mix(bottomColor, sky, skyMix * skyMix); gl_FragColor = vec4(sky, 1.0); // gl_FragColor = vec4(vec3(normalMix * normalMix), 1.0); }`,n=class n extends Ut.Component{get NAME(){return n.CLASS_NAME}constructor(){super()}InitEntity(){this.threejs_=new _r({antialias:!1}),this.threejs_.shadowMap.enabled=!0,this.threejs_.shadowMap.type=da,this.threejs_.setPixelRatio(window.devicePixelRatio),this.threejs_.setSize(window.innerWidth,window.innerHeight),this.threejs_.domElement.id="threejs",document.getElementById("container").appendChild(this.threejs_.domElement),window.addEventListener("resize",()=>{this.OnResize_()},!1);const o=60,s=1920/1080,a=.5,l=1e4;this.camera_=new $e(o,s,a,l),this.camera_.position.set(15,50,15),this.camera_.lookAt(0,0,0),this.uiCamera_=new $e(o,s,a,l),this.scene_=new Es,this.scene_.add(this.camera_),this.uiScene_=new Es,this.uiScene_.add(this.uiCamera_);let c=new Lo(8423603,.7);c.position.set(-10,500,10),c.target.position.set(0,0,0),this.scene_.add(c),this.uiScene_.add(c.clone()),this.sun_=c;const h={minFilter:qe,magFilter:qe,format:wt,type:li},u=new ji(window.innerWidth,window.innerHeight,h);u.stencilBuffer=!1,u.depthBuffer=!0,u.depthTexture=new Sr,u.depthTexture.format=Gi,u.depthTexture.type=ir,this.fxaa_=new qn(Rg);const d=new Oo(this.uiScene_,this.uiCamera_);d.clear=!1,this.composer_=new Tc(this.threejs_,u),this.composer_.addPass(new Oo(this.scene_,this.camera_)),this.composer_.addPass(d),this.composer_.addPass(this.fxaa_),this.composer_.addPass(new qn(Pg));const f=new Oe(new gi(.1,.01,.01),new vt({color:new he(16777215),depthWrite:!1,depthTest:!1}));f.position.set(0,0,-2);const m=new Oe(new gi(.01,.1,.01),new vt({color:new he(16777215),depthWrite:!1,depthTest:!1}));m.position.set(0,0,-2),this.uiCamera_.add(f),this.uiCamera_.add(m),this.LoadSky_(),this.OnResize_()}OnResize_(){this.camera_.aspect=window.innerWidth/window.innerHeight,this.camera_.updateProjectionMatrix(),this.threejs_.setSize(window.innerWidth,window.innerHeight),this.composer_.setSize(window.innerWidth,window.innerHeight);const o=this.threejs_.getPixelRatio();this.fxaa_.material.uniforms.resolution.value.x=1/(window.innerWidth*o),this.fxaa_.material.uniforms.resolution.value.y=1/(window.innerHeight*o)}LoadSky_(){const o=new Ys(4344437,16777215,.9);this.scene_.add(o),this.uiScene_.add(o.clone());const s=new So().load(["./resources/terrain/space-posx.jpg","./resources/terrain/space-negx.jpg","./resources/terrain/space-posy.jpg","./resources/terrain/space-negy.jpg","./resources/terrain/space-posz.jpg","./resources/terrain/space-negz.jpg"]);s.encoding=Vi;const a={topColor:{value:_t.SKY_COLOUR.clone()},bottomColor:{value:_t.FOG_COLOUR.clone()},offset:{value:0},exponent:{value:.6},background:{value:s},whiteBlend:{value:0},playerPos:{value:new A},time:{value:0}},l=new qm(5e3,32,15),c=new Qe({uniforms:a,vertexShader:e,fragmentShader:t,side:Ze}),h=new Oe(l,c);this.sky_=h,this.scene_.add(h)}Update(o){const s=this.FindEntity("player");if(!s)return;const a=s._position,l=new A(0,0,-1);l.applyQuaternion(s.Quaternion),l.multiplyScalar(750),this.sun_.position.copy(a),this.sun_.position.add(new A(-50,200,-10)),this.sun_.target.position.copy(a),this.sun_.updateMatrixWorld(),this.sun_.target.updateMatrixWorld(),this.sky_.position.copy(new A(a.x,0,a.z)),this.sky_.material.uniforms.playerPos.value.copy(a),this.sky_.material.uniforms.time.value+=o,this.sky_.material.needsUpdate=!0}Render(){this.uiCamera_.position.copy(this.camera_.position),this.uiCamera_.quaternion.copy(this.camera_.quaternion),this.composer_.render()}};wi(n,"CLASS_NAME","ThreeJSController");let i=n;return{ThreeJSController:i}})(),sa=function(){return{DictIntersection:function(e,t){const i={};for(let n in t)n in e&&(i[n]=e[n]);return i},DictDifference:function(e,t){const i={...e};for(let n in t)delete i[n];return i}}}(),Ng=(()=>{let e=0;class t{constructor(){this.worker_=new Worker(new URL("/Quick_MinecraftClone2/assets/voxel-builder-threaded-worker-ff5d78be.js",self.location),{type:"module"}),this.worker_.onmessage=r=>{this._OnMessage(r)},this.resolve_=null,this.id_=e++}_OnMessage(r){const o=this.resolve_;this.resolve_=null,o(r.data)}get id(){return this.id_}postMessage(r,o){this.resolve_=o,this.worker_.postMessage(r)}}class i{constructor(r){this.workers_=[...Array(r)].map(o=>new t),this.free_=[...this.workers_],this.busy_={},this.queue_=[]}get length(){return this.workers_.length}get Busy(){return this.queue_.length>0||Object.keys(this.busy_).length>0}Enqueue(r,o){this.queue_.push([r,o]),this.PumpQueue_()}PumpQueue_(){for(;this.free_.length>0&&this.queue_.length>0;){const r=this.free_.pop();this.busy_[r.id]=r;const[o,s]=this.queue_.shift();r.postMessage(o,a=>{delete this.busy_[r.id],this.free_.push(r),s(a),this.PumpQueue_()})}}}return{WorkerPool:i}})(),Ig=function(){var e=.5*(Math.sqrt(3)-1),t=(3-Math.sqrt(3))/6,i=1/3,n=1/6,r=(Math.sqrt(5)-1)/4,o=(5-Math.sqrt(5))/20;function s(h){var u;typeof h=="function"?u=h:h?u=l(h):u=Math.random,this.p=a(u),this.perm=new Uint8Array(512),this.permMod12=new Uint8Array(512);for(var d=0;d<512;d++)this.perm[d]=this.p[d&255],this.permMod12[d]=this.perm[d]%12}s.prototype={grad3:new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),grad4:new Float32Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]),noise2D:function(h,u){var d=this.permMod12,f=this.perm,m=this.grad3,v=0,_=0,g=0,p=(h+u)*e,E=Math.floor(h+p),S=Math.floor(u+p),T=(E+S)*t,x=E-T,L=S-T,W=h-x,U=u-L,B,H;W>U?(B=1,H=0):(B=0,H=1);var j=W-B+t,G=U-H+t,D=W-1+2*t,k=U-1+2*t,Y=E&255,Z=S&255,$=.5-W*W-U*U;if($>=0){var ne=d[Y+f[Z]]*3;$*=$,v=$*$*(m[ne]*W+m[ne+1]*U)}var ae=.5-j*j-G*G;if(ae>=0){var de=d[Y+B+f[Z+H]]*3;ae*=ae,_=ae*ae*(m[de]*j+m[de+1]*G)}var ce=.5-D*D-k*k;if(ce>=0){var ye=d[Y+1+f[Z+1]]*3;ce*=ce,g=ce*ce*(m[ye]*D+m[ye+1]*k)}return 70*(v+_+g)},noise3D:function(h,u,d){var f=this.permMod12,m=this.perm,v=this.grad3,_,g,p,E,S=(h+u+d)*i,T=Math.floor(h+S),x=Math.floor(u+S),L=Math.floor(d+S),W=(T+x+L)*n,U=T-W,B=x-W,H=L-W,j=h-U,G=u-B,D=d-H,k,Y,Z,$,ne,ae;j>=G?G>=D?(k=1,Y=0,Z=0,$=1,ne=1,ae=0):j>=D?(k=1,Y=0,Z=0,$=1,ne=0,ae=1):(k=0,Y=0,Z=1,$=1,ne=0,ae=1):GY?ne++:ae++,k>Z?ne++:de++,k>$?ne++:ce++,Y>Z?ae++:de++,Y>$?ae++:ce++,Z>$?de++:ce++;var ye,Ne,ie,M,w,O,P,F,R,N,I,V;ye=ne>=3?1:0,Ne=ae>=3?1:0,ie=de>=3?1:0,M=ce>=3?1:0,w=ne>=2?1:0,O=ae>=2?1:0,P=de>=2?1:0,F=ce>=2?1:0,R=ne>=1?1:0,N=ae>=1?1:0,I=de>=1?1:0,V=ce>=1?1:0;var X=k-ye+o,Q=Y-Ne+o,b=Z-ie+o,y=$-M+o,J=k-w+2*o,q=Y-O+2*o,z=Z-P+2*o,te=$-F+2*o,re=k-R+3*o,ue=Y-N+3*o,se=Z-I+3*o,ge=$-V+3*o,ve=k-1+4*o,be=Y-1+4*o,pe=Z-1+4*o,_e=$-1+4*o,Te=x&255,Ke=L&255,ct=W&255,zt=U&255,It=.6-k*k-Y*Y-Z*Z-$*$;if(It<0)_=0;else{var kt=m[Te+m[Ke+m[ct+m[zt]]]]%32*4;It*=It,_=It*It*(v[kt]*k+v[kt+1]*Y+v[kt+2]*Z+v[kt+3]*$)}var Ht=.6-X*X-Q*Q-b*b-y*y;if(Ht<0)g=0;else{var bi=m[Te+ye+m[Ke+Ne+m[ct+ie+m[zt+M]]]]%32*4;Ht*=Ht,g=Ht*Ht*(v[bi]*X+v[bi+1]*Q+v[bi+2]*b+v[bi+3]*y)}var ht=.6-J*J-q*q-z*z-te*te;if(ht<0)p=0;else{var st=m[Te+w+m[Ke+O+m[ct+P+m[zt+F]]]]%32*4;ht*=ht,p=ht*ht*(v[st]*J+v[st+1]*q+v[st+2]*z+v[st+3]*te)}var yt=.6-re*re-ue*ue-se*se-ge*ge;if(yt<0)E=0;else{var Qt=m[Te+R+m[Ke+N+m[ct+I+m[zt+V]]]]%32*4;yt*=yt,E=yt*yt*(v[Qt]*re+v[Qt+1]*ue+v[Qt+2]*se+v[Qt+3]*ge)}var et=.6-ve*ve-be*be-pe*pe-_e*_e;if(et<0)S=0;else{var Bt=m[Te+1+m[Ke+1+m[ct+1+m[zt+1]]]]%32*4;et*=et,S=et*et*(v[Bt]*ve+v[Bt+1]*be+v[Bt+2]*pe+v[Bt+3]*_e)}return 27*(_+g+p+E+S)}};function a(h){var u,d=new Uint8Array(256);for(u=0;u<256;u++)d[u]=u;for(u=0;u<255;u++){var f=u+~~(h()*(256-u)),m=d[u];d[u]=d[f],d[f]=m}return d}s._buildPermutationTable=a;function l(){var h=0,u=0,d=0,f=1,m=c();h=m(" "),u=m(" "),d=m(" ");for(var v=0;v>>0,f-=h,f*=h,h=f>>>0,f-=h,h+=f*4294967296}return(h>>>0)*23283064365386963e-26}}return{SimplexNoise:s}}(),Je=function(){class e{constructor(i){this.params_=i,this._Init()}_Init(){this._noise=new Ig.SimplexNoise(this.params_.seed)}Get(i,n,r){const o=2**-this.params_.persistence,s=i/this.params_.scale,a=n/this.params_.scale,l=r/this.params_.scale,c=this._noise;let h=1,u=1,d=0,f=0;for(let m=0;me>=t&&e<=i}}(),aa=(()=>{function e(T,x,L,W,U){const B=L.clone().sub(x),H=T.clone().sub(x),j=U-W,G=B.dot(B),D=H.dot(H),k=H.dot(B)/G,Y=Math.sqrt(D-k*k*G),Z=Math.max(0,Y-(k<.5?W:U)),$=Math.abs(k-.5)-.5,ne=j*j+G,ae=lt.sat((j*(Y-W)+k*G)/ne),de=Y-W-ae*j,ce=k-ae;return(de<0&&$<0?-1:1)*Math.sqrt(Math.min(Z*Z+$*$*G,de*de+ce*ce*G))}function t(T,x){return T.length()-x}const i=new A,n=new dt,r=new dt,o=new dt,s=new Zt,a=new tt,l=new tt,c=new tt,h=new A(1,0,0),u=new A(0,1,0),d=new A(0,0,1),f=new A;class m{constructor(x){this.sdfs_=[],this.pos_=x.clone(),this.aabb_=new dt(this.pos_.clone(),this.pos_.clone())}get AABB(){return this.aabb_}AddSphere(x,L,W){s.set(this.pos_.clone(),W),s.translate(L),s.getBoundingBox(n),this.aabb_.union(n);const U=L.clone();this.sdfs_.push(B=>(i.copy(B),i.sub(U),i.sub(this.pos_),t(i,W)<0?x:null))}AddCappedCone(x,L,W,U,B,H){s.set(W.clone(),B),s.getBoundingBox(r),s.set(U.clone(),H),s.getBoundingBox(o),n.makeEmpty(),n.union(r),n.union(o),n.translate(L),n.translate(this.pos_),this.aabb_.union(n);const j=W.clone(),G=U.clone(),D=L.clone();this.sdfs_.push(k=>(i.copy(k),i.sub(D),i.sub(this.pos_),e(i,j,G,B,H)<0?x:null))}Evaluate(x){for(let L=0;L{if(k=Math.max(k,1),Z>6){a.copy(Y),i.set(0,5,0),i.applyQuaternion(Y),i.add(G),U.AddSphere("tree_leaves",i,5);return}const $=new A(0,D,0),ne=(.03+v.Get(T,W++,L)*.08)*2*Math.PI,ae=(.25+v.Get(T,W++,L)*.25)*2*Math.PI;$.applyQuaternion(Y),$.add(G),U.AddCappedCone("tree_bark",f,G,$,k,k*.6),l.setFromAxisAngle(h,ne),c.setFromAxisAngle(u,ae),a.copy(Y),a.multiply(c),a.multiply(l),j($.clone(),D*.6,k*.6,a.clone(),Z+1);const de=v.Get(T,W++,L)*.01*2*Math.PI,ce=v.Get(T,W++,L)*.25*2*Math.PI;l.setFromAxisAngle(h,-(ne+de)),c.setFromAxisAngle(u,-(ae+ce)),a.copy(Y),a.multiply(c),a.multiply(l),j($.clone(),D*.6,k*.6,a.clone(),Z+1)};return l.setFromAxisAngle(h,B),c.setFromAxisAngle(u,H),a.copy(c),a.multiply(l),j(new A(0,-5,0),20,5,a.clone(),1),U.AddCappedCone("tree_bark",new A,new A(0,3,0),new A(12,-1,0),2,1),U.AddCappedCone("tree_bark",new A,new A(0,4,0),new A(-8,-1,-11),2,1),U.AddCappedCone("tree_bark",new A,new A(0,2,0),new A(-13,-1,-4),2,1),U}function S(T,x,L){let W=100;const U=new m(new A(T,x,L)),B=(.01+v.Get(T,W++,L)*.02)*2*Math.PI,H=v.Get(T,W++,L)*2*Math.PI,j=(D,k,Y,Z,$)=>{if($>7)return;const ne=new A(4,0,0),ae=-.075*2*Math.PI;ne.applyQuaternion(Z),ne.add(D),U.AddCappedCone("tree_leaves",f,D,ne,Y,Y),l.setFromAxisAngle(d,ae),a.copy(Z),a.multiply(l),j(ne.clone(),k,Y,a.clone(),$+1)},G=(D,k,Y,Z,$)=>{if(Y=Math.max(Y,1),$>3){j(D,k,1,new tt,$),c.setFromAxisAngle(u,.33*2*Math.PI),j(D,k,1,c.clone(),$),c.setFromAxisAngle(u,.66*2*Math.PI),j(D,k,1,c.clone(),$);return}const ne=new A(0,k,0),ae=(.05+v.Get(T,W++,L)*.02)*2*Math.PI;ne.applyQuaternion(Z),ne.add(D),U.AddCappedCone("tree_bark",f,D,ne,Y,Y*.6),l.setFromAxisAngle(h,ae),a.copy(Z),a.multiply(l),G(ne.clone(),k*.75,Y*.75,a.clone(),$+1)};return l.setFromAxisAngle(h,B),c.setFromAxisAngle(u,H),a.copy(c),a.multiply(l),G(new A(0,-5,0),15,2,a.clone(),1),U}return{TREE1:p,TREE2:E,PALM_TREE1:S,SPHERE:_,CONE1:g}})(),Fg=(()=>{const e=Math.floor(6.4),t=e+4,i=Math.floor(128*.7);new he(8421631),new he(16777088),new he(16777215),new he(4210752),new he(4259648);function n(m,v){return mi?"snow":"grass"}new Je.Noise({seed:6,octaves:1,scale:128,persistence:.5,lacunarity:2,exponentiation:4,height:32}),new A;class r{constructor(v){this.params_=v,this.N_Moon_=new Je.Noise({seed:4,octaves:5,scale:1024,persistence:.5,lacunarity:2,exponentiation:4,height:1}),this.N_Craters_=new Je.Noise({seed:7,octaves:1,scale:.99,persistence:.5,lacunarity:2,exponentiation:1,height:1}),this.InitCraters_()}InitCraters_(){this.craters_=[];for(let v=-this.params_.dimensions.x*10;v<=this.params_.dimensions.x*10;v+=8)for(let _=-this.params_.dimensions.z*10;_<=this.params_.dimensions.z*10;_+=8){const g=v+this.params_.offset.x,p=_+this.params_.offset.z;if(this.N_Craters_.Get(g,0,p)>.95){const E=Math.min(this.N_Craters_.Get(g,1,p)**4*100,50)+4;this.craters_.push([new A(g,0,p),E])}}}Get(v,_){const g=this.N_Moon_.Get(v,_,10),p=this.N_Moon_.Get(v,_,20);let E=Math.round(this.N_Moon_.Get(v+g,_+p,0)*64);for(let S=0;SW&&(L[0]="grass"),L[1]S&&(T="dirt"),[T,p]}}class a{constructor(v){this.params_=v,this.N_Terrain_=new Je.Noise({seed:4,octaves:4,scale:500.005,persistence:.5,lacunarity:2,exponentiation:6,height:1,range:[-1,1]}),this.N_Height_=new Je.Noise({seed:4,octaves:3,scale:500.005,persistence:.5,lacunarity:2,exponentiation:1,height:64})}Get(v,_){const g=[this.N_Terrain_.Get(v,0,_),this.N_Terrain_.Get(v,1,_)],p=this.N_Height_.Get(v+g[0],0,_+g[1]);return["sand",Math.floor(p)]}}class l{constructor(v){this.params_=v,this.N_Terrain_=new Je.Noise({seed:4,octaves:6,scale:4096,persistence:.5,lacunarity:2,exponentiation:6,height:1}),this.N_Height_=new Je.Noise({seed:4,octaves:3,scale:4096,persistence:.5,lacunarity:2,exponentiation:1,height:512}),this.N_Plateaus_=new Je.Noise({seed:5,octaves:4,scale:512,persistence:.5,lacunarity:2,exponentiation:2,height:1}),this.N_PlateausNum_=new Je.Noise({seed:6,octaves:4,scale:1024,persistence:.5,lacunarity:2,exponentiation:1,height:20}),this.N_Moisture_=new Je.Noise({seed:3,octaves:3,scale:512,persistence:.5,lacunarity:2,exponentiation:4,height:1})}Get(v,_){const g=this.N_Terrain_.Get(v,_,0),p=this.N_Height_.Get(v,_,0);let E=p*g;if(this.N_Plateaus_.Get(v,_,0)>.25){const T=Math.round(10+this.N_PlateausNum_.Get(v,_,0)),x=Math.round(p/T);E=Math.round(E/x)*x}const S=Math.floor(E);return this.N_Moisture_.Get(v,_,0),[n(S),S]}}const c=new Je.Noise({seed:10,octaves:1,scale:.99,persistence:.5,lacunarity:2,exponentiation:4,height:1}),h=new Je.Noise({seed:11,octaves:4,scale:2.01,persistence:.5,lacunarity:2,exponentiation:1,height:1}),u=new Je.Noise({seed:7,octaves:1,scale:.99,persistence:.5,lacunarity:2,exponentiation:1,height:1});class d{constructor(){this.sdfs_=[]}Add(v){this.sdfs_.push(v)}Intersects(v){for(let _=0;_.8){const[S,T]=this.GenerateNoise_(p,E),x=T;if(x<=e)continue;if(S=="grass"){let L=aa.TREE1;u.Get(p,1,E)<.15&&(L=aa.TREE2),v.Add(L(p,x,E))}else if(S=="sand"){let L=aa.PALM_TREE1;v.Add(L(p,x,E))}}}return v}CreateTerrain_(){const v={},_=this.params_.dimensions.x+1,g=this.params_.dimensions.x+1;for(let p=-1;p<_;p++)for(let E=-1;Ethis.Key_(g.position[0]+E,g.position[1]+S,g.position[2]+T)in v?.75:1;g.facesHidden[0]||(g.ao[0]=[p(1,0,1)*p(1,1,0)*p(1,1,1),p(1,0,-1)*p(1,1,0)*p(1,1,-1),p(1,0,1)*p(1,-1,0)*p(1,-1,1),p(1,0,-1)*p(1,-1,0)*p(1,-1,-1)]),g.facesHidden[1]||(g.ao[1]=[p(-1,0,-1)*p(-1,1,0)*p(-1,1,-1),p(-1,0,1)*p(-1,1,0)*p(-1,1,1),p(-1,0,-1)*p(-1,-1,0)*p(-1,-1,-1),p(-1,0,1)*p(-1,-1,0)*p(-1,-1,1)]),g.facesHidden[2]||(g.ao[2]=[p(0,1,-1)*p(-1,1,0)*p(-1,1,-1),p(0,1,-1)*p(1,1,0)*p(1,1,-1),p(0,1,1)*p(-1,1,0)*p(-1,1,1),p(0,1,1)*p(1,1,0)*p(1,1,1)]),g.facesHidden[3]||(g.ao[3]=[p(0,-1,1)*p(-1,-1,0)*p(-1,-1,1),p(0,-1,1)*p(1,-1,0)*p(1,-1,1),p(0,-1,-1)*p(-1,-1,0)*p(-1,-1,-1),p(0,-1,-1)*p(1,-1,0)*p(1,-1,-1)]),g.facesHidden[4]||(g.ao[4]=[p(-1,0,1)*p(0,1,1)*p(-1,1,1),p(1,0,1)*p(0,1,1)*p(1,1,1),p(-1,0,1)*p(0,-1,1)*p(-1,-1,1),p(1,0,1)*p(0,-1,1)*p(1,-1,1)]),g.facesHidden[5]||(g.ao[5]=[p(1,0,-1)*p(0,1,-1)*p(1,1,-1),p(-1,0,-1)*p(0,1,-1)*p(-1,1,-1),p(1,0,-1)*p(0,-1,-1)*p(1,-1,-1),p(-1,0,-1)*p(0,-1,-1)*p(-1,-1,-1)])}return v}ApplyFadeIn_(v){if(this.params_.currentTime<0||this.params_.currentTime>1)return;const _=this.params_.currentTime**2,g=_,p=_+.1-g,E=[];for(let S in v){const T=v[S],x=h.Get(...T.position),L=((T.position[1]+50)/250-g)/p;x=E||x.position[2]=S)&&_.push(T)}for(let T=0;T<_.length;++T)delete v[_[T]]}MergeCustomVoxels_(v){const _=this.params_.customVoxels,g=[];for(let p in _){const E=_[p];E.visible?(E.facesHidden=[!1,!1,!1,!1,!1],E.ao=[null,null,null,null,null,null]):g.push(p)}Object.assign(v,_);for(let p=0;p{class e{constructor(r){this.params_=r,this.voxels_={},this.group_=new ft,this.buildId_=0,this.lastBuiltId_=-1,this.building_=!1,this.dirty_=!1,this.builder_=new Fg.VoxelBlockBuilder,r.scene.add(this.group_)}Destroy(){this.ReleaseAssets_(),this.group_.parent.remove(this.group_)}ReleaseAssets_(){this.group_.traverse(r=>{r.material&&r.material.dispose(),r.geometry&&r.geometry.dispose()}),this.opaqueMesh_&&this.group_.remove(this.opaqueMesh_),this.transparentMesh_&&this.group_.remove(this.transparentMesh_)}Show(){this.group_.visible=!0}Hide(){this.group_.visible=!1}get Destroyed(){return!this.group_.parent}get Dirty(){return this.dirty_}Key_(r,o,s){return r+"."+o+"."+s}InsertVoxelAt(r,o,s){const a=this.Key_(...r);if(a in this.voxels_&&s)return;const l={position:[...r],type:o,visible:!0};this.voxels_[a]=l,this.buildId_++,this.dirty_=!0;const c=this.params_.parent.GetAdjacentBlocks(this.params_.offset.x,this.params_.offset.z);for(let h=-1;h<=1;++h)for(let u=-1;u<=1;++u)for(let d=-1;d<=1;++d)for(let f=0;f0&&(this.opaqueMesh_=this.BuildGeometry_(r.opaque,this.params_.materialOpaque),this.group_.add(this.opaqueMesh_)),r.transparent.positions.length>0&&(this.transparentMesh_=this.BuildGeometry_(r.transparent,this.params_.materialTransparent),this.group_.add(this.transparentMesh_)),this.voxels_=r.voxels,this.lastBuiltId_=r.buildId}}const t=7;class i{constructor(r){this.old_=[],this.blocks_=[],this.workerPool_=new Ng.WorkerPool(t),this.params_=r,this.currentTime_=.01}OnResult_(r,o){o.subject=="build_chunk_result"&&(r.RebuildMeshFromData(o.data),r.Show())}AllocateBlock(r){const o={...this.params_,...r},s=new e(o);return s.Hide(),this.blocks_.push(s),this.RebuildBlock_(s),s}RebuildBlock_(r){if(r.building_)return;const o={subject:"build_chunk",params:{buildId:r.buildId_,offset:r.params_.offset.toArray(),dimensions:this.params_.dimensions.toArray(),blockTypes:this.params_.blockTypes,currentTime:this.currentTime_}};r.building_=!0,this.workerPool_.Enqueue(o,s=>{r.building_=!1,this.OnResult_(r,s)})}ScheduleDestroy(r){this.old_.push(...r)}DestroyBlocks_(r){for(let o of r)o.Destroy()}get Busy(){return this.workerPool_.Busy}Update(r){this.Busy||(this.DestroyBlocks_(this.old_),this.old_=[]),this.blocks_=this.blocks_.filter(o=>!o.Destroyed);for(let o=0;o({VOXEL:{VS:` precision mediump float; // Attributes, declared by three.js // attribute vec3 position; // attribute vec3 normal; // attribute vec2 uv; attribute vec3 colour; attribute float uvSlice; // Outputs varying vec3 vNormal; varying vec3 vColour; varying vec3 vWorldPosition; varying vec3 vUV; uniform float fogTime; #define saturate(a) clamp( a, 0.0, 1.0 ) void main(){ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); vNormal = normal; vColour = colour; vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz; vUV = vec3(uv, uvSlice); } `,PS:` precision mediump float; precision mediump sampler2DArray; #define saturate(a) clamp( a, 0.0, 1.0 ) //========================================================================================== // hashes //========================================================================================== float hash1( vec2 p ) { p = 50.0*fract( p*0.3183099 ); return fract( p.x*p.y*(p.x+p.y) ); } float hash1( float n ) { return fract( n*17.0*fract( n*0.3183099 ) ); } vec2 hash2( float n ) { return fract(sin(vec2(n,n+1.0))*vec2(43758.5453123,22578.1459123)); } vec2 hash2( vec2 p ) { const vec2 k = vec2( 0.3183099, 0.3678794 ); p = p*k + k.yx; return fract( 16.0 * k*fract( p.x*p.y*(p.x+p.y)) ); } //========================================================================================== // noises //========================================================================================== // value noise, and its analytical derivatives vec4 noised( in vec3 x ) { vec3 p = floor(x); vec3 w = fract(x); vec3 u = w*w*w*(w*(w*6.0-15.0)+10.0); vec3 du = 30.0*w*w*(w*(w-2.0)+1.0); float n = p.x + 317.0*p.y + 157.0*p.z; float a = hash1(n+0.0); float b = hash1(n+1.0); float c = hash1(n+317.0); float d = hash1(n+318.0); float e = hash1(n+157.0); float f = hash1(n+158.0); float g = hash1(n+474.0); float h = hash1(n+475.0); float k0 = a; float k1 = b - a; float k2 = c - a; float k3 = e - a; float k4 = a - b - c + d; float k5 = a - c - e + g; float k6 = a - b - e + f; float k7 = - a + b + c - d + e - f - g + h; return vec4( -1.0+2.0*(k0 + k1*u.x + k2*u.y + k3*u.z + k4*u.x*u.y + k5*u.y*u.z + k6*u.z*u.x + k7*u.x*u.y*u.z), 2.0* du * vec3( k1 + k4*u.y + k6*u.z + k7*u.y*u.z, k2 + k5*u.z + k4*u.x + k7*u.z*u.x, k3 + k6*u.x + k5*u.y + k7*u.x*u.y ) ); } float noise( in vec3 x ) { vec3 p = floor(x); vec3 w = fract(x); vec3 u = w*w*w*(w*(w*6.0-15.0)+10.0); float n = p.x + 317.0*p.y + 157.0*p.z; float a = hash1(n+0.0); float b = hash1(n+1.0); float c = hash1(n+317.0); float d = hash1(n+318.0); float e = hash1(n+157.0); float f = hash1(n+158.0); float g = hash1(n+474.0); float h = hash1(n+475.0); float k0 = a; float k1 = b - a; float k2 = c - a; float k3 = e - a; float k4 = a - b - c + d; float k5 = a - c - e + g; float k6 = a - b - e + f; float k7 = - a + b + c - d + e - f - g + h; return -1.0+2.0*(k0 + k1*u.x + k2*u.y + k3*u.z + k4*u.x*u.y + k5*u.y*u.z + k6*u.z*u.x + k7*u.x*u.y*u.z); } vec3 noised( in vec2 x ) { vec2 p = floor(x); vec2 w = fract(x); vec2 u = w*w*w*(w*(w*6.0-15.0)+10.0); vec2 du = 30.0*w*w*(w*(w-2.0)+1.0); float a = hash1(p+vec2(0,0)); float b = hash1(p+vec2(1,0)); float c = hash1(p+vec2(0,1)); float d = hash1(p+vec2(1,1)); float k0 = a; float k1 = b - a; float k2 = c - a; float k4 = a - b - c + d; return vec3( -1.0+2.0*(k0 + k1*u.x + k2*u.y + k4*u.x*u.y), 2.0* du * vec2( k1 + k4*u.y, k2 + k4*u.x ) ); } float noise( in vec2 x ) { vec2 p = floor(x); vec2 w = fract(x); vec2 u = w*w*w*(w*(w*6.0-15.0)+10.0); #if 0 p *= 0.3183099; float kx0 = 50.0*fract( p.x ); float kx1 = 50.0*fract( p.x+0.3183099 ); float ky0 = 50.0*fract( p.y ); float ky1 = 50.0*fract( p.y+0.3183099 ); float a = fract( kx0*ky0*(kx0+ky0) ); float b = fract( kx1*ky0*(kx1+ky0) ); float c = fract( kx0*ky1*(kx0+ky1) ); float d = fract( kx1*ky1*(kx1+ky1) ); #else float a = hash1(p+vec2(0,0)); float b = hash1(p+vec2(1,0)); float c = hash1(p+vec2(0,1)); float d = hash1(p+vec2(1,1)); #endif return -1.0+2.0*( a + (b-a)*u.x + (c-a)*u.y + (a - b - c + d)*u.x*u.y ); } //========================================================================================== // fbm constructions //========================================================================================== const mat3 m3 = mat3( 0.00, 0.80, 0.60, -0.80, 0.36, -0.48, -0.60, -0.48, 0.64 ); const mat3 m3i = mat3( 0.00, -0.80, -0.60, 0.80, 0.36, -0.48, 0.60, -0.48, 0.64 ); const mat2 m2 = mat2( 0.80, 0.60, -0.60, 0.80 ); const mat2 m2i = mat2( 0.80, -0.60, 0.60, 0.80 ); //------------------------------------------------------------------------------------------ float fbm_4( in vec3 x ) { float f = 2.0; float s = 0.5; float a = 0.0; float b = 0.5; for( int i=0; i<4; i++ ) { float n = noise(x); a += b*n; b *= s; x = f*m3*x; } return a; } vec4 fbmd_8( in vec3 x ) { float f = 1.92; float s = 0.5; float a = 0.0; float b = 0.5; vec3 d = vec3(0.0); mat3 m = mat3(1.0,0.0,0.0, 0.0,1.0,0.0, 0.0,0.0,1.0); for( int i=0; i<7; i++ ) { vec4 n = noised(x); a += b*n.x; // accumulate values d += b*m*n.yzw; // accumulate derivatives b *= s; x = f*m3*x; m = f*m3i*m; } return vec4( a, d ); } vec4 fbmd_4( in vec3 x ) { float f = 1.92; float s = 0.5; float a = 0.0; float b = 0.5; vec3 d = vec3(0.0); mat3 m = mat3(1.0,0.0,0.0, 0.0,1.0,0.0, 0.0,0.0,1.0); for( int i=0; i<4; i++ ) { vec4 n = noised(x); a += b*n.x; // accumulate values d += b*m*n.yzw; // accumulate derivatives b *= s; x = f*m3*x; m = f*m3i*m; } return vec4( a, d ); } float fbm_9( in vec2 x ) { float f = 1.9; float s = 0.55; float a = 0.0; float b = 0.5; for( int i=0; i<9; i++ ) { float n = noise(x); a += b*n; b *= s; x = f*m2*x; } return a; } vec3 fbmd_9( in vec2 x ) { float f = 1.9; float s = 0.55; float a = 0.0; float b = 0.5; vec2 d = vec2(0.0); mat2 m = mat2(1.0,0.0,0.0,1.0); for( int i=0; i<9; i++ ) { vec3 n = noised(x); a += b*n.x; // accumulate values d += b*m*n.yz; // accumulate derivatives b *= s; x = f*m2*x; m = f*m2i*m; } return vec3( a, d ); } float fbm_4( in vec2 x ) { float f = 1.9; float s = 0.55; float a = 0.0; float b = 0.5; for( int i=0; i<4; i++ ) { float n = noise(x); a += b*n; b *= s; x = f*m2*x; } return a; } float sum( vec3 v ) { return v.x+v.y+v.z; } vec4 hash4( vec2 p ) { return fract( sin(vec4(1.0+dot(p,vec2(37.0,17.0)), 2.0+dot(p,vec2(11.0,47.0)), 3.0+dot(p,vec2(41.0,29.0)), 4.0+dot(p,vec2(23.0,31.0))))*103.0); } float smootherstep(float a, float b, float x) { x = x * x * x * (x * (x * 6.0 - 15.0) + 10.0); return x * (b - a) + a; } uniform vec3 fogColour; uniform float fogDensity; uniform vec2 fogRange; uniform float fogTime; uniform float fade; uniform float flow; uniform sampler2DArray diffuseMap; uniform sampler2D noiseMap; varying vec3 vUV; varying vec3 vNormal; varying vec3 vColour; varying vec3 vWorldPosition; vec4 _FogWithHeight() { vec3 fogOrigin = cameraPosition; vec3 fogDirection = normalize(vWorldPosition - fogOrigin); float fogDepth = distance(vWorldPosition, fogOrigin); // vec3 noiseSampleCoord = vWorldPosition * 0.05 + vec3(0, fogTime * 0.5, 0); // float noiseSample = fbm_4(noiseSampleCoord + fbm_4(noiseSampleCoord)) * 0.5 + 0.5; // fogDepth *= mix(noiseSample, 1.0, saturate((fogDepth - 250.0) / 500.0)); fogDepth *= fogDepth; float heightFactor = 0.025; float fogFactor = heightFactor * exp(-fogOrigin.y * fogDensity) * ( 1.0 - exp(-fogDepth * fogDirection.y * fogDensity)) / fogDirection.y; fogFactor = saturate(fogFactor); return vec4(fogColour, fogFactor); } vec4 _Fog() { vec3 fogOrigin = cameraPosition; vec3 fogDirection = normalize(vWorldPosition - fogOrigin); float fogDepth = distance(vWorldPosition, fogOrigin); float fogFactor = saturate((fogDepth - fogRange.x) / fogRange.y); vec3 noiseSampleCoord = vWorldPosition * 0.05 + vec3(0, fogTime * 0.5, 0); float noiseSample = fbm_4(noiseSampleCoord + fbm_4(noiseSampleCoord)) * 0.5 + 0.5; float noiseDropoff = saturate((fogDepth - fogRange.x) / fogRange.y); noiseDropoff *= noiseDropoff; noiseDropoff = mix(noiseSample, 1.0, noiseDropoff); fogFactor *= noiseDropoff; vec3 fogColourWithNoise = fogColour * noiseDropoff; return vec4(fogColourWithNoise, smootherstep(0.0, 1.0, fogFactor)); } void main() { vec4 diffuse = sRGBToLinear(texture2D(diffuseMap, vUV)); vec3 hemiLight1 = vec3(1.0, 1.0, 1.0); vec3 hemiLight2 = vec3(0.5, 0.1, 0.5); vec3 sunLightDir = normalize(vec3(0.1, 1.0, 0.0)); vec3 lighting = saturate(dot(vNormal, sunLightDir)) * 0.25 + vColour * 1.0; vec4 outColour = vec4(diffuse.xyz * lighting, 0.75 * fade); vec3 noiseDir = abs(vNormal); vec2 noiseCoords = ( noiseDir.x * vWorldPosition.yz + noiseDir.y * vWorldPosition.xz + noiseDir.z * vWorldPosition.xy); vec4 noisePixel = texture2D(noiseMap, noiseCoords / 64.0) * 0.2 + 0.8; outColour.xyz *= noisePixel.xyz; vec4 fog = _FogWithHeight(); outColour.xyz = mix(outColour.xyz, fog.xyz, fog.w); gl_FragColor = outColour; } `},CLOUD:{VS:` precision mediump float; // Attributes, declared by three.js // attribute vec3 position; // attribute vec3 normal; // attribute vec2 uv; // Outputs varying vec3 vWorldPosition; varying vec3 vNormal; #define saturate(a) clamp( a, 0.0, 1.0 ) void main(){ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz; vNormal = normal; } `,PS:` precision mediump float; precision mediump sampler2DArray; varying vec3 vWorldPosition; varying vec3 vNormal; uniform vec3 cloudMin; uniform vec3 cloudMax; #define saturate(a) clamp( a, 0.0, 1.0 ) // https://gist.github.com/DomNomNom/46bb1ce47f68d255fd5d float GetAABBDepth(vec3 rayOrigin, vec3 rayDir, vec3 boxMin, vec3 boxMax) { vec3 tMin = (boxMin - rayOrigin) / rayDir; vec3 tMax = (boxMax - rayOrigin) / rayDir; vec3 t1 = min(tMin, tMax); vec3 t2 = max(tMin, tMax); float tNear = max(max(t1.x, t1.y), t1.z); float tFar = min(min(t2.x, t2.y), t2.z); return (tFar - tNear); } vec4 GetCloudShading(vec3 rayOrigin, vec3 rayDir, vec3 boxMin, vec3 boxMax) { float depth = GetAABBDepth(rayOrigin, rayDir, boxMin, boxMax); float cloudDensity = 0.01; float opacity = 1.0 - exp(-cloudDensity * cloudDensity * depth * depth); vec3 sunDir = normalize(vec3(-1.0, -4.0, 0.0)); return vec4(vec3(saturate(dot(sunDir, vNormal)) + 0.75), opacity); } float sdBox( vec3 p, vec3 b, float r ) { vec3 d = abs(p) - b; return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0)) - r; } float map( in vec3 pos ) { return sdBox(pos, (cloudMax - cloudMin) * 0.25, 0.0); } // http://iquilezles.org/www/articles/normalsSDF/normalsSDF.htm vec3 calcNormal( in vec3 pos ) { // inspired by tdhooper and klems - a way to prevent the compiler from inlining map() 4 times vec3 n = vec3(0.0); for( int i=0; i<4; i++ ) { vec3 e = 0.5773*(2.0*vec3((((i+3)>>1)&1),((i>>1)&1),(i&1))-1.0); n += e*map(pos+0.0005*e); } return normalize(n); } void main() { vec3 fixedPosition = (cloudMax + cloudMin) * 0.5; vec3 viewDirection = normalize(vWorldPosition - cameraPosition); vec4 cloudColour = GetCloudShading(cameraPosition, viewDirection, cloudMin, cloudMax); gl_FragColor = cloudColour; } `},SUN:{VS:` precision mediump float; // Attributes, declared by three.js // attribute vec3 position; // attribute vec3 normal; // attribute vec2 uv; // Outputs varying vec3 vWorldPosition; varying vec2 vUV; #define saturate(a) clamp( a, 0.0, 1.0 ) void main(){ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); vUV = uv; } `,PS:` precision mediump float; precision mediump sampler2DArray; varying vec3 vWorldPosition; varying vec2 vUV; #define saturate(a) clamp( a, 0.0, 1.0 ) float sdCircle( vec2 p, float r ) { return length(p) - r; } float sdf_Box(vec2 coords, vec2 bounds) { vec2 dist = abs(coords) - bounds; return length(max(dist, 0.0)) + min(max(dist.x, dist.y), 0.0); } float smootherstep(float a, float b, float x) { x = clamp((x - a) / (b - a), 0.0, 1.0); return x * x * x * (x * ( x * 6.0 - 15.0) + 10.0); } float hash1( vec2 p ) { p = 50.0*fract( p*0.3183099 ); return fract( p.x*p.y*(p.x+p.y) ); } float noise( in vec2 x ) { vec2 p = floor(x); vec2 w = fract(x); vec2 u = w*w*w*(w*(w*6.0-15.0)+10.0); float a = hash1(p+vec2(0,0)); float b = hash1(p+vec2(1,0)); float c = hash1(p+vec2(0,1)); float d = hash1(p+vec2(1,1)); return -1.0+2.0*( a + (b-a)*u.x + (c-a)*u.y + (a - b - c + d)*u.x*u.y ); } void main() { vec2 uvStepped = floor(vUV * 32.0) / 32.0; float sunRadius = 0.125; //float d = 1.0 - clamp(sdCircle(uvStepped - 0.5, sunRadius) / (0.5 - sunRadius), 0.0, 1.0); float d = 1.0 - clamp(sdf_Box(uvStepped - 0.5, vec2(sunRadius)) / (0.5 - sunRadius), 0.0, 1.0); float noiseValue = noise(uvStepped * 32.0) * 0.1 + 0.9; vec4 core = sRGBToLinear(vec4(0.96, 0.9, 0.7, 1.0)); vec4 corona = sRGBToLinear(vec4(0.5, 0.2, 0.05, 1.0)) * noiseValue; vec4 sunColour = mix(corona, core, d * d); gl_FragColor = vec4(sunColour.xyz, d); } `},PLACEMENT:{VS:` precision mediump float; // Attributes, declared by three.js // attribute vec3 position; // attribute vec3 normal; // attribute vec2 uv; // Outputs varying vec2 vUV; void main(){ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); vUV = uv; } `,PS:` precision mediump float; precision mediump sampler2DArray; uniform float time; uniform vec3 edgeColour; #define saturate(a) clamp( a, 0.0, 1.0 ) varying vec2 vUV; float sdf_Box(vec2 coords, vec2 bounds) { vec2 dist = abs(coords) - bounds; return length(max(dist, 0.0)) + min(max(dist.x, dist.y), 0.0); } float smootherstep(float a, float b, float x) { x = clamp((x - a) / (b - a), 0.0, 1.0); return x * x * x * (x * ( x * 6.0 - 15.0) + 10.0); } void main() { float d = sdf_Box(vUV - 0.5, vec2(0.5)); float s = smoothstep(0.0, 0.1, abs(d)); float edgeColouring = mix(0.0, 1.0, 1.0 - s); float blink = clamp(sin(time * 10.0), 0.0, 1.0) * 0.1 + 0.9; gl_FragColor = vec4(edgeColour, edgeColouring * blink); } `}}))(),Dg=(()=>{function e(i){var n=document.createElement("canvas");n.width=i.width,n.height=i.height;var r=n.getContext("2d");return r.drawImage(i,0,0),r.getImageData(0,0,i.width,i.height)}class t{constructor(){this.Create_(),this.onLoad=()=>{}}Load(n,r){this.LoadAtlas_(n,r)}Create_(){this.manager_=new Jl,this.loader_=new Wn(this.manager_),this.textures_={},this.manager_.onLoad=()=>{this.OnLoad_()}}get Info(){return this.textures_}LoadTexture_(n){const r=this.loader_.load(n);return r.encoding=Vi,r}OnLoad_(){for(let n in this.textures_){const r=this.textures_[n],o=new Uint8Array(r.textures.length*4*16*16);for(let a=0;athis.LoadTexture_(o)),atlas:null}}}return{TextureAtlas:t}})(),la=(()=>({DEFS:{ocean:{colour:new he(16777215),texture:"ocean.png"},dirt:{colour:new he(16777215),texture:"dirt.png"},sand:{colour:new he(16777215),texture:"sand.png"},stone:{colour:new he(16777215),texture:"stone.png"},tree_bark:{colour:new he(16777215),texture:"tree-bark.png"},tree_leaves:{colour:new he(16777215),texture:"tree-leaves.png"},moon:{colour:new he(16777215),texture:"moon.png"},snow:{colour:new he(16777215),texture:["snow-side.png","snow-side.png","snow.png","snow.png","snow-side.png","snow-side.png"]},grass:{colour:new he(16777215),texture:["grass-side.png","grass-side.png","grass.png","dirt.png","grass-side.png","grass-side.png"]}}}))(),Ug=(()=>{const t=class t extends Ut.Component{get NAME(){return t.CLASS_NAME}constructor(n){super(),this.blocks_={},this.cellDimensions_=new A(n.cellSize,n.cellSize,n.cellSize),this.visibleDimensions_=[n.worldSize,n.worldSize],this.dirtyBlocks_={},this.ids_=0,this.totalTime_=0}InitEntity(){this.scene_=this.FindEntity("renderer").GetComponent("ThreeJSController").scene_,this.materialOpaque_=new Qe({uniforms:{diffuseMap:{value:null},noiseMap:{value:null},fogColour:{value:_t.FOG_COLOUR.clone()},fogDensity:{value:65e-6},fogRange:{value:new le(250,250)},fogTime:{value:0},fade:{value:1},flow:{value:0}},vertexShader:si.VOXEL.VS,fragmentShader:si.VOXEL.PS,side:Gt}),this.materialTransparent_=this.materialOpaque_.clone(),this.materialTransparent_.side=Gt,this.materialTransparent_.transparent=!0,this.LoadTextures_(),this.builder_=new Og.VoxelBuilder_Threaded({scene:this.scene_,dimensions:this.cellDimensions_,materialOpaque:this.materialOpaque_,materialTransparent:this.materialTransparent_,blockTypes:this.blockTypes_})}LoadTextures_(){this.blockTypes_={};const n=new Set;for(let l in la.DEFS){const c=la.DEFS[l];if(this.blockTypes_[l]={textures:[]},c.texture instanceof Array)for(let h=0;ho+l)),s.onLoad=()=>{this.materialOpaque_.uniforms.diffuseMap.value=s.Info.diffuse.atlas,this.materialTransparent_.uniforms.diffuseMap.value=s.Info.diffuse.atlas};const a=new Wn().load("./resources/simplex-noise.png");a.wrapS=Mi,a.wrapT=Mi,a.minFilter=Ta,a.magFilter=rt,this.materialOpaque_.uniforms.noiseMap.value=a,this.materialTransparent_.uniforms.noiseMap.value=a}Key_(n,r,o){return n+"."+r+"."+o}BlockIndex_(n,r){const o=Math.floor(n/this.cellDimensions_.x),s=Math.floor(r/this.cellDimensions_.z);return[o,s]}FindBlock_(n,r){const[o,s]=this.BlockIndex_(n,r),a=this.Key_(o,0,s);return a in this.blocks_?this.blocks_[a]:null}GetAdjacentBlocks(n,r){const o=[];for(let s=-1;s<=1;++s)for(let a=-1;a<=1;++a){if(s==0&&a==0)continue;const[l,c]=this.BlockIndex_(n,r),h=this.Key_(l+s,0,c+a);h in this.blocks_&&o.push(this.blocks_[h])}return o}InsertVoxelAt(n,r,o){const s=this.FindBlock_(n[0],n[2]);s&&s.InsertVoxelAt(n,r,o)}RemoveVoxelAt(n){const r=this.FindBlock_(n[0],n[2]);r&&r.RemoveVoxelAt(n)}HasVoxelAt(n,r,o){const s=this.FindBlock_(n,o);return s?s.HasVoxelAt(n,r,o):!1}FindVoxelsNear(n,r){const[o,s]=this.BlockIndex_(n.x-r,n.z-r),[a,l]=this.BlockIndex_(n.x+r,n.z+r),c=[];for(let h=o;h<=a;h++)for(let u=s;u<=l;u++){const d=this.Key_(h,0,u);if(d in this.blocks_){const f=this.blocks_[d];c.push(...f.FindVoxelsNear(n,r))}}return c}FindIntersectionsWithRay(n,r){const o=this.FindVoxelsNear(n.origin,r),s=[],a=h=>{const u=new A(h.position[0],h.position[1],h.position[2]),d=new A(.5,.5,.5),f=new A;f.copy(u),f.sub(d);const m=new A;return m.copy(u),m.add(d),new dt(f,m)},l=o.map(h=>a(h)),c=new A;for(let h=0;hh.distance-u.distance),s}Update(n){this.builder_.Update(n),this.builder_.Busy||this.UpdateTerrain_(),this.totalTime_+=n,this.materialOpaque_.uniforms.fogTime.value=this.totalTime_*.5,this.materialTransparent_.uniforms.fogTime.value=this.totalTime_*.5,this.materialTransparent_.uniforms.flow.value=this.totalTime_*.5;const r=this.FindEntity("renderer").GetComponent("ThreeJSController");r.sky_.material.uniforms.whiteBlend.value=this.builder_.currentTime_,this.FindEntity("player").Position.y<6&&!Fr.skipOceans?(this.materialOpaque_.uniforms.fogRange.value.set(..._t.UNDERWATER_RANGE),this.materialTransparent_.uniforms.fogRange.value.set(..._t.UNDERWATER_RANGE),this.materialOpaque_.uniforms.fogColour.value.copy(_t.UNDERWATER_COLOUR),this.materialTransparent_.uniforms.fogColour.value.copy(_t.UNDERWATER_COLOUR),r.sky_.material.uniforms.bottomColor.value.copy(_t.UNDERWATER_COLOUR)):(this.materialOpaque_.uniforms.fogRange.value.set(..._t.FOG_RANGE),this.materialTransparent_.uniforms.fogRange.value.set(..._t.FOG_RANGE),this.materialOpaque_.uniforms.fogColour.value.copy(_t.FOG_COLOUR),this.materialTransparent_.uniforms.fogColour.value.copy(_t.FOG_COLOUR),r.sky_.material.uniforms.bottomColor.value.copy(_t.FOG_COLOUR)),r.sky_.material.needsUpdate=!0,this.materialOpaque_.needsUpdate=!0,this.materialTransparent_.needsUpdate=!0}UpdateTerrain_(){const n=this.FindEntity("player"),r=this.BlockIndex_(n.Position.x,n.Position.z),o=this.visibleDimensions_[0],s=this.visibleDimensions_[1];let a={};for(let d=-o;d<=o;d++)for(let f=-s;f<=s;f++){const m=d+r[0],v=f+r[1],_=this.Key_(m,0,v);a[_]=[m,v]}const l=sa.DictIntersection(this.blocks_,a),c=sa.DictDifference(a,this.blocks_),h=Object.values(sa.DictDifference(this.blocks_,a));this.builder_.ScheduleDestroy(h),a=l;const u=[];for(let d in c){const[f,m]=c[d],v=((r[0]-f)**2+(r[1]-m)**2)**.5;u.push([v,d,c[d]])}u.sort((d,f)=>d[0]-f[0]);for(let d=0;d{class e{constructor(){this._ids=0,this._entitiesMap={},this._entities=[]}_GenerateName(){return this._ids+=1,"__name__"+this._ids}Get(i){return this._entitiesMap[i]}Filter(i){return this._entities.filter(i)}Add(i,n){n||(n=this._GenerateName()),this._entitiesMap[n]=i,this._entities.push(i),i.SetParent(this),i.SetName(n),i.InitEntity()}SetActive(i,n){const r=this._entities.indexOf(i);if(n){if(r>=0)return;this._entities.push(i)}else{if(r<0)return;this._entities.splice(r,1)}}Update(i){const n=[],r=[];for(let o=0;o{const t=class t extends Ut.Component{get NAME(){return t.CLASS_NAME}constructor(){super()}InitEntity(){this.radius_=1.5,this.keys_={forward:!1,backward:!1,left:!1,right:!1},this.standing=!0,this.velocity_=new A(0,0,0),this.decceleration_=new A(-10,-9.8*5,-10),this.acceleration_=new A(75,20,75),this.acceleration_=new A(200,25,200);const n=this.FindEntity("renderer").GetComponent("ThreeJSController");this.element_=n.threejs_.domElement,this.camera_=n.camera_,this.SetupPointerLock_(),this.controls_=new Do(this.camera_,document.body),n.scene_.add(this.controls_.getObject()),this.controls_.getObject().position.copy(this.Parent.Position),document.addEventListener("keydown",r=>this.OnKeyDown_(r),!1),document.addEventListener("keyup",r=>this.OnKeyUp_(r),!1)}OnKeyDown_(n){switch(n.keyCode){case 38:case 87:this.keys_.forward=!0;break;case 37:case 65:this.keys_.left=!0;break;case 40:case 83:this.keys_.backward=!0;break;case 39:case 68:this.keys_.right=!0;break;case 32:this.standing&&(this.velocity_.y=this.acceleration_.y,this.standing=!1);break}}OnKeyUp_(n){switch(n.keyCode){case 38:case 87:this.keys_.forward=!1;break;case 37:case 65:this.keys_.left=!1;break;case 40:case 83:this.keys_.backward=!1;break;case 39:case 68:this.keys_.right=!1;break;case 79:break;case 80:break;case 84:this.OnCycleTools_();break;case 219:this.OnCycleTextures_(-1);break;case 221:this.OnCycleTextures_(1);break;case 13:this.keys_.enter=!0;break}}_onMouseUp(n){this.keys_.enter=!0}SetupPointerLock_(){if("pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document){const n=o=>{document.pointerLockElement===document.body||document.mozPointerLockElement===document.body||document.webkitPointerLockElement===document.body?(this.enabled_=!0,this.controls_.enabled=!0):this.controls_.enabled=!1},r=o=>{console.log(o)};document.addEventListener("pointerlockchange",n,!1),document.addEventListener("webkitpointerlockchange",n,!1),document.addEventListener("mozpointerlockchange",n,!1),document.addEventListener("pointerlockerror",r,!1),document.addEventListener("mozpointerlockerror",r,!1),document.addEventListener("webkitpointerlockerror",r,!1),this.element_.addEventListener("click",o=>{if(document.body.requestPointerLock=document.body.requestPointerLock||document.body.mozRequestPointerLock||document.body.webkitRequestPointerLock,/Firefox/i.test(navigator.userAgent)){const s=a=>{(document.fullscreenElement===document.body||document.mozFullscreenElement===document.body||document.mozFullScreenElement===document.body)&&(document.removeEventListener("fullscreenchange",s),document.removeEventListener("mozfullscreenchange",s),document.body.requestPointerLock())};document.addEventListener("fullscreenchange",s,!1),document.addEventListener("mozfullscreenchange",s,!1),document.body.requestFullscreen=document.body.requestFullscreen||document.body.mozRequestFullscreen||document.body.mozRequestFullScreen||document.body.webkitRequestFullscreen,document.body.requestFullscreen()}else document.body.requestPointerLock()},!1)}}_FindIntersections(n,r){const o=new Zt(r,this.radius_);return n.filter(s=>o.intersectsBox(s))}OnCycleTools_(){this.FindEntity("ui").GetComponent("UIController").CycleTool_()}OnCycleTextures_(n){this.FindEntity("ui").GetComponent("UIController").CycleBuildIcon_(n)}Update(n){const r=this.controls_.getObject();this.keys_.enter&&this.Broadcast({topic:"input.pressed",value:"enter"}),this.keys_.enter=!1;const o=this.velocity_,s=new A(this.velocity_.x*this.decceleration_.x,this.decceleration_.y,this.velocity_.z*this.decceleration_.z);s.multiplyScalar(n),s.z=Math.sign(s.z)*Math.min(Math.abs(s.z),Math.abs(o.z)),this.velocity_.add(s),this.velocity_.y=Math.max(this.velocity_.y,-50),this.keys_.forward&&(this.velocity_.z-=this.acceleration_.z*n),this.keys_.backward&&(this.velocity_.z+=this.acceleration_.z*n),this.keys_.left&&(this.velocity_.x-=this.acceleration_.x*n),this.keys_.right&&(this.velocity_.x+=this.acceleration_.x*n);const a=this.FindEntity("voxels").GetComponent("SparseVoxelCellManager").FindVoxelsNear(r.position,3).filter(g=>g.type!="ocean"),l=g=>{const p=new A(g.position[0],g.position[1],g.position[2]),E=new A(.5,.5,.5),S=new A;S.copy(p),S.sub(E);const T=new A;return T.copy(p),T.add(E),new dt(S,T)},c=a.map(g=>l(g)),h=new A;h.copy(r.position);const u=new A(0,0,1);u.applyQuaternion(r.quaternion),u.y=0,u.normalize();const d=new A(1,0,0);d.applyQuaternion(r.quaternion),d.normalize(),d.multiplyScalar(this.velocity_.x*n),u.multiplyScalar(this.velocity_.z*n);const f=this._FindIntersections(c,r.position).length>0;r.position.add(u),r.position.add(d);let m=this._FindIntersections(c,r.position);m.length>0&&!f&&r.position.copy(h),h.copy(r.position);const v=.01;let _=v;for(;_0){r.position.copy(h),this.velocity_.y=Math.max(0,this.velocity_.y),this.standing=!0;break}_=Math.min(_+v,n)}r.position.y<-100&&(this.velocity_.y=0,r.position.y=250,this.standing=!0),this.Parent.SetPosition(r.position),this.Parent.SetQuaternion(r.quaternion)}};wi(t,"CLASS_NAME","PlayerController");let e=t;return{PlayerController:e}})();var Bg=function(){function e(M){Ue.call(this,M),this.dracoLoader=null,this.ddsLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(w){return new s(w)}),this.register(function(w){return new l(w)}),this.register(function(w){return new c(w)}),this.register(function(w){return new a(w)}),this.register(function(w){return new r(w)}),this.register(function(w){return new h(w)})}e.prototype=Object.assign(Object.create(Ue.prototype),{constructor:e,load:function(M,w,O,P){var F=this,R;this.resourcePath!==""?R=this.resourcePath:this.path!==""?R=this.path:R=Yn.extractUrlBase(M),this.manager.itemStart(M);var N=function(V){P?P(V):console.error(V),F.manager.itemError(M),F.manager.itemEnd(M)},I=new Yt(this.manager);I.setPath(this.path),I.setResponseType("arraybuffer"),I.setRequestHeader(this.requestHeader),I.setWithCredentials(this.withCredentials),I.load(M,function(V){try{F.parse(V,R,function(X){w(X),F.manager.itemEnd(M)},N)}catch(X){N(X)}},O,N)},setDRACOLoader:function(M){return this.dracoLoader=M,this},setDDSLoader:function(M){return this.ddsLoader=M,this},setKTX2Loader:function(M){return this.ktx2Loader=M,this},setMeshoptDecoder:function(M){return this.meshoptDecoder=M,this},register:function(M){return this.pluginCallbacks.indexOf(M)===-1&&this.pluginCallbacks.push(M),this},unregister:function(M){return this.pluginCallbacks.indexOf(M)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(M),1),this},parse:function(M,w,O,P){var F,R={},N={};if(typeof M=="string")F=M;else{var I=Yn.decodeText(new Uint8Array(M,0,4));if(I===u){try{R[i.KHR_BINARY_GLTF]=new m(M)}catch(q){P&&P(q);return}F=R[i.KHR_BINARY_GLTF].content}else F=Yn.decodeText(new Uint8Array(M))}var V=JSON.parse(F);if(V.asset===void 0||V.asset.version[0]<2){P&&P(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}var X=new ce(V,{path:w||this.resourcePath||"",crossOrigin:this.crossOrigin,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});X.fileLoader.setRequestHeader(this.requestHeader);for(var Q=0;Q=0&&N[y]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+y+'".')}}X.setExtensions(R),X.setPlugins(N),X.parse(O,P)}});function t(){var M={};return{get:function(w){return M[w]},add:function(w,O){M[w]=O},remove:function(w){delete M[w]},removeAll:function(){M={}}}}var i={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",MSFT_TEXTURE_DDS:"MSFT_texture_dds"};function n(M){if(!M)throw new Error("THREE.GLTFLoader: Attempting to load .dds texture without importing DDSLoader");this.name=i.MSFT_TEXTURE_DDS,this.ddsLoader=M}function r(M){this.parser=M,this.name=i.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}r.prototype._markDefs=function(){for(var M=this.parser,w=this.parser.json.nodes||[],O=0,P=w.length;O=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return w.loadTextureImage(M,R,N)};function c(M){this.parser=M,this.name=i.EXT_TEXTURE_WEBP,this.isSupported=null}c.prototype.loadTexture=function(M){var w=this.name,O=this.parser,P=O.json,F=P.textures[M];if(!F.extensions||!F.extensions[w])return null;var R=F.extensions[w],N=P.images[R.source],I=N.uri?O.options.manager.getHandler(N.uri):O.textureLoader;return this.detectSupport().then(function(V){if(V)return O.loadTextureImage(M,N,I);if(P.extensionsRequired&&P.extensionsRequired.indexOf(w)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return O.loadTexture(M)})},c.prototype.detectSupport=function(){return this.isSupported||(this.isSupported=new Promise(function(M){var w=new Image;w.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",w.onload=w.onerror=function(){M(w.height===1)}})),this.isSupported};function h(M){this.name=i.EXT_MESHOPT_COMPRESSION,this.parser=M}h.prototype.loadBufferView=function(M){var w=this.parser.json,O=w.bufferViews[M];if(O.extensions&&O.extensions[this.name]){var P=O.extensions[this.name],F=this.parser.getDependency("buffer",P.buffer),R=this.parser.options.meshoptDecoder;if(!R||!R.supported){if(w.extensionsRequired&&w.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([F,R.ready]).then(function(N){var I=P.byteOffset||0,V=P.byteLength||0,X=P.count,Q=P.byteStride,b=new ArrayBuffer(X*Q),y=new Uint8Array(N[0],I,V);return R.decodeGltfBuffer(new Uint8Array(b),X,Q,y,P.mode,P.filter),b})}else return null};var u="glTF",d=12,f={JSON:1313821514,BIN:5130562};function m(M){this.name=i.KHR_BINARY_GLTF,this.content=null,this.body=null;var w=new DataView(M,0,d);if(this.header={magic:Yn.decodeText(new Uint8Array(M.slice(0,4))),version:w.getUint32(4,!0),length:w.getUint32(8,!0)},this.header.magic!==u)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");for(var O=this.header.length-d,P=new DataView(M,d),F=0;F",w).replace("#include ",O).replace("#include ",P).replace("#include ",F).replace("#include ",R)},Object.defineProperties(this,{specular:{get:function(){return N.specular.value},set:function(I){N.specular.value=I}},specularMap:{get:function(){return N.specularMap.value},set:function(I){N.specularMap.value=I,I?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return N.glossiness.value},set:function(I){N.glossiness.value=I}},glossinessMap:{get:function(){return N.glossinessMap.value},set:function(I){N.glossinessMap.value=I,I?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(M)}g.prototype=Object.create(Mt.prototype),g.prototype.constructor=g,g.prototype.copy=function(M){return Mt.prototype.copy.call(this,M),this.specularMap=M.specularMap,this.specular.copy(M.specular),this.glossinessMap=M.glossinessMap,this.glossiness=M.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this};function p(){return{name:i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,specularGlossinessParams:["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"],getMaterialType:function(){return g},extendParams:function(M,w,O){var P=w.extensions[this.name];M.color=new he(1,1,1),M.opacity=1;var F=[];if(Array.isArray(P.diffuseFactor)){var R=P.diffuseFactor;M.color.fromArray(R),M.opacity=R[3]}if(P.diffuseTexture!==void 0&&F.push(O.assignTexture(M,"map",P.diffuseTexture)),M.emissive=new he(0,0,0),M.glossiness=P.glossinessFactor!==void 0?P.glossinessFactor:1,M.specular=new he(1,1,1),Array.isArray(P.specularFactor)&&M.specular.fromArray(P.specularFactor),P.specularGlossinessTexture!==void 0){var N=P.specularGlossinessTexture;F.push(O.assignTexture(M,"glossinessMap",N)),F.push(O.assignTexture(M,"specularMap",N))}return Promise.all(F)},createMaterial:function(M){var w=new g(M);return w.fog=!0,w.color=M.color,w.map=M.map===void 0?null:M.map,w.lightMap=null,w.lightMapIntensity=1,w.aoMap=M.aoMap===void 0?null:M.aoMap,w.aoMapIntensity=1,w.emissive=M.emissive,w.emissiveIntensity=1,w.emissiveMap=M.emissiveMap===void 0?null:M.emissiveMap,w.bumpMap=M.bumpMap===void 0?null:M.bumpMap,w.bumpScale=1,w.normalMap=M.normalMap===void 0?null:M.normalMap,w.normalMapType=Wi,M.normalScale&&(w.normalScale=M.normalScale),w.displacementMap=null,w.displacementScale=1,w.displacementBias=0,w.specularMap=M.specularMap===void 0?null:M.specularMap,w.specular=M.specular,w.glossinessMap=M.glossinessMap===void 0?null:M.glossinessMap,w.glossiness=M.glossiness,w.alphaMap=null,w.envMap=M.envMap===void 0?null:M.envMap,w.envMapIntensity=1,w.refractionRatio=.98,w}}}function E(){this.name=i.KHR_MESH_QUANTIZATION}function S(M,w,O,P){Tt.call(this,M,w,O,P)}S.prototype=Object.create(Tt.prototype),S.prototype.constructor=S,S.prototype.copySampleValue_=function(M){for(var w=this.resultBuffer,O=this.sampleValues,P=this.valueSize,F=M*P*3+P,R=0;R!==P;R++)w[R]=O[F+R];return w},S.prototype.beforeStart_=S.prototype.copySampleValue_,S.prototype.afterEnd_=S.prototype.copySampleValue_,S.prototype.interpolate_=function(M,w,O,P){for(var F=this.resultBuffer,R=this.sampleValues,N=this.valueSize,I=N*2,V=N*3,X=P-w,Q=(O-w)/X,b=Q*Q,y=b*Q,J=M*V,q=J-V,z=-2*y+3*b,te=y-b,re=1-z,ue=te-b+Q,se=0;se!==N;se++){var ge=R[q+se+N],ve=R[q+se+I]*X,be=R[J+se+N],pe=R[J+se]*X;F[se]=re*ge+ue*ve+z*be+te*pe}return F};var T={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},x={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},L={9728:rt,9729:qe,9984:jo,9985:Ma,9986:Xo,9987:an},W={33071:ut,33648:Dr,10497:Mi},U={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},B={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},H={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},j={CUBICSPLINE:void 0,LINEAR:ln,STEP:or},G={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function D(M,w){return typeof M!="string"||M===""?"":(/^https?:\/\//i.test(w)&&/^\//.test(M)&&(w=w.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(M)||/^data:.*,.*$/i.test(M)||/^blob:.*$/i.test(M)?M:w+M)}function k(M){return M.DefaultMaterial===void 0&&(M.DefaultMaterial=new Mt({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Gt})),M.DefaultMaterial}function Y(M,w,O){for(var P in O.extensions)M[P]===void 0&&(w.userData.gltfExtensions=w.userData.gltfExtensions||{},w.userData.gltfExtensions[P]=O.extensions[P])}function Z(M,w){w.extras!==void 0&&(typeof w.extras=="object"?Object.assign(M.userData,w.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+w.extras))}function $(M,w,O){for(var P=!1,F=!1,R=0,N=w.length;R=2&&z.setY(ct,_e[Te*I+1]),I>=3&&z.setZ(ct,_e[Te*I+2]),I>=4&&z.setW(ct,_e[Te*I+3]),I>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return z})},ce.prototype.loadTexture=function(M){var w=this,O=this.json,P=this.options,F=O.textures[M],R=F.extensions||{},N;R[i.MSFT_TEXTURE_DDS]?N=O.images[R[i.MSFT_TEXTURE_DDS].source]:N=O.images[F.source];var I;return N.uri&&(I=P.manager.getHandler(N.uri)),I||(I=R[i.MSFT_TEXTURE_DDS]?w.extensions[i.MSFT_TEXTURE_DDS].ddsLoader:this.textureLoader),this.loadTextureImage(M,N,I)},ce.prototype.loadTextureImage=function(M,w,O){var P=this,F=this.json,R=this.options,N=F.textures[M],I=self.URL||self.webkitURL,V=w.uri,X=!1,Q=!0;return w.mimeType==="image/jpeg"&&(Q=!1),w.bufferView!==void 0&&(V=P.getDependency("bufferView",w.bufferView).then(function(b){if(w.mimeType==="image/png"){var y=new DataView(b,25,1).getUint8(0,!1);Q=y===6||y===4||y===3}X=!0;var J=new Blob([b],{type:w.mimeType});return V=I.createObjectURL(J),V})),Promise.resolve(V).then(function(b){return new Promise(function(y,J){var q=y;O.isImageBitmapLoader===!0&&(q=function(z){y(new Ar(z))}),O.load(D(b,R.path),q,void 0,J)})}).then(function(b){X===!0&&I.revokeObjectURL(V),b.flipY=!1,N.name&&(b.name=N.name),Q||(b.format=Ti);var y=F.samplers||{},J=y[N.sampler]||{};return b.magFilter=L[J.magFilter]||qe,b.minFilter=L[J.minFilter]||an,b.wrapS=W[J.wrapS]||Mi,b.wrapT=W[J.wrapT]||Mi,P.associations.set(b,{type:"textures",index:M}),b})},ce.prototype.assignTexture=function(M,w,O){var P=this;return this.getDependency("texture",O.index).then(function(F){if(O.texCoord!==void 0&&O.texCoord!=0&&!(w==="aoMap"&&O.texCoord==1)&&console.warn("THREE.GLTFLoader: Custom UV set "+O.texCoord+" for texture "+w+" not yet supported."),P.extensions[i.KHR_TEXTURE_TRANSFORM]){var R=O.extensions!==void 0?O.extensions[i.KHR_TEXTURE_TRANSFORM]:void 0;if(R){var N=P.associations.get(F);F=P.extensions[i.KHR_TEXTURE_TRANSFORM].extendTexture(F,R),P.associations.set(F,N)}}M[w]=F})},ce.prototype.assignFinalMaterial=function(M){var w=M.geometry,O=M.material,P=w.attributes.tangent!==void 0,F=w.attributes.color!==void 0,R=w.attributes.normal===void 0,N=M.isSkinnedMesh===!0,I=Object.keys(w.morphAttributes).length>0,V=I&&w.morphAttributes.normal!==void 0;if(M.isPoints){var X="PointsMaterial:"+O.uuid,Q=this.cache.get(X);Q||(Q=new Di,Me.prototype.copy.call(Q,O),Q.color.copy(O.color),Q.map=O.map,Q.sizeAttenuation=!1,this.cache.add(X,Q)),O=Q}else if(M.isLine){var X="LineBasicMaterial:"+O.uuid,b=this.cache.get(X);b||(b=new Rt,Me.prototype.copy.call(b,O),b.color.copy(O.color),this.cache.add(X,b)),O=b}if(P||F||R||N||I){var X="ClonedMaterial:"+O.uuid+":";O.isGLTFSpecularGlossinessMaterial&&(X+="specular-glossiness:"),N&&(X+="skinning:"),P&&(X+="vertex-tangents:"),F&&(X+="vertex-colors:"),R&&(X+="flat-shading:"),I&&(X+="morph-targets:"),V&&(X+="morph-normals:");var y=this.cache.get(X);y||(y=O.clone(),N&&(y.skinning=!0),F&&(y.vertexColors=!0),R&&(y.flatShading=!0),I&&(y.morphTargets=!0),V&&(y.morphNormals=!0),P&&(y.vertexTangents=!0,y.normalScale&&(y.normalScale.y*=-1),y.clearcoatNormalScale&&(y.clearcoatNormalScale.y*=-1)),this.cache.add(X,y),this.associations.set(y,this.associations.get(O))),O=y}O.aoMap&&w.attributes.uv2===void 0&&w.attributes.uv!==void 0&&w.setAttribute("uv2",w.attributes.uv),M.material=O},ce.prototype.getMaterialType=function(){return Mt},ce.prototype.loadMaterial=function(M){var w=this,O=this.json,P=this.extensions,F=O.materials[M],R,N={},I=F.extensions||{},V=[];if(I[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var X=P[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];R=X.getMaterialType(),V.push(X.extendParams(N,F,w))}else if(I[i.KHR_MATERIALS_UNLIT]){var Q=P[i.KHR_MATERIALS_UNLIT];R=Q.getMaterialType(),V.push(Q.extendParams(N,F,w))}else{var b=F.pbrMetallicRoughness||{};if(N.color=new he(1,1,1),N.opacity=1,Array.isArray(b.baseColorFactor)){var y=b.baseColorFactor;N.color.fromArray(y),N.opacity=y[3]}b.baseColorTexture!==void 0&&V.push(w.assignTexture(N,"map",b.baseColorTexture)),N.metalness=b.metallicFactor!==void 0?b.metallicFactor:1,N.roughness=b.roughnessFactor!==void 0?b.roughnessFactor:1,b.metallicRoughnessTexture!==void 0&&(V.push(w.assignTexture(N,"metalnessMap",b.metallicRoughnessTexture)),V.push(w.assignTexture(N,"roughnessMap",b.metallicRoughnessTexture))),R=this._invokeOne(function(q){return q.getMaterialType&&q.getMaterialType(M)}),V.push(Promise.all(this._invokeAll(function(q){return q.extendMaterialParams&&q.extendMaterialParams(M,N)})))}F.doubleSided===!0&&(N.side=on);var J=F.alphaMode||G.OPAQUE;return J===G.BLEND?(N.transparent=!0,N.depthWrite=!1):(N.transparent=!1,J===G.MASK&&(N.alphaTest=F.alphaCutoff!==void 0?F.alphaCutoff:.5)),F.normalTexture!==void 0&&R!==vt&&(V.push(w.assignTexture(N,"normalMap",F.normalTexture)),N.normalScale=new le(1,-1),F.normalTexture.scale!==void 0&&N.normalScale.set(F.normalTexture.scale,-F.normalTexture.scale)),F.occlusionTexture!==void 0&&R!==vt&&(V.push(w.assignTexture(N,"aoMap",F.occlusionTexture)),F.occlusionTexture.strength!==void 0&&(N.aoMapIntensity=F.occlusionTexture.strength)),F.emissiveFactor!==void 0&&R!==vt&&(N.emissive=new he().fromArray(F.emissiveFactor)),F.emissiveTexture!==void 0&&R!==vt&&V.push(w.assignTexture(N,"emissiveMap",F.emissiveTexture)),Promise.all(V).then(function(){var q;return R===g?q=P[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(N):q=new R(N),F.name&&(q.name=F.name),q.map&&(q.map.encoding=Vi),q.emissiveMap&&(q.emissiveMap.encoding=Vi),Z(q,F),w.associations.set(q,{type:"materials",index:M}),F.extensions&&Y(P,q,F),q})},ce.prototype.createUniqueName=function(M){for(var w=gt.sanitizeNodeName(M||""),O=w,P=1;this.nodeNamesUsed[O];++P)O=w+"_"+P;return this.nodeNamesUsed[O]=!0,O};function ye(M,w,O){var P=w.attributes,F=new dt;if(P.POSITION!==void 0){var R=O.json.accessors[P.POSITION],N=R.min,I=R.max;if(N!==void 0&&I!==void 0)F.set(new A(N[0],N[1],N[2]),new A(I[0],I[1],I[2]));else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;var V=w.targets;if(V!==void 0){for(var X=new A,Q=new A,b=0,y=V.length;b0&&ne(ue,F),ue.name=w.createUniqueName(F.name||"mesh_"+M),Z(ue,F),re.extensions&&Y(P,ue,re),w.assignFinalMaterial(ue),J.push(ue)}if(J.length===1)return J[0];for(var ge=new ft,q=0,z=J.length;q1?I=new ft:N.length===1?I=N[0]:I=new we,I!==N[0])for(var V=0,X=N.length;V{const i=class i extends Ut.Component{get NAME(){return i.CLASS_NAME}constructor(){super(),this.voxelType_="stone",this.timer_=0,this.active_=!1}InitComponent(){this._RegisterHandler("input.pressed",o=>this.OnInput_(o)),this._RegisterHandler("ui.blockChanged",o=>this.OnBlockIcon_(o)),this._RegisterHandler("ui.toolChanged",o=>this.OnToolChanged_(o))}OnToolChanged_(o){o.value!="build"?this.LoseFocus():this.GainFocus()}LoseFocus(){this.voxelMeshGroup_.visible=!1,this.placementMesh_.visible=!1,this.active_=!1}GainFocus(){this.voxelMeshGroup_.visible=!0,this.placementMesh_.visible=!0,this.active_=!0}OnBlockIcon_(o){this.voxelType_=o.value,this.UpdateVoxelMesh_()}UpdateVoxelMesh_(){const o=this.FindEntity("voxels").GetComponent("SparseVoxelCellManager"),s=[],a=[];for(let l=0;l<6;++l)for(let c=0;c<4*3;++c)s.push(1,1,1),a.push(o.blockTypes_[this.voxelType_].textures[2]);this.voxelMesh_.geometry.setAttribute("colour",new Fe(s,3)),this.voxelMesh_.geometry.setAttribute("uvSlice",new Fe(a,1))}InitEntity(){const o=this.FindEntity("renderer").GetComponent("ThreeJSController").scene_,s=this.FindEntity("renderer").GetComponent("ThreeJSController").uiCamera_,a=this.FindEntity("voxels").GetComponent("SparseVoxelCellManager"),l=new gi(1,1,1),c=new Qe({uniforms:{time:{value:0},edgeColour:{value:new he(0)}},vertexShader:si.PLACEMENT.VS,fragmentShader:si.PLACEMENT.PS,side:Gt,blending:Bi,transparent:!0,depthWrite:!1}),h=c.clone();h.side=Ze;const u=new Oe(l,c),d=new Oe(l,h);u.renderOrder=1,this.placementMesh_=new ft,this.placementMesh_.add(u),this.placementMesh_.add(d),this.placementMesh_.scale.setScalar(.999),this.material1_=c,this.material2_=h;const f=new gi(1,1,1);this.voxelMesh_=new Oe(f,a.materialOpaque_.clone()),this.voxelMesh_.position.set(1.25,-1.25,-4),this.voxelMesh_.rotateY(.125*2*Math.PI),this.voxelMesh_.material.depthWrite=!1,this.voxelMesh_.material.depthTest=!1,this.voxelMeshGroup_=new ft,this.voxelMeshGroup_.add(this.voxelMesh_),this.voxelMeshGroup_.position.set(0,0,2),this.voxelMeshRotEnd_=this.voxelMeshGroup_.quaternion.clone(),this.voxelMeshGroup_.rotateX(-.125*2*Math.PI),this.voxelMeshRotStart_=this.voxelMeshGroup_.quaternion.clone(),this.voxelMeshGroup_.quaternion.identity(),s.add(this.voxelMeshGroup_);const m=new tn(".quaternion",[0,1],[...this.voxelMeshRotStart_.toArray(),...this.voxelMeshRotEnd_.toArray()]),v=new At("rot",-1,[m]);this.mixer_=new Co(this.voxelMeshGroup_),this.action_=this.mixer_.clipAction(v),o.add(this.placementMesh_),this.UpdateVoxelMesh_(),this.LoseFocus()}OnInput_(o){this.active_&&o.value=="enter"&&this.PerformAction()}PerformAction(){if(!this.active_||!this.placementMesh_.visible)return;const o=this.FindEntity("voxels").GetComponent("SparseVoxelCellManager"),s=[this.placementMesh_.position.x,this.placementMesh_.position.y,this.placementMesh_.position.z];o.HasVoxelAt(...s)||(o.InsertVoxelAt(s,this.voxelType_),this.action_.setLoop(Yo,1),this.action_.clampWhenFinished=!0,this.action_.timeScale=3,this.action_.reset(),this.action_.play())}Update(o){if(!this.active_)return;this.mixer_.update(o),this.timer_+=o,this.material1_.uniforms.time.value=this.timer_,this.material2_.uniforms.time.value=this.timer_,this.material1_.needsUpdate=!0,this.material2_.needsUpdate=!0;const s=this.FindEntity("voxels").GetComponent("SparseVoxelCellManager");this.voxelMesh_.material.uniforms.diffuseMap.value=s.materialOpaque_.uniforms.diffuseMap.value,this.placementMesh_.visible=!1;const a=this.FindEntity("player"),l=new A(0,0,-1);l.applyQuaternion(a.Quaternion);const c=new qi(a.Position,l),h=s.FindIntersectionsWithRay(c,5).filter(f=>f.voxel.visible);if(!h.length)return;const u=[...h[0].voxel.position],d=this.FindClosestSide_(u,c);d&&(s.HasVoxelAt(...d)||(this.placementMesh_.position.set(...d),this.placementMesh_.visible=!0))}FindClosestSide_(o,s){const a=[[...o],[...o],[...o],[...o],[...o],[...o]];a[0][0]-=1,a[1][0]+=1,a[2][1]-=1,a[3][1]+=1,a[4][2]-=1,a[5][2]+=1;const l=d=>{const f=new A(...d),m=new A(.5,.5,.5),v=new A;v.copy(f),v.sub(m);const _=new A;return _.copy(f),_.add(m),new dt(v,_)},c=a.map(d=>l(d)),h=new A,u=[];for(let d=0;dd.distance-f.distance),u.length>0?u[0].position:null}};wi(i,"CLASS_NAME","VoxelTools_Insert");let e=i;const n=class n extends Ut.Component{get NAME(){return n.CLASS_NAME}constructor(){super(),this.timer_=0,this.active_=!0}InitEntity(){this.LoadModel_()}InitComponent(){this._RegisterHandler("input.pressed",o=>this.OnInput_(o)),this._RegisterHandler("ui.toolChanged",o=>this.OnToolChanged_(o))}OnToolChanged_(o){o.value!="break"?this.LoseFocus():this.GainFocus()}LoseFocus(){this.balls_.visible=!1,this.placementMesh_.visible=!1,this.active_=!1}GainFocus(){this.balls_.visible=!0,this.placementMesh_.visible=!0,this.active_=!0}LoadModel_(){const o=this.FindEntity("renderer").GetComponent("ThreeJSController").scene_,s=this.FindEntity("renderer").GetComponent("ThreeJSController").uiCamera_;this.balls_=new ft,s.add(this.balls_),new Bg().load("./resources/pickaxe/scene.gltf",d=>{d.scene.traverse(g=>{g.material&&(g.material.depthWrite=!1,g.material.depthTest=!1)}),this.mesh_=d.scene,this.mesh_.position.set(2,2,1),this.mesh_.scale.setScalar(.1),this.mesh_.rotateZ(.25*2*Math.PI),this.mesh_.rotateY(-.1*2*Math.PI),this.group_=new ft,this.group_.add(this.mesh_),this.group_.position.set(0,-3,-4);const f=this.group_.quaternion.clone();this.group_.rotateX(-.25*2*Math.PI);const m=this.group_.quaternion.clone();this.group_.quaternion.identity(),this.balls_.add(this.group_);const v=new tn(".quaternion",[0,1,2],[...f.toArray(),...m.toArray(),...f.toArray()]),_=new At("rot",-1,[v]);this.mixer_=new Co(this.group_),this.action_=this.mixer_.clipAction(_)});const a=new gi(1,1,1),l=new Qe({uniforms:{time:{value:0},edgeColour:{value:new he(16711680)}},vertexShader:si.PLACEMENT.VS,fragmentShader:si.PLACEMENT.PS,side:Gt,blending:Bi,transparent:!0,depthWrite:!1}),c=l.clone();c.side=Ze;const h=new Oe(a,l),u=new Oe(a,c);h.renderOrder=1,this.placementMesh_=new ft,this.placementMesh_.add(h),this.placementMesh_.add(u),this.placementMesh_.scale.setScalar(1.0001),this.material1_=l,this.material2_=c,o.add(this.placementMesh_),this.LoseFocus()}OnInput_(o){this.active_&&o.value=="enter"&&this.PerformAction()}PerformAction(){if(!this.active_||!this.placementMesh_.visible)return;const o=this.FindEntity("voxels").GetComponent("SparseVoxelCellManager"),s=[this.placementMesh_.position.x,this.placementMesh_.position.y,this.placementMesh_.position.z];o.HasVoxelAt(...s)&&(o.RemoveVoxelAt(s),this.action_&&(this.action_.setLoop(Yo,1),this.action_.clampWhenFinished=!0,this.action_.timeScale=10,this.action_.reset(),this.action_.play()))}Update(o){if(!this.active_)return;this.mixer_&&this.mixer_.update(o),this.timer_+=o,this.material1_.uniforms.time.value=this.timer_,this.material2_.uniforms.time.value=this.timer_,this.material1_.needsUpdate=!0,this.material2_.needsUpdate=!0;const s=this.FindEntity("voxels").GetComponent("SparseVoxelCellManager"),a=this.FindEntity("player"),l=new A(0,0,-1);l.applyQuaternion(a.Quaternion);const c=new qi(a.Position,l),h=s.FindIntersectionsWithRay(c,4);if(!h.length)return;const u=[...h[0].voxel.position];s.HasVoxelAt(...u)&&(this.placementMesh_.position.set(...u),this.placementMesh_.visible=!0)}};wi(n,"CLASS_NAME","VoxelTools_Delete");let t=n;return{VoxelTools_Insert:e,VoxelTools_Delete:t}})(),Gg=(()=>{const t=class t extends Ut.Component{get NAME(){return t.CLASS_NAME}constructor(){super()}InitEntity(){this.iconBar_=document.getElementById("icon-bar"),this.icons_=[];const n=["dirt","stone","sand","grass","snow","moon","tree_bark","tree_leaves"];for(let r of n){const o=document.createElement("DIV");let s=la.DEFS[r].texture;s instanceof Array&&(s=s[2]),o.className="icon-bar-item",o.style="background-image: url('./resources/minecraft/textures/blocks/"+s+"');",o.blockType=r,this.iconBar_.appendChild(o),this.icons_.push(o)}this.toolTypes_=["build","break"],this.toolIndex_=0,this.iconIndex_=0,this.icons_[0].classList.toggle("highlight"),this.UpdateToolBlockType_(),this.UpdateToolType_()}CycleBuildIcon_(n){this.icons_[this.iconIndex_].classList.remove("highlight"),this.iconIndex_=(this.iconIndex_+this.icons_.length+n)%this.icons_.length,this.icons_[this.iconIndex_].classList.toggle("highlight"),this.UpdateToolBlockType_()}CycleTool_(){this.toolIndex_=(this.toolIndex_+1)%this.toolTypes_.length,this.UpdateToolType_()}UpdateToolBlockType_(){this.FindEntity("player").Broadcast({topic:"ui.blockChanged",value:this.icons_[this.iconIndex_].blockType})}UpdateToolType_(){this.FindEntity("player").Broadcast({topic:"ui.toolChanged",value:this.toolTypes_[this.toolIndex_]})}};wi(t,"CLASS_NAME","UIController");let e=t;return{UIController:e}})();class Vg{constructor(){this._Initialize()}_Initialize(){this.entityManager_=new zg.EntityManager,this.LoadControllers_(),this.previousRAF_=null,this.RAF_()}CreateGUI_(){this._guiParams={general:{}},this._gui=new GUI,this._gui.close()}LoadControllers_(){const t=new Ut.Entity;t.AddComponent(new Cg.ThreeJSController),this.entityManager_.Add(t,"renderer"),this.renderer_=t.GetComponent("ThreeJSController"),this.scene_=t.GetComponent("ThreeJSController").scene_,this.camera_=t.GetComponent("ThreeJSController").camera_,this.threejs_=t.GetComponent("ThreeJSController").threejs_;const i=new Ut.Entity;i.AddComponent(new Ug.SparseVoxelCellManager({cellSize:Fr.WORLD_BLOCK_SIZE,worldSize:Fr.WORLD_SIZE})),this.entityManager_.Add(i,"voxels");const n=new Ut.Entity;n.AddComponent(new kg.CloudController),this.entityManager_.Add(n);const r=new Ut.Entity;r.AddComponent(new Hg.PlayerController),r.AddComponent(new Sc.VoxelTools_Insert),r.AddComponent(new Sc.VoxelTools_Delete),r.SetPosition(new A(..._t.PLAYER_POS)),r.SetQuaternion(new tt(..._t.PLAYER_ROT)),this.entityManager_.Add(r,"player");const o=new Ut.Entity;o.AddComponent(new Gg.UIController),this.entityManager_.Add(o,"ui")}RAF_(){requestAnimationFrame(t=>{this.previousRAF_===null&&(this.previousRAF_=t),this.Step_(t-this.previousRAF_),this.renderer_.Render(),this.previousRAF_=t,setTimeout(()=>{this.RAF_()},1)})}Step_(t){const i=Math.min(.03333333333333333,t*.001);this.entityManager_.Update(i)}}window.addEventListener("DOMContentLoaded",()=>{new Vg});