1(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function n(i){if(i.ep)return;i.ep=!0;const r=t(i);fetch(i.href,r)}})();const Ko="183",hs={ROTATE:0,DOLLY:1,PAN:2},Oi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},sg=0,bh=1,rg=2,So=1,og=2,go=3,ii=0,vn=1,Tt=2,bi=0,wr=1,Mh=2,Sh=3,wh=4,ag=5,Rs=100,cg=101,lg=102,ug=103,dg=104,hg=200,fg=201,pg=202,mg=203,iu=204,su=205,gg=206,xg=207,yg=208,vg=209,_g=210,bg=211,Mg=212,Sg=213,wg=214,ru=0,ou=1,au=2,Ir=3,cu=4,lu=5,uu=6,du=7,kp=0,Tg=1,Eg=2,ti=0,xd=1,yd=2,vd=3,_d=4,bd=5,Md=6,Sd=7,Th="attached",Ag="detached",Bp=300,Os=301,Dr=302,Wc=303,Xc=304,Rc=306,Nr=1e3,yi=1001,pc=1002,Ut=1003,zp=1004,xo=1005,It=1006,nc=1007,vi=1008,Nn=1009,Vp=1010,Hp=1011,Fo=1012,wd=1013,si=1014,En=1015,Wn=1016,Td=1017,Ed=1018,ko=1020,Gp=35902,Wp=35899,Xp=1021,qp=1022,An=1023,Gi=1026,Ds=1027,Ad=1028,Pc=1029,Ur=1030,Cd=1031,Rd=1033,ic=33776,sc=33777,rc=33778,oc=33779,hu=35840,fu=35841,pu=35842,mu=35843,gu=36196,xu=37492,yu=37496,vu=37488,_u=37489,bu=37490,Mu=37491,Su=37808,wu=37809,Tu=37810,Eu=37811,Au=37812,Cu=37813,Ru=37814,Pu=37815,Lu=37816,Iu=37817,Du=37818,Nu=37819,Uu=37820,Ou=37821,Fu=36492,ku=36494,Bu=36495,zu=36283,Vu=36284,Hu=36285,Gu=36286,Bo=2300,zo=2301,qc=2302,Eh=2303,Ah=2400,Ch=2401,Rh=2402,Cg=2500,Rg=0,jp=1,Wu=2,Pg=3200,Lg=3201,Yp=0,Ig=1,os="",At="srgb",mn="srgb-linear",mc="linear",ut="srgb",Hs=7680,Ph=519,Dg=512,Ng=513,Ug=514,Pd=515,Og=516,Fg=517,Ld=518,kg=519,Xu=35044,Lh="300 es",$n=2e3,Vo=2001;function Bg(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function zg(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Ho(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Vg(){const s=Ho("canvas");return s.style.display="block",s}const Ih={};function gc(...s){const e="THREE."+s.shift();console.log(e,...s)}function Kp(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function Ne(...s){s=Kp(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function We(...s){s=Kp(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function xc(...s){const e=s.join(" ");e in Ih||(Ih[e]=!0,Ne(...s))}function Hg(s,e,t){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}const Gg={[ru]:ou,[au]:uu,[cu]:du,[Ir]:lu,[ou]:ru,[uu]:au,[du]:cu,[lu]:Ir};class ks{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const i=n[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let r=0,o=i.length;r<o;r++)i[r].call(this,e);e.target=null}}}const on=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","5
15","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Dh=1234567;const wo=Math.PI/180,Or=180/Math.PI;function ni(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(on[s&255]+on[s>>8&255]+on[s>>16&255]+on[s>>24&255]+"-"+on[e&255]+on[e>>8&255]+"-"+on[e>>16&15|64]+on[e>>24&255]+"-"+on[t&63|128]+on[t>>8&255]+"-"+on[t>>16&255]+on[t>>24&255]+on[n&255]+on[n>>8&255]+on[n>>16&255]+on[n>>24&255]).toLowerCase()}function qe(s,e,t){return Math.max(e,Math.min(t,s))}function Id(s,e){return(s%e+e)%e}function Wg(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function Xg(s,e,t){return s!==e?(t-s)/(e-s):0}function To(s,e,t){return(1-t)*s+t*e}function qg(s,e,t,n){return To(s,e,1-Math.exp(-t*n))}function jg(s,e=1){return e-Math.abs(Id(s,e*2)-e)}function Yg(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function Kg(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function Zg(s,e){return s+Math.floor(Math.random()*(e-s+1))}function Jg(s,e){return s+Math.random()*(e-s)}function Qg(s){return s*(.5-Math.random())}function $g(s){s!==void 0&&(Dh=s);let e=Dh+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function e0(s){return s*wo}function t0(s){return s*Or}function n0(s){return(s&s-1)===0&&s!==0}function i0(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function s0(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function r0(s,e,t,n,i){const r=Math.cos,o=Math.sin,a=r(t/2),c=o(t/2),l=r((e+n)/2),d=o((e+n)/2),u=r((e-n)/2),h=o((e-n)/2),f=r((n-e)/2),m=o((n-e)/2);switch(i){case"XYX":s.set(a*d,c*u,c*h,a*l);break;case"YZY":s.set(c*h,a*d,c*u,a*l);break;case"ZXZ":s.set(c*u,c*h,a*d,a*l);break;case"XZX":s.set(a*d,c*m,c*f,a*l);break;case"YXY":s.set(c*f,a*d,c*m,a*l);break;case"ZYZ":s.set(c*m,c*f,a*d,a*l);break;default:Ne("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Qn(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function ht(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const Ct={DEG2RAD:wo,RAD2DEG:Or,generateUUID:ni,clamp:qe,euclideanModulo:Id,mapLinear:Wg,inverseLerp:Xg,lerp:To,damp:qg,pingpong:jg,smoothstep:Yg,smootherstep:Kg,randInt:Zg,randFloat:Jg,randFloatSpread:Qg,seededRandom:$g,degToRad:e0,radToDeg:t0,isPowerOfTwo:n0,ceilPowerOfTwo:i0,floorPowerOfTwo:s0,setQuaternionFromProperEuler:r0,normalize:ht,denormalize:Qn};class xe{constructor(e=0,t=0){xe.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}
vendor: 102,950 bytes, line 1
1sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,e,t))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(qe(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*i+e.x,this.y=r*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class kn{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,o,a){let c=n[i+0],l=n[i+1],d=n[i+2],u=n[i+3],h=r[o+0],f=r[o+1],m=r[o+2],x=r[o+3];if(u!==x||c!==h||l!==f||d!==m){let p=c*h+l*f+d*m+u*x;p<0&&(h=-h,f=-f,m=-m,x=-x,p=-p);let g=1-a;if(p<.9995){const y=Math.acos(p),_=Math.sin(y);g=Math.sin(g*y)/_,a=Math.sin(a*y)/_,c=c*g+h*a,l=l*g+f*a,d=d*g+m*a,u=u*g+x*a}else{c=c*g+h*a,l=l*g+f*a,d=d*g+m*a,u=u*g+x*a;const y=1/Math.sqrt(c*c+l*l+d*d+u*u);c*=y,l*=y,d*=y,u*=y}}e[t]=c,e[t+1]=l,e[t+2]=d,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,o){const a=n[i],c=n[i+1],l=n[i+2],d=n[i+3],u=r[o],h=r[o+1],f=r[o+2],m=r[o+3];return e[t]=a*m+d*u+c*f-l*h,e[t+1]=c*m+d*h+l*u-a*f,e[t+2]=l*m+d*f+a*h-c*u,e[t+3]=d*m-a*u-c*h-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,r=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(n/2),d=a(i/2),u=a(r/2),h=c(n/2),f=c(i/2),m=c(r/2);switch(o){case"XYZ":this._x=h*d*u+l*f*m,this._y=l*f*u-h*d*m,this._z=l*d*m+h*f*u,this._w=l*d*u-h*f*m;break;case"YXZ":this._x=h*d*u+l*f*m,this._y=l*f*u-h*d*m,this._z=l*d*m-h*f*u,this._w=l*d*u+h*f*m;break;case"ZXY":this._x=h*d*u-l*f*m,this._y=l*f*u+h*d*m,this._z=l*d*m+h*f*u,this._w=l*d*u-h*f*m;break;case"ZYX":this._x=h*d*u-l*f*m,this._y=l*f*u+h*d*m,this._z=l*d*m-h*f*u,this._w=l*d*u+h*f*m;break;case"YZX":this._x=h*d*u+l*f*m,this._y=l*f*u+h*d*m,this._z=l*d*m-h*f*u,this._w=l*d*u-h*f*m;break;case"XZY":this._x=h*d*u-l*f*m,this._y=l*f*u-h*d*m,this._z=l*d*m+h*f*u,this._w=l*d*u+h*f*m;break;default:Ne("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],o=t[1],a=t[5],c=t[9],l=t[2],d=t[6],u=t[10],h=n+a+u;if(h>0){const f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(d-c)*f,this._y=(r-l)*f,this._z=(o-i)*f}else if(n>a&&n>u){const f=2*Math.sqrt(1+n-a-u);this._w=(d-c)/f,this._x=.25*f,this._y=(i+o)/f,this._z=(r+l)/f}else if(a>u){const f=2*Math.sqrt(1+a-n-u);this._w=(r-l)/f,this._x=(i+o)/f,this._y=.25*f,this._z=(c+d)/f}else{const f=2*Math.sqrt(1+u-n-a);this._w=(o-i)/f,this._x=(r+l)/f,this._y=(c+d)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(qe(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,o=e._w,a=t._x,c=t._y,l=t._z,d=t._w;return this._x=n*d+o*a+i*l-r*c,this._y=i*d+o*c+r*a-n*l,this._z=r*d+o*l+n*c-i*a,this._w=o*d-n*a-i*c-r*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,i=e._y,r=e._z,o=e._w,a=this.dot(e);a<0&&(n=-n,i=-i,r=-r,o=-o,a=-a);let c=1-t;if(a<.9995){const l=Math.acos(a),d=Math.sin(l);c=Math.sin(c*l)/d,t=Math.sin(t*l)/d,this._x=this._x*c+n*t,this._y=this._y*c+i*t,this._z=this._z*c+r*t,this._w=this._w*c+o*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+i*t,this._z=this._z*c+r*t,this._w=this._w*c+o*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class D{constructor(e=0,t=0,n=0){D.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Nh.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Nh.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*i-a*n),d=2*(a*t-r*i),u=2*(r*n-o*t);return this.x=t+c*l+o*u-a*d,this.y=n+c*d+a*l-r*u,this.z=i+c*u+r*d-o*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,e,t))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,o=t.x,a=t.y,c=t.z;return this.x=i*c-r*a,this.y=r*o-n*c,this.z=n*a-i*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return jc.copy(this).projectOnVector(e),this.sub(jc)}reflect(e){return this.sub(jc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(qe(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const jc=new D,Nh=new kn;class $e{constructor(e,t,n,i,r,o,a,c,l){$e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,o,a,c,l)}set(e,t,n,i,r,o,a,c,l){const d=this.elements;return d[0]=e,d[1]=i,d[2]=a,d[3]=t,d[4]=r,d[5]=c,d[6]=n,d[7]=o,d[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],d=n[4],u=n[7],h=n[2],f=n[5],m=n[8],x=i[0],p=i[3],g=i[6],y=i[1],_=i[4],v=i[7],M=i[2],w=i[5],E=i[8];return r[0]=o*x+a*y+c*M,r[3]=o*p+a*_+c*w,r[6]=o*g+a*v+c*E,r[1]=l*x+d*y+u*M,r[4]=l*p+d*_+u*w,r[7]=l*g+d*v+u*E,r[2]=h*x+f*y+m*M,r[5]=h*p+f*_+m*w,r[8]=h*g+f*v+m*E,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],d=e[8];return t*o*d-t*a*l-n*r*d+n*a*c+i*r*l-i*o*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],d=e[8],u=d*o-a*l,h=a*c-d*r,f=l*r-o*c,m=t*u+n*h+i*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/m;return e[0]=u*x,e[1]=(i*l-d*n)*x,e[2]=(a*n-i*o)*x,e[3]=h*x,e[4]=(d*t-i*c)*x,e[5]=(i*r-a*t)*x,e[6]=f*x,e[7]=(n*c-l*t)*x,e[8]=(o*t-n*r)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,o,a){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*o+l*a)+o+e,-i*l,i*c,-i*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Yc.makeScale(e,t)),this}rotate(e){return this.premultiply(Yc.makeRotation(-e)),this}translate(e,t){return this.premultiply(Yc.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Yc=new $e,Uh=new $e().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Oh=new $e().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function o0(){const s={enabled:!0,workingColorSpace:mn,spaces:{},convert:function(i,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===ut&&(i.r=Bi(i.r),i.g=Bi(i.g),i.b=Bi(i.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===ut&&(i.r=Tr(i.r),i.g=Tr(i.g),i.b=Tr(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===os?mc:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,o){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return xc("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return xc("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[mn]:{primaries:e,whitePoint:n,transfer:mc,toXYZ:Uh,fromXYZ:Oh,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:At},outputColorSpaceConfig:{drawingBufferColorSpace:At}},[At]:{primaries:e,whitePoint:n,transfer:ut,toXYZ:Uh,fromXYZ:Oh,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:At}}}),s}const it=o0();function Bi(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Tr(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let Gs;class a0{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Gs===void 0&&(Gs=Ho("canvas")),Gs.width=e.width,Gs.height=e.height;const i=Gs.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=Gs}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Ho("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let o=0;o<r.length;o++)r[o]=Bi(r[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Bi(t[n]/255)*255):t[n]=Bi(t[n]);return{data:t,width:e.width,height:e.height}}else return Ne("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let c0=0;class Dd{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:c0++}),this.uuid=ni(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?r.push(Kc(i[o].image)):r.push(Kc(i[o]))}else r=Kc(i);n.url=r}return t||(e.images[this.uuid]=n),n}}function Kc(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?a0.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(Ne("Texture: Unable to serialize Texture."),{})}let l0=0;const Zc=new D;class Ot extends ks{constructor(e=Ot.DEFAULT_IMAGE,t=Ot.DEFAULT_MAPPING,n=yi,i=yi,r=It,o=vi,a=An,c=Nn,l=Ot.DEFAULT_ANISOTROPY,d=os){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:l0++}),this.uuid=ni(),this.name="",this.source=new Dd(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new xe(0,0),this.repeat=new xe(1,1),this.center=new xe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new $e,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Zc).x}get height(){return this.source.getSize(Zc).y}get depth(){return this.source.getSize(Zc).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,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.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){Ne(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Ne(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,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,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Bp)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Nr:e.x=e.x-Math.floor(e.x);break;case yi:e.x=e.x<0?0:1;break;case pc: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 Nr:e.y=e.y-Math.floor(e.y);break;case yi:e.y=e.y<0?0:1;break;case pc: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}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Ot.DEFAULT_IMAGE=null;Ot.DEFAULT_MAPPING=Bp;Ot.DEFAULT_ANISOTROPY=1;class bt{constructor(e=0,t=0,n=0,i=1){bt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const c=e.elements,l=c[0],d=c[4],u=c[8],h=c[1],f=c[5],m=c[9],x=c[2],p=c[6],g=c[10];if(Math.abs(d-h)<.01&&Math.abs(u-x)<.01&&Math.abs(m-p)<.01){if(Math.abs(d+h)<.1&&Math.abs(u+x)<.1&&Math.abs(m+p)<.1&&Math.abs(l+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const _=(l+1)/2,v=(f+1)/2,M=(g+1)/2,w=(d+h)/4,E=(u+x)/4,b=(m+p)/4;return _>v&&_>M?_<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(_),i=w/n,r=E/n):v>M?v<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(v),n=w/i,r=b/i):M<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(M),n=E/r,i=b/r),this.set(n,i,r,t),this}let y=Math.sqrt((p-m)*(p-m)+(u-x)*(u-x)+(h-d)*(h-d));return Math.abs(y)<.001&&(y=1),this.x=(p-m)/y,this.y=(u-x)/y,this.z=(h-d)/y,this.w=Math.acos((l+f+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this.w=qe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this.w=qe(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,e,t))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class u0 extends ks{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:It,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new bt(0,0,e,t),this.scissorTest=!1,this.viewport=new bt(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:n.depth},r=new Ot(i),o=n.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:It,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new Dd(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class On extends u0{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Zp extends Ot{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Ut,this.minFilter=Ut,this.wrapR=yi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class d0 extends Ot{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Ut,this.minFilter=Ut,this.wrapR=yi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Oe{constructor(e,t,n,i,r,o,a,c,l,d,u,h,f,m,x,p){Oe.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,o,a,c,l,d,u,h,f,m,x,p)}set(e,t,n,i,r,o,a,c,l,d,u,h,f,m,x,p){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=o,g[9]=a,g[13]=c,g[2]=l,g[6]=d,g[10]=u,g[14]=h,g[3]=f,g[7]=m,g[11]=x,g[15]=p,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 Oe().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,n=e.elements,i=1/Ws.setFromMatrixColumn(e,0).length(),r=1/Ws.setFromMatrixColumn(e,1).length(),o=1/Ws.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(i),l=Math.sin(i),d=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){const h=o*d,f=o*u,m=a*d,x=a*u;t[0]=c*d,t[4]=-c*u,t[8]=l,t[1]=f+m*l,t[5]=h-x*l,t[9]=-a*c,t[2]=x-h*l,t[6]=m+f*l,t[10]=o*c}else if(e.order==="YXZ"){const h=c*d,f=c*u,m=l*d,x=l*u;t[0]=h+x*a,t[4]=m*a-f,t[8]=o*l,t[1]=o*u,t[5]=o*d,t[9]=-a,t[2]=f*a-m,t[6]=x+h*a,t[10]=o*c}else if(e.order==="ZXY"){const h=c*d,f=c*u,m=l*d,x=l*u;t[0]=h-x*a,t[4]=-o*u,t[8]=m+f*a,t[1]=f+m*a,t[5]=o*d,t[9]=x-h*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){const h=o*d,f=o*u,m=a*d,x=a*u;t[0]=c*d,t[4]=m*l-f,t[8]=h*l+x,t[1]=c*u,t[5]=x*l+h,t[9]=f*l-m,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){const h=o*c,f=o*l,m=a*c,x=a*l;t[0]=c*d,t[4]=x-h*u,t[8]=m*u+f,t[1]=u,t[5]=o*d,t[9]=-a*d,t[2]=-l*d,t[6]=f*u+m,t[10]=h-x*u}else if(e.order==="XZY"){const h=o*c,f=o*l,m=a*c,x=a*l;t[0]=c*d,t[4]=-u,t[8]=l*d,t[1]=h*u+x,t[5]=o*d,t[9]=f*u-m,t[2]=m*u-f,t[6]=a*d,t[10]=x*u+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(h0,e,f0)}lookAt(e,t,n){const i=this.elements;return Ln.subVectors(e,t),Ln.lengthSq()===0&&(Ln.z=1),Ln.normalize(),Ki.crossVectors(n,Ln),Ki.lengthSq()===0&&(Math.abs(n.z)===1?Ln.x+=1e-4:Ln.z+=1e-4,Ln.normalize(),Ki.crossVectors(n,Ln)),Ki.normalize(),ea.crossVectors(Ln,Ki),i[0]=Ki.x,i[4]=ea.x,i[8]=Ln.x,i[1]=Ki.y,i[5]=ea.y,i[9]=Ln.y,i[2]=Ki.z,i[6]=ea.z,i[10]=Ln.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],d=n[1],u=n[5],h=n[9],f=n[13],m=n[2],x=n[6],p=n[10],g=n[14],y=n[3],_=n[7],v=n[11],M=n[15],w=i[0],E=i[4],b=i[8],S=i[12],P=i[1],A=i[5],T=i[9],I=i[13],k=i[2],F=i[6],L=i[10],O=i[14],H=i[3],W=i[7],q=i[11],Z=i[15];return r[0]=o*w+a*P+c*k+l*H,r[4]=o*E+a*A+c*F+l*W,r[8]=o*b+a*T+c*L+l*q,r[12]=o*S+a*I+c*O+l*Z,r[1]=d*w+u*P+h*k+f*H,r[5]=d*E+u*A+h*F+f*W,r[9]=d*b+u*T+h*L+f*q,r[13]=d*S+u*I+h*O+f*Z,r[2]=m*w+x*P+p*k+g*H,r[6]=m*E+x*A+p*F+g*W,r[10]=m*b+x*T+p*L+g*q,r[14]=m*S+x*I+p*O+g*Z,r[3]=y*w+_*P+v*k+M*H,r[7]=y*E+_*A+v*F+M*W,r[11]=y*b+_*T+v*L+M*q,r[15]=y*S+_*I+v*O+M*Z,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],o=e[1],a=e[5],c=e[9],l=e[13],d=e[2],u=e[6],h=e[10],f=e[14],m=e[3],x=e[7],p=e[11],g=e[15],y=c*f-l*h,_=a*f-l*u,v=a*h-c*u,M=o*f-l*d,w=o*h-c*d,E=o*u-a*d;return t*(x*y-p*_+g*v)-n*(m*y-p*M+g*w)+i*(m*_-x*M+g*E)-r*(m*v-x*w+p*E)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],d=e[8],u=e[9],h=e[10],f=e[11],m=e[12],x=e[13],p=e[14],g=e[15],y=t*a-n*o,_=t*c-i*o,v=t*l-r*o,M=n*c-i*a,w=n*l-r*a,E=i*l-r*c,b=d*x-u*m,S=d*p-h*m,P=d*g-f*m,A=u*p-h*x,T=u*g-f*x,I=h*g-f*p,k=y*I-_*T+v*A+M*P-w*S+E*b;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const F=1/k;return e[0]=(a*I-c*T+l*A)*F,e[1]=(i*T-n*I-r*A)*F,e[2]=(x*E-p*w+g*M)*F,e[3]=(h*w-u*E-f*M)*F,e[4]=(c*P-o*I-l*S)*F,e[5]=(t*I-i*P+r*S)*F,e[6]=(p*v-m*E-g*_)*F,e[7]=(d*E-h*v+f*_)*F,e[8]=(o*T-a*P+l*b)*F,e[9]=(n*P-t*T-r*b)*F,e[10]=(m*w-x*v+g*y)*F,e[11]=(u*v-d*w-f*y)*F,e[12]=(a*S-o*A-c*b)*F,e[13]=(t*A-n*S+i*b)*F,e[14]=(x*_-m*M-p*y)*F,e[15]=(d*M-u*_+h*y)*F,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,o=e.x,a=e.y,c=e.z,l=r*o,d=r*a;return this.set(l*o+n,l*a-i*c,l*c+i*a,0,l*a+i*c,d*a+n,d*c-i*o,0,l*c-i*a,d*c+i*o,r*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,o){return this.set(1,n,r,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,o=t._y,a=t._z,c=t._w,l=r+r,d=o+o,u=a+a,h=r*l,f=r*d,m=r*u,x=o*d,p=o*u,g=a*u,y=c*l,_=c*d,v=c*u,M=n.x,w=n.y,E=n.z;return i[0]=(1-(x+g))*M,i[1]=(f+v)*M,i[2]=(m-_)*M,i[3]=0,i[4]=(f-v)*w,i[5]=(1-(h+g))*w,i[6]=(p+y)*w,i[7]=0,i[8]=(m+_)*E,i[9]=(p-y)*E,i[10]=(1-(h+x))*E,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];const r=this.determinant();if(r===0)return n.set(1,1,1),t.identity(),this;let o=Ws.set(i[0],i[1],i[2]).length();const a=Ws.set(i[4],i[5],i[6]).length(),c=Ws.set(i[8],i[9],i[10]).length();r<0&&(o=-o),Yn.copy(this);const l=1/o,d=1/a,u=1/c;return Yn.elements[0]*=l,Yn.elements[1]*=l,Yn.elements[2]*=l,Yn.elements[4]*=d,Yn.elements[5]*=d,Yn.elements[6]*=d,Yn.elements[8]*=u,Yn.elements[9]*=u,Yn.elements[10]*=u,t.setFromRotationMatrix(Yn),n.x=o,n.y=a,n.z=c,this}makePerspective(e,t,n,i,r,o,a=$n,c=!1){const l=this.elements,d=2*r/(t-e),u=2*r/(n-i),h=(t+e)/(t-e),f=(n+i)/(n-i);let m,x;if(c)m=r/(o-r),x=o*r/(o-r);else if(a===$n)m=-(o+r)/(o-r),x=-2*o*r/(o-r);else if(a===Vo)m=-o/(o-r),x=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=d,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=x,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,r,o,a=$n,c=!1){const l=this.elements,d=2/(t-e),u=2/(n-i),h=-(t+e)/(t-e),f=-(n+i)/(n-i);let m,x;if(c)m=1/(o-r),x=o/(o-r);else if(a===$n)m=-2/(o-r),x=-(o+r)/(o-r);else if(a===Vo)m=-1/(o-r),x=-r/(o-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=d,l[4]=0,l[8]=0,l[12]=h,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=m,l[14]=x,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Ws=new D,Yn=new Oe,h0=new D(0,0,0),f0=new D(1,1,1),Ki=new D,ea=new D,Ln=new D,Fh=new Oe,kh=new kn;class Xn{constructor(e=0,t=0,n=0,i=Xn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],o=i[4],a=i[8],c=i[1],l=i[5],d=i[9],u=i[2],h=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(qe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-d,f),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-qe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(qe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-qe(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(h,f),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(qe(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-qe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-d,f),this._y=0);break;default:Ne("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Fh.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Fh,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return kh.setFromEuler(this),this.setFromQuaternion(kh,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Xn.DEFAULT_ORDER="XYZ";class Nd{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let p0=0;const Bh=new D,Xs=new kn,Ai=new Oe,ta=new D,Kr=new D,m0=new D,g0=new kn,zh=new D(1,0,0),Vh=new D(0,1,0),Hh=new D(0,0,1),Gh={type:"added"},x0={type:"removed"},qs={type:"childadded",child:null},Jc={type:"childremoved",child:null};class Et extends ks{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:p0++}),this.uuid=ni(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Et.DEFAULT_UP.clone();const e=new D,t=new Xn,n=new kn,i=new D(1,1,1);function r(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Oe},normalMatrix:{value:new $e}}),this.matrix=new Oe,this.matrixWorld=new Oe,this.matrixAutoUpdate=Et.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Et.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Nd,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Xs.setFromAxisAngle(e,t),this.quaternion.multiply(Xs),this}rotateOnWorldAxis(e,t){return Xs.setFromAxisAngle(e,t),this.quaternion.premultiply(Xs),this}rotateX(e){return this.rotateOnAxis(zh,e)}rotateY(e){return this.rotateOnAxis(Vh,e)}rotateZ(e){return this.rotateOnAxis(Hh,e)}translateOnAxis(e,t){return Bh.copy(e).applyQuaternion(this.quaternion),this.position.add(Bh.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(zh,e)}translateY(e){return this.translateOnAxis(Vh,e)}translateZ(e){return this.translateOnAxis(Hh,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ai.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?ta.copy(e):ta.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Kr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ai.lookAt(Kr,ta,this.up):Ai.lookAt(ta,Kr,this.up),this.quaternion.setFromRotationMatrix(Ai),i&&(Ai.extractRotation(i.matrixWorld),Xs.setFromRotationMatrix(Ai),this.quaternion.premultiply(Xs.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(We("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Gh),qs.child=e,this.dispatchEvent(qs),qs.child=null):We("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(x0),Jc.child=e,this.dispatchEvent(Jc),Jc.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ai.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ai.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ai),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Gh),qs.child=e,this.dispatchEvent(qs),qs.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Kr,e,m0),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Kr,g0,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,i=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let l=0,d=c.length;l<d;l++){const u=c[l];r(e.shapes,u)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(r(e.materials,this.material[c]));i.material=a}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const c=this.animations[a];i.animations.push(r(e.animations,c))}}if(t){const a=o(e.geometries),c=o(e.materials),l=o(e.textures),d=o(e.images),u=o(e.shapes),h=o(e.skeletons),f=o(e.animations),m=o(e.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),d.length>0&&(n.images=d),u.length>0&&(n.shapes=u),h.length>0&&(n.skeletons=h),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=i,n;function o(a){const c=[];for(const l in a){const d=a[l];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(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),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,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.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}Et.DEFAULT_UP=new D(0,1,0);Et.DEFAULT_MATRIX_AUTO_UPDATE=!0;Et.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Kt extends Et{constructor(){super(),this.isGroup=!0,this.type="Group"}}const y0={type:"move"};class Qc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Kt,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Kt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Kt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,o=null;const a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(const x of e.hand.values()){const p=t.getJointPose(x,n),g=this._getHandJoint(l,x);p!==null&&(g.matrix.fromArray(p.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=p.radius),g.visible=p!==null}const d=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],h=d.position.distanceTo(u.position),f=.02,m=.005;l.inputState.pinching&&h>f+m?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=f-m&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(y0)))}return a!==null&&(a.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Kt;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const Jp={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},Zi={h:0,s:0,l:0},na={h:0,s:0,l:0};function $c(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class ze{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=At){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,it.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=it.workingColorSpace){return this.r=e,this.g=t,this.b=n,it.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=it.workingColorSpace){if(e=Id(e,1),t=qe(t,0,1),n=qe(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=$c(o,r,e+1/3),this.g=$c(o,r,e),this.b=$c(o,r,e-1/3)}return it.colorSpaceToWorking(this,i),this}setStyle(e,t=At){function n(r){r!==void 0&&parseFloat(r)<1&&Ne("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ne("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);Ne("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=At){const n=Jp[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ne("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Bi(e.r),this.g=Bi(e.g),this.b=Bi(e.b),this}copyLinearToSRGB(e){return this.r=Tr(e.r),this.g=Tr(e.g),this.b=Tr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=At){return it.workingToColorSpace(an.copy(this),e),Math.round(qe(an.r*255,0,255))*65536+Math.round(qe(an.g*255,0,255))*256+Math.round(qe(an.b*255,0,255))}getHexString(e=At){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace(an.copy(this),t);const n=an.r,i=an.g,r=an.b,o=Math.max(n,i,r),a=Math.min(n,i,r);let c,l;const d=(a+o)/2;if(a===o)c=0,l=0;else{const u=o-a;switch(l=d<=.5?u/(o+a):u/(2-o-a),o){case n:c=(i-r)/u+(i<r?6:0);break;case i:c=(r-n)/u+2;break;case r:c=(n-i)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=d,e}getRGB(e,t=it.workingColorSpace){return it.workingToColorSpace(an.copy(this),t),e.r=an.r,e.g=an.g,e.b=an.b,e}getStyle(e=At){it.workingToColorSpace(an.copy(this),e);const t=an.r,n=an.g,i=an.b;return e!==At?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Zi),this.setHSL(Zi.h+e,Zi.s+t,Zi.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Zi),e.getHSL(na);const n=To(Zi.h,na.h,t),i=To(Zi.s,na.s,t),r=To(Zi.l,na.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const an=new ze;ze.NAMES=Jp;class yc extends Et{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Xn,this.environmentIntensity=1,this.environmentRotation=new Xn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Kn=new D,Ci=new D,el=new D,Ri=new D,js=new D,Ys=new D,Wh=new D,tl=new D,nl=new D,il=new D,sl=new bt,rl=new bt,ol=new bt;class tn{constructor(e=new D,t=new D,n=new D){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Kn.subVectors(e,t),i.cross(Kn);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Kn.subVectors(i,t),Ci.subVectors(n,t),el.subVectors(e,t);const o=Kn.dot(Kn),a=Kn.dot(Ci),c=Kn.dot(el),l=Ci.dot(Ci),d=Ci.dot(el),u=o*l-a*a;if(u===0)return r.set(0,0,0),null;const h=1/u,f=(l*c-a*d)*h,m=(o*d-a*c)*h;return r.set(1-f-m,m,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Ri)===null?!1:Ri.x>=0&&Ri.y>=0&&Ri.x+Ri.y<=1}static getInterpolation(e,t,n,i,r,o,a,c){return this.getBarycoord(e,t,n,i,Ri)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,Ri.x),c.addScaledVector(o,Ri.y),c.addScaledVector(a,Ri.z),c)}static getInterpolatedAttribute(e,t,n,i,r,o){return sl.setScalar(0),rl.setScalar(0),ol.setScalar(0),sl.fromBufferAttribute(e,t),rl.fromBufferAttribute(e,n),ol.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(sl,r.x),o.addScaledVector(rl,r.y),o.addScaledVector(ol,r.z),o}static isFrontFacing(e,t,n,i){return Kn.subVectors(n,t),Ci.subVectors(e,t),Kn.cross(Ci).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Kn.subVectors(this.c,this.b),Ci.subVectors(this.a,this.b),Kn.cross(Ci).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return tn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return tn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return tn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return tn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return tn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let o,a;js.subVectors(i,n),Ys.subVectors(r,n),tl.subVectors(e,n);const c=js.dot(tl),l=Ys.dot(tl);if(c<=0&&l<=0)return t.copy(n);nl.subVectors(e,i);const d=js.dot(nl),u=Ys.dot(nl);if(d>=0&&u<=d)return t.copy(i);const h=c*u-d*l;if(h<=0&&c>=0&&d<=0)return o=c/(c-d),t.copy(n).addScaledVector(js,o);il.subVectors(e,r);const f=js.dot(il),m=Ys.dot(il);if(m>=0&&f<=m)return t.copy(r);const x=f*l-c*m;if(x<=0&&l>=0&&m<=0)return a=l/(l-m),t.copy(n).addScaledVector(Ys,a);const p=d*m-f*u;if(p<=0&&u-d>=0&&f-m>=0)return Wh.subVectors(r,i),a=(u-d)/(u-d+(f-m)),t.copy(i).addScaledVector(Wh,a);const g=1/(p+x+h);return o=x*g,a=h*g,t.copy(n).addScaledVector(js,o).addScaledVector(Ys,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class ct{constructor(e=new D(1/0,1/0,1/0),t=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Zn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Zn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Zn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,Zn):Zn.fromBufferAttribute(r,o),Zn.applyMatrix4(e.matrixWorld),this.expandByPoint(Zn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),ia.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),ia.copy(n.boundingBox)),ia.applyMatrix4(e.matrixWorld),this.union(ia)}const i=e.children;for(let r=0,o=i.length;r<o;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Zn),Zn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Zr),sa.subVectors(this.max,Zr),Ks.subVectors(e.a,Zr),Zs.subVectors(e.b,Zr),Js.subVectors(e.c,Zr),Ji.subVectors(Zs,Ks),Qi.subVectors(Js,Zs),gs.subVectors(Ks,Js);let t=[0,-Ji.z,Ji.y,0,-Qi.z,Qi.y,0,-gs.z,gs.y,Ji.z,0,-Ji.x,Qi.z,0,-Qi.x,gs.z,0,-gs.x,-Ji.y,Ji.x,0,-Qi.y,Qi.x,0,-gs.y,gs.x,0];return!al(t,Ks,Zs,Js,sa)||(t=[1,0,0,0,1,0,0,0,1],!al(t,Ks,Zs,Js,sa))?!1:(ra.crossVectors(Ji,Qi),t=[ra.x,ra.y,ra.z],al(t,Ks,Zs,Js,sa))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Zn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Zn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Pi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Pi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Pi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Pi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Pi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Pi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Pi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Pi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Pi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Pi=[new D,new D,new D,new D,new D,new D,new D,new D],Zn=new D,ia=new ct,Ks=new D,Zs=new D,Js=new D,Ji=new D,Qi=new D,gs=new D,Zr=new D,sa=new D,ra=new D,xs=new D;function al(s,e,t,n,i){for(let r=0,o=s.length-3;r<=o;r+=3){xs.fromArray(s,r);const a=i.x*Math.abs(xs.x)+i.y*Math.abs(xs.y)+i.z*Math.abs(xs.z),c=e.dot(xs),l=t.dot(xs),d=n.dot(xs);if(Math.max(-Math.max(c,l,d),Math.min(c,l,d))>a)return!1}return!0}const kt=new D,oa=new xe;let v0=0;class Rt{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:v0++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Xu,this.updateRanges=[],this.gpuType=En,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)oa.fromBufferAttribute(this,t),oa.applyMatrix3(e),this.setXY(t,oa.x,oa.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)kt.fromBufferAttribute(this,t),kt.applyMatrix3(e),this.setXYZ(t,kt.x,kt.y,kt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)kt.fromBufferAttribute(this,t),kt.applyMatrix4(e),this.setXYZ(t,kt.x,kt.y,kt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)kt.fromBufferAttribute(this,t),kt.applyNormalMatrix(e),this.setXYZ(t,kt.x,kt.y,kt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)kt.fromBufferAttribute(this,t),kt.transformDirection(e),this.setXYZ(t,kt.x,kt.y,kt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Qn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ht(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Qn(t,this.array)),t}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Qn(t,this.array)),t}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Qn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Qn(t,this.array)),t}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Xu&&(e.usage=this.usage),e}}class Ud extends Rt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Qp extends Rt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class rt extends Rt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const _0=new ct,Jr=new D,cl=new D;class fn{constructor(e=new D,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):_0.setFromPoints(e).getCenter(n);let i=0;for(let r=0,o=e.length;r<o;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Jr.subVectors(e,this.center);const t=Jr.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Jr,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(cl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Jr.copy(e.center).add(cl)),this.expandByPoint(Jr.copy(e.center).sub(cl))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let b0=0;const Bn=new Oe,ll=new Et,Qs=new D,In=new ct,Qr=new ct,jt=new D;class vt extends ks{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:b0++}),this.uuid=ni(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Bg(e)?Qp:Ud)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new $e().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Bn.makeRotationFromQuaternion(e),this.applyMatrix4(Bn),this}rotateX(e){return Bn.makeRotationX(e),this.applyMatrix4(Bn),this}rotateY(e){return Bn.makeRotationY(e),this.applyMatrix4(Bn),this}rotateZ(e){return Bn.makeRotationZ(e),this.applyMatrix4(Bn),this}translate(e,t,n){return Bn.makeTranslation(e,t,n),this.applyMatrix4(Bn),this}scale(e,t,n){return Bn.makeScale(e,t,n),this.applyMatrix4(Bn),this}lookAt(e){return ll.lookAt(e),ll.updateMatrix(),this.applyMatrix4(ll.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Qs).negate(),this.translate(Qs.x,Qs.y,Qs.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,r=e.length;i<r;i++){const o=e[i];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new rt(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}e.length>t.count&&Ne("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ct);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){We("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const r=t[n];In.setFromBufferAttribute(r),this.morphTargetsRelative?(jt.addVectors(this.boundingBox.min,In.min),this.boundingBox.expandByPoint(jt),jt.addVectors(this.boundingBox.max,In.max),this.boundingBox.expandByPoint(jt)):(this.boundingBox.expandByPoint(In.min),this.boundingBox.expandByPoint(In.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&We('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new fn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){We("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(e){const n=this.boundingSphere.center;if(In.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){const a=t[r];Qr.setFromBufferAttribute(a),this.morphTargetsRelative?(jt.addVectors(In.min,Qr.min),In.expandByPoint(jt),jt.addVectors(In.max,Qr.max),In.expandByPoint(jt)):(In.expandByPoint(Qr.min),In.expandByPoint(Qr.max))}In.getCenter(n);let i=0;for(let r=0,o=e.count;r<o;r++)jt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(jt));if(t)for(let r=0,o=t.length;r<o;r++){const a=t[r],c=this.morphTargetsRelative;for(let l=0,d=a.count;l<d;l++)jt.fromBufferAttribute(a,l),c&&(Qs.fromBufferAttribute(e,l),jt.add(Qs)),i=Math.max(i,n.distanceToSquared(jt))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&We('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){We("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Rt(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),a=[],c=[];for(let b=0;b<n.count;b++)a[b]=new D,c[b]=new D;const l=new D,d=new D,u=new D,h=new xe,f=new xe,m=new xe,x=new D,p=new D;function g(b,S,P){l.fromBufferAttribute(n,b),d.fromBufferAttribute(n,S),u.fromBufferAttribute(n,P),h.fromBufferAttribute(r,b),f.fromBufferAttribute(r,S),m.fromBufferAttribute(r,P),d.sub(l),u.sub(l),f.sub(h),m.sub(h);const A=1/(f.x*m.y-m.x*f.y);isFinite(A)&&(x.copy(d).multiplyScalar(m.y).addScaledVector(u,-f.y).multiplyScalar(A),p.copy(u).multiplyScalar(f.x).addScaledVector(d,-m.x).multiplyScalar(A),a[b].add(x),a[S].add(x),a[P].add(x),c[b].add(p),c[S].add(p),c[P].add(p))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let b=0,S=y.length;b<S;++b){const P=y[b],A=P.start,T=P.count;for(let I=A,k=A+T;I<k;I+=3)g(e.getX(I+0),e.getX(I+1),e.getX(I+2))}const _=new D,v=new D,M=new D,w=new D;function E(b){M.fromBufferAttribute(i,b),w.copy(M);const S=a[b];_.copy(S),_.sub(M.multiplyScalar(M.dot(S))).normalize(),v.crossVectors(w,S);const A=v.dot(c[b])<0?-1:1;o.setXYZW(b,_.x,_.y,_.z,A)}for(let b=0,S=y.length;b<S;++b){const P=y[b],A=P.start,T=P.count;for(let I=A,k=A+T;I<k;I+=3)E(e.getX(I+0)),E(e.getX(I+1)),E(e.getX(I+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Rt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let h=0,f=n.count;h<f;h++)n.setXYZ(h,0,0,0);const i=new D,r=new D,o=new D,a=new D,c=new D,l=new D,d=new D,u=new D;if(e)for(let h=0,f=e.count;h<f;h+=3){const m=e.getX(h+0),x=e.getX(h+1),p=e.getX(h+2);i.fromBufferAttribute(t,m),r.fromBufferAttribute(t,x),o.fromBufferAttribute(t,p),d.subVectors(o,r),u.subVectors(i,r),d.cross(u),a.fromBufferAttribute(n,m),c.fromBufferAttribute(n,x),l.fromBufferAttribute(n,p),a.add(d),c.add(d),l.add(d),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z),n.setXYZ(p,l.x,l.y,l.z)}else for(let h=0,f=t.count;h<f;h+=3)i.fromBufferAttribute(t,h+0),r.fromBufferAttribute(t,h+1),o.fromBufferAttribute(t,h+2),d.subVectors(o,r),u.subVectors(i,r),d.cross(u),n.setXYZ(h+0,d.x,d.y,d.z),n.setXYZ(h+1,d.x,d.y,d.z),n.setXYZ(h+2,d.x,d.y,d.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)jt.fromBufferAttribute(e,t),jt.normalize(),e.setXYZ(t,jt.x,jt.y,jt.z)}toNonIndexed(){function e(a,c){const l=a.array,d=a.itemSize,u=a.normalized,h=new l.constructor(c.length*d);let f=0,m=0;for(let x=0,p=c.length;x<p;x++){a.isInterleavedBufferAttribute?f=c[x]*a.data.stride+a.offset:f=c[x]*d;for(let g=0;g<d;g++)h[m++]=l[f++]}return new Rt(h,d,u)}if(this.index===null)return Ne("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new vt,n=this.index.array,i=this.attributes;for(const a in i){const c=i[a],l=e(c,n);t.setAttribute(a,l)}const r=this.morphAttributes;for(const a in r){const c=[],l=r[a];for(let d=0,u=l.length;d<u;d++){const h=l[d],f=e(h,n);c.push(f)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[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 n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const i={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],d=[];for(let u=0,h=l.length;u<h;u++){const f=l[u];d.push(f.toJSON(e.data))}d.length>0&&(i[c]=d,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const i=e.attributes;for(const l in i){const d=i[l];this.setAttribute(l,d.clone(t))}const r=e.morphAttributes;for(const l in r){const d=[],u=r[l];for(let h=0,f=u.length;h<f;h++)d.push(u[h].clone(t));this.morphAttributes[l]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let l=0,d=o.length;l<d;l++){const u=o[l];this.addGroup(u.start,u.count,u.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}class $p{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Xu,this.updateRanges=[],this.version=0,this.uuid=ni()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ni()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ni()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const gn=new D;class Lc{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)gn.fromBufferAttribute(this,t),gn.applyMatrix4(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)gn.fromBufferAttribute(this,t),gn.applyNormalMatrix(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)gn.fromBufferAttribute(this,t),gn.transformDirection(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Qn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ht(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Qn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Qn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Qn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Qn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){gc("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new Rt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Lc(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){gc("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let M0=0;class Mi extends ks{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:M0++}),this.uuid=ni(),this.name="",this.type="Material",this.blending=wr,this.side=ii,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=iu,this.blendDst=su,this.blendEquation=Rs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ze(0,0,0),this.blendAlpha=0,this.depthFunc=Ir,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Ph,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Hs,this.stencilZFail=Hs,this.stencilZPass=Hs,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){Ne(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Ne(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};
vendor: 9,098 bytes, line 1
1n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==wr&&(n.blending=this.blending),this.side!==ii&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==iu&&(n.blendSrc=this.blendSrc),this.blendDst!==su&&(n.blendDst=this.blendDst),this.blendEquation!==Rs&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Ir&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Ph&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Hs&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Hs&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Hs&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const o=[];for(const a in r){const c=r[a];delete c.metadata,o.push(c)}return o}if(t){const r=i(e.textures),o=i(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipSh
vendor: 5,530 bytes, line 1
1adows,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.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const Li=new D,ul=new D,aa=new D,$i=new D,dl=new D,ca=new D,hl=new D;class Si{constructor(e=new D,t=new D(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Li.copy(this.origin).addScaledVector(this.direction,t),Li.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){ul.copy(e).add(t).multiplyScalar(.5),aa.copy(t).sub(e).normalize(),$i.copy(this.origin).sub(ul);const r=e.distanceTo(t)*.5,o=-this.direction.dot(aa),a=$i.dot(this.direction),c=-$i.dot(aa),l=$i.lengthSq(),d=Math.abs(1-o*o);let u,h,f,m;if(d>0)if(u=o*c-a,h=o*a-c,m=r*d,u>=0)if(h>=-m)if(h<=m){const x=1/d;u*=x,h*=x,f=u*(u+o*h+2*a)+h*(o*u+h+2*c)+l}else h=r,u=Math.max(0,-(o*h+a)),f=-u*u+h*(h+2*c)+l;else h=-r,u=Math.max(0,-(o*h+a)),f=-u*u+h*(h+2*c)+l;else h<=-m?(u=Math.max(0,-(-o*r+a)),h=u>0?-r:Math.min(Math.max(-r,-c),r),f=-u*u+h*(h+2*c)+l):h<=m?(u=0,h=Math.min(Math.max(-r,-c),r),f=h*(h+2*c)+l):(u=Math.max(0,-(o*r+a)),h=u>0?r:Math.min(Math.max(-r,-c),r),f=-u*u+h*(h+2*c)+l);else h=o>0?-r:r,u=Math.max(0,-(o*h+a)),f=-u*u+h*(h+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(ul).addScaledVector(aa,h),f}intersectSphere(e,t){Li.subVectors(e.center,this.origin);const n=Li.dot(this.direction),i=Li.dot(Li)-n*n,r=e.radius*e.radius;if(i>r)return null;const o=Math.sqrt(r-i),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,o,a,c;const l=1/this.direction.x,d=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(n=(e.min.x-h.x)*l,i=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,i=(e.min.x-h.x)*l),d>=0?(r=(e.min.y-h.y)*d,o=(e.max.y-h.y)*d):(r=(e.max.y-h.y)*d,o=(e.min.y-h.y)*d),n>o||r>i||((r>n||isNaN(n))&&(n=r),(o<i||isNaN(i))&&(i=o),u>=0?(a=(e.min.z-h.z)*u,c=(e.max.z-h.z)*u):(a=(e.max.z-h.z)*u,c=(e.min.z-h.z)*u),n>c||a>i)||((a>n||n!==n)&&(n=a),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Li)!==null}intersectTriangle(e,t,n,i,r){dl.subVectors(t,e),ca.subVectors(n,e),hl.crossVectors(dl,ca);let o=this.direction.dot(hl),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;$i.subVectors(this.origin,e);const c=a*this.direction.dot(ca.crossVectors($i,ca));if(c<0)return null;const l=a*this.direction.dot(dl.cross($i));if(l<0||c+l>o)return null;const d=-a*$i.dot(hl);return d<0?null:this.at(d/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class nn extends Mi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ze(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.envMapRotation=new Xn,this.combine=kp,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Xh=new Oe,ys=new Si,la=new fn,qh=new D,ua=new D,da=new D,ha=new D,fl=new D,fa=new D,jh=new D,pa=new D;
vendor: 5,172 bytes, line 1
1class Qe extends Et{constructor(e=new vt,t=new nn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const a=this.morphTargetInfluences;if(r&&a){fa.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const d=a[c],u=r[c];d!==0&&(fl.fromBufferAttribute(u,e),o?fa.addScaledVector(fl,d):fa.addScaledVector(fl.sub(t),d))}t.add(fa)}return t}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),la.copy(n.boundingSphere),la.applyMatrix4(r),ys.copy(e.ray).recast(e.near),!(la.containsPoint(ys.origin)===!1&&(ys.intersectSphere(la,qh)===null||ys.origin.distanceToSquared(qh)>(e.far-e.near)**2))&&(Xh.copy(r).invert(),ys.copy(e.ray).applyMatrix4(Xh),!(n.boundingBox!==null&&ys.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ys)))}_computeIntersections(e,t,n){let i;const r=this.geometry,o=this.material,a=r.index,c=r.attributes.position,l=r.attributes.uv,d=r.attributes.uv1,u=r.attributes.normal,h=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,x=h.length;m<x;m++){const p=h[m],g=o[p.materialIndex],y=Math.max(p.start,f.start),_=Math.min(a.count,Math.min(p.start+p.count,f.start+f.count));for(let v=y,M=_;v<M;v+=3){const w=a.getX(v),E=a.getX(v+1),b=a.getX(v+2);i=ma(this,g,e,n,l,d,u,w,E,b),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=p.materialIndex,t.push(i))}}else{const m=Math.max(0,f.start),x=Math.min(a.count,f.start+f.count);for(let p=m,g=x;p<g;p+=3){const y=a.getX(p),_=a.getX(p+1),v=a.getX(p+2);i=ma(this,o,e,n,l,d,u,y,_,v),i&&(i.faceIndex=Math.floor(p/3),t.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let m=0,x=h.length;m<x;m++){const p=h[m],g=o[p.materialIndex],y=Math.max(p.start,f.start),_=Math.min(c.count,Math.min(p.start+p.count,f.start+f.count));for(let v=y,M=_;v<M;v+=3){const w=v,E=v+1,b=v+2;i=ma(this,g,e,n,l,d,u,w,E,b),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=p.materialIndex,t.push(i))}}else{const m=Math.max(0,f.start),x=Math.min(c.count,f.start+f.count);for(let p=m,g=x;p<g;p+=3){const y=p,_=p+1,v=p+2;i=ma(this,o,e,n,l,d,u,y,_,v),i&&(i.faceIndex=Math.floor(p/3),t.push(i))}}}}function S0(s,e,t,n,i,r,o,a){let c;if(e.side===vn?c=n.intersectTriangle(o,r,i,!0,a):c=n.intersectTriangle(i,r,o,e.side===ii,a),c===null)return null;pa.copy(a),pa.applyMatrix4(s.matrixWorld);const l=t.ray.origin.distanceTo(pa);return l<t.near||l>t.far?null:{distance:l,point:pa.clone(),object:s}}function ma(s,e,t,n,i,r,o,a,c,l){s.getVertexPosition(a,ua),s.getVertexPosition(c,da),s.getVertexPosition(l,ha);const d=S0(s,e,t,n,ua,da,ha,jh);if(d){const u=new D;tn.getBarycoord(jh,ua,da,ha,u),i&&(d.uv=tn.getInterpolatedAttribute(i,a,c,l,u,new xe)),r&&(d.uv1=tn.getInterpolatedAttribute(r,a,c,l,u,new xe)),o&&(d.normal=tn.getInterpolatedAttribute(o,a,c,l,u,new D),d.normal.dot(n.direction)>0&&d.normal.multiplyScalar(-1));const h={a,b:c,c:l,normal:new D,materialIndex:0};tn.getNormal(ua,da,ha,h.normal),d.face=h,d.barycoord=u}return d}const Yh=new D,Kh=new bt,Zh=new bt,w0=new D,Jh=new Oe,ga=new D,pl=new fn,Qh=new Oe,ml=new Si;class em extends Qe{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Th,this.bindMatrix=new Oe,this.bindMatrixInverse=new Oe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ct),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ga),this.boundingBox.expandByPoint(ga)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new fn),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ga),this.boundingSphere.expandByPoint(ga)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),pl.copy(this.boundingSphere),pl.applyM
vendor: 7,683 bytes, line 1
1atrix4(i),e.ray.intersectsSphere(pl)!==!1&&(Qh.copy(i).invert(),ml.copy(e.ray).applyMatrix4(Qh),!(this.boundingBox!==null&&ml.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,ml)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new bt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Th?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Ag?this.bindMatrixInverse.copy(this.bindMatrix).invert():Ne("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;Kh.fromBufferAttribute(i.attributes.skinIndex,e),Zh.fromBufferAttribute(i.attributes.skinWeight,e),Yh.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const o=Zh.getComponent(r);if(o!==0){const a=Kh.getComponent(r);Jh.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(w0.copy(Yh).applyMatrix4(Jh),o)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Od extends Et{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Er extends Ot{constructor(e=null,t=1,n=1,i,r,o,a,c,l=Ut,d=Ut,u,h){super(null,o,a,c,l,d,i,r,u,h),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const $h=new Oe,T0=new Oe;class Ic{constructor(e=[],t=[]){this.uuid=ni(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ne("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Oe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Oe;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,o=e.length;r<o;r++){const a=e[r]?e[r].matrixWorld:T0;$h.multiplyMatrices(a,t[r]),$h.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Ic(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Er(t,e,e,An,En);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const r=e.bones[n];let o=t[r];o===void 0&&(Ne("Skeleton: No bone found with UUID:",r),o=new Od),this.bones.push(o),this.boneInverses.push(new Oe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){const o=t[i];e.bones.push(o.uuid);const a=n[i];e.boneInverses.push(a.toArray())}return e}}class qu extends Rt{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const $s=new Oe,ef=new Oe,xa=[],tf=new ct,E0=new Oe,$r=new Qe,eo=new fn;class Fd extends Qe{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new qu(new Float32Array(n*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,E0)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ct),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,$s),tf.copy(e.boundingBox).applyMatrix4($s),this.boundingBox.union(tf)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new fn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,$s),eo.copy(e.boundingSphere).applyMatrix4($s),this.boundingSphere.union(eo)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=e.previousInstanceMatrix.clone()),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,o=e*r+1;for(let a=0;a<n.length;a++)n[a]=i[o+a]}raycast(e,t){const n=this.matrixWorld,i=this.count;if($r.geometry=this.geometry,$r.material=this.material,$r.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),eo.copy(this.boundingSphere),eo.applyMatrix4(n),e.ray.intersectsSphere(eo)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,$s),ef.multiplyMatrices(n,$s),$r.matrixWorld=ef,$r.raycast(e,xa);for(let o=0,a=xa.length;o<a;o++){const c=xa[o];c.instanceId=r,c.object=this,t.push(c)}xa.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new qu(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Er(new Float32Array(i*this.count),i,this.count,Ad,En));const r=this.morphTexture.source.data.data;let o=0;for(let l=0;l<n.length;l++)o+=n[l];const a=this.geometry.morphTargetsRelative?1:1-o,c=i*e;r[c]=a,r.set(n,c+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const gl=new D,A0=new D,C0=new $e;class gi{constructor(e=new D(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}
1setFromCoplanarPoints(e,t,n){const i=gl.subVectors(n,t).cross(A0.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(gl),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||C0.getNormalMatrix(e),i=this.coplanarPoint(gl).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const vs=new fn,R0=new xe(.5,.5),ya=new D;class Hr{constructor(e=new gi,t=new gi,n=new gi,i=new gi,r=new gi,o=new gi){this.planes=[e,t,n,i,r,o]}set(e,t,n,i,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=$n,n=!1){const i=this.planes,r=e.elements,o=r[0],a=r[1],c=r[2],l=r[3],d=r[4],u=r[5],h=r[6],f=r[7],m=r[8],x=r[9],p=r[10],g=r[11],y=r[12],_=r[13],v=r[14],M=r[15];if(i[0].setComponents(l-o,f-d,g-m,M-y).normalize(),i[1].setComponents(l+o,f+d,g+m,M+y).normalize(),i[2].setComponents(l+a,f+u,g+x,M+_).normalize(),i[3].setComponents(l-a,f-u,g-x,M-_).normalize(),n)i[4].setComponents(c,h,p,v).normalize(),i[5].setComponents(l-c,f-h,g-p,M-v).normalize();else if(i[4].setComponents(l-c,f-h,g-p,M-v).normalize(),t===$n)i[5].setComponents(l+c,f+h,g+p,M+v).normalize();else if(t===Vo)i[5].setComponents(c,h,p,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),vs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),vs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(vs)}intersectsSprite(e){vs.center.set(0,0,0);const t=R0.distanceTo(e.center);return vs.radius=.7071067811865476+t,vs.applyMatrix4(e.matrixWorld),this.intersectsSphere(vs)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(ya.x=i.normal.x>0?e.max.x:e.min.x,ya.y=i.normal.y>0?e.max.y:e.min.y,ya.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ya)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const ci=new Oe,li=new Hr;class kd{constructor(){this.coordinateSystem=$n}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(ci.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),li.setFromProjectionMatrix(ci,i.coordinateSystem,i.reversedDepth),li.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(ci.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),li.setFromProjectionMatrix(ci,i.coordinateSystem,i.reversedDepth),li.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(ci.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),li.setFromProjectionMatrix(ci,i.coordinateSystem,i.reversedDepth),li.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(ci.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),li.setFromProjectionMatrix(ci,i.coordinateSystem,i.reversedDepth),li.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(ci.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),li.setFromProjectionMatrix(ci,i.coordinateSystem,i.reversedDepth),li.containsPoint(e))return!0}return!1}clone(){return new kd}}function xl(s,e){return s-e}function P0(s,e){return s.z-e.z}function L0(s,e){return e.z-s.z}class I0{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,i){const r=this.pool,o=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];o.push(a),this.index++,a.start=e,a.count=t,a.z=n,a.index=i}reset(){this.list.length=0,this.index=0}}const Mn=new Oe,D0=new ze(1,1,1),nf=new Hr,N0=new kd,va=new ct,_s=new fn,to=new D,sf=new D,U0=new D,yl=new I0,cn=new Qe,_a=[];function O0(s,e,t=0){const n=e.itemSize;
1if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){const i=s.count;for(let r=0;r<i;r++)for(let o=0;o<n;o++)e.setComponent(r+t,o,s.getComponent(r,o))}else e.array.set(s.array,t*n);e.needsUpdate=!0}function bs(s,e){if(s.constructor!==e.constructor){const t=Math.min(s.length,e.length);for(let n=0;n<t;n++)e[n]=s[n]}else{const t=Math.min(s.length,e.length);e.set(new s.constructor(s.buffer,0,t))}}class F0 extends Qe{constructor(e,t,n=t*2,i){super(new vt,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new Er(t,e,e,An,En);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new Er(t,e,e,Pc,si);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new Er(t,e,e,An,En);
1n.colorSpace=it.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(this._geometryInitialized===!1){for(const r in e.attributes){const o=e.getAttribute(r),{array:a,itemSize:c,normalized:l}=o,d=new a.constructor(n*c),u=new Rt(d,c,l);t.setAttribute(r,u)}if(e.getIndex()!==null){const r=n>65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new Rt(r,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=e.getAttribute(n),r=t.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ct);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(t[n].active===!1)continue;const r=t[n].geometryIndex;this.getMatrixAt(n,Mn),this.getBoundingBoxAt(r,va).applyMatrix4(Mn),e.union(va)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new fn);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(t[n].active===!1)continue;const r=t[n].geometryIndex;this.getMatrixAt(n,Mn),this.getBoundingSphereAt(r,_s).applyMatrix4(Mn),e.union(_s)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(xl),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));const r=this._matricesTexture;Mn.identity().toArray(r.image.data,i*16),r.needsUpdate=!0;const o=this._colorsTexture;return o&&(D0.toArray(o.image.data,i*4),o.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const o=e.getIndex();if(o!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?o.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let c;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(xl),c=this._availableGeometryIds.shift(),r[c]=i):(c=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(c,e),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,c}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,i=n.getIndex()!==null,r=n.getIndex(),o=t.getIndex(),a=this._geometryInfo[e];if(i&&o.count>a.reservedIndexCount||t.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const c=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=t.getAttribute("position").count;for(const d in n.attributes){const u=t.getAttribute(d),h=n.getAttribute(d);O0(u,h,c);const f=u.itemSize;
1for(let m=u.count,x=l;m<x;m++){const p=c+m;for(let g=0;g<f;g++)h.setComponent(p,g,0)}h.needsUpdate=!0,h.addUpdateRange(c*f,l*f)}if(i){const d=a.indexStart,u=a.reservedIndexCount;a.indexCount=t.getIndex().count;for(let h=0;h<o.count;h++)r.setX(d+h,c+o.getX(h));for(let h=o.count,f=u;h<f;h++)r.setX(d+h,c);r.needsUpdate=!0,r.addUpdateRange(d,a.reservedIndexCount)}return a.start=i?a.indexStart:a.vertexStart,a.count=i?a.indexCount:a.vertexCount,a.boundingBox=null,t.boundingBox!==null&&(a.boundingBox=t.boundingBox.clone()),a.boundingSphere=null,t.boundingSphere!==null&&(a.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let i=0,r=n.length;i<r;i++)n[i].active&&n[i].geometryIndex===e&&this.deleteInstance(i);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const n=this._geometryInfo,i=n.map((o,a)=>a).sort((o,a)=>n[o].vertexStart-n[a].vertexStart),r=this.geometry;for(let o=0,a=n.length;o<a;o++){const c=i[o],l=n[c];if(l.active!==!1){if(r.index!==null){if(l.indexStart!==t){const{indexStart:d,vertexStart:u,reservedIndexCount:h}=l,f=r.index,m=f.array,x=e-u;for(let p=d;p<d+h;p++)m[p]=m[p]+x;f.array.copyWithin(t,d,d+h),f.addUpdateRange(t,h),f.needsUpdate=!0,l.indexStart=t}t+=l.reservedIndexCount}if(l.vertexStart!==e){const{vertexStart:d,reservedVertexCount:u}=l,h=r.attributes;for(const f in h){const m=h[f],{array:x,itemSize:p}=m;x.copyWithin(e*p,d*p,(d+u)*p),m.addUpdateRange(e*p,u*p),m.needsUpdate=!0}l.vertexStart=e}e+=l.reservedVertexCount,l.start=r.index?l.indexStart:l.vertexStart}}return this._nextIndexStart=t,this._nextVertexStart=e,this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(i.boundingBox===null){const r=new ct,o=n.index,a=n.attributes.position;for(let c=i.start,l=i.start+i.count;c<l;c++){let d=c;o&&(d=o.getX(d)),r.expandByPoint(to.fromBufferAttribute(a,d))}i.boundingBox=r}return t.copy(i.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(i.boundingSphere===null){const r=new fn;this.getBoundingBoxAt(e,va),va.getCenter(r.center);const o=n.index,a=n.attributes.position;let c=0;for(let l=i.start,d=i.start+i.count;l<d;l++){let u=l;o&&(u=o.getX(u)),to.fromBufferAttribute(a,u),c=Math.max(c,r.center.distanceToSquared(to))}r.radius=Math.sqrt(c),i.boundingSphere=r}return t.copy(i.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const n=this._matricesTexture,i=this._matricesTexture.image.data;return t.toArray(i,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){const t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(xl);t[t.length-1]===n.length-1;)n.pop(),t.pop();if(e<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const i=new Int32Array(e),r=new Int32Array(e);bs(this._multiDrawCounts,i),bs(this._multiDrawStarts,r),this._multiDrawCounts=i,this._multiDrawStarts=r,this._maxInstanceCount=e;const o=this._indirectTexture,a=this._matricesTexture,c=this._colorsTexture;o.dispose(),this._initIndirectTexture(),bs(o.image.data,this._indirectTexture.image.data),a.dispose(),this._initMatricesTexture(),bs(a.image.data,this._matricesTexture.image.data),c&&(c.dispose(),this._initColorsTexture(),bs(c.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const n=[...this._geometryInfo].filter(a=>a.active);if(Math.max(...n.map(a=>a.vertexStart+a.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(c=>c.indexStart+c.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new vt,this._initializeGeometry(r));const o=this.geometry;r.index&&bs(r.index.array,o.index.array);for(const a in r.attributes)bs(r.attributes[a].array,o.attributes[a].array)}raycast(e,t){const n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,o=this.geometry;cn.material=this.material,cn.geometry.index=o.index,cn.geometry.attributes=o.attributes,cn.geometry.boundingBox===null&&(cn.geometry.boundingBox=new ct),cn.geometry.boundingSphere===null&&(cn.geometry.boundingSphere=new fn);for(let a=0,c=n.length;a<c;a++){if(!n[a].visible||!n[a].active)continue;const l=n[a].geometryIndex,d=i[l];cn.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(a,cn.matrixWorld).premultiply(r),this.getBoundingBoxAt(l,cn.geometry.boundingBox),this.getBoundingSphereAt(l,cn.geometry.boundingSphere),cn.raycast(e,_a);for(let u=0,h=_a.length;u<h;u++){const f=_a[u];f.object=this,f.batchId=a,t.push(f)}_a.length=0}cn.material=null,cn.geometry.index=null,cn.geometry.attributes={},cn.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex();let a=o===null?1:o.array.BYTES_PER_ELEMENT,c=1;r.wireframe&&(c=2,a=i.attributes.position.count>65535?4:2);const l=this._instanceInfo,d=this._multiDrawStarts,u=this._multiDrawCounts,h=this._geometryInfo,f=this.perObjectFrustumCulled,m=this._indirectTexture,x=m.image.data,p=n.isArrayCamera?N0:nf;f&&!n.isArrayCamera&&(Mn.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),nf.setFromProjectionMatrix(Mn,n.c
1oordinateSystem,n.reversedDepth));let g=0;if(this.sortObjects){Mn.copy(this.matrixWorld).invert(),to.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Mn),sf.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Mn);for(let v=0,M=l.length;v<M;v++)if(l[v].visible&&l[v].active){const w=l[v].geometryIndex;this.getMatrixAt(v,Mn),this.getBoundingSphereAt(w,_s).applyMatrix4(Mn);let E=!1;if(f&&(E=!p.intersectsSphere(_s,n)),!E){const b=h[w],S=U0.subVectors(_s.center,to).dot(sf);yl.push(b.start,b.count,S,v)}}const y=yl.list,_=this.customSort;_===null?y.sort(r.transparent?L0:P0):_.call(this,y,n);for(let v=0,M=y.length;v<M;v++){const w=y[v];d[g]=w.start*a*c,u[g]=w.count*c,x[g]=w.index,g++}yl.reset()}else for(let y=0,_=l.length;y<_;y++)if(l[y].visible&&l[y].active){const v=l[y].geometryIndex;let M=!1;if(f&&(this.getMatrixAt(y,Mn),this.getBoundingSphereAt(v,_s).applyMatrix4(Mn),M=!p.intersectsSphere(_s,n)),!M){const w=h[v];d[g]=w.start*a*c,u[g]=w.count*c,x[g]=y,g++}}m.needsUpdate=!0,this._multiDrawCount=g,this._visibilityChanged=!1}onBeforeShadow(e,t,n,i,r,o){this.onBeforeRender(e,null,i,r,o)}}class tm extends Mi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ze(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const vc=new D,_c=new D,rf=new Oe,no=new Si,ba=new fn,vl=new D,of=new D;class Zo extends Et{constructor(e=new vt,t=new tm){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)vc.fromBufferAttribute(t,i-1),_c.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=vc.distanceTo(_c);e.setAttribute("lineDistance",new rt(n,1))}else Ne("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ba.copy(n.boundingSphere),ba.applyMatrix4(i),ba.radius+=r,e.ray.intersectsSphere(ba)===!1)return;rf.copy(i).invert(),no.copy(e.ray).applyMatrix4(rf);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,d=n.index,h=n.attributes.position;if(d!==null){const f=Math.max(0,o.start),m=Math.min(d.count,o.start+o.count);for(let x=f,p=m-1;x<p;x+=l){const g=d.getX(x),y=d.getX(x+1),_=Ma(this,e,no,c,g,y,x);_&&t.push(_)}if(this.isLineLoop){const x=d.getX(m-1),p=d.getX(f),g=Ma(this,e,no,c,x,p,m-1);g&&t.push(g)}}else{const f=Math.max(0,o.start),m=Math.min(h.count,o.start+o.count);for(let x=f,p=m-1;x<p;x+=l){const g=Ma(this,e,no,c,x,x+1,x);g&&t.push(g)}if(this.isLineLoop){const x=Ma(this,e,no,c,m-1,f,m-1);x&&t.push(x)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Ma(s,e,t,n,i,r,o){const a=s.geometry.attributes.position;if(vc.fromBufferAttribute(a,i),_c.fromBufferAttribute(a,r),t.distanceSqToSegment(vc,_c,vl,of)>n)return;vl.applyMatrix4(s.matrixWorld);const l=e.ray.origin.distanceTo(vl);if(!(l<e.near||l>e.far))return{distance:l,point:of.clone().applyMatrix4(s.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:s}}const af=new D,cf=new D;class Bd extends Zo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)af.fromBufferAttribute(t,i),cf.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+af.distanceTo(cf);e.setAttribute("lineDistance",new rt(n,1))}else Ne("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class zd extends Zo{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Vd extends Mi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ze(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const lf=new Oe,ju=new Si,Sa=new fn,wa=new D;
vendor: 4,362 bytes, line 1
1class Dc extends Et{constructor(e=new vt,t=new Vd){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Sa.copy(n.boundingSphere),Sa.applyMatrix4(i),Sa.radius+=r,e.ray.intersectsSphere(Sa)===!1)return;lf.copy(i).invert(),ju.copy(e.ray).applyMatrix4(lf);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=n.index,u=n.attributes.position;if(l!==null){const h=Math.max(0,o.start),f=Math.min(l.count,o.start+o.count);for(let m=h,x=f;m<x;m++){const p=l.getX(m);wa.fromBufferAttribute(u,p),uf(wa,p,c,i,e,t,this)}}else{const h=Math.max(0,o.start),f=Math.min(u.count,o.start+o.count);for(let m=h,x=f;m<x;m++)wa.fromBufferAttribute(u,m),uf(wa,m,c,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function uf(s,e,t,n,i,r,o){const a=ju.distanceSqToPoint(s);if(a<t){const c=new D;ju.closestPointToPoint(s,c),c.applyMatrix4(n);const l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;r.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}class nm extends Ot{constructor(e=[],t=Os,n,i,r,o,a,c,l,d){super(e,t,n,i,r,o,a,c,l,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class im extends Ot{constructor(e,t,n,i,r,o,a,c,l){super(e,t,n,i,r,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Go extends Ot{constructor(e,t,n=si,i,r,o,a=Ut,c=Ut,l,d=Gi,u=1){if(d!==Gi&&d!==Ds)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const h={width:e,height:t,depth:u};super(h,i,r,o,a,c,d,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Dd(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class k0 extends Go{constructor(e,t=si,n=Os,i,r,o=Ut,a=Ut,c,l=Gi){const d={width:e,height:e,depth:1},u=[d,d,d,d,d,d];super(e,e,t,n,i,r,o,a,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class sm extends Ot{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class ei extends vt{constructor(e=1,t=1,n=1,i=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:o};const a=this;i=Math.floor(i),r=Math.floor(r),o=Math.floor(o);const c=[],l=[],d=[],u=[];let h=0,f=0;m("z","y","x",-1,-1,n,t,e,o,r,0),m("z","y","x",1,-1,n,t,-e,o,r,1),m("x","z","y",1,1,e,n,t,i,o,2),m("x","z","y",1,-1,e,n,-t,i,o,3),m("x","y","z",1,-1,e,t,n,i,r,4),m("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new rt(l,3)),this.setAttribute("normal",new rt(d,3)),this.setAttribute("uv",new rt(u,2));function m(x,p,g,y,_,v,M,w,E,b,S){const P=v/E,A=M/b,T=v/2,I=M/2,k=w/2,F=E+1,L=b+1;let O=0,H=0;const W=new D;for(let q=0;q<L;q++){const Z=q*A-I;for(let V=0;V<F;V++){const K=V*P-T;W[x]=K*y,W[p]=Z*_,W[g]=k,l.push(W.x,W.y,W.z),W[x]=0,W[p]=0,W[g]=w>0?1:-1,d.push(W.x,W.y,W.z),u.push(V/E),u.push(1-q/b),O+=1}}for(let q=0;q<b;q++)for(let Z=0;Z<E;Z++){const V=h+Z+F*q,K=h+Z+F*(q+1),ce=h+(Z+1)+F*(q+1),$=h+(Z+1)+F*q;c.push(V,K,$),c.push(K,ce,$),H+=6}a.addGroup(f,H,S),f+=H,h+=O}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ei(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Ps extends vt{constructor(e=1,t=1,n=4,i=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radiu
1s:e,height:t,capSegments:n,radialSegments:i,heightSegments:r},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i)),r=Math.max(1,Math.floor(r));const o=[],a=[],c=[],l=[],d=t/2,u=Math.PI/2*e,h=t,f=2*u+h,m=n*2+r,x=i+1,p=new D,g=new D;for(let y=0;y<=m;y++){let _=0,v=0,M=0,w=0;if(y<=n){const S=y/n,P=S*Math.PI/2;v=-d-e*Math.cos(P),M=e*Math.sin(P),w=-e*Math.cos(P),_=S*u}else if(y<=n+r){const S=(y-n)/r;v=-d+S*t,M=e,w=0,_=u+S*h}else{const S=(y-n-r)/n,P=S*Math.PI/2;v=d+e*Math.sin(P),M=e*Math.cos(P),w=e*Math.sin(P),_=u+h+S*u}const E=Math.max(0,Math.min(1,_/f));let b=0;y===0?b=.5/i:y===m&&(b=-.5/i);for(let S=0;S<=i;S++){const P=S/i,A=P*Math.PI*2,T=Math.sin(A),I=Math.cos(A);g.x=-M*I,g.y=v,g.z=M*T,a.push(g.x,g.y,g.z),p.set(-M*I,w,M*T),p.normalize(),c.push(p.x,p.y,p.z),l.push(P+b,E)}if(y>0){const S=(y-1)*x;for(let P=0;P<i;P++){const A=S+P,T=S+P+1,I=y*x+P,k=y*x+P+1;o.push(A,T,I),o.push(T,k,I)}}}this.setIndex(o),this.setAttribute("position",new rt(a,3)),this.setAttribute("normal",new rt(c,3)),this.setAttribute("uv",new rt(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ps(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class Wo extends vt{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const r=[],o=[],a=[],c=[],l=new D,d=new xe;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let u=0,h=3;u<=t;u++,h+=3){const f=n+u/t*i;l.x=e*Math.cos(f),l.y=e*Math.sin(f),o.push(l.x,l.y,l.z),a.push(0,0,1),d.x=(o[h]/e+1)/2,d.y=(o[h+1]/e+1)/2,c.push(d.x,d.y)}for(let u=1;u<=t;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new rt(o,3)),this.setAttribute("normal",new rt(a,3)),this.setAttribute("uv",new rt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Wo(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Hd extends vt{constructor(e=1,t=1,n=1,i=32,r=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:c};const l=this;i=Math.floor(i),r=Math.floor(r);const d=[],u=[],h=[],f=[];let m=0;const x=[],p=n/2;let g=0;y(),o===!1&&(e>0&&_(!0),t>0&&_(!1)),this.setIndex(d),this.setAttribute("position",new rt(u,3)),this.setAttribute("normal",new rt(h,3)),this.setAttribute("uv",new rt(f,2));function y(){const v=new D,M=new D;let w=0;const E=(t-e)/n;for(let b=0;b<=r;b++){const S=[],P=b/r,A=P*(t-e)+e;for(let T=0;T<=i;T++){const I=T/i,k=I*c+a,F=Math.sin(k),L=Math.cos(k);M.x=A*F,M.y=-P*n+p,M.z=A*L,u.push(M.x,M.y,M.z),v.set(F,E,L).normalize(),h.push(v.x,v.y,v.z),f.push(I,1-P),S.push(m++)}x.push(S)}for(let b=0;b<i;b++)for(let S=0;S<r;S++){const P=x[S][b],A=x[S+1][b],T=x[S+1][b+1],I=x[S][b+1];(e>0||S!==0)&&(d.push(P,A,I),w+=3),(t>0||S!==r-1)&&(d.push(A,T,I),w+=3)}l.addGroup(g,w,0),g+=w}function _(v){const M=m,w=new xe,E=new D;let b=0;const S=v===!0?e:t,P=v===!0?1:-1;for(let T=1;T<=i;T++)u.push(0,p*P,0),h.push(0,P,0),f.push(.5,.5),m++;const A=m;for(let T=0;T<=i;T++){const k=T/i*c+a,F=Math.cos(k),L=Math.sin(k);E.x=S*L,E.y=p*P,E.z=S*F,u.push(E.x,E.y,E.z),h.push(0,P,0),w.x=F*.5+.5,w.y=L*.5*P+.5,f.push(w.x,w.y),m++}for(let T=0;T<i;T++){const I=M+T,k=A+T;v===!0?d.push(k,k+1,I):d.push(k+1,k,I),b+=3}l.addGroup(g,b,v===!0?1:2),g+=b}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Hd(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class qi{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){Ne("Curve: .getPoint() not implemented.")}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let i=0;const r=n.length;let o;t?o=t:o=e*n[r-1];let a=0,c=r-1,l;for(;a<=c;)if(i=Math.floor(a+(c-a)/2),l=n[i]-o,l<0)a=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===o)return i/(r-1);const d=n[i],h=n[i+1]-d,f=(o-d)/h;return(i+f)/(r-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const o=this.getPoint(i),a=this.getPoint(r),c=t||(o.isVector2?new xe:new D);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new D,i=[],r=[],o=[],a=new D,c=new Oe;for(let f=0;f<=e;f++){const m=f/e;i[f]=this.getTangentAt(m,new D)}r[0]=new D,o[0]=new D;let l=Number.MAX_VALUE;const d=Math.abs(i[0].x),u=Math.abs(i[0].y),h=Math.abs(i[0].z);d<=l&&(l=d,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),h<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),o[0].crossVectors(i[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();const m=Math.acos(qe(i[f-1].dot(i[f]),-1,1));r[f].applyMatrix4(c.makeRotationAxis(a,m))}o[f].crossVectors(i[f],r[f])}if(t===!0){let f=Math.acos(qe(r[0].dot(r[e]),-1,1));f/=e,i[0].dot(a.crossVectors(r[0],r[e]))>0&&(f=-f);for(let m=1;m<=e;m++)r[m].applyMatrix4(c.makeRotationAxis(i[m],f*m)),o[m].crossVectors(i[m],r[m])}return{tangents:i,normals:r,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.t
vendor: 26,088 bytes, lines 1-5
1ype,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class rm extends qi{constructor(e=0,t=0,n=1,i=1,r=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t=new xe){const n=t,i=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(o?r=0:r=i),this.aClockwise===!0&&!o&&(r===i?r=-i:r=r-i);const a=this.aStartAngle+e*r;let c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const d=Math.cos(this.aRotation),u=Math.sin(this.aRotation),h=c-this.aX,f=l-this.aY;c=h*d-f*u+this.aX,l=h*u+f*d+this.aY}return n.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class B0 extends rm{constructor(e,t,n,i,r,o){super(e,t,n,n,i,r,o),this.isArcCurve=!0,this.type="ArcCurve"}}function Gd(){let s=0,e=0,t=0,n=0;function i(r,o,a,c){s=r,e=a,t=-3*r+3*o-2*a-c,n=2*r-2*o+a+c}return{initCatmullRom:function(r,o,a,c,l){i(o,a,l*(a-r),l*(c-o))},initNonuniformCatmullRom:function(r,o,a,c,l,d,u){let h=(o-r)/l-(a-r)/(l+d)+(a-o)/d,f=(a-o)/d-(c-o)/(d+u)+(c-a)/u;h*=d,f*=d,i(o,a,h,f)},calc:function(r){const o=r*r,a=o*r;return s+e*r+t*o+n*a}}}const Ta=new D,_l=new Gd,bl=new Gd,Ml=new Gd;class Wd extends qi{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new D){const n=t,i=this.points,r=i.length,o=(r-(this.closed?0:1))*e;let a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/r)+1)*r:c===0&&a===r-1&&(a=r-2,c=1);let l,d;this.closed||a>0?l=i[(a-1)%r]:(Ta.subVectors(i[0],i[1]).add(i[0]),l=Ta);const u=i[a%r],h=i[(a+1)%r];if(this.closed||a+2<r?d=i[(a+2)%r]:(Ta.subVectors(i[r-1],i[r-2]).add(i[r-1]),d=Ta),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let m=Math.pow(l.distanceToSquared(u),f),x=Math.pow(u.distanceToSquared(h),f),p=Math.pow(h.distanceToSquared(d),f);x<1e-4&&(x=1),m<1e-4&&(m=x),p<1e-4&&(p=x),_l.initNonuniformCatmullRom(l.x,u.x,h.x,d.x,m,x,p),bl.initNonuniformCatmullRom(l.y,u.y,h.y,d.y,m,x,p),Ml.initNonuniformCatmullRom(l.z,u.z,h.z,d.z,m,x,p)}else this.curveType==="catmullrom"&&(_l.initCatmullRom(l.x,u.x,h.x,d.x,this.tension),bl.initCatmullRom(l.y,u.y,h.y,d.y,this.tension),Ml.initCatmullRom(l.z,u.z,h.z,d.z,this.tension));return n.set(_l.calc(c),bl.calc(c),Ml.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new D().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function df(s,e,t,n,i){const r=(n-e)*.5,o=(i-t)*.5,a=s*s,c=s*a;return(2*t-2*n+r+o)*c+(-3*t+3*n-2*r-o)*a+r*s+t}function z0(s,e){const t=1-s;return t*t*e}function V0(s,e){return 2*(1-s)*s*e}function H0(s,e){return s*s*e}function Eo(s,e,t,n){return z0(s,e)+V0(s,t)+H0(s,n)}function G0(s,e){const t=1-s;return t*t*t*e}function W0(s,e){const t=1-s;return 3*t*t*s*e}function X0(s,e){return 3*(1-s)*s*s*e}function q0(s,e){return s*s*s*e}function Ao(s,e,t,n,i){return G0(s,e)+W0(s,t)+X0(s,n)+q0(s,i)}class j0 extends qi{constructor(e=new xe,t=new xe,n=new xe,i=new xe){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new xe){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Ao(e,i.x,r.x,o.x,a.x),Ao(e,i.y,r.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Y0 extends qi{constructor(e=new D,t=new D,n=new D,i=new D){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new D){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Ao(e,i.x,r.x,o.x,a.x),Ao(e,i.y,r.y,o.y,a.y),Ao(e,i.z,r.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class K0 extends qi{constructor(e=new xe,t=new xe){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new xe){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new xe){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Z0 extends qi{constructor(e=new D,t=new D){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new D){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new D){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class J0 extends qi{constructor(e=new xe,t=new xe,n=new xe){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new xe){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(Eo(e,i.x,r.x,o.x),Eo(e,i.y,r.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class om extends qi{constructor(e=new D,t=new D,n=new D){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new D){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(Eo(e,i.x,r.x,o.x),Eo(e,i.y,r.y,o.y),Eo(e,i.z,r.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Q0 extends qi{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new xe){const n=t,i=this.points,r=(i.length-1)*e,o=Math.floor(r),a=r-o,c=i[o===0?o:o-1],l=i[o],d=i[o>i.length-2?i.length-1:o+1],u=i[o>i.length-3?i.length-1:o+2];return n.set(df(a,c.x,l.x,d.x,u.x),df(a,c.y,l.y,d.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new xe().fromArray(i))}return this}}var $0=Object.freeze({__proto__:null,ArcCurve:B0,CatmullRomCurve3:Wd,CubicBezierCurve:j0,CubicBezierCurve3:Y0,EllipseCurve:rm,LineCurve:K0,LineCurve3:Z0,QuadraticBezierCurve:J0,QuadraticBezierCurve3:om,SplineCurve:Q0});class Nc extends vt{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,o=t/2,a=Math.floor(n),c=Math.floor(i),l=a+1,d=c+1,u=e/a,h=t/c,f=[],m=[],x=[],p=[];for(let g=0;g<d;g++){const y=g*h-o;for(let _=0;_<l;_++){const v=_*u-r;m.push(v,-y,0),x.push(0,0,1),p.push(_/a),p.push(1-g/c)}}for(let g=0;g<c;g++)for(let y=0;y<a;y++){const _=y+l*g,v=y+l*(g+1),M=y+1+l*(g+1),w=y+1+l*g;f.push(_,v,w),f.push(v,M,w)}this.setIndex(f),this.setAttribute("position",new rt(m,3)),this.setAttribute("normal",new rt(x,3)),this.setAttribute("uv",new rt(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Nc(e.width,e.height,e.widthSegments,e.heightSegments)}}class Xd extends vt{constructor(e=.5,t=1,n=32,i=1,r=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:o},n=Math.max(3,n),i=Math.max(1,i);const a=[],c=[],l=[],d=[];let u=e;const h=(t-e)/i,f=new D,m=new xe;for(let x=0;x<=i;x++){for(let p=0;p<=n;p++){const g=r+p/n*o;f.x=u*Math.cos(g),f.y=u*Math.sin(g),c.push(f.x,f.y,f.z),l.push(0,0,1),m.x=(f.x/t+1)/2,m.y=(f.y/t+1)/2,d.push(m.x,m.y)}u+=h}for(let x=0;x<i;x++){const p=x*(n+1);for(let g=0;g<n;g++){const y=g+p,_=y,v=y+n+1,M=y+n+2,w=y+1;a.push(_,v,w),a.push(v,M,w)}}this.setIndex(a),this.setAttribute("position",new rt(c,3)),this.setAttribute("normal",new rt(l,3)),this.setAttribute("uv",new rt(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xd(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Cn extends vt{constructor(e=1,t=32,n=16,i=0,r=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:r,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const c=Math.min(o+a,Math.PI);let l=0;const d=[],u=new D,h=new D,f=[],m=[],x=[],p=[];for(let g=0;g<=n;g++){const y=[],_=g/n;let v=0;g===0&&o===0?v=.5/t:g===n&&c===Math.PI&&(v=-.5/t);for(let M=0;M<=t;M++){const w=M/t;u.x=-e*Math.cos(i+w*r)*Math.sin(o+_*a),u.y=e*Math.cos(o+_*a),u.z=e*Math.sin(i+w*r)*Math.sin(o+_*a),m.push(u.x,u.y,u.z),h.copy(u).normalize(),x.push(h.x,h.y,h.z),p.push(w+v,1-_),y.push(l++)}d.push(y)}for(let g=0;g<n;g++)for(let y=0;y<t;y++){const _=d[g][y+1],v=d[g][y],M=d[g+1][y],w=d[g+1][y+1];(g!==0||o>0)&&f.push(_,v,w),(g!==n-1||c<Math.PI)&&f.push(v,M,w)}this.setIndex(f),this.setAttribute("position",new rt(m,3)),this.setAttribute("normal",new rt(x,3)),this.setAttribute("uv",new rt(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Cn(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class qd extends vt{constructor(e=1,t=.4,n=12,i=48,r=Math.PI*2,o=0,a=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:r,thetaStart:o,thetaLength:a},n=Math.floor(n),i=Math.floor(i);const c=[],l=[],d=[],u=[],h=new D,f=new D,m=new D;for(let x=0;x<=n;x++){const p=o+x/n*a;for(let g=0;g<=i;g++){const y=g/i*r;f.x=(e+t*Math.cos(p))*Math.cos(y),f.y=(e+t*Math.cos(p))*Math.sin(y),f.z=t*Math.sin(p),l.push(f.x,f.y,f.z),h.x=e*Math.cos(y),h.y=e*Math.sin(y),m.subVectors(f,h).normalize(),d.push(m.x,m.y,m.z),u.push(g/i),u.push(x/n)}}for(let x=1;x<=n;x++)for(let p=1;p<=i;p++){const g=(i+1)*x+p-1,y=(i+1)*(x-1)+p-1,_=(i+1)*(x-1)+p,v=(i+1)*x+p;c.push(g,y,v),c.push(y,_,v)}this.setIndex(c),this.setAttribute("position",new rt(l,3)),this.setAttribute("normal",new rt(d,3)),this.setAttribute("uv",new rt(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new qd(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class jd extends vt{constructor(e=new om(new D(-1,-1,0),new D(-1,1,0),new D(1,1,0)),t=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:r};const o=e.computeFrenetFrames(t,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new D,c=new D,l=new xe;let d=new D;const u=[],h=[],f=[],m=[];x(),this.setIndex(m),this.setAttribute("position",new rt(u,3)),this.setAttribute("normal",new rt(h,3)),this.setAttribute("uv",new rt(f,2));function x(){for(let _=0;_<t;_++)p(_);p(r===!1?t:0),y(),g()}function p(_){d=e.getPointAt(_/t,d);const v=o.normals[_],M=o.binormals[_];for(let w=0;w<=i;w++){const E=w/i*Math.PI*2,b=Math.sin(E),S=-Math.cos(E);c.x=S*v.x+b*M.x,c.y=S*v.y+b*M.y,c.z=S*v.z+b*M.z,c.normalize(),h.push(c.x,c.y,c.z),a.x=d.x+n*c.x,a.y=d.y+n*c.y,a.z=d.z+n*c.z,u.push(a.x,a.y,a.z)}}function g(){for(let _=1;_<=t;_++)for(let v=1;v<=i;v++){const M=(i+1)*(_-1)+(v-1),w=(i+1)*_+(v-1),E=(i+1)*_+v,b=(i+1)*(_-1)+v;m.push(M,w,b),m.push(w,E,b)}}function y(){for(let _=0;_<=t;_++)for(let v=0;v<=i;v++)l.x=_/t,l.y=v/i,f.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new jd(new $0[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}function Fr(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(Ne("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function xn(s){const e={};for(let t=0;t<s.length;t++){const n=Fr(s[t]);for(const i in n)e[i]=n[i]}return e}function ex(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function am(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:it.workingColorSpace}const Ar={clone:Fr,merge:xn};var tx=`void main() { 2 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 3}`,nx=`void main() { 4 gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); 5}`;class pn extends Mi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=tx,this.fragmentShader=nx,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Fr(e.uniforms),this.uniformsGroups=ex(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?t.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[i]={type:"m4",value:o.toArray()}:t.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class cm extends pn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Un extends Mi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ze(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yp,this.normalScale=new xe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class qn extends Un{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new xe(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return qe(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ze(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ze(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ze(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class lm extends Mi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Pg,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class ix extends Mi{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function Ea(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function sx(s){function e(i,r){return s[i]-s[r]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function hf(s,e,t){const n=s.length,i=new s.constructor(n);for(let r=0,o=0;o!==n;++r){const a=t[r]*e;for(let c=0;c!==e;++c)i[o++]=s[a+c]}return i}function um(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(e.push(r.time),t.push(...o)),r=s[i++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do o=r[n],o!==void 0&&(e.push(r.time),t.push(o)),r=s[i++];while(r!==void 0)}class Gr{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];n:{e:{let o;t:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=t[++n],e<i)break e}o=t.length;break t}if(!(e>=r)){const a=t[1];e<a&&(n=2,r=a);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(i=r,r=t[--n-1],e>=r)break e}o=n,n=0;break t}break n}for(;n<o;){const a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let o=0;o!==i;++o)t[o]=n[r+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class rx extends Gr{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ah,endingEnd:Ah}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,o=e+1,a=i[r],c=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Ch:r=e,a=2*t-n;break
5;case Rh:r=i.length-2,a=t+i[r]-i[r+1];break;default:r=e,a=n}if(c===void 0)switch(this.getSettings_().endingEnd){case Ch:o=e,c=2*n-t;break;case Rh:o=1,c=n+i[1]-i[0];break;default:o=e-1,c=t}const l=(n-t)*.5,d=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-n),this._offsetPrev=r*d,this._offsetNext=o*d}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,d=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,f=this._weightNext,m=(n-t)/(i-t),x=m*m,p=x*m,g=-h*p+2*h*x-h*m,y=(1+h)*p+(-1.5-2*h)*x+(-.5+h)*m+1,_=(-1-f)*p+(1.5+f)*x+.5*m,v=f*p-f*x;for(let M=0;M!==a;++M)r[M]=g*o[d+M]+y*o[l+M]+_*o[c+M]+v*o[u+M];return r}}class ox extends Gr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,d=(n-t)/(i-t),u=1-d;for(let h=0;h!==a;++h)r[h]=o[l+h]*u+o[c+h]*d;return r}}class ax extends Gr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class cx extends Gr{interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,d=this.settings||this.DefaultSettings_,u=d.inTangents,h=d.outTangents;if(!u||!h){const x=(n-t)/(i-t),p=1-x;for(let g=0;g!==a;++g)r[g]=o[l+g]*p+o[c+g]*x;return r}const f=a*2,m=e-1;for(let x=0;x!==a;++x){const p=o[l+x],g=o[c+x],y=m*f+x*2,_=h[y],v=h[y+1],M=e*f+x*2,w=u[M],E=u[M+1];let b=(n-t)/(i-t),S,P,A,T,I;for(let k=0;k<8;k++){S=b*b,P=S*b,A=1-b,T=A*A,I=T*A;const L=I*t+3*T*b*_+3*A*S*w+P*i-n;if(Math.abs(L)<1e-10)break;const O=3*T*(_-t)+6*A*b*(w-_)+3*S*(i-w);if(Math.abs(O)<1e-10)break;b=b-L/O,b=Math.max(0,Math.min(1,b))}r[x]=I*p+3*T*b*v+3*A*S*E+P*g}return r}}class oi{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Ea(t,this.TimeBufferType),this.values=Ea(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Ea(e.times,Array),values:Ea(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new ax(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new ox(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new rx(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new cx(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.settings=this.settings),t}setInterpolation(e){let t;switch(e){case Bo:t=this.InterpolantFactoryMethodDiscrete;break;case zo:t=this.InterpolantFactoryMethodLinear;break;case qc:t=this.InterpolantFactoryMethodSmooth;break;case Eh:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return Ne("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Bo;case this.InterpolantFactoryMethodLinear:return zo;case this.InterpolantFactoryMethodSmooth:return qc;case this.InterpolantFactoryMethodBezier:return Eh}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,o=i-1;for(;r!==i&&n[r]<e;)++r;for(;o!==-1&&n[o]>t;)--o;if(++o,r!==0||o!==i){r>=o&&(o=Math.max(o,1),r=o-1);const a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(We("KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;r===0&&(We("KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){const c=n[a];if(typeof c=="number"&&isNaN(c)){We("KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){We("KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(i!==void 0&&zg(i))for(let a=0,c=i.length;a!==c;++a){const l=i[a];if(isNaN(l)){We("KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===qc,r=e.length-1;let o=1;for(let a=1;a<r;++a){let c=!1;const l=e[a],d=e[a+1];if(l!==d&&(a!==1||l!==e[0]))if(i)c=!0;else{const u=a*n,h=u-n,f=u+n;for(let m=0;m!==n;++m){const x=t[u+m];if(x!==t[h+m]||x!==t[f+m]){c=!0;break}}}
vendor: 23,741 bytes, line 5
5if(c){if(a!==o){e[o]=e[a];const u=a*n,h=o*n;for(let f=0;f!==n;++f)t[h+f]=t[u+f]}++o}}if(r>0){e[o]=e[r];for(let a=r*n,c=o*n,l=0;l!==n;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}oi.prototype.ValueTypeName="";oi.prototype.TimeBufferType=Float32Array;oi.prototype.ValueBufferType=Float32Array;oi.prototype.DefaultInterpolation=zo;class Wr extends oi{constructor(e,t,n){super(e,t,n)}}Wr.prototype.ValueTypeName="bool";Wr.prototype.ValueBufferType=Array;Wr.prototype.DefaultInterpolation=Bo;Wr.prototype.InterpolantFactoryMethodLinear=void 0;Wr.prototype.InterpolantFactoryMethodSmooth=void 0;class dm extends oi{constructor(e,t,n,i){super(e,t,n,i)}}dm.prototype.ValueTypeName="color";class kr extends oi{constructor(e,t,n,i){super(e,t,n,i)}}kr.prototype.ValueTypeName="number";class lx extends Gr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(n-t)/(i-t);let l=e*a;for(let d=l+a;l!==d;l+=4)kn.slerpFlat(r,0,o,l-a,o,l,c);return r}}class Br extends oi{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new lx(this.times,this.values,this.getValueSize(),e)}}Br.prototype.ValueTypeName="quaternion";Br.prototype.InterpolantFactoryMethodSmooth=void 0;class Xr extends oi{constructor(e,t,n){super(e,t,n)}}Xr.prototype.ValueTypeName="string";Xr.prototype.ValueBufferType=Array;Xr.prototype.DefaultInterpolation=Bo;Xr.prototype.InterpolantFactoryMethodLinear=void 0;Xr.prototype.InterpolantFactoryMethodSmooth=void 0;class zr extends oi{constructor(e,t,n,i){super(e,t,n,i)}}zr.prototype.ValueTypeName="vector";class ux{constructor(e="",t=-1,n=[],i=Cg){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=ni(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(hx(n[o]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,o=n.length;r!==o;++r)t.push(oi.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,o=[];for(let a=0;a<r;a++){let c=[],l=[];c.push((a+r-1)%r,a,(a+1)%r),l.push(0,1,0);const d=sx(c);c=hf(c,1,d),l=hf(l,1,d),!i&&c[0]===0&&(c.push(r),l.push(l[0])),o.push(new kr(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){const l=e[a],d=l.name.match(r);if(d&&d.length>1){const u=d[1];let h=i[u];h||(i[u]=h=[]),h.push(l)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(Ne("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return We("AnimationClip: No animation in JSONLoader data."),null;const n=function(u,h,f,m,x){if(f.length!==0){const p=[],g=[];um(f,p,g,m),p.length!==0&&x.push(new u(h,p,g))}},i=[],r=e.name||"default",o=e.fps||30,a=e.blendMode;let c=e.length||-1;const l=e.hierarchy||[];for(let u=0;u<l.length;u++){const h=l[u].keys;if(!(!h||h.length===0))if(h[0].morphTargets){const f={};let m;for(m=0;m<h.length;m++)if(h[m].morphTargets)for(let x=0;x<h[m].morphTargets.length;x++)f[h[m].morphTargets[x]]=-1;for(const x in f){const p=[],g=[];for(let y=0;y!==h[m].morphTargets.length;++y){const _=h[m];p.push(_.time),g.push(_.morphTarget===x?1:0)}i.push(new kr(".morphTargetInfluence["+x+"]",p,g))}c=f.length*o}else{const f=".bones["+t[u].name+"]";n(zr,f+".position",h,"pos",i),n(Br,f+".quaternion",h,"rot",i),n(zr,f+".scale",h,"scl",i)}}return i.length===0?null:new this(r,c,i,a)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function dx(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return kr;case"vector":case"vector2":case"vector3":case"vector4":return zr;case"color":return dm;case"quaternion":return Br;case"bool":case"boolean":return Wr;case"string":return Xr}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function hx(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=dx(s.type);if(s.times===void 0){const t=[],n=[];um(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Fi={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(ff(s)||(this.files[s]=e))},get:function(s){if(this.enabled!==!1&&!ff(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function ff(s){try{const e=s.slice(s.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class fx{constructor(e,t,n){const i=this;let r=!1,o=0,a=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(d){a++,r===!1&&i.onStart!==void 0&&i.onStart(d,o,a),r=!0},this.itemEnd=function(d){o++,i.onProgress!==void 0&&i.onProgress(d,o,a),o===a&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(d){i.onError!==void 0&&i.onError(d)},this.resolveURL=function(d){return c?c(d):d},this.setURLModifier=function(d){return c=d,this},this.addHandler=function(d,u){return l.push(d,u),this},this.removeHandler=function(d){const u=l.indexOf(d);return u!==-1&&l.splice(u,2),this},this.getHandler=function(d){for(let u=0,h=l.length;u<h;u+=2){const f=l[u],m=l[u+1];if(f.global&&(f.lastIndex=0),f.test(d))return m}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const px=new fx;class Bs{constructor(e){this.manager=e!==void 0?e:px,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Bs.DEFAULT_MATERIAL_NAME="__DEFAULT";const Ii={};class mx extends Error{constructor(e,t){super(e),this.response=t}}class bc extends Bs{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Fi.get(`file:${e}`);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(Ii[e]!==void 0){Ii[e].push({onLoad:t,onProgress:n,onError:i});return}Ii[e]=[],Ii[e].push({onLoad:t,onProgress:n,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&Ne("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const d=Ii[e],u=l.body.getReader(),h=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=h?parseInt(h):0,m=f!==0;let x=0;const p=new ReadableStream({start(g){y();function y(){u.read().then(({done:_,value:v})=>{if(_)g.close();else{x+=v.byteLength;const M=new ProgressEvent("progress",{lengthComputable:m,loaded:x,total:f});for(let w=0,E=d.length;w<E;w++){const b=d[w];b.onProgress&&b.onProgress(M)}g.enqueue(v),y()}},_=>{g.error(_)})}}});return new Response(p)}else throw new mx(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(d=>new DOMParser().parseFromString(d,a));case"json":return l.json();default:if(a==="")return l.text();{const u=/charset="?([^;"\s]*)"?/i.exec(a),h=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(h);return l.arrayBuffer().then(m=>f.decode(m))}}}).then(l=>{Fi.add(`file:${e}`,l);const d=Ii[e];delete Ii[e];for(let u=0,h=d.length;u<h;u++){const f=d[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const d=Ii[e];if(d===void 0)throw this.manager.itemError(e),l;delete Ii[e];for(let u=0,h=d.length;u<h;u++){const f=d[u];f.onError&&f.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const er=new WeakMap;class gx extends Bs{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Fi.get(`image:${e}`);if(o!==void 0){if(o.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0);else{let u=er.get(o);u===void 0&&(u=[],er.set(o,u)),u.push({onLoad:t,onError:i})}return o}const a=Ho("img");function c(){d(),t&&t(this);const u=er.get(this)||[];for(let h=0;h<u.length;h++){const f=u[h];f.onLoad&&f.onLoad(this)}er.delete(this),r.manager.itemEnd(e)}function l(u){d(),i&&i(u),Fi.remove(`image:${e}`);const h=er.get(this)||[];for(let f=0;f<h.length;f++){const m=h[f];m.onError&&m.onError(u)}er.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function d(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),Fi.add(`image:${e}`,a),r.manager.itemStart(e),a.src=e,a}}class xx extends Bs{constructor(e){super(e)}load(e,t,n,i){const r=new Ot,o=new gx(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){r.image=a,r.needsUpdate=!0,t!==void 0&&t(r)},n,i),r}}class Uc extends Et{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new ze(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class Yd extends Uc{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ze(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const Sl=new Oe,pf=new D,mf=new D;class Kd{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new xe(512,512),this.mapType=Nn,this.map=null,this.mapPass=null,this.matrix=new Oe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Hr,this._frameExtents=new xe(1,1),this._viewportCount=1,this._viewports=[new bt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;pf.setFromMatrixPosition(e.matrixWorld),t.position.copy(pf),mf.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(mf),t.updateMatrixWorld(),Sl.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Sl,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Vo||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Sl)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const Aa=new D,Ca=new kn,ui=new D;class hm extends Et{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Oe,this.projectionMatrix=new Oe,this.projectionMatrixInverse=new Oe,this.coordinateSystem=$n,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Aa,Ca,ui),ui.x===1&&ui.y===1&&ui.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Aa,Ca,ui.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(Aa,Ca,ui),ui.x===1&&ui.y===1&&ui.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Aa,Ca,ui.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const es=new D,gf=new xe,xf=new xe;class ln extends hm{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Or*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(wo*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Or*2*Math.atan(Math.tan(wo*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){es.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(es.x,es.y).multiplyScalar(-e/es.z),es.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(es.x,es.y).multiplyScalar(-e/es.z)}getViewSize(e,t){return this.getViewBounds(e,gf,xf),t.subVectors(xf,gf)}setViewOffset(e,t,n,i,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=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(wo*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,l=o.fullHeight;r+=o.offsetX*i/c,t-=o.offsetY*n/l,i*=o.width/c,n*=o.height/l}const a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class yx extends Kd{constructor(){super(new ln(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=Or*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class vx extends Uc{constructor(e,t,n=0,i=Math.PI/3,r=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.distance=n,this.angle=i,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new yx}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class _x extends Kd{constructor(){super(new ln(90,1,.5,500)),this.isPointLightShadow=!0}}class bx extends Uc{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new _x}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Jo extends hm{constructor(e=-1,t=1,n=1,i=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,o=n+e,a=i+t,c=i-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,o=r+l*this.view.width,a-=d*this.view.offsetY,c=a-d*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Mx extends Kd{constructor(){super(new Jo(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Zd extends Uc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.shadow=new Mx}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class Co{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}const wl=new WeakMap;class Sx extends Bs{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Ne("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Ne("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Fi.get(`image-bitmap:${e}`);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(l=>{if(wl.has(o)===!0)i&&i(wl.get(o)),r.manager.itemError(e),r.manager.itemEnd(e);else return t&&t(l),r.manager.itemEnd(e),l});return}return setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,a.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){return Fi.add(`image-bitmap:${e}`,l),t&&t(l),r.manager.itemEnd(e),l}).catch(function(l){i&&i(l),wl.set(c,l),Fi.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Fi.add(`image-bitmap:${e}`,c),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const tr=-90,nr=1;
5class wx extends Et{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ln(tr,nr,e,t);i.layers=this.layers,this.add(i);const r=new ln(tr,nr,e,t);r.layers=this.layers,this.add(r);const o=new ln(tr,nr,e,t);o.layers=this.layers,this.add(o);const a=new ln(tr,nr,e,t);a.layers=this.layers,this.add(a);const c=new ln(tr,nr,e,t);c.layers=this.layers,this.add(c);const l=new ln(tr,nr,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,o,a,c]=t;for(const l of t)this.remove(l);if(e===$n)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Vo)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,o,a,c,l,d]=this.children,u=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;const x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let p=!1;e.isWebGLRenderer===!0?p=e.state.buffers.depth.getReversed():p=e.reversedDepthBuffer,e.setRenderTarget(n,0,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,2,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,3,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=x,e.setRenderTarget(n,5,i),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,d),e.setRenderTarget(u,h,f),e.xr.enabled=m,n.texture.needsPMREMUpdate=!0}}class Tx extends ln{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Ex{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=Ax.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function Ax(){this._document.hidden===!1&&this.reset()}const Jd="\\[\\]\\.:\\/",Cx=new RegExp("["+Jd+"]","g"),Qd="[^"+Jd+"]",Rx="[^"+Jd.replace("\\.","")+"]",Px=/((?:WC+[\/:])*)/.source.replace("WC",Qd),Lx=/(WCOD+)?/.source.replace("WCOD",Rx),Ix=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Qd),Dx=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Qd),Nx=new RegExp("^"+Px+Lx+Ix+Dx+"$"),Ux=["material","materials","bones","map"];class Ox{constructor(e,t,n){const i=n||ft.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ft{constructor(e,t,n){this.path=t,this.parsedPath=n||ft.parseTrackName(t),this.node=ft.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new ft.Composite(e,t,n):new ft(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Cx,"")}static parseTrackName(e){const t=Nx.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);Ux.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r){for(let o=0;o<r.length;o++){const a=r[o];if(a.name===t||a.uuid===t)return a;const c=n(a.children);if(c)return c}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}
vendor: 4,165 bytes, line 5
5_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=ft.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ne("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){We("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){We("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){We("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let d=0;d<e.length;d++)if(e[d].name===l){l=d;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){We("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){We("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){We("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){We("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const o=e[i];if(o===void 0){const l=t.nodeName;We("PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?a=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){We("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){We("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ft.Composite=Ox;ft.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ft.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ft.prototype.GetterByBindingType=[ft.prototype._getValue_direct,ft.prototype._getValue_array,ft.prototype._getValue_arrayElement,ft.prototype._getValue_toArray];ft.prototype.SetterByBindingTypeAndVersioning=[[ft.prototype._setValue_direct,ft.prototype._setValue_direct_setNeedsUpdate,ft.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ft.prototype._setValue_array,ft.prototype._setValue_array_setNeedsUpdate,ft.prototype._setValue_array_setMatr
5ixWorldNeedsUpdate],[ft.prototype._setValue_arrayElement,ft.prototype._setValue_arrayElement_setNeedsUpdate,ft.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ft.prototype._setValue_fromArray,ft.prototype._setValue_fromArray_setNeedsUpdate,ft.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const yf=new Oe;class Oc{constructor(e,t,n=0,i=1/0){this.ray=new Si(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Nd,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):We("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return yf.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(yf),this}intersectObject(e,t=!0,n=[]){return Yu(e,this,n,t),n.sort(vf),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)Yu(e[i],this,n,t);return n.sort(vf),n}}function vf(s,e){return s.distance-e.distance}function Yu(s,e,t,n){let i=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(i=!1),i===!0&&n===!0){const r=s.children;for(let o=0,a=r.length;o<a;o++)Yu(r[o],e,t,!0)}}class _f{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=qe(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(qe(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const bf=new D,Ra=new D,ir=new D,sr=new D,Tl=new D,Fx=new D,kx=new D;class wi{constructor(e=new D,t=new D){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){bf.subVectors(e,this.start),Ra.subVectors(this.end,this.start);const n=Ra.dot(Ra);let r=Ra.dot(bf)/n;return t&&(r=qe(r,0,1)),r}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(e,t=Fx,n=kx){const i=10000000000000001e-32;let r,o;const a=this.start,c=e.start,l=this.end,d=e.end;ir.subVectors(l,a),sr.subVectors(d,c),Tl.subVectors(a,c);const u=ir.dot(ir),h=sr.dot(sr),f=sr.dot(Tl);if(u<=i&&h<=i)return t.copy(a),n.copy(c),t.sub(n),t.dot(t);if(u<=i)r=0,o=f/h,o=qe(o,0,1);else{const m=ir.dot(Tl);if(h<=i)o=0,r=qe(-m/u,0,1);else{const x=ir.dot(sr),p=u*h-x*x;p!==0?r=qe((x*f-m*h)/p,0,1):r=0,o=(x*r+f)/h,o<0?(o=0,r=qe(-m/u,0,1)):o>1&&(o=1,r=qe((x-m)/u,0,1))}}return t.copy(a).addScaledVector(ir,r),n.copy(c).addScaledVector(sr,o),t.distanceToSquared(n)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class fm extends ks{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ne("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function Mf(s,e,t,n){const i=Bx(n);switch(t){case Xp:return s*e;case Ad:return s*e/i.components*i.byteLength;case Pc:return s*e/i.components*i.byteLength;case Ur:return s*e*2/i.components*i.byteLength;case Cd:return s*e*2/i.components*i.byteLength;case qp:return s*e*3/i.components*i.byteLength;case An:return s*e*4/i.components*i.byteLength;case Rd:return s*e*4/i.components*i.byteLength;case ic:case sc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case rc:case oc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case fu:case mu:return Math.max(s,16)*Math.max(e,8)/4;case hu:case pu:return Math.max(s,8)*Math.max(e,8)/2;case gu:case xu:case vu:case _u:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case yu:case bu:case Mu:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Su:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case wu:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case Tu:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Eu:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case Au:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case Cu:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case Ru:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case Pu:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case Lu:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;
vendor: 5,615 bytes, lines 5-64
5case Iu:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case Du:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case Nu:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case Uu:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case Ou:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case Fu:case ku:case Bu:return Math.ceil(s/4)*Math.ceil(e/4)*16;case zu:case Vu:return Math.ceil(s/4)*Math.ceil(e/4)*8;case Hu:case Gu:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Bx(s){switch(s){case Nn:case Vp:return{byteLength:1,components:1};case Fo:case Hp:case Wn:return{byteLength:2,components:1};case Td:case Ed:return{byteLength:2,components:4};case si:case wd:case En:return{byteLength:4,components:1};case Gp:case Wp:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ko}}));typeof window<"u"&&(window.__THREE__?Ne("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ko);function pm(){let s=null,e=!1,t=null,n=null;function i(r,o){t(r,o),n=s.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=s.requestAnimationFrame(i),e=!0)},stop:function(){s.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function zx(s){const e=new WeakMap;function t(a,c){const l=a.array,d=a.usage,u=l.byteLength,h=s.createBuffer();s.bindBuffer(c,h),s.bufferData(c,l,d),a.onUploadCallback();let f;if(l instanceof Float32Array)f=s.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)f=s.HALF_FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?f=s.HALF_FLOAT:f=s.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=s.SHORT;else if(l instanceof Uint32Array)f=s.UNSIGNED_INT;else if(l instanceof Int32Array)f=s.INT;else if(l instanceof Int8Array)f=s.BYTE;else if(l instanceof Uint8Array)f=s.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:u}}function n(a,c,l){const d=c.array,u=c.updateRanges;if(s.bindBuffer(l,a),u.length===0)s.bufferSubData(l,0,d);else{u.sort((f,m)=>f.start-m.start);let h=0;for(let f=1;f<u.length;f++){const m=u[h],x=u[f];x.start<=m.start+m.count+1?m.count=Math.max(m.count,x.start+x.count-m.start):(++h,u[h]=x)}u.length=h+1;for(let f=0,m=u.length;f<m;f++){const x=u[f];s.bufferSubData(l,x.start*d.BYTES_PER_ELEMENT,d,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);const c=e.get(a);c&&(s.deleteBuffer(c.buffer),e.delete(a))}function o(a,c){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){const d=e.get(a);(!d||d.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}const l=e.get(a);if(l===void 0)e.set(a,t(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,a,c),l.version=a.version}}return{get:i,remove:r,update:o}}var Vx=`#ifdef USE_ALPHAHASH 6 if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard; 7#endif`,Hx=`#ifdef USE_ALPHAHASH 8 const float ALPHA_HASH_SCALE = 0.05; 9 float hash2D( vec2 value ) { 10 return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) ); 11 } 12 float hash3D( vec3 value ) { 13 return hash2D( vec2( hash2D( value.xy ), value.z ) ); 14 } 15 float getAlphaHashThreshold( vec3 position ) { 16 float maxDeriv = max( 17 length( dFdx( position.xyz ) ), 18 length( dFdy( position.xyz ) ) 19 ); 20 float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv ); 21 vec2 pixScales = vec2( 22 exp2( floor( log2( pixScale ) ) ), 23 exp2( ceil( log2( pixScale ) ) ) 24 ); 25 vec2 alpha = vec2( 26 hash3D( floor( pixScales.x * position.xyz ) ), 27 hash3D( floor( pixScales.y * position.xyz ) ) 28 ); 29 float lerpFactor = fract( log2( pixScale ) ); 30 float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y; 31 float a = min( lerpFactor, 1.0 - lerpFactor ); 32 vec3 cases = vec3( 33 x * x / ( 2.0 * a * ( 1.0 - a ) ), 34 ( x - 0.5 * a ) / ( 1.0 - a ), 35 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) ) 36 ); 37 float threshold = ( x < ( 1.0 - a ) ) 38 ? ( ( x < a ) ? cases.x : cases.y ) 39 : cases.z; 40 return clamp( threshold , 1.0e-6, 1.0 ); 41 } 42#endif`,Gx=`#ifdef USE_ALPHAMAP 43 diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g; 44#endif`,Wx=`#ifdef USE_ALPHAMAP 45 uniform sampler2D alphaMap; 46#endif`,Xx=`#ifdef USE_ALPHATEST 47 #ifdef ALPHA_TO_COVERAGE 48 diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a ); 49 if ( diffuseColor.a == 0.0 ) discard; 50 #else 51 if ( diffuseColor.a < alphaTest ) discard; 52 #endif 53#endif`,qx=`#ifdef USE_ALPHATEST 54 uniform float alphaTest; 55#endif`,jx=`#ifdef USE_AOMAP 56 float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0; 57 reflectedLight.indirectDiffuse *= ambientOcclusion; 58 #if defined( USE_CLEARCOAT ) 59 clearcoatSpecularIndirect *= ambientOcclusion; 60 #endif 61 #if defined( USE_SHEEN ) 62 sheenSpecularIndirect *= ambientOcclusion; 63 #endif 64 #if defined( USE_ENVMAP ) && defined( STANDARD )
65 float dotNV = saturate( dot( geometryNormal, geometryViewDir ) ); 66 reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); 67 #endif 68#endif`,Yx=`#ifdef USE_AOMAP 69 uniform sampler2D aoMap; 70 uniform float aoMapIntensity; 71#endif`,Kx=`#ifdef USE_BATCHING 72 #if ! defined( GL_ANGLE_multi_draw ) 73 #define gl_DrawID _gl_DrawID 74 uniform int _gl_DrawID; 75 #endif 76 uniform highp sampler2D batchingTexture; 77 uniform highp usampler2D batchingIdTexture; 78 mat4 getBatchingMatrix( const in float i ) { 79 int size = textureSize( batchingTexture, 0 ).x; 80 int j = int( i ) * 4; 81 int x = j % size; 82 int y = j / size; 83 vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 ); 84 vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 ); 85 vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 ); 86 vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 ); 87 return mat4( v1, v2, v3, v4 ); 88 } 89 float getIndirectIndex( const in int i ) { 90 int size = textureSize( batchingIdTexture, 0 ).x; 91 int x = i % size; 92 int y = i / size; 93 return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r ); 94 } 95#endif 96#ifdef USE_BATCHING_COLOR 97 uniform sampler2D batchingColorTexture; 98 vec4 getBatchingColor( const in float i ) { 99 int size = textureSize( batchingColorTexture, 0 ).x; 100 int j = int( i ); 101 int x = j % size; 102 int y = j / size; 103 return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ); 104 } 105#endif`,Zx=`#ifdef USE_BATCHING 106 mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) ); 107#endif`,Jx=`vec3 transformed = vec3( position ); 108#ifdef USE_ALPHAHASH 109 vPosition = vec3( position ); 110#endif`,Qx=`vec3 objectNormal = vec3( normal ); 111#ifdef USE_TANGENT 112 vec3 objectTangent = vec3( tangent.xyz ); 113#endif`,$x=`float G_BlinnPhong_Implicit( ) { 114 return 0.25; 115} 116float D_BlinnPhong( const in float shininess, const in float dotNH ) { 117 return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); 118} 119vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { 120 vec3 halfDir = normalize( lightDir + viewDir ); 121 float dotNH = saturate( dot( normal, halfDir ) ); 122 float dotVH = saturate( dot( viewDir, halfDir ) ); 123 vec3 F = F_Schlick( specularColor, 1.0, dotVH ); 124 float G = G_BlinnPhong_Implicit( ); 125 float D = D_BlinnPhong( shininess, dotNH ); 126 return F * ( G * D ); 127} // validated`,ey=`#ifdef USE_IRIDESCENCE 128 const mat3 XYZ_TO_REC709 = mat3( 129 3.2404542, -0.9692660, 0.0556434, 130 -1.5371385, 1.8760108, -0.2040259, 131 -0.4985314, 0.0415560, 1.0572252 132 ); 133 vec3 Fresnel0ToIor( vec3 fresnel0 ) { 134 vec3 sqrtF0 = sqrt( fresnel0 ); 135 return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); 136 } 137 vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { 138 return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); 139 } 140 float IorToFresnel0( float transmittedIor, float incidentIor ) { 141 return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); 142 } 143 vec3 evalSensitivity( float OPD, vec3 shift ) { 144 float phase = 2.0 * PI * OPD * 1.0e-9; 145 vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); 146 vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); 147 vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); 148 vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); 149 xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); 150 xyz /= 1.0685e-7; 151 vec3 rgb = XYZ_TO_REC709 * xyz; 152 return rgb; 153 } 154 vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { 155 vec3 I; 156 float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); 157 float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); 158 float cosTheta2Sq = 1.0 - sinTheta2Sq; 159 if ( cosTheta2Sq < 0.0 ) { 160 return vec3( 1.0 ); 161 } 162 float cosTheta2 = sqrt( cosTheta2Sq ); 163 float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
164 float R12 = F_Schlick( R0, 1.0, cosTheta1 ); 165 float T121 = 1.0 - R12; 166 float phi12 = 0.0; 167 if ( iridescenceIOR < outsideIOR ) phi12 = PI; 168 float phi21 = PI - phi12; 169 vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); 170 vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); 171 vec3 phi23 = vec3( 0.0 ); 172 if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; 173 if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; 174 if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; 175 float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; 176 vec3 phi = vec3( phi21 ) + phi23; 177 vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); 178 vec3 r123 = sqrt( R123 ); 179 vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); 180 vec3 C0 = R12 + Rs; 181 I = C0; 182 vec3 Cm = Rs - T121; 183 for ( int m = 1; m <= 2; ++ m ) { 184 Cm *= r123; 185 vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); 186 I += Cm * Sm; 187 } 188 return max( I, vec3( 0.0 ) ); 189 } 190#endif`,ty=`#ifdef USE_BUMPMAP 191 uniform sampler2D bumpMap; 192 uniform float bumpScale; 193 vec2 dHdxy_fwd() { 194 vec2 dSTdx = dFdx( vBumpMapUv ); 195 vec2 dSTdy = dFdy( vBumpMapUv ); 196 float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x; 197 float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll; 198 float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll; 199 return vec2( dBx, dBy ); 200 } 201 vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { 202 vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) ); 203 vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) ); 204 vec3 vN = surf_norm; 205 vec3 R1 = cross( vSigmaY, vN ); 206 vec3 R2 = cross( vN, vSigmaX ); 207 float fDet = dot( vSigmaX, R1 ) * faceDirection; 208 vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); 209 return normalize( abs( fDet ) * surf_norm - vGrad ); 210 } 211#endif`,ny=`#if NUM_CLIPPING_PLANES > 0 212 vec4 plane; 213 #ifdef ALPHA_TO_COVERAGE 214 float distanceToPlane, distanceGradient; 215 float clipOpacity = 1.0; 216 #pragma unroll_loop_start 217 for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { 218 plane = clippingPlanes[ i ]; 219 distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; 220 distanceGradient = fwidth( distanceToPlane ) / 2.0; 221 clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); 222 if ( clipOpacity == 0.0 ) discard; 223 } 224 #pragma unroll_loop_end 225 #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES 226 float unionClipOpacity = 1.0; 227 #pragma unroll_loop_start 228 for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { 229 plane = clippingPlanes[ i ]; 230 distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; 231 distanceGradient = fwidth( distanceToPlane ) / 2.0; 232 unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); 233 } 234 #pragma unroll_loop_end 235 clipOpacity *= 1.0 - unionClipOpacity; 236 #endif 237 diffuseColor.a *= clipOpacity; 238 if ( diffuseColor.a == 0.0 ) discard; 239 #else 240 #pragma unroll_loop_start 241 for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { 242 plane = clippingPlanes[ i ]; 243 if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; 244 } 245 #pragma unroll_loop_end 246 #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES 247 bool clipped = true; 248 #pragma unroll_loop_start 249 for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { 250 plane = clippingPlanes[ i ]; 251 clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; 252 } 253 #pragma unroll_loop_end 254 if ( clipped ) discard; 255 #endif 256 #endif 257#endif`,iy=`#if NUM_CLIPPING_PLANES > 0 258 varying vec3 vClipPosition; 259 uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; 260#endif`,sy=`#if NUM_CLIPPING_PLANES > 0 261 varying vec3 vClipPosition; 262#endif`,ry=`#if NUM_CLIPPING_PLANES > 0 263 vClipPosition = - mvPosition.xyz; 264#endif`,oy=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) 265 diffuseColor *= vColor; 266#endif`,ay=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) 267 varying vec4 vColor; 268#endif`,cy=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) 269 varying vec4 vColor; 270#endif`,ly=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) 271 vColor = vec4( 1.0 ); 272#endif 273#ifdef USE_COLOR_ALPHA 274 vColor *= color; 275#elif defined( USE_COLOR ) 276 vColor.rgb *= color; 277#endif 278#ifdef USE_INSTANCING_COLOR 279 vColor.rgb *= instanceColor.rgb; 280#endif 281#ifdef USE_BATCHING_COLOR 282 vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); 283#endif`,uy=`#define PI 3.141592653589793 284#define PI2 6.283185307179586 285#define PI_HALF 1.5707963267948966 286#define RECIPROCAL_PI 0.3183098861837907 287#define RECIPROCAL_PI2 0.15915494309189535 288#define EPSILON 1e-6 289#ifndef saturate 290#define saturate( a ) clamp( a, 0.0, 1.0 ) 291#endif 292#define whiteComplement( a ) ( 1.0 - saturate( a ) ) 293float pow2( const in float x ) { return x*x; } 294vec3 pow2( const in vec3 x ) { return x*x; } 295float pow3( const in float x ) { return x*x*x; } 296float pow4( const in float x ) { float x2 = x*x; return x2*x2; } 297float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } 298float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } 299highp float rand( const in vec2 uv ) { 300 const highp float a = 12.9898, b = 78.233, c = 43758.5453; 301 highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); 302 return fract( sin( sn ) * c ); 303} 304#ifdef HIGH_PRECISION 305 float precisionSafeLength( vec3 v ) { return length( v ); } 306#else 307 float precisionSafeLength( vec3 v ) { 308 float maxComponent = max3( abs( v ) ); 309 return length( v / maxComponent ) * maxComponent; 310 } 311#endif 312struct IncidentLight { 313 vec3 color; 314 vec3 direction; 315 bool visible; 316}; 317struct ReflectedLight { 318 vec3 directDiffuse; 319 vec3 directSpecular; 320 vec3 indirectDiffuse; 321 vec3 indirectSpecular; 322}; 323#ifdef USE_ALPHAHASH 324 varying vec3 vPosition; 325#endif 326vec3 transformDirection( in vec3 dir, in mat4 matrix ) { 327 return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); 328} 329vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { 330 return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); 331} 332bool isPerspectiveMatrix( mat4 m ) { 333 return m[ 2 ][ 3 ] == - 1.0; 334} 335vec2 equirectUv( in vec3 dir ) { 336 float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; 337 float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; 338 return vec2( u, v ); 339}
340vec3 BRDF_Lambert( const in vec3 diffuseColor ) { 341 return RECIPROCAL_PI * diffuseColor; 342} 343vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { 344 float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); 345 return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); 346} 347float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { 348 float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); 349 return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); 350} // validated`,dy=`#ifdef ENVMAP_TYPE_CUBE_UV 351 #define cubeUV_minMipLevel 4.0 352 #define cubeUV_minTileSize 16.0 353 float getFace( vec3 direction ) { 354 vec3 absDirection = abs( direction ); 355 float face = - 1.0; 356 if ( absDirection.x > absDirection.z ) { 357 if ( absDirection.x > absDirection.y ) 358 face = direction.x > 0.0 ? 0.0 : 3.0; 359 else 360 face = direction.y > 0.0 ? 1.0 : 4.0; 361 } else { 362 if ( absDirection.z > absDirection.y ) 363 face = direction.z > 0.0 ? 2.0 : 5.0; 364 else 365 face = direction.y > 0.0 ? 1.0 : 4.0; 366 } 367 return face; 368 } 369 vec2 getUV( vec3 direction, float face ) { 370 vec2 uv; 371 if ( face == 0.0 ) { 372 uv = vec2( direction.z, direction.y ) / abs( direction.x ); 373 } else if ( face == 1.0 ) { 374 uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); 375 } else if ( face == 2.0 ) { 376 uv = vec2( - direction.x, direction.y ) / abs( direction.z ); 377 } else if ( face == 3.0 ) { 378 uv = vec2( - direction.z, direction.y ) / abs( direction.x ); 379 } else if ( face == 4.0 ) { 380 uv = vec2( - direction.x, direction.z ) / abs( direction.y ); 381 } else { 382 uv = vec2( direction.x, direction.y ) / abs( direction.z ); 383 } 384 return 0.5 * ( uv + 1.0 ); 385 } 386 vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { 387 float face = getFace( direction ); 388 float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); 389 mipInt = max( mipInt, cubeUV_minMipLevel ); 390 float faceSize = exp2( mipInt ); 391 highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; 392 if ( face > 2.0 ) { 393 uv.y += faceSize; 394 face -= 3.0; 395 } 396 uv.x += face * faceSize; 397 uv.x += filterInt * 3.0 * cubeUV_minTileSize; 398 uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); 399 uv.x *= CUBEUV_TEXEL_WIDTH; 400 uv.y *= CUBEUV_TEXEL_HEIGHT; 401 #ifdef texture2DGradEXT 402 return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; 403 #else 404 return texture2D( envMap, uv ).rgb; 405 #endif 406 } 407 #define cubeUV_r0 1.0 408 #define cubeUV_m0 - 2.0 409 #define cubeUV_r1 0.8 410 #define cubeUV_m1 - 1.0 411 #define cubeUV_r4 0.4 412 #define cubeUV_m4 2.0 413 #define cubeUV_r5 0.305 414 #define cubeUV_m5 3.0 415 #define cubeUV_r6 0.21 416 #define cubeUV_m6 4.0 417 float roughnessToMip( float roughness ) { 418 float mip = 0.0; 419 if ( roughness >= cubeUV_r1 ) { 420 mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; 421 } else if ( roughness >= cubeUV_r4 ) { 422 mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; 423 } else if ( roughness >= cubeUV_r5 ) { 424 mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; 425 } else if ( roughness >= cubeUV_r6 ) { 426 mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; 427 } else { 428 mip = - 2.0 * log2( 1.16 * roughness ); } 429 return mip; 430 } 431 vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { 432 float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); 433 float mipF = fract( mip ); 434 float mipInt = floor( mip ); 435 vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); 436 if ( mipF == 0.0 ) { 437 return vec4( color0, 1.0 ); 438 } else { 439 vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); 440 return vec4( mix( color0, color1, mipF ), 1.0 ); 441 } 442 } 443#endif`,hy=`vec3 transformedNormal = objectNormal; 444#ifdef USE_TANGENT 445 vec3 transformedTangent = objectTangent; 446#endif 447#ifdef USE_BATCHING 448 mat3 bm = mat3( batchingMatrix ); 449 transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); 450 transformedNormal = bm * transformedNormal; 451 #ifdef USE_TANGENT 452 transformedTangent = bm * transformedTangent; 453 #endif 454#endif 455#ifdef USE_INSTANCING 456 mat3 im = mat3( instanceMatrix ); 457 transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); 458 transformedNormal = im * transformedNormal; 459 #ifdef USE_TANGENT 460 transformedTangent = im * transformedTangent; 461 #endif 462#endif 463transformedNormal = normalMatrix * transformedNormal; 464#ifdef FLIP_SIDED 465 transformedNormal = - transformedNormal; 466#endif 467#ifdef USE_TANGENT 468 transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; 469 #ifdef FLIP_SIDED 470 transformedTangent = - transformedTangent; 471 #endif 472#endif`,fy=`#ifdef USE_DISPLACEMENTMAP 473 uniform sampler2D displacementMap; 474 uniform float displacementScale; 475 uniform float displacementBias; 476#endif`,py=`#ifdef USE_DISPLACEMENTMAP 477 transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + dis
477placementBias ); 478#endif`,my=`#ifdef USE_EMISSIVEMAP 479 vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); 480 #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE 481 emissiveColor = sRGBTransferEOTF( emissiveColor ); 482 #endif 483 totalEmissiveRadiance *= emissiveColor.rgb; 484#endif`,gy=`#ifdef USE_EMISSIVEMAP 485 uniform sampler2D emissiveMap; 486#endif`,xy="gl_FragColor = linearToOutputTexel( gl_FragColor );",yy=`vec4 LinearTransferOETF( in vec4 value ) { 487 return value; 488} 489vec4 sRGBTransferEOTF( in vec4 value ) { 490 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 ); 491} 492vec4 sRGBTransferOETF( in vec4 value ) { 493 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 ); 494}`,vy=`#ifdef USE_ENVMAP 495 #ifdef ENV_WORLDPOS 496 vec3 cameraToFrag; 497 if ( isOrthographic ) { 498 cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); 499 } else { 500 cameraToFrag = normalize( vWorldPosition - cameraPosition ); 501 } 502 vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); 503 #ifdef ENVMAP_MODE_REFLECTION 504 vec3 reflectVec = reflect( cameraToFrag, worldNormal ); 505 #else 506 vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); 507 #endif 508 #else 509 vec3 reflectVec = vReflect; 510 #endif 511 #ifdef ENVMAP_TYPE_CUBE 512 vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); 513 #ifdef ENVMAP_BLENDING_MULTIPLY 514 outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); 515 #elif defined( ENVMAP_BLENDING_MIX ) 516 outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); 517 #elif defined( ENVMAP_BLENDING_ADD ) 518 outgoingLight += envColor.xyz * specularStrength * reflectivity; 519 #endif 520 #endif 521#endif`,_y=`#ifdef USE_ENVMAP 522 uniform float envMapIntensity; 523 uniform float flipEnvMap; 524 uniform mat3 envMapRotation; 525 #ifdef ENVMAP_TYPE_CUBE 526 uniform samplerCube envMap; 527 #else 528 uniform sampler2D envMap; 529 #endif 530#endif`,by=`#ifdef USE_ENVMAP 531 uniform float reflectivity; 532 #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) 533 #define ENV_WORLDPOS 534 #endif 535 #ifdef ENV_WORLDPOS 536 varying vec3 vWorldPosition; 537 uniform float refractionRatio; 538 #else 539 varying vec3 vReflect; 540 #endif 541#endif`,My=`#ifdef USE_ENVMAP 542 #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) 543 #define ENV_WORLDPOS 544 #endif 545 #ifdef ENV_WORLDPOS 546 547 varying vec3 vWorldPosition; 548 #else 549 varying vec3 vReflect; 550 uniform float refractionRatio; 551 #endif 552#endif`,Sy=`#ifdef USE_ENVMAP 553 #ifdef ENV_WORLDPOS 554 vWorldPosition = worldPosition.xyz; 555 #else 556 vec3 cameraToVertex; 557 if ( isOrthographic ) { 558 cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); 559 } else {
560 cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); 561 } 562 vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); 563 #ifdef ENVMAP_MODE_REFLECTION 564 vReflect = reflect( cameraToVertex, worldNormal ); 565 #else 566 vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); 567 #endif 568 #endif 569#endif`,wy=`#ifdef USE_FOG 570 vFogDepth = - mvPosition.z; 571#endif`,Ty=`#ifdef USE_FOG 572 varying float vFogDepth; 573#endif`,Ey=`#ifdef USE_FOG 574 #ifdef FOG_EXP2 575 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); 576 #else 577 float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); 578 #endif 579 gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); 580#endif`,Ay=`#ifdef USE_FOG 581 uniform vec3 fogColor; 582 varying float vFogDepth; 583 #ifdef FOG_EXP2 584 uniform float fogDensity; 585 #else 586 uniform float fogNear; 587 uniform float fogFar; 588 #endif 589#endif`,Cy=`#ifdef USE_GRADIENTMAP 590 uniform sampler2D gradientMap; 591#endif 592vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { 593 float dotNL = dot( normal, lightDirection ); 594 vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); 595 #ifdef USE_GRADIENTMAP 596 return vec3( texture2D( gradientMap, coord ).r ); 597 #else 598 vec2 fw = fwidth( coord ) * 0.5; 599 return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); 600 #endif 601}`,Ry=`#ifdef USE_LIGHTMAP 602 uniform sampler2D lightMap; 603 uniform float lightMapIntensity; 604#endif`,Py=`LambertMaterial material; 605material.diffuseColor = diffuseColor.rgb; 606material.specularStrength = specularStrength;`,Ly=`varying vec3 vViewPosition; 607struct LambertMaterial { 608 vec3 diffuseColor; 609 float specularStrength; 610}; 611void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { 612 float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); 613 vec3 irradiance = dotNL * directLight.color; 614 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 615} 616void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { 617 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 618} 619#define RE_Direct RE_Direct_Lambert 620#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Iy=`uniform bool receiveShadow; 621uniform vec3 ambientLightColor; 622#if defined( USE_LIGHT_PROBES ) 623 uniform vec3 lightProbe[ 9 ]; 624#endif 625vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { 626 float x = normal.x, y = normal.y, z = normal.z; 627 vec3 result = shCoefficients[ 0 ] * 0.886227; 628 result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; 629 result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; 630 result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; 631 result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; 632 result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; 633 result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); 634 result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; 635 result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); 636 return result; 637} 638vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { 639 vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); 640 vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); 641 return irradiance; 642} 643vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { 644 vec3 irradiance = ambientLightColor; 645 return irradiance; 646} 647float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { 648 float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); 649 if ( cutoffDistance > 0.0 ) { 650 distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); 651 } 652 return distanceFalloff; 653} 654float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { 655 return smoothstep( coneCosine, penumbraCosine, angleCosine ); 656} 657#if NUM_DIR_LIGHTS > 0 658 struct DirectionalLight { 659 vec3 direction; 660 vec3 color; 661 }; 662 uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; 663 void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { 664 light.color = directionalLight.color; 665 light.direction = directionalLight.direction; 666 light.visible = true; 667 } 668#endif 669#if NUM_POINT_LIGHTS > 0 670 struct PointLight { 671 vec3 position; 672 vec3 color; 673 float distance; 674 float decay; 675 }; 676 uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; 677 void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { 678 vec3 lVector = pointLight.position - geometryPosition; 679 light.direction = normalize( lVector ); 680 float lightDistance = length( lVector ); 681 light.color = pointLight.color; 682 light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); 683 light.visible = ( light.color != vec3( 0.0 ) ); 684 } 685#endif
686#if NUM_SPOT_LIGHTS > 0 687 struct SpotLight { 688 vec3 position; 689 vec3 direction; 690 vec3 color; 691 float distance; 692 float decay; 693 float coneCos; 694 float penumbraCos; 695 }; 696 uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; 697 void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { 698 vec3 lVector = spotLight.position - geometryPosition; 699 light.direction = normalize( lVector ); 700 float angleCos = dot( light.direction, spotLight.direction ); 701 float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); 702 if ( spotAttenuation > 0.0 ) { 703 float lightDistance = length( lVector ); 704 light.color = spotLight.color * spotAttenuation; 705 light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); 706 light.visible = ( light.color != vec3( 0.0 ) ); 707 } else { 708 light.color = vec3( 0.0 ); 709 light.visible = false; 710 } 711 } 712#endif 713#if NUM_RECT_AREA_LIGHTS > 0 714 struct RectAreaLight { 715 vec3 color; 716 vec3 position; 717 vec3 halfWidth; 718 vec3 halfHeight; 719 }; 720 uniform sampler2D ltc_1; uniform sampler2D ltc_2; 721 uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; 722#endif 723#if NUM_HEMI_LIGHTS > 0 724 struct HemisphereLight { 725 vec3 direction; 726 vec3 skyColor; 727 vec3 groundColor; 728 }; 729 uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; 730 vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { 731 float dotNL = dot( normal, hemiLight.direction ); 732 float hemiDiffuseWeight = 0.5 * dotNL + 0.5; 733 vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); 734 return irradiance; 735 } 736#endif`,Dy=`#ifdef USE_ENVMAP 737 vec3 getIBLIrradiance( const in vec3 normal ) { 738 #ifdef ENVMAP_TYPE_CUBE_UV 739 vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); 740 vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); 741 return PI * envMapColor.rgb * envMapIntensity; 742 #else 743 return vec3( 0.0 ); 744 #endif 745 } 746 vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { 747 #ifdef ENVMAP_TYPE_CUBE_UV 748 vec3 reflectVec = reflect( - viewDir, normal ); 749 reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); 750 reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); 751 vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); 752 return envMapColor.rgb * envMapIntensity; 753 #else 754 return vec3( 0.0 ); 755 #endif 756 } 757 #ifdef USE_ANISOTROPY 758 vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { 759 #ifdef ENVMAP_TYPE_CUBE_UV 760 vec3 bentNormal = cross( bitangent, viewDir ); 761 bentNormal = normalize( cross( bentNormal, bitangent ) ); 762 bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); 763 return getIBLRadiance( viewDir, bentNormal, roughness ); 764 #else 765 return vec3( 0.0 ); 766 #endif 767 } 768 #endif 769#endif`,Ny=`ToonMaterial material; 770material.diffuseColor = diffuseColor.rgb;`,Uy=`varying vec3 vViewPosition; 771struct ToonMaterial { 772 vec3 diffuseColor; 773}; 774void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { 775 vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; 776 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 777} 778void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { 779 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 780} 781#define RE_Direct RE_Direct_Toon 782#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Oy=`BlinnPhongMaterial material; 783material.diffuseColor = diffuseColor.rgb; 784material.specularColor = specular; 785material.specularShininess = shininess; 786material.specularStrength = specularStrength;`,Fy=`varying vec3 vViewPosition; 787struct BlinnPhongMaterial { 788 vec3 diffuseColor; 789 vec3 specularColor; 790 float specularShininess; 791 float specularStrength; 792}; 793void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
794 float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); 795 vec3 irradiance = dotNL * directLight.color; 796 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 797 reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; 798} 799void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { 800 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 801} 802#define RE_Direct RE_Direct_BlinnPhong 803#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,ky=`PhysicalMaterial material; 804material.diffuseColor = diffuseColor.rgb; 805material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); 806material.metalness = metalnessFactor; 807vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); 808float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); 809material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; 810material.roughness = min( material.roughness, 1.0 ); 811#ifdef IOR 812 material.ior = ior; 813 #ifdef USE_SPECULAR 814 float specularIntensityFactor = specularIntensity; 815 vec3 specularColorFactor = specularColor; 816 #ifdef USE_SPECULAR_COLORMAP 817 specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; 818 #endif 819 #ifdef USE_SPECULAR_INTENSITYMAP 820 specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; 821 #endif 822 material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); 823 #else 824 float specularIntensityFactor = 1.0; 825 vec3 specularColorFactor = vec3( 1.0 ); 826 material.specularF90 = 1.0; 827 #endif 828 material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; 829 material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); 830#else 831 material.specularColor = vec3( 0.04 ); 832 material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); 833 material.specularF90 = 1.0; 834#endif 835#ifdef USE_CLEARCOAT 836 material.clearcoat = clearcoat; 837 material.clearcoatRoughness = clearcoatRoughness; 838 material.clearcoatF0 = vec3( 0.04 ); 839 material.clearcoatF90 = 1.0; 840 #ifdef USE_CLEARCOATMAP 841 material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; 842 #endif 843 #ifdef USE_CLEARCOAT_ROUGHNESSMAP 844 material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; 845 #endif 846 material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); 847 material.clearcoatRoughness += geometryRoughness; 848 material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); 849#endif 850#ifdef USE_DISPERSION 851 material.dispersion = dispersion; 852#endif 853#ifdef USE_IRIDESCENCE 854 material.iridescence = iridescence; 855 material.iridescenceIOR = iridescenceIOR; 856 #ifdef USE_IRIDESCENCEMAP 857 material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; 858 #endif 859 #ifdef USE_IRIDESCENCE_THICKNESSMAP 860 material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; 861 #else 862 material.iridescenceThickness = iridescenceThicknessMaximum; 863 #endif 864#endif 865#ifdef USE_SHEEN 866 material.sheenColor = sheenColor; 867 #ifdef USE_SHEEN_COLORMAP 868 material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; 869 #endif 870 material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); 871 #ifdef USE_SHEEN_ROUGHNESSMAP 872 material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; 873 #endif 874#endif 875#ifdef USE_ANISOTROPY 876 #ifdef USE_ANISOTROPYMAP 877 mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); 878 vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; 879 vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; 880 #else 881 vec2 anisotropyV = anisotropyVector; 882 #endif 883 material.anisotropy = length( anisotropyV ); 884 if( material.anisotropy == 0.0 ) { 885 anisotropyV = vec2( 1.0, 0.0 ); 886 } else { 887 anisotropyV /= material.anisotropy; 888 material.anisotropy = saturate( material.anisotropy ); 889 } 890 material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
891 material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; 892 material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; 893#endif`,By
vendor: 9,654 bytes, lines 893-1124
893=`uniform sampler2D dfgLUT; 894struct PhysicalMaterial { 895 vec3 diffuseColor; 896 vec3 diffuseContribution; 897 vec3 specularColor; 898 vec3 specularColorBlended; 899 float roughness; 900 float metalness; 901 float specularF90; 902 float dispersion; 903 #ifdef USE_CLEARCOAT 904 float clearcoat; 905 float clearcoatRoughness; 906 vec3 clearcoatF0; 907 float clearcoatF90; 908 #endif 909 #ifdef USE_IRIDESCENCE 910 float iridescence; 911 float iridescenceIOR; 912 float iridescenceThickness; 913 vec3 iridescenceFresnel; 914 vec3 iridescenceF0; 915 vec3 iridescenceFresnelDielectric; 916 vec3 iridescenceFresnelMetallic; 917 #endif 918 #ifdef USE_SHEEN 919 vec3 sheenColor; 920 float sheenRoughness; 921 #endif 922 #ifdef IOR 923 float ior; 924 #endif 925 #ifdef USE_TRANSMISSION 926 float transmission; 927 float transmissionAlpha; 928 float thickness; 929 float attenuationDistance; 930 vec3 attenuationColor; 931 #endif 932 #ifdef USE_ANISOTROPY 933 float anisotropy; 934 float alphaT; 935 vec3 anisotropyT; 936 vec3 anisotropyB; 937 #endif 938}; 939vec3 clearcoatSpecularDirect = vec3( 0.0 ); 940vec3 clearcoatSpecularIndirect = vec3( 0.0 ); 941vec3 sheenSpecularDirect = vec3( 0.0 ); 942vec3 sheenSpecularIndirect = vec3(0.0 ); 943vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { 944 float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); 945 float x2 = x * x; 946 float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); 947 return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); 948} 949float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { 950 float a2 = pow2( alpha ); 951 float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); 952 float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); 953 return 0.5 / max( gv + gl, EPSILON ); 954} 955float D_GGX( const in float alpha, const in float dotNH ) { 956 float a2 = pow2( alpha ); 957 float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; 958 return RECIPROCAL_PI * a2 / pow2( denom ); 959} 960#ifdef USE_ANISOTROPY 961 float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { 962 float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); 963 float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); 964 float v = 0.5 / ( gv + gl ); 965 return v; 966 } 967 float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { 968 float a2 = alphaT * alphaB; 969 highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); 970 highp float v2 = dot( v, v ); 971 float w2 = a2 / v2; 972 return RECIPROCAL_PI * a2 * pow2 ( w2 ); 973 } 974#endif 975#ifdef USE_CLEARCOAT 976 vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { 977 vec3 f0 = material.clearcoatF0; 978 float f90 = material.clearcoatF90; 979 float roughness = material.clearcoatRoughness; 980 float alpha = pow2( roughness ); 981 vec3 halfDir = normalize( lightDir + viewDir ); 982 float dotNL = saturate( dot( normal, lightDir ) ); 983 float dotNV = saturate( dot( normal, viewDir ) ); 984 float dotNH = saturate( dot( normal, halfDir ) ); 985 float dotVH = saturate( dot( viewDir, halfDir ) ); 986 vec3 F = F_Schlick( f0, f90, dotVH ); 987 float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); 988 float D = D_GGX( alpha, dotNH ); 989 return F * ( V * D ); 990 } 991#endif 992vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { 993 vec3 f0 = material.specularColorBlended; 994 float f90 = material.specularF90; 995 float roughness = material.roughness; 996 float alpha = pow2( roughness ); 997 vec3 halfDir = normalize( lightDir + viewDir ); 998 float dotNL = saturate( dot( normal, lightDir ) ); 999 float dotNV = saturate( dot( normal, viewDir ) ); 1000 float dotNH = saturate( dot( normal, halfDir ) ); 1001 float dotVH = saturate( dot( viewDir, halfDir ) ); 1002 vec3 F = F_Schlick( f0, f90, dotVH ); 1003 #ifdef USE_IRIDESCENCE 1004 F = mix( F, material.iridescenceFresnel, material.iridescence ); 1005 #endif 1006 #ifdef USE_ANISOTROPY 1007 float dotTL = dot( material.anisotropyT, lightDir ); 1008 float dotTV = dot( material.anisotropyT, viewDir ); 1009 float dotTH = dot( material.anisotropyT, halfDir ); 1010 float dotBL = dot( material.anisotropyB, lightDir ); 1011 float dotBV = dot( material.anisotropyB, viewDir ); 1012 float dotBH = dot( material.anisotropyB, halfDir ); 1013 float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); 1014 float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); 1015 #else 1016 float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); 1017 float D = D_GGX( alpha, dotNH ); 1018 #endif 1019 return F * ( V * D ); 1020} 1021vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { 1022 const float LUT_SIZE = 64.0; 1023 const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; 1024 const float LUT_BIAS = 0.5 / LUT_SIZE; 1025 float dotNV = saturate( dot( N, V ) ); 1026 vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); 1027 uv = uv * LUT_SCALE + LUT_BIAS; 1028 return uv; 1029} 1030float LTC_ClippedSphereFormFactor( const in vec3 f ) { 1031 float l = length( f ); 1032 return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); 1033} 1034vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { 1035 float x = dot( v1, v2 ); 1036 float y = abs( x ); 1037 float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; 1038 float b = 3.4175940 + ( 4.1616724 + y ) * y; 1039 float v = a / b; 1040 float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; 1041 return cross( v1, v2 ) * theta_sintheta; 1042} 1043vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { 1044 vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; 1045 vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; 1046 vec3 lightNormal = cross( v1, v2 ); 1047 if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); 1048 vec3 T1, T2; 1049 T1 = normalize( V - N * dot( V, N ) ); 1050 T2 = - cross( N, T1 ); 1051 mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); 1052 vec3 coords[ 4 ]; 1053 coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); 1054 coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); 1055 coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); 1056 coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); 1057 coords[ 0 ] = normalize( coords[ 0 ] ); 1058 coords[ 1 ] = normalize( coords[ 1 ] ); 1059 coords[ 2 ] = normalize( coords[ 2 ] ); 1060 coords[ 3 ] = normalize( coords[ 3 ] ); 1061 vec3 vectorFormFactor = vec3( 0.0 ); 1062 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); 1063 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); 1064 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); 1065 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); 1066 float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); 1067 return vec3( result ); 1068} 1069#if defined( USE_SHEEN ) 1070float D_Charlie( float roughness, float dotNH ) { 1071 float alpha = pow2( roughness ); 1072 float invAlpha = 1.0 / alpha; 1073 float cos2h = dotNH * dotNH; 1074 float sin2h = max( 1.0 - cos2h, 0.0078125 ); 1075 return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); 1076} 1077float V_Neubelt( float dotNV, float dotNL ) { 1078 return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); 1079} 1080vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { 1081 vec3 halfDir = normalize( lightDir + viewDir ); 1082 float dotNL = saturate( dot( normal, lightDir ) ); 1083 float dotNV = saturate( dot( normal, viewDir ) ); 1084 float dotNH = saturate( dot( normal, halfDir ) ); 1085 float D = D_Charlie( sheenRoughness, dotNH ); 1086 float V = V_Neubelt( dotNV, dotNL ); 1087 return sheenColor * ( D * V ); 1088} 1089#endif 1090float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { 1091 float dotNV = saturate( dot( normal, viewDir ) ); 1092 float r2 = roughness * roughness; 1093 float rInv = 1.0 / ( roughness + 0.1 ); 1094 float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; 1095 float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; 1096 float DG = exp( a * dotNV + b ); 1097 return saturate( DG ); 1098} 1099vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { 1100 float dotNV = saturate( dot( normal, viewDir ) ); 1101 vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; 1102 return specularColor * fab.x + specularF90 * fab.y; 1103} 1104#ifdef USE_IRIDESCENCE 1105void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { 1106#else 1107void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { 1108#endif 1109 float dotNV = saturate( dot( normal, viewDir ) ); 1110 vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; 1111 #ifdef USE_IRIDESCENCE 1112 vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); 1113 #else 1114 vec3 Fr = specularColor; 1115 #endif 1116 vec3 FssEss = Fr * fab.x + specularF90 * fab.y; 1117 float Ess = fab.x + fab.y; 1118 float Ems = 1.0 - Ess; 1119 vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); 1120 singleScatter += FssEss; 1121 multiScatter += Fms * Ems; 1122} 1123vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { 1124 vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
vendor: 8,354 bytes, lines 1125-1254
1125 float dotNL = saturate( dot( normal, lightDir ) ); 1126 float dotNV = saturate( dot( normal, viewDir ) ); 1127 vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; 1128 vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; 1129 vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; 1130 vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; 1131 float Ess_V = dfgV.x + dfgV.y; 1132 float Ess_L = dfgL.x + dfgL.y; 1133 float Ems_V = 1.0 - Ess_V; 1134 float Ems_L = 1.0 - Ess_L; 1135 vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; 1136 vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); 1137 float compensationFactor = Ems_V * Ems_L; 1138 vec3 multiScatter = Fms * compensationFactor; 1139 return singleScatter + multiScatter; 1140} 1141#if NUM_RECT_AREA_LIGHTS > 0 1142 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { 1143 vec3 normal = geometryNormal; 1144 vec3 viewDir = geometryViewDir; 1145 vec3 position = geometryPosition; 1146 vec3 lightPos = rectAreaLight.position; 1147 vec3 halfWidth = rectAreaLight.halfWidth; 1148 vec3 halfHeight = rectAreaLight.halfHeight; 1149 vec3 lightColor = rectAreaLight.color; 1150 float roughness = material.roughness; 1151 vec3 rectCoords[ 4 ]; 1152 rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; 1153 rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; 1154 rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; 1155 vec2 uv = LTC_Uv( normal, viewDir, roughness ); 1156 vec4 t1 = texture2D( ltc_1, uv ); 1157 vec4 t2 = texture2D( ltc_2, uv ); 1158 mat3 mInv = mat3( 1159 vec3( t1.x, 0, t1.y ), 1160 vec3( 0, 1, 0 ), 1161 vec3( t1.z, 0, t1.w ) 1162 ); 1163 vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); 1164 reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); 1165 reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); 1166 #ifdef USE_CLEARCOAT 1167 vec3 Ncc = geometryClearcoatNormal; 1168 vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); 1169 vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); 1170 vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); 1171 mat3 mInvClearcoat = mat3( 1172 vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), 1173 vec3( 0, 1, 0 ), 1174 vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) 1175 ); 1176 vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; 1177 clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); 1178 #endif 1179 } 1180#endif 1181void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { 1182 float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); 1183 vec3 irradiance = dotNL * directLight.color; 1184 #ifdef USE_CLEARCOAT 1185 float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); 1186 vec3 ccIrradiance = dotNLcc * directLight.color; 1187 clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); 1188 #endif 1189 #ifdef USE_SHEEN 1190 1191 sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); 1192 1193 float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); 1194 float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); 1195 1196 float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); 1197 1198 irradiance *= sheenEnergyComp; 1199 1200 #endif 1201 reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); 1202 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); 1203} 1204void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { 1205 vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); 1206 #ifdef USE_SHEEN 1207 float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); 1208 float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; 1209 diffuse *= sheenEnergyComp; 1210 #endif 1211 reflectedLight.indirectDiffuse += diffuse; 1212} 1213void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { 1214 #ifdef USE_CLEARCOAT 1215 clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); 1216 #endif 1217 #ifdef USE_SHEEN 1218 sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; 1219 #endif 1220 vec3 singleScatteringDielectric = vec3( 0.0 ); 1221 vec3 multiScatteringDielectric = vec3( 0.0 ); 1222 vec3 singleScatteringMetallic = vec3( 0.0 ); 1223 vec3 multiScatteringMetallic = vec3( 0.0 ); 1224 #ifdef USE_IRIDESCENCE 1225 computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); 1226 computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); 1227 #else 1228 computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); 1229 computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); 1230 #endif 1231 vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); 1232 vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); 1233 vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; 1234 vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); 1235 vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; 1236 vec3 indirectSpecular = radiance * singleScattering; 1237 indirectSpecular += multiScattering * cosineWeightedIrradiance; 1238 vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; 1239 #ifdef USE_SHEEN 1240 float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); 1241 float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; 1242 indirectSpecular *= sheenEnergyComp; 1243 indirectDiffuse *= sheenEnergyComp; 1244 #endif 1245 reflectedLight.indirectSpecular += indirectSpecular; 1246 reflectedLight.indirectDiffuse += indirectDiffuse; 1247} 1248#define RE_Direct RE_Direct_Physical 1249#define RE_Direct_RectArea RE_Direct_RectArea_Physical 1250#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical 1251#define RE_IndirectSpecular RE_IndirectSpecular_Physical 1252float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { 1253 return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); 1254}`,
1254zy=` 1255vec3 geometryPosition = - vViewPosition; 1256vec3 geometryNormal = normal; 1257vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); 1258vec3 geometryClearcoatNormal = vec3( 0.0 ); 1259#ifdef USE_CLEARCOAT 1260 geometryClearcoatNormal = clearcoatNormal; 1261#endif 1262#ifdef USE_IRIDESCENCE 1263 float dotNVi = saturate( dot( normal, geometryViewDir ) ); 1264 if ( material.iridescenceThickness == 0.0 ) { 1265 material.iridescence = 0.0; 1266 } else { 1267 material.iridescence = saturate( material.iridescence ); 1268 } 1269 if ( material.iridescence > 0.0 ) { 1270 material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); 1271 material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); 1272 material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); 1273 material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); 1274 } 1275#endif 1276IncidentLight directLight; 1277#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) 1278 PointLight pointLight; 1279 #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 1280 PointLightShadow pointLightShadow; 1281 #endif 1282 #pragma unroll_loop_start 1283 for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { 1284 pointLight = pointLights[ i ]; 1285 getPointLightInfo( pointLight, geometryPosition, directLight ); 1286 #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) 1287 pointLightShadow = pointLightShadows[ i ]; 1288 directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; 1289 #endif 1290 RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1291 } 1292 #pragma unroll_loop_end 1293#endif 1294#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) 1295 SpotLight spotLight; 1296 vec4 spotColor; 1297 vec3 spotLightCoord; 1298 bool inSpotLightMap; 1299 #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 1300 SpotLightShadow spotLightShadow; 1301 #endif 1302 #pragma unroll_loop_start 1303 for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { 1304 spotLight = spotLights[ i ]; 1305 getSpotLightInfo( spotLight, geometryPosition, directLight ); 1306 #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) 1307 #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX 1308 #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) 1309 #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS 1310 #else 1311 #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) 1312 #endif 1313 #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) 1314 spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; 1315 inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); 1316 spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); 1317 directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; 1318 #endif 1319 #undef SPOT_LIGHT_MAP_INDEX 1320 #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) 1321 spotLightShadow = spotLightShadows[ i ]; 1322 directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; 1323 #endif 1324 RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1325 } 1326 #pragma unroll_loop_end 1327#endif 1328#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) 1329 DirectionalLight directionalLight; 1330 #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 1331 DirectionalLightShadow directionalLightShadow; 1332 #endif 1333 #pragma unroll_loop_start 1334 for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { 1335 directionalLight = directionalLights[ i ]; 1336 getDirectionalLightInfo( directionalLight, directLight ); 1337 #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) 1338 directionalLightShadow = directionalLightShadows[ i ]; 1339 directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; 1340 #endif 1341 RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1342 } 1343 #pragma unroll_loop_end 1344#endif 1345#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) 1346 RectAreaLight rectAreaLight; 1347 #pragma unroll_loop_start 1348 for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { 1349 rectAreaLight = rectAreaLights[ i ]; 1350 RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1351 } 1352 #pragma unroll_loop_end 1353#endif 1354#if defined( RE_IndirectDiffuse ) 1355 vec3 iblIrradiance = vec3( 0.0 ); 1356 vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); 1357 #if defined( USE_LIGHT_PROBES ) 1358 irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); 1359 #endif 1360 #if ( NUM_HEMI_LIGHTS > 0 ) 1361 #pragma unroll_loop_start 1362 for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { 1363 irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); 1364 } 1365 #pragma unroll_loop_end 1366 #endif 1367#endif 1368#if defined( RE_IndirectSpecular ) 1369 vec3 radiance = vec3( 0.0 ); 1370 vec3 clearcoatRadiance = vec3( 0.0 ); 1371#endif`,Vy=`#if defined( RE_IndirectDiffuse ) 1372 #ifdef USE_LIGHTMAP 1373 vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); 1374 vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; 1375 irradiance += lightMapIrradiance; 1376 #endif 1377 #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) 1378 #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) 1379 iblIrradiance += getIBLIrradiance( geometryNormal ); 1380 #endif 1381 #endif 1382#endif 1383#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) 1384 #ifdef USE_ANISOTROPY 1385 radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); 1386 #else 1387 radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); 1388 #endif 1389 #ifdef USE_CLEARCOAT 1390 clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); 1391 #endif 1392#endif`,Hy=`#if defined( RE_IndirectDiffuse ) 1393 #if defined( LAMBERT ) || defined( PHONG ) 1394 irradiance += iblIrradiance; 1395 #endif 1396 RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1397#endif 1398#if defined( RE_IndirectSpecular ) 1399 RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1400#endif`,Gy=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) 1401 gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; 1402#endif`,Wy=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) 1403 uniform float logDepthBufFC; 1404 varying float vFragDepth; 1405 varying float vIsPerspective; 1406#endif`,Xy=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER 1407 varying float vFragDepth; 1408 varying float vIsPerspective; 1409#endif`,qy=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER 1410 vFragDepth = 1.0 + gl_Position.w; 1411 vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); 1412#endif`,jy=`#ifdef USE_MAP 1413 vec4 sampledDiffuseColor = texture2D( map, vMapUv ); 1414 #ifdef DECODE_VIDEO_TEXTURE 1415 sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); 1416 #endif 1417 diffuseColor *= sampledDiffuseColor; 1418#endif`,Yy=`#ifdef USE_MAP 1419 uniform sampler2D map; 1420#endif`,Ky=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) 1421 #if defined( USE_POINTS_UV ) 1422 vec2 uv = vUv; 1423 #else 1424 vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; 1425 #endif 1426#endif 1427#ifdef USE_MAP 1428 diffuseColor *= texture2D( map, uv ); 1429#endif 1430#ifdef USE_ALPHAMAP 1431 diffuseColor.a *= texture2D( alphaMap, uv ).g; 1432#endif`,Zy=`#if defined( USE_POINTS_UV ) 1433 varying vec2 vUv; 1434#else 1435 #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) 1436 uniform mat3 uvTransform; 1437 #endif 1438#endif 1439#ifdef USE_MAP 1440 uniform sampler2D map; 1441#endif 1442#ifdef USE_ALPHAMAP 1443 uniform sampler2D alphaMap; 1444#endif`,Jy=`float metalnessFactor = metalness; 1445#ifdef USE_METALNESSMAP 1446 vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); 1447 metalnessFactor *= texelMetalness.b; 1448#endif`,Qy=`#ifdef USE_METALNESSMAP 1449 uniform sampler2D metalnessMap; 1450#endif`,$y=`#ifdef USE_INSTANCING_MORPH 1451 float morphTargetInfluences[ MORPHTARGETS_COUNT ]; 1452 float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; 1453 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1454 morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; 1455 } 1456#endif`,ev=`#if defined( USE_MORPHCOLORS ) 1457 vColor *= morphTargetBaseInfluence; 1458 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1459 #if defined( USE_COLOR_ALPHA ) 1460 if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; 1461 #elif defined( USE_COLOR ) 1462 if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; 1463 #endif 1464 } 1465#endif`,tv=`#ifdef USE_MORPHNORMALS 1466 objectNormal *= morphTargetBaseInfluence; 1467 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1468 if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; 1469 } 1470#endif`,nv=`#ifdef USE_MORPHTARGETS 1471 #ifndef USE_INSTANCING_MORPH 1472 uniform float morphTargetBaseInfluence; 1473 uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; 1474 #endif 1475 uniform sampler2DArray morphTargetsTexture; 1476 uniform ivec2 morphTargetsTextureSize; 1477 vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { 1478 int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; 1479 int y = texelIndex / morphTargetsTextureSize.x; 1480 int x = texelIndex - y * morphTargetsTextureSize.x; 1481 ivec3 morphUV = ivec3( x, y, morphTargetIndex ); 1482 return texelFetch( morphTargetsTexture, morphUV, 0 ); 1483 } 1484#endif`,iv=`#ifdef USE_MORPHTARGETS 1485 transformed *= morphTargetBaseInfluence; 1486 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1487 if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; 1488 } 1489#endif`,sv=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; 1490#ifdef FLAT_SHADED 1491 vec3 fdx = dFdx( vViewPosition ); 1492 vec3 fdy = dFdy( vViewPosition ); 1493 vec3 normal = normalize( cross( fdx, fdy ) ); 1494#else 1495 vec3 normal = normalize( vNormal ); 1496 #ifdef DOUBLE_SIDED 1497 normal *= faceDirection; 1498 #endif 1499#endif 1500#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) 1501 #ifdef USE_TANGENT 1502 mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); 1503 #else 1504 mat3 tbn = getTangentFrame( - vViewPosition, normal, 1505 #if defined( USE_NORMALMAP ) 1506 vNormalMapUv 1507 #elif defined( USE_CLEARCOAT_NORMALMAP ) 1508 vClearcoatNormalMapUv 1509 #else 1510 vUv 1511 #endif 1512 ); 1513 #endif 1514 #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) 1515 tbn[0] *= faceDirection; 1516 tbn[1] *= faceDirection; 1517 #endif 1518#endif 1519#ifdef USE_CLEARCOAT_NORMALMAP 1520 #ifdef USE_TANGENT 1521 mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); 1522 #else 1523 mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); 1524 #endif 1525 #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) 1526 tbn2[0] *= faceDirection; 1527 tbn2[1] *= faceDirection; 1528 #endif 1529#endif 1530vec3 nonPerturbedNormal = normal;`,rv=`#ifdef USE_NORMALMAP_OBJECTSPACE 1531 normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; 1532 #ifdef FLIP_SIDED 1533 normal = - normal; 1534 #endif 1535 #ifdef DOUBLE_SIDED 1536 normal = normal * faceDirection; 1537 #endif 1538 normal = normalize( normalMatrix * normal ); 1539#elif defined( USE_NORMALMAP_TANGENTSPACE ) 1540 vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; 1541 mapN.xy *= normalScale; 1542 normal = normalize( tbn * mapN ); 1543#elif defined( USE_BUMPMAP )
1544 normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); 1545#endif`,ov=`#ifndef FLAT_SHADED 1546 varying vec3 vNormal; 1547 #ifdef USE_TANGENT 1548 varying vec3 vTangent; 1549 varying vec3 vBitangent; 1550 #endif 1551#endif`,av=`#ifndef FLAT_SHADED 1552 varying vec3 vNormal; 1553 #ifdef USE_TANGENT 1554 varying vec3 vTangent; 1555 varying vec3 vBitangent; 1556 #endif 1557#endif`,cv=`#ifndef FLAT_SHADED 1558 vNormal = normalize( transformedNormal ); 1559 #ifdef USE_TANGENT 1560 vTangent = normalize( transformedTangent ); 1561 vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); 1562 #endif 1563#endif`,lv=`#ifdef USE_NORMALMAP 1564 uniform sampler2D normalMap; 1565 uniform vec2 normalScale; 1566#endif 1567#ifdef USE_NORMALMAP_OBJECTSPACE 1568 uniform mat3 normalMatrix; 1569#endif 1570#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) 1571 mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { 1572 vec3 q0 = dFdx( eye_pos.xyz ); 1573 vec3 q1 = dFdy( eye_pos.xyz ); 1574 vec2 st0 = dFdx( uv.st ); 1575 vec2 st1 = dFdy( uv.st ); 1576 vec3 N = surf_norm; 1577 vec3 q1perp = cross( q1, N ); 1578 vec3 q0perp = cross( N, q0 ); 1579 vec3 T = q1perp * st0.x + q0perp * st1.x; 1580 vec3 B = q1perp * st0.y + q0perp * st1.y; 1581 float det = max( dot( T, T ), dot( B, B ) ); 1582 float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); 1583 return mat3( T * scale, B * scale, N ); 1584 } 1585#endif`,uv=`#ifdef USE_CLEARCOAT 1586 vec3 clearcoatNormal = nonPerturbedNormal; 1587#endif`,dv=`#ifdef USE_CLEARCOAT_NORMALMAP 1588 vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; 1589 clearcoatMapN.xy *= clearcoatNormalScale; 1590 clearcoatNormal = normalize( tbn2 * clearcoatMapN ); 1591#endif`,hv=`#ifdef USE_CLEARCOATMAP 1592 uniform sampler2D clearcoatMap; 1593#endif 1594#ifdef USE_CLEARCOAT_NORMALMAP 1595 uniform sampler2D clearcoatNormalMap; 1596 uniform vec2 clearcoatNormalScale; 1597#endif 1598#ifdef USE_CLEARCOAT_ROUGHNESSMAP 1599 uniform sampler2D clearcoatRoughnessMap; 1600#endif`,fv=`#ifdef USE_IRIDESCENCEMAP 1601 uniform sampler2D iridescenceMap; 1602#endif 1603#ifdef USE_IRIDESCENCE_THICKNESSMAP 1604 uniform sampler2D iridescenceThicknessMap; 1605#endif`,pv=`#ifdef OPAQUE 1606diffuseColor.a = 1.0; 1607#endif 1608#ifdef USE_TRANSMISSION 1609diffuseColor.a *= material.transmissionAlpha; 1610#endif 1611gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,mv=`vec3 packNormalToRGB( const in vec3 normal ) { 1612 return normalize( normal ) * 0.5 + 0.5; 1613} 1614vec3 unpackRGBToNormal( const in vec3 rgb ) { 1615 return 2.0 * rgb.xyz - 1.0; 1616} 1617const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; 1618const float Inv255 = 1. / 255.; 1619const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); 1620const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); 1621const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); 1622const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); 1623vec4 packDepthToRGBA( const in float v ) { 1624 if( v <= 0.0 ) 1625 return vec4( 0., 0., 0., 0. ); 1626 if( v >= 1.0 ) 1627 return vec4( 1., 1., 1., 1. ); 1628 float vuf; 1629 float af = modf( v * PackFactors.a, vuf ); 1630 float bf = modf( vuf * ShiftRight8, vuf ); 1631 float gf = modf( vuf * ShiftRight8, vuf ); 1632 return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); 1633} 1634vec3 packDepthToRGB( const in float v ) { 1635 if( v <= 0.0 ) 1636 return vec3( 0., 0., 0. ); 1637 if( v >= 1.0 ) 1638 return vec3( 1., 1., 1. ); 1639 float vuf; 1640 float bf = modf( v * PackFactors.b, vuf ); 1641 float gf = modf( vuf * ShiftRight8, vuf ); 1642 return vec3( vuf * Inv255, gf * PackUpscale, bf ); 1643} 1644vec2 packDepthToRG( const in float v ) { 1645 if( v <= 0.0 ) 1646 return vec2( 0., 0. ); 1647 if( v >= 1.0 ) 1648 return vec2( 1., 1. ); 1649 float vuf; 1650 float gf = modf( v * 256., vuf ); 1651 return vec2( vuf * Inv255, gf ); 1652} 1653float unpackRGBAToDepth( const in vec4 v ) { 1654 return dot( v, UnpackFactors4 ); 1655} 1656float unpackRGBToDepth( const in vec3 v ) { 1657 return dot( v, UnpackFactors3 ); 1658} 1659float unpackRGToDepth( const in vec2 v ) { 1660 return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; 1661} 1662vec4 pack2HalfToRGBA( const in vec2 v ) {
1663 vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); 1664 return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); 1665} 1666vec2 unpackRGBATo2Half( const in vec4 v ) { 1667 return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); 1668} 1669float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { 1670 return ( viewZ + near ) / ( near - far ); 1671} 1672float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { 1673 #ifdef USE_REVERSED_DEPTH_BUFFER 1674 1675 return depth * ( far - near ) - far; 1676 #else 1677 return depth * ( near - far ) - near; 1678 #endif 1679} 1680float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { 1681 return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); 1682} 1683float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { 1684 1685 #ifdef USE_REVERSED_DEPTH_BUFFER 1686 return ( near * far ) / ( ( near - far ) * depth - near ); 1687 #else 1688 return ( near * far ) / ( ( far - near ) * depth - far ); 1689 #endif 1690}`,gv=`#ifdef PREMULTIPLIED_ALPHA 1691 gl_FragColor.rgb *= gl_FragColor.a; 1692#endif`,xv=`vec4 mvPosition = vec4( transformed, 1.0 ); 1693#ifdef USE_BATCHING 1694 mvPosition = batchingMatrix * mvPosition; 1695#endif 1696#ifdef USE_INSTANCING 1697 mvPosition = instanceMatrix * mvPosition; 1698#endif 1699mvPosition = modelViewMatrix * mvPosition; 1700gl_Position = projectionMatrix * mvPosition;`,yv=`#ifdef DITHERING 1701 gl_FragColor.rgb = dithering( gl_FragColor.rgb ); 1702#endif`,vv=`#ifdef DITHERING 1703 vec3 dithering( vec3 color ) { 1704 float grid_position = rand( gl_FragCoord.xy ); 1705 vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); 1706 dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); 1707 return color + dither_shift_RGB; 1708 } 1709#endif`,_v=`float roughnessFactor = roughness; 1710#ifdef USE_ROUGHNESSMAP 1711 vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); 1712 roughnessFactor *= texelRoughness.g; 1713#endif`,bv=`#ifdef USE_ROUGHNESSMAP 1714 uniform sampler2D roughnessMap; 1715#endif`,Mv=`#if NUM_SPOT_LIGHT_COORDS > 0 1716 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; 1717#endif 1718#if NUM_SPOT_LIGHT_MAPS > 0 1719 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; 1720#endif 1721#ifdef USE_SHADOWMAP 1722 #if NUM_DIR_LIGHT_SHADOWS > 0 1723 #if defined( SHADOWMAP_TYPE_PCF ) 1724 uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; 1725 #else 1726 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; 1727 #endif 1728 varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; 1729 struct DirectionalLightShadow { 1730 float shadowIntensity; 1731 float shadowBias; 1732 float shadowNormalBias; 1733 float shadowRadius; 1734 vec2 shadowMapSize; 1735 }; 1736 uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; 1737 #endif 1738 #if NUM_SPOT_LIGHT_SHADOWS > 0 1739 #if defined( SHADOWMAP_TYPE_PCF ) 1740 uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; 1741 #else 1742 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; 1743 #endif 1744 struct SpotLightShadow { 1745 float shadowIntensity; 1746 float shadowBias; 1747 float shadowNormalBias; 1748 float shadowRadius; 1749 vec2 shadowMapSize; 1750 }; 1751 uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; 1752 #endif 1753 #if NUM_POINT_LIGHT_SHADOWS > 0 1754 #if defined( SHADOWMAP_TYPE_PCF ) 1755 uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; 1756 #elif defined( SHADOWMAP_TYPE_BASIC ) 1757 uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; 1758 #endif 1759 varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; 1760 struct PointLightShadow { 1761 float shadowIntensity; 1762 float shadowBias; 1763 float shadowNormalBias; 1764 float shadowRadius; 1765 vec2 shadowMapSize; 1766 float shadowCameraNear; 1767 float shadowCameraFar; 1768 }; 1769 uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; 1770 #endif 1771 #if defined( SHADOWMAP_TYPE_PCF ) 1772 float interleavedGradientNoise( vec2 position ) { 1773 return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); 1774 } 1775 vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { 1776 const float goldenAngle = 2.399963229728653; 1777 float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); 1778 float theta = float( sampleIndex ) * goldenAngle + phi; 1779 return vec2( cos( theta ), sin( theta ) ) * r; 1780 } 1781 #endif 1782 #if defined( SHADOWMAP_TYPE_PCF ) 1783 float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { 1784 float shadow = 1.0; 1785 shadowCoord.xyz /= shadowCoord.w; 1786 shadowCoord.z += shadowBias; 1787 bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; 1788 bool frustumTest = inFrustum && shadowCoord.z <= 1.0; 1789 if ( frustumTest ) { 1790 vec2 texelSize = vec2( 1.0 ) / shadowMapSize; 1791 float radius = shadowRadius * texelSize.x; 1792 float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; 1793 shadow = ( 1794 texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + 1795 texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + 1796 texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + 1797 texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + 1798 texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) 1799 ) * 0.2; 1800 } 1801 return mix( 1.0, shadow, shadowIntensity ); 1802 } 1803 #elif defined( SHADOWMAP_TYPE_VSM ) 1804 float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { 1805 float shadow = 1.0; 1806 shadowCoord.xyz /= shadowCoord.w; 1807 #ifdef USE_REVERSED_DEPTH_BUFFER 1808 shadowCoord.z -= shadowBias; 1809 #else 1810 shadowCoord.z += shadowBias; 1811 #endif 1812 bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; 1813 bool frustumTest = inFrustum && shadowCoord.z <= 1.0; 1814 if ( frustumTest ) { 1815 vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; 1816 float mean = distribution.x; 1817 float variance = distribution.y * distribution.y; 1818 #ifdef USE_REVERSED_DEPTH_BUFFER 1819 float hard_shadow = step( mean, shadowCoord.z ); 1820 #else 1821 float hard_shadow = step( shadowCoord.z, mean ); 1822 #endif 1823 1824 if ( hard_shadow == 1.0 ) { 1825 shadow = 1.0; 1826 } else { 1827 variance = max( variance, 0.0000001 ); 1828 float d = shadowCoord.z - mean; 1829 float p_max = variance / ( variance + d * d ); 1830 p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); 1831 shadow = max( hard_shadow, p_max ); 1832 } 1833 } 1834 return mix( 1.0, shadow, shadowIntensity ); 1835 } 1836 #else 1837 float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { 1838 float shadow = 1.0; 1839 shadowCoord.xyz /= shadowCoord.w; 1840 #ifdef USE_REVERSED_DEPTH_BUFFER 1841 shadowCoord.z -= shadowBias; 1842 #else 1843 shadowCoord.z += shadowBias; 1844 #endif 1845 bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; 1846 bool frustumTest = inFrustum && shadowCoord.z <= 1.0; 1847 if ( frustumTest ) { 1848 float depth = texture2D( shadowMap, shadowCoord.xy ).r; 1849 #ifdef USE_REVERSED_DEPTH_BUFFER 1850 shadow = step( depth, shadowCoord.z ); 1851 #else 1852 shadow = step( shadowCoord.z, depth ); 1853 #endif 1854 } 1855 return mix( 1.0, shadow, shadowIntensity ); 1856 } 1857 #endif 1858 #if NUM_POINT_LIGHT_SHADOWS > 0 1859 #if defined( SHADOWMAP_TYPE_PCF ) 1860 float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { 1861 float shadow = 1.0; 1862 vec3 lightToPosition = shadowCoord.xyz; 1863 vec3 bd3D = normalize( lightToPosition ); 1864 vec3 absVec = abs( lightToPosition ); 1865 float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); 1866 if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { 1867 #ifdef USE_REVERSED_DEPTH_BUFFER 1868 float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
1869 dp -= shadowBias; 1870 #else 1871 float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); 1872 dp += shadowBias; 1873 #endif 1874 float texelSize = shadowRadius / shadowMapSize.x; 1875 vec3 absDir = abs( bd3D ); 1876 vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); 1877 tangent = normalize( cross( bd3D, tangent ) ); 1878 vec3 bitangent = cross( bd3D, tangent ); 1879 float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; 1880 vec2 sample0 = vogelDiskSample( 0, 5, phi ); 1881 vec2 sample1 = vogelDiskSample( 1, 5, phi ); 1882 vec2 sample2 = vogelDiskSample( 2, 5, phi ); 1883 vec2 sample3 = vogelDiskSample( 3, 5, phi ); 1884 vec2 sample4 = vogelDiskSample( 4, 5, phi ); 1885 shadow = ( 1886 texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + 1887 texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + 1888 texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + 1889 texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + 1890 texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) 1891 ) * 0.2; 1892 } 1893 return mix( 1.0, shadow, shadowIntensity ); 1894 } 1895 #elif defined( SHADOWMAP_TYPE_BASIC ) 1896 float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { 1897 float shadow = 1.0; 1898 vec3 lightToPosition = shadowCoord.xyz; 1899 vec3 absVec = abs( lightToPosition ); 1900 float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); 1901 if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { 1902 float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); 1903 dp += shadowBias; 1904 vec3 bd3D = normalize( lightToPosition ); 1905 float depth = textureCube( shadowMap, bd3D ).r; 1906 #ifdef USE_REVERSED_DEPTH_BUFFER 1907 depth = 1.0 - depth; 1908 #endif 1909 shadow = step( dp, depth ); 1910 } 1911 return mix( 1.0, shadow, shadowIntensity ); 1912 } 1913 #endif 1914 #endif 1915#endif`,Sv=`#if NUM_SPOT_LIGHT_COORDS > 0 1916 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; 1917 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; 1918#endif 1919#ifdef USE_SHADOWMAP 1920 #if NUM_DIR_LIGHT_SHADOWS > 0 1921 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; 1922 varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; 1923 struct DirectionalLightShadow { 1924 float shadowIntensity; 1925 float shadowBias; 1926 float shadowNormalBias; 1927 float shadowRadius; 1928 vec2 shadowMapSize; 1929 }; 1930 uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; 1931 #endif 1932 #if NUM_SPOT_LIGHT_SHADOWS > 0 1933 struct SpotLightShadow { 1934 float shadowIntensity; 1935 float shadowBias; 1936 float shadowNormalBias; 1937 float shadowRadius; 1938 vec2 shadowMapSize; 1939 }; 1940 uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; 1941 #endif 1942 #if NUM_POINT_LIGHT_SHADOWS > 0 1943 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; 1944 varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; 1945 struct PointLightShadow { 1946 float shadowIntensity; 1947 float shadowBias; 1948 float shadowNormalBias; 1949 float shadowRadius; 1950 vec2 shadowMapSize; 1951 float shadowCameraNear; 1952 float shadowCameraFar; 1953 }; 1954 uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; 1955 #endif 1956#endif`,wv=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) 1957 vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); 1958 vec4 shadowWorldPosition; 1959#endif 1960#if defined( USE_SHADOWMAP ) 1961 #if NUM_DIR_LIGHT_SHADOWS > 0 1962 #pragma unroll_loop_start 1963 for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { 1964 shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); 1965 vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; 1966 } 1967 #pragma unroll_loop_end 1968 #endif 1969 #if NUM_POINT_LIGHT_SHADOWS > 0 1970 #pragma unroll_loop_start 1971 for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { 1972 shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); 1973 vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; 1974 } 1975 #pragma unroll_loop_end 1976 #endif 1977#endif
1978#if NUM_SPOT_LIGHT_COORDS > 0 1979 #pragma unroll_loop_start 1980 for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { 1981 shadowWorldPosition = worldPosition; 1982 #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) 1983 shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; 1984 #endif 1985 vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; 1986 } 1987 #pragma unroll_loop_end 1988#endif`,Tv=`float getShadowMask() { 1989 float shadow = 1.0; 1990 #ifdef USE_SHADOWMAP 1991 #if NUM_DIR_LIGHT_SHADOWS > 0 1992 DirectionalLightShadow directionalLight; 1993 #pragma unroll_loop_start 1994 for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { 1995 directionalLight = directionalLightShadows[ i ]; 1996 shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; 1997 } 1998 #pragma unroll_loop_end 1999 #endif 2000 #if NUM_SPOT_LIGHT_SHADOWS > 0 2001 SpotLightShadow spotLight; 2002 #pragma unroll_loop_start 2003 for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { 2004 spotLight = spotLightShadows[ i ]; 2005 shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; 2006 } 2007 #pragma unroll_loop_end 2008 #endif 2009 #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) 2010 PointLightShadow pointLight; 2011 #pragma unroll_loop_start 2012 for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { 2013 pointLight = pointLightShadows[ i ]; 2014 shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; 2015 } 2016 #pragma unroll_loop_end 2017 #endif 2018 #endif 2019 return shadow; 2020}`,Ev=`#ifdef USE_SKINNING 2021 mat4 boneMatX = getBoneMatrix( skinIndex.x ); 2022 mat4 boneMatY = getBoneMatrix( skinIndex.y ); 2023 mat4 boneMatZ = getBoneMatrix( skinIndex.z ); 2024 mat4 boneMatW = getBoneMatrix( skinIndex.w ); 2025#endif`,Av=`#ifdef USE_SKINNING 2026 uniform mat4 bindMatrix; 2027 uniform mat4 bindMatrixInverse; 2028 uniform highp sampler2D boneTexture; 2029 mat4 getBoneMatrix( const in float i ) { 2030 int size = textureSize( boneTexture, 0 ).x; 2031 int j = int( i ) * 4; 2032 int x = j % size; 2033 int y = j / size; 2034 vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); 2035 vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); 2036 vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); 2037 vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); 2038 return mat4( v1, v2, v3, v4 ); 2039 } 2040#endif`,Cv=`#ifdef USE_SKINNING 2041 vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); 2042 vec4 skinned = vec4( 0.0 ); 2043 skinned += boneMatX * skinVertex * skinWeight.x; 2044 skinned += boneMatY * skinVertex * skinWeight.y; 2045 skinned += boneMatZ * skinVertex * skinWeight.z; 2046 skinned += boneMatW * skinVertex * skinWeight.w; 2047 transformed = ( bindMatrixInverse * skinned ).xyz; 2048#endif`,Rv=`#ifdef USE_SKINNING 2049 mat4 skinMatrix = mat4( 0.0 ); 2050 skinMatrix += skinWeight.x * boneMatX; 2051 skinMatrix += skinWeight.y * boneMatY; 2052 skinMatrix += skinWeight.z * boneMatZ; 2053 skinMatrix += skinWeight.w * boneMatW; 2054 skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; 2055 objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; 2056 #ifdef USE_TANGENT 2057 objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; 2058 #endif 2059#endif`,Pv=`float specularStrength; 2060#ifdef USE_SPECULARMAP 2061 vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); 2062 specularStrength = texelSpecular.r; 2063#else 2064 specularStrength = 1.0; 2065#endif`,Lv=`#ifdef USE_SPECULARMAP 2066 uniform sampler2D specularMap; 2067#endif`,Iv=`#if defined( TONE_MAPPING ) 2068 gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); 2069#endif`,Dv=`#ifndef saturate 2070#define saturate( a ) clamp( a, 0.0, 1.0 ) 2071#endif 2072uniform float toneMappingExposure; 2073vec3 LinearToneMapping( vec3 color ) { 2074 return saturate( toneMappingExposure * color ); 2075} 2076vec3 ReinhardToneMapping( vec3 color ) { 2077 color *= toneMappingExposure; 2078 return saturate( color / ( vec3( 1.0 ) + color ) ); 2079} 2080vec3 CineonToneMapping( vec3 color ) { 2081 color *= toneMappingExposure; 2082 color = max( vec3( 0.0 ), color - 0.004 ); 2083 return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); 2084} 2085vec3 RRTAndODTFit( vec3 v ) { 2086 vec3 a = v * ( v + 0.0245786 ) - 0.000090537; 2087 vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; 2088 return a / b; 2089} 2090vec3 ACESFilmicToneMapping( vec3 color ) { 2091 const mat3 ACESInputMat = mat3( 2092 vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), 2093 vec3( 0.04823, 0.01566, 0.83777 ) 2094 ); 2095 const mat3 ACESOutputMat = mat3( 2096 vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), 2097 vec3( -0.07367, -0.00605, 1.07602 ) 2098 ); 2099 color *= toneMappingExposure / 0.6; 2100 color = ACESInputMat * color; 2101 color = RRTAndODTFit( color ); 2102 color = ACESOutputMat * color; 2103 return saturate( color ); 2104} 2105const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( 2106 vec3( 1.6605, - 0.1246, - 0.0182 ), 2107 vec3( - 0.5876, 1.1329, - 0.1006 ), 2108 vec3( - 0.0728, - 0.0083, 1.1187 ) 2109); 2110const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( 2111 vec3( 0.6274, 0.0691, 0.0164 ), 2112 vec3( 0.3293, 0.9195, 0.0880 ), 2113 vec3( 0.0433, 0.0113, 0.8956 ) 2114); 2115vec3 agxDefaultContrastApprox( vec3 x ) { 2116 vec3 x2 = x * x; 2117 vec3 x4 = x2 * x2; 2118 return + 15.5 * x4 * x2 2119 - 40.14 * x4 * x 2120 + 31.96 * x4 2121 - 6.868 * x2 * x 2122 + 0.4298 * x2 2123 + 0.1191 * x 2124 - 0.00232; 2125} 2126vec3 AgXToneMapping( vec3 color ) { 2127 const mat3 AgXInsetMatrix = mat3( 2128 vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), 2129 vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), 2130 vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) 2131 );
2132 const mat3 AgXOutsetMatrix = mat3( 2133 vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), 2134 vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), 2135 vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) 2136 ); 2137 const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; 2138 color *= toneMappingExposure; 2139 color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; 2140 color = AgXInsetMatrix * color; 2141 color = max( color, 1e-10 ); color = log2( color ); 2142 color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); 2143 color = clamp( color, 0.0, 1.0 ); 2144 color = agxDefaultContrastApprox( color ); 2145 color = AgXOutsetMatrix * color; 2146 color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); 2147 color = LINEAR_REC2020_TO_LINEAR_SRGB * color; 2148 color = clamp( color, 0.0, 1.0 ); 2149 return color; 2150} 2151vec3 NeutralToneMapping( vec3 color ) { 2152 const float StartCompression = 0.8 - 0.04; 2153 const float Desaturation = 0.15; 2154 color *= toneMappingExposure; 2155 float x = min( color.r, min( color.g, color.b ) ); 2156 float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; 2157 color -= offset; 2158 float peak = max( color.r, max( color.g, color.b ) ); 2159 if ( peak < StartCompression ) return color; 2160 float d = 1. - StartCompression; 2161 float newPeak = 1. - d * d / ( peak + d - StartCompression ); 2162 color *= newPeak / peak; 2163 float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); 2164 return mix( color, vec3( newPeak ), g ); 2165} 2166vec3 CustomToneMapping( vec3 color ) { return color; }`,Nv=`#ifdef USE_TRANSMISSION 2167 material.transmission = transmission; 2168 material.transmissionAlpha = 1.0; 2169 material.thickness = thickness; 2170 material.attenuationDistance = attenuationDistance; 2171 material.attenuationColor = attenuationColor; 2172 #ifdef USE_TRANSMISSIONMAP 2173 material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; 2174 #endif 2175 #ifdef USE_THICKNESSMAP 2176 material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; 2177 #endif 2178 vec3 pos = vWorldPosition; 2179 vec3 v = normalize( cameraPosition - pos ); 2180 vec3 n = inverseTransformDirection( normal, viewMatrix ); 2181 vec4 transmitted = getIBLVolumeRefraction( 2182 n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, 2183 pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, 2184 material.attenuationColor, material.attenuationDistance ); 2185 material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); 2186 totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); 2187#endif`,Uv=`#ifdef USE_TRANSMISSION 2188 uniform float transmission; 2189 uniform float thickness; 2190 uniform float attenuationDistance; 2191 uniform vec3 attenuationColor; 2192 #ifdef USE_TRANSMISSIONMAP 2193 uniform sampler2D transmissionMap; 2194 #endif 2195 #ifdef USE_THICKNESSMAP 2196 uniform sampler2D thicknessMap; 2197 #endif 2198 uniform vec2 transmissionSamplerSize; 2199 uniform sampler2D transmissionSamplerMap; 2200 uniform mat4 modelMatrix; 2201 uniform mat4 projectionMatrix; 2202 varying vec3 vWorldPosition; 2203 float w0( float a ) { 2204 return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); 2205 } 2206 float w1( float a ) { 2207 return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); 2208 } 2209 float w2( float a ){ 2210 return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); 2211 } 2212 float w3( float a ) { 2213 return ( 1.0 / 6.0 ) * ( a * a * a ); 2214 } 2215 float g0( float a ) { 2216 return w0( a ) + w1( a ); 2217 } 2218 float g1( float a ) { 2219 return w2( a ) + w3( a ); 2220 } 2221 float h0( float a ) { 2222 return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); 2223 } 2224 float h1( float a ) { 2225 return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); 2226 } 2227 vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { 2228 uv = uv * texelSize.zw + 0.5; 2229 vec2 iuv = floor( uv ); 2230 vec2 fuv = fract( uv ); 2231 float g0x = g0( fuv.x ); 2232 float g1x = g1( fuv.x ); 2233 float h0x = h0( fuv.x ); 2234 float h1x = h1( fuv.x ); 2235 float h0y = h0( fuv.y ); 2236 float h1y = h1( fuv.y ); 2237 vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; 2238 vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; 2239 vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; 2240 vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; 2241 return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + 2242 g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); 2243 } 2244 vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { 2245 vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); 2246 vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); 2247 vec2 fLodSizeInv = 1.0 / fLodSize; 2248 vec2 cLodSizeInv = 1.0 / cLodSize; 2249 vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); 2250 vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); 2251 return mix( fSample, cSample, fract( lod ) ); 2252 } 2253 vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { 2254 vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); 2255 vec3 modelScale; 2256 modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); 2257 modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); 2258 modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); 2259 return normalize( refractionVector ) * thickness * modelScale; 2260 } 2261 float applyIorToRoughness( const in float roughness, const in float ior ) { 2262 return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); 2263 } 2264 vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { 2265 float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); 2266 return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); 2267 } 2268 vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { 2269 if ( isinf( attenuationDistance ) ) { 2270 return vec3( 1.0 ); 2271 } else { 2272 vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; 2273 vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; 2274 } 2275 } 2276 vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, 2277 const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, 2278 const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, 2279 const in vec3 attenuationColor, const in float attenuationDistance ) { 2280 vec4 transmittedLight; 2281 vec3 transmittance; 2282 #ifdef USE_DISPERSION 2283 float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; 2284 vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); 2285 for ( int i = 0; i < 3; i ++ ) { 2286 vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); 2287 vec3 refractedRayExit = position + transmissionRay; 2288 vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); 2289 vec2 refractionCoords = ndcPos.xy / ndcPos.w; 2290 refractionCoords += 1.0; 2291 refractionCoords /= 2.0; 2292 vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); 2293 transmittedLight[ i ] = transmissionSample[ i ]; 2294 transmittedLight.a += transmissionSample.a; 2295 transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; 2296 } 2297 transmittedLight.a /= 3.0; 2298 #else 2299 vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); 2300 vec3 refractedRayExit = position + transmissionRay; 2301 vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); 2302 vec2 refractionCoords = ndcPos.xy / ndcPos.w; 2303 refractionCoords += 1.0; 2304 refractionCoords /= 2.0; 2305 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); 2306 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); 2307 #endif 2308 vec3 attenuatedColor = transmittance * transmittedLight.rgb; 2309 vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); 2310 float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; 2311 return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); 2312 } 2313#endif`,Ov=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) 2314 varying vec2 vUv; 2315#endif 2316#ifdef USE_MAP 2317 varying vec2 vMapUv; 2318#endif 2319#ifdef USE_ALPHAMAP
2320 varying vec2 vAlphaMapUv; 2321#endif 2322#ifdef USE_LIGHTMAP 2323 varying vec2 vLightMapUv; 2324#endif 2325#ifdef USE_AOMAP 2326 varying vec2 vAoMapUv; 2327#endif 2328#ifdef USE_BUMPMAP 2329 varying vec2 vBumpMapUv; 2330#endif 2331#ifdef USE_NORMALMAP 2332 varying vec2 vNormalMapUv; 2333#endif 2334#ifdef USE_EMISSIVEMAP 2335 varying vec2 vEmissiveMapUv; 2336#endif 2337#ifdef USE_METALNESSMAP 2338 varying vec2 vMetalnessMapUv; 2339#endif 2340#ifdef USE_ROUGHNESSMAP 2341 varying vec2 vRoughnessMapUv; 2342#endif 2343#ifdef USE_ANISOTROPYMAP 2344 varying vec2 vAnisotropyMapUv; 2345#endif 2346#ifdef USE_CLEARCOATMAP 2347 varying vec2 vClearcoatMapUv; 2348#endif 2349#ifdef USE_CLEARCOAT_NORMALMAP 2350 varying vec2 vClearcoatNormalMapUv; 2351#endif 2352#ifdef USE_CLEARCOAT_ROUGHNESSMAP 2353 varying vec2 vClearcoatRoughnessMapUv; 2354#endif 2355#ifdef USE_IRIDESCENCEMAP 2356 varying vec2 vIridescenceMapUv; 2357#endif 2358#ifdef USE_IRIDESCENCE_THICKNESSMAP 2359 varying vec2 vIridescenceThicknessMapUv; 2360#endif 2361#ifdef USE_SHEEN_COLORMAP 2362 varying vec2 vSheenColorMapUv; 2363#endif 2364#ifdef USE_SHEEN_ROUGHNESSMAP 2365 varying vec2 vSheenRoughnessMapUv; 2366#endif 2367#ifdef USE_SPECULARMAP 2368 varying vec2 vSpecularMapUv; 2369#endif 2370#ifdef USE_SPECULAR_COLORMAP 2371 varying vec2 vSpecularColorMapUv; 2372#endif 2373#ifdef USE_SPECULAR_INTENSITYMAP 2374 varying vec2 vSpecularIntensityMapUv; 2375#endif 2376#ifdef USE_TRANSMISSIONMAP 2377 uniform mat3 transmissionMapTransform; 2378 varying vec2 vTransmissionMapUv; 2379#endif 2380#ifdef USE_THICKNESSMAP 2381 uniform mat3 thicknessMapTransform; 2382 varying vec2 vThicknessMapUv; 2383#endif`,Fv=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) 2384 varying vec2 vUv; 2385#endif 2386#ifdef USE_MAP 2387 uniform mat3 mapTransform; 2388 varying vec2 vMapUv; 2389#endif 2390#ifdef USE_ALPHAMAP 2391 uniform mat3 alphaMapTransform; 2392 varying vec2 vAlphaMapUv; 2393#endif 2394#ifdef USE_LIGHTMAP 2395 uniform mat3 lightMapTransform; 2396 varying vec2 vLightMapUv; 2397#endif 2398#ifdef USE_AOMAP 2399 uniform mat3 aoMapTransform; 2400 varying vec2 vAoMapUv; 2401#endif 2402#ifdef USE_BUMPMAP 2403 uniform mat3 bumpMapTransform; 2404 varying vec2 vBumpMapUv; 2405#endif 2406#ifdef USE_NORMALMAP 2407 uniform mat3 normalMapTransform; 2408 varying vec2 vNormalMapUv; 2409#endif 2410#ifdef USE_DISPLACEMENTMAP 2411 uniform mat3 displacementMapTransform; 2412 varying vec2 vDisplacementMapUv; 2413#endif 2414#ifdef USE_EMISSIVEMAP 2415 uniform mat3 emissiveMapTransform; 2416 varying vec2 vEmissiveMapUv; 2417#endif 2418#ifdef USE_METALNESSMAP 2419 uniform mat3 metalnessMapTransform; 2420 varying vec2 vMetalnessMapUv; 2421#endif 2422#ifdef USE_ROUGHNESSMAP 2423 uniform mat3 roughnessMapTransform; 2424 varying vec2 vRoughnessMapUv; 2425#endif 2426#ifdef USE_ANISOTROPYMAP 2427 uniform mat3 anisotropyMapTransform; 2428 varying vec2 vAnisotropyMapUv; 2429#endif 2430#ifdef USE_CLEARCOATMAP 2431 uniform mat3 clearcoatMapTransform; 2432 varying vec2 vClearcoatMapUv; 2433#endif 2434#ifdef USE_CLEARCOAT_NORMALMAP 2435 uniform mat3 clearcoatNormalMapTransform; 2436 varying vec2 vClearcoatNormalMapUv; 2437#endif 2438#ifdef USE_CLEARCOAT_ROUGHNESSMAP 2439 uniform mat3 clearcoatRoughnessMapTransform; 2440 varying vec2 vClearcoatRoughnessMapUv; 2441#endif 2442#ifdef USE_SHEEN_COLORMAP 2443 uniform mat3 sheenColorMapTransform; 2444 varying vec2 vSheenColorMapUv; 2445#endif 2446#ifdef USE_SHEEN_ROUGHNESSMAP 2447 uniform mat3 sheenRoughnessMapTransform; 2448 varying vec2 vSheenRoughnessMapUv; 2449#endif 2450#ifdef USE_IRIDESCENCEMAP 2451 uniform mat3 iridescenceMapTransform; 2452 varying vec2 vIridescenceMapUv; 2453#endif 2454#ifdef USE_IRIDESCENCE_THICKNESSMAP 2455 uniform mat3 iridescenceThicknessMapTransform; 2456 varying vec2 vIridescenceThicknessMapUv; 2457#endif 2458#ifdef USE_SPECULARMAP 2459 uniform mat3 specularMapTransform; 2460 varying vec2 vSpecularMapUv; 2461#endif 2462#ifdef USE_SPECULAR_COLORMAP 2463 uniform mat3 specularColorMapTransform; 2464 varying vec2 vSpecularColorMapUv; 2465#endif 2466#ifdef USE_SPECULAR_INTENSITYMAP 2467 uniform mat3 specularIntensityMapTransform; 2468 varying vec2 vSpecularIntensityMapUv; 2469#endif 2470#ifdef USE_TRANSMISSIONMAP 2471 uniform mat3 transmissionMapTransform; 2472 varying vec2 vTransmissionMapUv; 2473#endif 2474#ifdef USE_THICKNESSMAP 2475 uniform mat3 thicknessMapTransform; 2476 varying vec2 vThicknessMapUv; 2477#endif`,kv=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) 2478 vUv = vec3( uv, 1 ).xy; 2479#endif 2480#ifdef USE_MAP 2481 vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; 2482#endif 2483#ifdef USE_ALPHAMAP 2484 vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; 2485#endif 2486#ifdef USE_LIGHTMAP 2487 vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; 2488#endif 2489#ifdef USE_AOMAP 2490 vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; 2491#endif 2492#ifdef USE_BUMPMAP 2493 vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; 2494#endif 2495#ifdef USE_NORMALMAP 2496 vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; 2497#endif 2498#ifdef USE_DISPLACEMENTMAP 2499 vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; 2500#endif 2501#ifdef USE_EMISSIVEMAP 2502 vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; 2503#endif 2504#ifdef USE_METALNESSMAP 2505 vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; 2506#endif 2507#ifdef USE_ROUGHNESSMAP 2508 vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; 2509#endif 2510#ifdef USE_ANISOTROPYMAP 2511 vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; 2512#endif 2513#ifdef USE_CLEARCOATMAP 2514 vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; 2515#endif 2516#ifdef USE_CLEARCOAT_NORMALMAP 2517 vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; 2518#endif 2519#ifdef USE_CLEARCOAT_ROUGHNESSMAP 2520 vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; 2521#endif
2522#ifdef USE_IRIDESCENCEMAP 2523 vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; 2524#endif 2525#ifdef USE_IRIDESCENCE_THICKNESSMAP 2526 vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; 2527#endif 2528#ifdef USE_SHEEN_COLORMAP 2529 vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; 2530#endif 2531#ifdef USE_SHEEN_ROUGHNESSMAP 2532 vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; 2533#endif 2534#ifdef USE_SPECULARMAP 2535 vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; 2536#endif 2537#ifdef USE_SPECULAR_COLORMAP 2538 vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; 2539#endif 2540#ifdef USE_SPECULAR_INTENSITYMAP 2541 vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; 2542#endif 2543#ifdef USE_TRANSMISSIONMAP 2544 vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; 2545#endif 2546#ifdef USE_THICKNESSMAP 2547 vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; 2548#endif`,Bv=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 2549 vec4 worldPosition = vec4( transformed, 1.0 ); 2550 #ifdef USE_BATCHING 2551 worldPosition = batchingMatrix * worldPosition; 2552 #endif 2553 #ifdef USE_INSTANCING 2554 worldPosition = instanceMatrix * worldPosition; 2555 #endif 2556 worldPosition = modelMatrix * worldPosition; 2557#endif`;const zv=`varying vec2 vUv; 2558uniform mat3 uvTransform; 2559void main() { 2560 vUv = ( uvTransform * vec3( uv, 1 ) ).xy; 2561 gl_Position = vec4( position.xy, 1.0, 1.0 ); 2562}`,Vv=`uniform sampler2D t2D; 2563uniform float backgroundIntensity; 2564varying vec2 vUv; 2565void main() { 2566 vec4 texColor = texture2D( t2D, vUv ); 2567 #ifdef DECODE_VIDEO_TEXTURE 2568 texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); 2569 #endif 2570 texColor.rgb *= backgroundIntensity; 2571 gl_FragColor = texColor; 2572 #include <tonemapping_fragment> 2573 #include <colorspace_fragment> 2574}`,Hv=`varying vec3 vWorldDirection; 2575#include <common> 2576void main() { 2577 vWorldDirection = transformDirection( position, modelMatrix ); 2578 #include <begin_vertex> 2579 #include <project_vertex> 2580 gl_Position.z = gl_Position.w; 2581}`,Gv=`#ifdef ENVMAP_TYPE_CUBE 2582 uniform samplerCube envMap; 2583#elif defined( ENVMAP_TYPE_CUBE_UV ) 2584 uniform sampler2D envMap; 2585#endif 2586uniform float flipEnvMap; 2587uniform float backgroundBlurriness; 2588uniform float backgroundIntensity; 2589uniform mat3 backgroundRotation; 2590varying vec3 vWorldDirection; 2591#include <cube_uv_reflection_fragment> 2592void main() { 2593 #ifdef ENVMAP_TYPE_CUBE 2594 vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); 2595 #elif defined( ENVMAP_TYPE_CUBE_UV ) 2596 vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); 2597 #else 2598 vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); 2599 #endif 2600 texColor.rgb *= backgroundIntensity; 2601 gl_FragColor = texColor; 2602 #include <tonemapping_fragment> 2603 #include <colorspace_fragment> 2604}`,Wv=`varying vec3 vWorldDirection; 2605#include <common> 2606void main() { 2607 vWorldDirection = transformDirection( position, modelMatrix ); 2608 #include <begin_vertex> 2609 #include <project_vertex> 2610 gl_Position.z = gl_Position.w; 2611}`,Xv=`uniform samplerCube tCube; 2612uniform float tFlip; 2613uniform float opacity; 2614varying vec3 vWorldDirection; 2615void main() { 2616 vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); 2617 gl_FragColor = texColor; 2618 gl_FragColor.a *= opacity; 2619 #include <tonemapping_fragment> 2620 #include <colorspace_fragment> 2621}`,qv=`#include <common> 2622#include <batching_pars_vertex> 2623#include <uv_pars_vertex> 2624#include <displacementmap_pars_vertex> 2625#include <morphtarget_pars_vertex> 2626#include <skinning_pars_vertex> 2627#include <logdepthbuf_pars_vertex> 2628#include <clipping_planes_pars_vertex> 2629varying vec2 vHighPrecisionZW; 2630void main() { 2631 #include <uv_vertex> 2632 #include <batching_vertex> 2633 #include <skinbase_vertex> 2634 #include <morphinstance_vertex> 2635 #ifdef USE_DISPLACEMENTMAP 2636 #include <beginnormal_vertex> 2637 #include <morphnormal_vertex> 2638 #include <skinnormal_vertex> 2639 #endif 2640 #include <begin_vertex> 2641 #include <morphtarget_vertex> 2642 #include <skinning_vertex> 2643 #include <displacementmap_vertex> 2644 #include <project_vertex> 2645 #include <logdepthbuf_vertex> 2646 #include <clipping_planes_vertex> 2647 vHighPrecisionZW = gl_Position.zw; 2648}`,jv=`#if DEPTH_PACKING == 3200 2649 uniform float opacity; 2650#endif 2651#include <common> 2652#include <packing> 2653#include <uv_pars_fragment> 2654#include <map_pars_fragment> 2655#include <alphamap_pars_fragment> 2656#include <alphatest_pars_fragment> 2657#include <alphahash_pars_fragment> 2658#include <logdepthbuf_pars_fragment> 2659#include <clipping_planes_pars_fragment> 2660varying vec2 vHighPrecisionZW; 2661void main() { 2662 vec4 diffuseColor = vec4( 1.0 ); 2663 #include <clipping_planes_fragment> 2664 #if DEPTH_PACKING == 3200 2665 diffuseColor.a = opacity; 2666 #endif 2667 #include <map_fragment> 2668 #include <alphamap_fragment> 2669 #include <alphatest_fragment> 2670 #include <alphahash_fragment> 2671 #include <logdepthbuf_fragment> 2672 #ifdef USE_REVERSED_DEPTH_BUFFER 2673 float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; 2674 #else 2675 float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; 2676 #endif 2677 #if DEPTH_PACKING == 3200 2678 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); 2679 #elif DEPTH_PACKING == 3201 2680 gl_FragColor = packDepthToRGBA( fragCoordZ ); 2681 #elif DEPTH_PACKING == 3202 2682 gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); 2683 #elif DEPTH_PACKING == 3203 2684 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); 2685 #endif 2686}`,Yv=`#define DISTANCE 2687varying vec3 vWorldPosition; 2688#include <common> 2689#include <batching_pars_vertex> 2690#include <uv_pars_vertex> 2691#include <displacementmap_pars_vertex> 2692#include <morphtarget_pars_vertex> 2693#include <skinning_pars_vertex> 2694#include <clipping_planes_pars_vertex> 2695void main() { 2696 #include <uv_vertex> 2697 #include <batching_vertex> 2698 #include <skinbase_vertex> 2699 #include <morphinstance_vertex> 2700 #ifdef USE_DISPLACEMENTMAP 2701 #include <beginnormal_vertex> 2702 #include <morphnormal_vertex> 2703 #include <skinnormal_vertex> 2704 #endif 2705 #include <begin_vertex> 2706 #include <morphtarget_vertex> 2707 #include <skinning_vertex> 2708 #include <displacementmap_vertex> 2709 #include <project_vertex> 2710 #include <worldpos_vertex> 2711 #include <clipping_planes_vertex> 2712 vWorldPosition = worldPosition.xyz; 2713}`,Kv=`#define DISTANCE 2714uniform vec3 referencePosition; 2715uniform float nearDistance; 2716uniform float farDistance; 2717varying vec3 vWorldPosition; 2718#include <common> 2719#include <uv_pars_fragment> 2720#include <map_pars_fragment> 2721#include <alphamap_pars_fragment> 2722#include <alphatest_pars_fragment> 2723#include <alphahash_pars_fragment> 2724#include <clipping_planes_pars_fragment> 2725void main () { 2726 vec4 diffuseColor = vec4( 1.0 ); 2727 #include <clipping_planes_fragment> 2728 #include <map_fragment> 2729 #include <alphamap_fragment> 2730 #include <alphatest_fragment> 2731 #include <alphahash_fragment> 2732 float dist = length( vWorldPosition - referencePosition ); 2733 dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); 2734 dist = saturate( dist ); 2735 gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); 2736}`,Zv=`varying vec3 vWorldDirection; 2737#include <common> 2738void main() { 2739 vWorldDirection = transformDirection( position, modelMatrix ); 2740 #include <begin_vertex> 2741 #include <project_vertex> 2742}`,Jv=`uniform sampler2D tEquirect; 2743varying vec3 vWorldDirection; 2744#include <common> 2745void main() { 2746 vec3 direction = normalize( vWorldDirection ); 2747 vec2 sampleUV = equirectUv( direction ); 2748 gl_FragColor = texture2D( tEquirect, sampleUV ); 2749 #include <tonemapping_fragment> 2750 #include <colorspace_fragment> 2751}`,Qv=`uniform float scale; 2752attribute float lineDistance; 2753varying float vLineDistance; 2754#include <common> 2755#include <uv_pars_vertex> 2756#include <color_pars_vertex> 2757#include <fog_pars_vertex> 2758#include <morphtarget_pars_vertex> 2759#include <logdepthbuf_pars_vertex> 2760#include <clipping_planes_pars_vertex> 2761void main() { 2762 vLineDistance = scale * lineDistance; 2763 #include <uv_vertex> 2764 #include <color_vertex> 2765 #include <morphinstance_vertex> 2766 #include <morphcolor_vertex> 2767 #include <begin_vertex> 2768 #include <morphtarget_vertex> 2769 #include <project_vertex> 2770 #include <logdepthbuf_vertex> 2771 #include <clipping_planes_vertex> 2772 #include <fog_vertex> 2773}`,$v=`uniform vec3 diffuse; 2774uniform float opacity; 2775uniform float dashSize; 2776uniform float totalSize; 2777varying float vLineDistance; 2778#include <common> 2779#include <color_pars_fragment> 2780#include <uv_pars_fragment> 2781#include <map_pars_fragment> 2782#include <fog_pars_fragment> 2783#include <logdepthbuf_pars_fragment> 2784#include <clipping_planes_pars_fragment> 2785void main() { 2786 vec4 diffuseColor = vec4( diffuse, opacity ); 2787 #include <clipping_planes_fragment> 2788 if ( mod( vLineDistance, totalSize ) > dashSize ) { 2789 discard; 2790 } 2791 vec3 outgoingLight = vec3( 0.0 ); 2792 #include <logdepthbuf_fragment> 2793 #include <map_fragment> 2794 #include <color_fragment> 2795 outgoingLight = diffuseColor.rgb; 2796 #include <opaque_fragment> 2797 #include <tonemapping_fragment> 2798 #include <colorspace_fragment> 2799 #include <fog_fragment> 2800 #include <premultiplied_alpha_fragment> 2801}`,e_=`#include <common> 2802#include <batching_pars_vertex> 2803#include <uv_pars_vertex> 2804#include <envmap_pars_vertex> 2805#include <color_pars_vertex> 2806#include <fog_pars_vertex> 2807#include <morphtarget_pars_vertex> 2808#include <skinning_pars_vertex> 2809#include <logdepthbuf_pars_vertex> 2810#include <clipping_planes_pars_vertex> 2811void main() { 2812 #include <uv_vertex> 2813 #include <color_vertex> 2814 #include <morphinstance_vertex> 2815 #include <morphcolor_vertex> 2816 #include <batching_vertex> 2817 #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) 2818 #include <beginnormal_vertex> 2819 #include <morphnormal_vertex> 2820 #include <skinbase_vertex> 2821 #include <skinnormal_vertex> 2822 #include <defaultnormal_vertex> 2823 #endif 2824 #include <begin_vertex> 2825 #include <morphtarget_vertex> 2826 #include <skinning_vertex> 2827 #include <project_vertex> 2828 #include <logdepthbuf_vertex> 2829 #include <clipping_planes_vertex> 2830 #include <worldpos_vertex> 2831 #include <envmap_vertex> 2832 #include <fog_vertex> 2833}`,t_=`uniform vec3 diffuse; 2834uniform float opacity; 2835#ifndef FLAT_SHADED 2836 varying vec3 vNormal; 2837#endif 2838#include <common> 2839#include <dithering_pars_fragment> 2840#include <color_pars_fragment> 2841#include <uv_pars_fragment> 2842#include <map_pars_fragment> 2843#include <alphamap_pars_fragment> 2844#include <alphatest_pars_fragment> 2845#include <alphahash_pars_fragment> 2846#include <aomap_pars_fragment> 2847#include <lightmap_pars_fragment> 2848#include <envmap_common_pars_fragment> 2849#include <envmap_pars_fragment> 2850#include <fog_pars_fragment> 2851#include <specularmap_pars_fragment> 2852#include <logdepthbuf_pars_fragment> 2853#include <clipping_planes_pars_fragment> 2854void main() { 2855 vec4 diffuseColor = vec4( diffuse, opacity ); 2856 #include <clipping_planes_fragment> 2857 #include <logdepthbuf_fragment> 2858 #include <map_fragment> 2859 #include <color_fragment> 2860 #include <alphamap_fragment> 2861 #include <alphatest_fragment> 2862 #include <alphahash_fragment> 2863 #include <specularmap_fragment> 2864 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 2865 #ifdef USE_LIGHTMAP 2866 vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); 2867 reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; 2868 #else 2869 reflectedLight.indirectDiffuse += vec3( 1.0 ); 2870 #endif 2871 #include <aomap_fragment> 2872 reflectedLight.indirectDiffuse *= diffuseColor.rgb; 2873 vec3 outgoingLight = reflectedLight.indirectDiffuse; 2874 #include <envmap_fragment> 2875 #include <opaque_fragment> 2876 #include <tonemapping_fragment> 2877 #include <colorspace_fragment> 2878 #include <fog_fragment> 2879 #include <premultiplied_alpha_fragment> 2880 #include <dithering_fragment> 2881}`,n_=`#define LAMBERT 2882varying vec3 vViewPosition; 2883#include <common> 2884#include <batching_pars_vertex> 2885#include <uv_pars_vertex> 2886#include <displacementmap_pars_vertex> 2887#include <envmap_pars_vertex> 2888#include <color_pars_vertex> 2889#include <fog_pars_vertex> 2890#include <normal_pars_vertex> 2891#include <morphtarget_pars_vertex> 2892#include <skinning_pars_vertex> 2893#include <shadowmap_pars_vertex> 2894#include <logdepthbuf_pars_vertex> 2895#include <clipping_planes_pars_vertex> 2896void main() { 2897 #include <uv_vertex> 2898 #include <color_vertex> 2899 #include <morphinstance_vertex> 2900 #include <morphcolor_vertex> 2901 #include <batching_vertex> 2902 #include <beginnormal_vertex> 2903 #include <morphnormal_vertex> 2904 #include <skinbase_vertex> 2905 #include <skinnormal_vertex> 2906 #include <defaultnormal_vertex> 2907 #include <normal_vertex> 2908 #include <begin_vertex> 2909 #include <morphtarget_vertex> 2910 #include <skinning_vertex> 2911 #include <displacementmap_vertex> 2912 #include <project_vertex> 2913 #include <logdepthbuf_vertex> 2914 #include <clipping_planes_vertex> 2915 vViewPosition = - mvPosition.xyz; 2916 #include <worldpos_vertex> 2917 #include <envmap_vertex> 2918 #include <shadowmap_vertex> 2919 #include <fog_vertex> 2920}`,i_=`#define LAMBERT 2921uniform vec3 diffuse; 2922uniform vec3 emissive; 2923uniform float opacity; 2924#include <common> 2925#include <dithering_pars_fragment> 2926#include <color_pars_fragment> 2927#include <uv_pars_fragment> 2928#include <map_pars_fragment> 2929#include <alphamap_pars_fragment> 2930#include <alphatest_pars_fragment> 2931#include <alphahash_pars_fragment> 2932#include <aomap_pars_fragment> 2933#include <lightmap_pars_fragment> 2934#include <emissivemap_pars_fragment> 2935#include <cube_uv_reflection_fragment> 2936#include <envmap_common_pars_fragment> 2937#include <envmap_pars_fragment> 2938#include <envmap_physical_pars_fragment> 2939#include <fog_pars_fragment> 2940#include <bsdfs> 2941#include <lights_pars_begin> 2942#include <normal_pars_fragment> 2943#include <lights_lambert_pars_fragment> 2944#include <shadowmap_pars_fragment> 2945#include <bumpmap_pars_fragment> 2946#include <normalmap_pars_fragment> 2947#include <specularmap_pars_fragment> 2948#include <logdepthbuf_pars_fragment> 2949#include <clipping_planes_pars_fragment> 2950void main() { 2951 vec4 diffuseColor = vec4( diffuse, opacity ); 2952 #include <clipping_planes_fragment> 2953 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 2954 vec3 totalEmissiveRadiance = emissive; 2955 #include <logdepthbuf_fragment> 2956 #include <map_fragment> 2957 #include <color_fragment> 2958 #include <alphamap_fragment> 2959 #include <alphatest_fragment> 2960 #include <alphahash_fragment> 2961 #include <specularmap_fragment> 2962 #include <normal_fragment_begin> 2963 #include <normal_fragment_maps> 2964 #include <emissivemap_fragment> 2965 #include <lights_lambert_fragment> 2966 #include <lights_fragment_begin> 2967 #include <lights_fragment_maps> 2968 #include <lights_fragment_end> 2969 #include <aomap_fragment> 2970 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; 2971 #include <envmap_fragment> 2972 #include <opaque_fragment> 2973 #include <tonemapping_fragment> 2974 #include <colorspace_fragment> 2975 #include <fog_fragment> 2976 #include <premultiplied_alpha_fragment> 2977 #include <dithering_fragment> 2978}`,s_=`#define MATCAP 2979varying vec3 vViewPosition; 2980#include <common> 2981#include <batching_pars_vertex> 2982#include <uv_pars_vertex> 2983#include <color_pars_vertex> 2984#include <displacementmap_pars_vertex> 2985#include <fog_pars_vertex> 2986#include <normal_pars_vertex> 2987#include <morphtarget_pars_vertex> 2988#include <skinning_pars_vertex> 2989#include <logdepthbuf_pars_vertex> 2990#include <clipping_planes_pars_vertex> 2991void main() { 2992 #include <uv_vertex> 2993 #include <color_vertex> 2994 #include <morphinstance_vertex> 2995 #include <morphcolor_vertex> 2996 #include <batching_vertex> 2997 #include <beginnormal_vertex> 2998 #include <morphnormal_vertex> 2999 #include <skinbase_vertex> 3000 #include <skinnormal_vertex> 3001 #include <defaultnormal_vertex> 3002 #include <normal_vertex> 3003 #include <begin_vertex> 3004 #include <morphtarget_vertex> 3005 #include <skinning_vertex> 3006 #include <displacementmap_vertex> 3007 #include <project_vertex> 3008 #include <logdepthbuf_vertex> 3009 #include <clipping_planes_vertex> 3010 #include <fog_vertex> 3011 vViewPosition = - mvPosition.xyz; 3012}`,r_=`#define MATCAP 3013uniform vec3 diffuse; 3014uniform float opacity; 3015uniform sampler2D matcap; 3016varying vec3 vViewPosition; 3017#include <common> 3018#include <dithering_pars_fragment> 3019#include <color_pars_fragment> 3020#include <uv_pars_fragment> 3021#include <map_pars_fragment> 3022#include <alphamap_pars_fragment> 3023#include <alphatest_pars_fragment> 3024#include <alphahash_pars_fragment> 3025#include <fog_pars_fragment> 3026#include <normal_pars_fragm
3026ent> 3027#include <bumpmap_pars_fragment> 3028#include <normalmap_pars_fragment> 3029#include <logdepthbuf_pars_fragment> 3030#include <clipping_planes_pars_fragment> 3031void main() { 3032 vec4 diffuseColor = vec4( diffuse, opacity ); 3033 #include <clipping_planes_fragment> 3034 #include <logdepthbuf_fragment> 3035 #include <map_fragment> 3036 #include <color_fragment> 3037 #include <alphamap_fragment> 3038 #include <alphatest_fragment> 3039 #include <alphahash_fragment> 3040 #include <normal_fragment_begin> 3041 #include <normal_fragment_maps> 3042 vec3 viewDir = normalize( vViewPosition ); 3043 vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); 3044 vec3 y = cross( viewDir, x ); 3045 vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; 3046 #ifdef USE_MATCAP 3047 vec4 matcapColor = texture2D( matcap, uv ); 3048 #else 3049 vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); 3050 #endif 3051 vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; 3052 #include <opaque_fragment> 3053 #include <tonemapping_fragment> 3054 #include <colorspace_fragment> 3055 #include <fog_fragment> 3056 #include <premultiplied_alpha_fragment> 3057 #include <dithering_fragment> 3058}`,o_=`#define NORMAL 3059#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) 3060 varying vec3 vViewPosition; 3061#endif 3062#include <common> 3063#include <batching_pars_vertex> 3064#include <uv_pars_vertex> 3065#include <displacementmap_pars_vertex> 3066#include <normal_pars_vertex> 3067#include <morphtarget_pars_vertex> 3068#include <skinning_pars_vertex> 3069#include <logdepthbuf_pars_vertex> 3070#include <clipping_planes_pars_vertex> 3071void main() { 3072 #include <uv_vertex> 3073 #include <batching_vertex> 3074 #include <beginnormal_vertex> 3075 #include <morphinstance_vertex> 3076 #include <morphnormal_vertex> 3077 #include <skinbase_vertex> 3078 #include <skinnormal_vertex> 3079 #include <defaultnormal_vertex> 3080 #include <normal_vertex> 3081 #include <begin_vertex> 3082 #include <morphtarget_vertex> 3083 #include <skinning_vertex> 3084 #include <displacementmap_vertex> 3085 #include <project_vertex> 3086 #include <logdepthbuf_vertex> 3087 #include <clipping_planes_vertex> 3088#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) 3089 vViewPosition = - mvPosition.xyz; 3090#endif 3091}`,a_=`#define NORMAL 3092uniform float opacity; 3093#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) 3094 varying vec3 vViewPosition; 3095#endif 3096#include <uv_pars_fragment> 3097#include <normal_pars_fragment> 3098#include <bumpmap_pars_fragment> 3099#include <normalmap_pars_fragment> 3100#include <logdepthbuf_pars_fragment> 3101#include <clipping_planes_pars_fragment> 3102void main() { 3103 vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); 3104 #include <clipping_planes_fragment> 3105 #include <logdepthbuf_fragment> 3106 #include <normal_fragment_begin> 3107 #include <normal_fragment_maps> 3108 gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); 3109 #ifdef OPAQUE 3110 gl_FragColor.a = 1.0; 3111 #endif 3112}`,c_=`#define PHONG 3113varying vec3 vViewPosition; 3114#include <common> 3115#include <batching_pars_vertex> 3116#include <uv_pars_vertex> 3117#include <displacementmap_pars_vertex> 3118#include <envmap_pars_vertex> 3119#include <color_pars_vertex> 3120#include <fog_pars_vertex> 3121#include <normal_pars_vertex> 3122#include <morphtarget_pars_vertex> 3123#include <skinning_pars_vertex> 3124#include <shadowmap_pars_vertex> 3125#include <logdepthbuf_pars_vertex> 3126#include <clipping_planes_pars_vertex> 3127void main() { 3128 #include <uv_vertex> 3129 #include <color_vertex> 3130 #include <morphcolor_vertex> 3131 #include <batching_vertex> 3132 #include <beginnormal_vertex> 3133 #include <morphinstance_vertex> 3134 #include <morphnormal_vertex> 3135 #include <skinbase_vertex> 3136 #include <skinnormal_vertex> 3137 #include <defaultnormal_vertex> 3138 #include <normal_vertex> 3139 #include <begin_vertex> 3140 #include <morphtarget_vertex> 3141 #include <skinning_vertex> 3142 #include <displacementmap_vertex> 3143 #include <project_vertex> 3144 #include <logdepthbuf_vertex> 3145 #include <clipping_planes_vertex> 3146 vViewPosition = - mvPosition.xyz; 3147 #include <worldpos_vertex> 3148 #include <envmap_vertex> 3149 #include <shadowmap_vertex> 3150 #include <fog_vertex> 3151}`,l_=`#define PHONG 3152uniform vec3 diffuse; 3153uniform vec3 emissive; 3154uniform vec3 specular; 3155uniform float shininess; 3156uniform float opacity; 3157#include <common> 3158#include <dithering_pars_fragment> 3159#include <color_pars_fragment> 3160#include <uv_pars_fragment> 3161#include <map_pars_fragment> 3162#include <alphamap_pars_fragment> 3163#include <alphatest_pars_fragment> 3164#include <alphahash_pars_fragment> 3165#include <aomap_pars_fragment> 3166#include <lightmap_pars_fragment> 3167#include <emissivemap_pars_fragment> 3168#include <cube_uv_reflection_fragment> 3169#include <envmap_common_pars_fragment> 3170#include <envmap_pars_fragment> 3171#include <envmap_physical_pars_fragment> 3172#include <fog_pars_fragment> 3173#include <bsdfs> 3174#include <lights_pars_begin> 3175#include <normal_pars_fragment> 3176#include <lights_phong_pars_fragment> 3177#include <shadowmap_pars_fragment> 3178#include <bumpmap_pars_fragment> 3179#include <normalmap_pars_fragment> 3180#include <specularmap_pars_fragment> 3181#include <logdepthbuf_pars_fragment> 3182#include <clipping_planes_pars_fragment> 3183void main() { 3184 vec4 diffuseColor = vec4( diffuse, opacity ); 3185 #include <clipping_planes_fragment> 3186 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 3187 vec3 totalEmissiveRadiance = emissive; 3188 #include <logdepthbuf_fragment> 3189 #include <map_fragment> 3190 #include <color_fragment> 3191 #include <alphamap_fragment> 3192 #include <alphatest_fragment> 3193 #include <alphahash_fragment> 3194 #include <specularmap_fragment> 3195 #include <normal_fragment_begin> 3196 #include <normal_fragment_maps> 3197 #include <emissivemap_fragment> 3198 #include <lights_phong_fragment> 3199 #include <lights_fragment_begin> 3200 #include <lights_fragment_maps> 3201 #include <lights_fragment_end> 3202 #include <aomap_fragment> 3203 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; 3204 #include <envmap_fragment> 3205 #include <opaque_fragment> 3206 #include <tonemapping_fragment> 3207 #include <colorspace_fragment> 3208 #include <fog_fragment> 3209 #include <premultiplied_alpha_fragment> 3210 #include <dithering_fragment> 3211}`,u_=`#define STANDARD 3212varying vec3 vViewPosition; 3213#ifdef USE_TRANSMISSION 3214 varying vec3 vWorldPosition; 3215#endif 3216#include <common> 3217#include <batching_pars_vertex> 3218#include <uv_pars_vertex> 3219#include <displacementmap_pars_vertex> 3220#include <color_pars_vertex> 3221#include <fog_pars_vertex> 3222#include <normal_pars_vertex> 3223#include <morphtarget_pars_vertex> 3224#include <skinning_pars_vertex> 3225#include <shadowmap_pars_vertex> 3226#include <logdepthbuf_pars_vertex> 3227#include <clipping_planes_pars_vertex> 3228void main() { 3229 #include <uv_vertex> 3230 #include <color_vertex> 3231 #include <morphinstance_vertex> 3232 #include <morphcolor_vertex> 3233 #include <batching_vertex> 3234 #include <beginnormal_vertex> 3235 #include <morphnormal_vertex> 3236 #include <skinbase_vertex> 3237 #include <skinnormal_vertex> 3238 #include <defaultnormal_vertex> 3239 #include <normal_vertex> 3240 #include <begin_vertex> 3241 #include <morphtarget_vertex> 3242 #include <skinning_vertex> 3243 #include <displacementmap_vertex> 3244 #include <project_vertex> 3245 #include <logdepthbuf_vertex> 3246 #include <clipping_planes_vertex> 3247 vViewPosition = - mvPosition.xyz; 3248 #include <worldpos_vertex> 3249 #include <shadowmap_vertex> 3250 #include <fog_vertex> 3251#ifdef USE_TRANSMISSION 3252 vWorldPosition = worldPosition.xyz; 3253#endif 3254}`,d_=`#define STANDARD 3255#ifdef PHYSICAL 3256 #define IOR 3257 #define USE_SPECULAR 3258#endif 3259uniform vec3 diffuse; 3260uniform vec3 emissive; 3261uniform float roughness; 3262uniform float metalness; 3263uniform float opacity; 3264#ifdef IOR 3265 uniform float ior; 3266#endif 3267#ifdef USE_SPECULAR 3268 uniform float specularIntensity; 3269 uniform vec3 specularColor; 3270 #ifdef USE_SPECULAR_COLORMAP 3271 uniform sampler2D specularColorMap; 3272 #endif 3273 #ifdef USE_SPECULAR_INTENSITYMAP 3274 uniform sampler2D specularIntensityMap; 3275 #endif 3276#endif 3277#ifdef USE_CLEARCOAT 3278 uniform float clearcoat; 3279 uniform float clearcoatRoughness; 3280#endif 3281#ifdef USE_DISPERSION 3282 uniform float dispersion; 3283#endif
3284#ifdef USE_IRIDESCENCE 3285 uniform float iridescence; 3286 uniform float iridescenceIOR; 3287 uniform float iridescenceThicknessMinimum; 3288 uniform float iridescenceThicknessMaximum; 3289#endif 3290#ifdef USE_SHEEN 3291 uniform vec3 sheenColor; 3292 uniform float sheenRoughness; 3293 #ifdef USE_SHEEN_COLORMAP 3294 uniform sampler2D sheenColorMap; 3295 #endif 3296 #ifdef USE_SHEEN_ROUGHNESSMAP 3297 uniform sampler2D sheenRoughnessMap; 3298 #endif 3299#endif 3300#ifdef USE_ANISOTROPY 3301 uniform vec2 anisotropyVector; 3302 #ifdef USE_ANISOTROPYMAP 3303 uniform sampler2D anisotropyMap; 3304 #endif 3305#endif 3306varying vec3 vViewPosition; 3307#include <common> 3308#include <dithering_pars_fragment> 3309#include <color_pars_fragment> 3310#include <uv_pars_fragment> 3311#include <map_pars_fragment> 3312#include <alphamap_pars_fragment> 3313#include <alphatest_pars_fragment> 3314#include <alphahash_pars_fragment> 3315#include <aomap_pars_fragment> 3316#include <lightmap_pars_fragment> 3317#include <emissivemap_pars_fragment> 3318#include <iridescence_fragment> 3319#include <cube_uv_reflection_fragment> 3320#include <envmap_common_pars_fragment> 3321#include <envmap_physical_pars_fragment> 3322#include <fog_pars_fragment> 3323#include <lights_pars_begin> 3324#include <normal_pars_fragment> 3325#include <lights_physical_pars_fragment> 3326#include <transmission_pars_fragment> 3327#include <shadowmap_pars_fragment> 3328#include <bumpmap_pars_fragment> 3329#include <normalmap_pars_fragment> 3330#include <clearcoat_pars_fragment> 3331#include <iridescence_pars_fragment> 3332#include <roughnessmap_pars_fragment> 3333#include <metalnessmap_pars_fragment> 3334#include <logdepthbuf_pars_fragment> 3335#include <clipping_planes_pars_fragment> 3336void main() { 3337 vec4 diffuseColor = vec4( diffuse, opacity ); 3338 #include <clipping_planes_fragment> 3339 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 3340 vec3 totalEmissiveRadiance = emissive; 3341 #include <logdepthbuf_fragment> 3342 #include <map_fragment> 3343 #include <color_fragment> 3344 #include <alphamap_fragment> 3345 #include <alphatest_fragment> 3346 #include <alphahash_fragment> 3347 #include <roughnessmap_fragment> 3348 #include <metalnessmap_fragment> 3349 #include <normal_fragment_begin> 3350 #include <normal_fragment_maps> 3351 #include <clearcoat_normal_fragment_begin> 3352 #include <clearcoat_normal_fragment_maps> 3353 #include <emissivemap_fragment> 3354 #include <lights_physical_fragment> 3355 #include <lights_fragment_begin> 3356 #include <lights_fragment_maps> 3357 #include <lights_fragment_end> 3358 #include <aomap_fragment> 3359 vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; 3360 vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; 3361 #include <transmission_fragment> 3362 vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; 3363 #ifdef USE_SHEEN 3364 3365 outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; 3366 3367 #endif 3368 #ifdef USE_CLEARCOAT 3369 float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); 3370 vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); 3371 outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; 3372 #endif 3373 #include <opaque_fragment> 3374 #include <tonemapping_fragment> 3375 #include <colorspace_fragment> 3376 #include <fog_fragment> 3377 #include <premultiplied_alpha_fragment> 3378 #include <dithering_fragment> 3379}`,h_=`#define TOON 3380varying vec3 vViewPosition; 3381#include <common> 3382#include <batching_pars_vertex> 3383#include <uv_pars_vertex> 3384#include <displacementmap_pars_vertex> 3385#include <color_pars_vertex> 3386#include <fog_pars_vertex> 3387#include <normal_pars_vertex> 3388#include <morphtarget_pars_vertex> 3389#include <skinning_pars_vertex> 3390#include <shadowmap_pars_vertex> 3391#include <logdepthbuf_pars_vertex> 3392#include <clipping_planes_pars_vertex> 3393void main() { 3394 #include <uv_vertex> 3395 #include <color_vertex> 3396 #include <morphinstance_vertex> 3397 #include <morphcolor_vertex> 3398 #include <batching_vertex> 3399 #include <beginnormal_vertex> 3400 #include <morphnormal_vertex> 3401 #include <skinbase_vertex> 3402 #include <skinnormal_vertex> 3403 #include <defaultnormal_vertex> 3404 #include <normal_vertex> 3405 #include <begin_vertex> 3406 #include <morphtarget_vertex> 3407 #include <skinning_vertex> 3408 #include <displacementmap_vertex> 3409 #include <project_vertex> 3410 #include <logdepthbuf_vertex> 3411 #include <clipping_planes_vertex> 3412 vViewPosition = - mvPosition.xyz; 3413 #include <worldpos_vertex> 3414 #include <shadowmap_vertex> 3415 #include <fog_vertex> 3416}`,f_=`#define TOON 3417uniform vec3 diffuse; 3418uniform vec3 emissive; 3419uniform float opacity; 3420#include <common> 3421#include <dithering_pars_fragment> 3422#include <color_pars_fragment> 3423#include <uv_pars_fragment> 3424#include <map_pars_fragment> 3425#include <alphamap_pars_fragment> 3426#include <alphatest_pars_fragment> 3427#include <alphahash_pars_fragment> 3428#include <aomap_pars_fragment> 3429#include <lightmap_pars_fragment> 3430#include <emissivemap_pars_fragment> 3431#include <gradientmap_pars_fragment> 3432#include <fog_pars_fragment> 3433#include <bsdfs> 3434#include <lights_pars_begin> 3435#include <normal_pars_fragment> 3436#include <lights_toon_pars_fragment> 3437#include <shadowmap_pars_fragment> 3438#include <bumpmap_pars_fragment> 3439#include <normalmap_pars_fragment> 3440#include <logdepthbuf_pars_fragment> 3441#include <clipping_planes_pars_fragment> 3442void main() { 3443 vec4 diffuseColor = vec4( diffuse, opacity ); 3444 #include <clipping_planes_fragment> 3445 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 3446 vec3 totalEmissiveRadiance = emissive; 3447 #include <logdepthbuf_fragment> 3448 #include <map_fragment> 3449 #include <color_fragment> 3450 #include <alphamap_fragment> 3451 #include <alphatest_fragment> 3452 #include <alphahash_fragment> 3453 #include <normal_fragment_begin> 3454 #include <normal_fragment_maps> 3455 #include <emissivemap_fragment> 3456 #include <lights_toon_fragment> 3457 #include <lights_fragment_begin> 3458 #include <lights_fragment_maps> 3459 #include <lights_fragment_end> 3460 #include <aomap_fragment> 3461 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; 3462 #include <opaque_fragment> 3463 #include <tonemapping_fragment> 3464 #include <colorspace_fragment> 3465 #include <fog_fragment> 3466 #include <premultiplied_alpha_fragment> 3467 #include <dithering_fragment> 3468}`,p_=`uniform float size; 3469uniform float scale; 3470#include <common> 3471#include <color_pars_vertex> 3472#include <fog_pars_vertex> 3473#include <morphtarget_pars_vertex> 3474#include <logdepthbuf_pars_vertex> 3475#include <clipping_planes_pars_vertex> 3476#ifdef USE_POINTS_UV 3477 varying vec2 vUv; 3478 uniform mat3 uvTransform; 3479#endif 3480void main() { 3481 #ifdef USE_POINTS_UV 3482 vUv = ( uvTransform * vec3( uv, 1 ) ).xy; 3483 #endif 3484 #include <color_vertex> 3485 #include <morphinstance_vertex> 3486 #include <morphcolor_vertex> 3487 #include <begin_vertex> 3488 #include <morphtarget_vertex> 3489 #include <project_vertex> 3490 gl_PointSize = size; 3491 #ifdef USE_SIZEATTENUATION 3492 bool isPerspective = isPerspectiveMatrix( projectionMatrix ); 3493 if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); 3494 #endif 3495 #include <logdepthbuf_vertex> 3496 #include <clipping_planes_vertex> 3497 #include <worldpos_vertex> 3498 #include <fog_vertex> 3499}`,m_=`uniform vec3 diffuse; 3500uniform float opacity; 3501#include <common> 3502#include <color_pars_fragment> 3503#include <map_particle_pars_fragment> 3504#include <alphatest_pars_fragment> 3505#include <alphahash_pars_fragment> 3506#include <fog_pars_fragment> 3507#include <logdepthbuf_pars_fragment> 3508#include <clipping_planes_pars_fragment> 3509void main() { 3510 vec4 diffuseColor = vec4( diffuse, opacity ); 3511 #include <clipping_planes_fragment> 3512 vec3 outgoingLight = vec3( 0.0 ); 3513 #include <logdepthbuf_fragment> 3514 #include <map_particle_fragment> 3515 #include <color_fragment> 3516 #include <alphatest_fragment> 3517 #include <alphahash_fragment> 3518 outgoingLight = diffuseColor.rgb; 3519 #include <opaque_fragment> 3520 #include <tonemapping_fragment> 3521 #include <colorspace_fragment> 3522 #include <fog_fragment> 3523 #include <premultiplied_alpha_fragment> 3524}`,g_=`#include <common> 3525#include <batching_pars_vertex> 3526#include <fog_pars_vertex> 3527#include <morphtarget_pars_vertex> 3528#include <skinning_pars_vertex> 3529#include <logdepthbuf_pars_vertex> 3530#include <shadowmap_pars_vertex> 3531void main() { 3532 #include <batching_vertex> 3533 #include <beginnormal_vertex> 3534 #include <morphinstance_vertex> 3535 #include <morphnormal_vertex> 3536 #include <skinbase_vertex> 3537 #include <skinnormal_vertex> 3538 #include <defaultnormal_vertex> 3539 #include <begin_vertex> 3540 #include <morphtarget_vertex> 3541 #include <skinning_vertex> 3542 #include <project_vertex> 3543 #include <logdepthbuf_vertex> 3544 #include <worldpos_vertex> 3545 #include <shadowmap_vertex> 3546 #include <fog_vertex> 3547}`,x_=`uniform vec3 color; 3548uniform float opacity; 3549#include <common> 3550#include <fog_pars_fragment> 3551#include <bsdfs> 3552#include <lights_pars_begin> 3553#include <logdepthbuf_pars_fragment> 3554#include <shadowmap_pars_fragment> 3555#include <shadowmask_pars_fragment> 3556void main() { 3557 #include <logdepthbuf_fragment> 3558 gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); 3559 #include <tonemapping_fragment> 3560 #include <colorspace_fragment> 3561 #include <fog_fragment> 3562 #include <premultiplied_alpha_fragment> 3563}`,y_=`uniform float rotation; 3564uniform vec2 center; 3565#include <common> 3566#include <uv_pars_vertex> 3567#include <fog_pars_vertex> 3568#include <logdepthbuf_pars_vertex> 3569#include <clipping_planes_pars_vertex> 3570void main() { 3571 #include <uv_vertex> 3572 vec4 mvPosition = modelViewMatrix[ 3 ]; 3573 vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); 3574 #ifndef USE_SIZEATTENUATION 3575 bool isPerspective = isPerspectiveMatrix( projectionMatrix ); 3576 if ( isPerspective ) scale *= - mvPosition.z; 3577 #endif 3578 vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; 3579 vec2 rotatedPosition; 3580 rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; 3581 rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; 3582 mvPosition.xy += rotatedPosition; 3583 gl_Position = projectionMatrix * mvPosition; 3584 #include <logdepthbuf_vertex> 3585 #include <clipping_planes_vertex> 3586 #include <fog_vertex> 3587}`,v_=`uniform vec3 diffuse; 3588uniform float opacity; 3589#include <common> 3590#include <uv_pars_fragment> 3591#include <map_pars_fragment> 3592#include <alphamap_pars_fragment> 3593#include <alphatest_pars_fragment> 3594#include <alphahash_pars_fragment> 3595#include <fog_pars_fragment> 3596#include <logdepthbuf_pars_fragment> 3597#include <clipping_planes_pars_fragment> 3598void main() { 3599 vec4 diffuseColor = vec4( diffuse, opacity ); 3600 #include <clipping_planes_fragment> 3601 vec3 outgoingLight = vec3( 0.0 ); 3602 #include <logdepthbuf_fragment> 3603 #include <map_fragment> 3604 #include <alphamap_fragment> 3605 #include <alphatest_fragment> 3606 #include <alphahash_fragment> 3607 outgoingLight = diffuseColor.rgb; 3608 #include <opaque_fragment> 3609 #include <tonemapping_fragment> 3610 #include <colorspace_fragment> 3611 #include <fog_fragment> 3612}`,et={alphahash_fragment:Vx,alphahash_pars_fragment:Hx,alphamap_fragment:Gx,alphamap_pars_fragment:Wx,alphatest_fragment:Xx,alphatest_pars_fragment:qx,aomap_fragment:jx,aomap_pars_fragment:Yx,batching_pars_vertex:Kx,batching_vertex:Zx,begin_vertex:Jx,beginnormal_vertex:Qx,bsdfs:$x,iridescence_fragment:ey,bumpmap_pars_fragment:ty,clipping_planes_fragment:ny,clipping_planes_pars_fragment:iy,clipping_planes_pars_vertex:sy,clipping_planes_vertex:ry,color_fragment:oy,color_pars_fragment:ay,color_pars_vertex:cy,color_vertex:ly,common:uy,cube_uv_reflection_fragment:dy,defaultnormal_vertex:hy,displacementmap_pars_vertex:fy,displacementmap_vertex:py,emissivemap_fragment:my,emissivemap_pars_fragment:gy,colorspace_fragment:xy,colorspace_pars_fragment:yy,envmap_fragment:vy,envmap_common_pars_fragment:_y,envmap_pars_fragment:by,envmap_pars_vertex:My,envmap_physical_pars_fragment:Dy,envmap_vertex:Sy,fog_vertex:wy,fog_pars_vertex:Ty,fog_fragment:Ey,fog_pars_fragment:Ay,gradientmap_pars_fragment:Cy,lightmap_pars_fragment:Ry,lights_lambert_fragment:Py,lights_lambert_pars_fragment:Ly,lights_pars_begin:Iy,lights_toon_fragment:Ny,lights_toon_pars_fragment:Uy,lights_phong_fragment:Oy,lights_phong_pars_fragment:Fy,lights_physical_fragment:ky,lights_physical_pars_fragment:By,lights_fragment_begin:zy,lights_fragment_maps:Vy,lights_fragment_end:Hy,logdepthbuf_fragment:Gy,logdepthbuf_pars_fragment:Wy,logdepthbuf_pars_vertex:Xy,logdepthbuf_vertex:qy,map_fragment:jy,map_pars_fragment:Yy,map_particle_fragment:Ky,map_particle_pars_fragment:Zy,metalnessmap_fragment:Jy,metalnessmap_pars_fragment:Qy,morphinstance_vertex:$y,morphcolor_vertex:ev,morphnormal_vertex:tv,morphtarget_pars_vertex:nv,morphtarget_vertex:iv,normal_fragment_begin:sv,normal_fragment_maps:rv,normal_pars_fragment:ov,normal_pars_vertex:av,normal_vertex:cv,normalmap_pars_fragment:lv,clearcoat_normal_fragment_begin:uv,clearcoat_normal_fragment_maps:dv,clearcoat_pars_fragment:hv,iridescence_pars_fragment:fv,opaque_fragment:pv,packing:mv,premultiplied_alpha_fragment:gv,project_vertex:xv,dithering_fragment:yv,dithering_pars_fragment:vv,roughnessmap_fragment:_v,roughnessmap_pars_fragment:bv,shadowmap_pars_fragment:Mv,shadowmap_pars_vertex:Sv,shadowmap_vertex:wv,shadowmask_pars_fragment:Tv,skinbase_vertex:Ev,skinning_pars_vertex:Av,skinning_vertex:Cv,skinnormal_vertex:Rv,specularmap_fragment:Pv,specularmap_pars_fragment:Lv,tonemapping_fragment:Iv,tonemapping_pars_fragment:Dv,transmission_fragment:Nv,transmission_pars_fragment:Uv,uv_pars_fragment:Ov,uv_pars_vertex:Fv,uv_vertex:kv,worldpos_vertex:Bv,background_vert:zv,background_frag:Vv,backgroundCube_vert:Hv,backgroundCube_frag:Gv,cube_vert:Wv,cube_frag:Xv,depth_vert:qv,depth_frag:jv,distance_vert:Yv,distance_frag:Kv,equirect_vert:Zv,equirect_frag:Jv,linedashed_vert:Qv,linedashed_frag:$v,meshbasic_vert:e_,meshbasic_frag:t_,meshlambert_vert:n_,meshlambert_frag:i_,meshmatcap_vert:s_,meshmatcap_frag:r_,meshnormal_vert:o_,meshnormal_frag:a_,meshphong_vert:c_,meshphong_frag:l_,meshphysical_vert:u_,meshphysical_frag:d_,meshtoon_vert:h_,meshtoon_frag:f_,points_vert:p_,points_frag:m_,shadow_vert:g_,shadow_frag:x_,sprite_vert:y_,sprite_frag:v_},ve={common:{diffuse:{value:new ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new $e},alphaMap:{value:null},alphaMapTransform:{value:new $e},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new $e}},envmap:{envMap:{value:null},envMapRotation:{value:new $e},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new $e}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new $e}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new $e},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new $e},normalScale:{value:new xe(1,1)}}
vendor: 6,936 bytes, line 3612
3612,displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new $e},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new $e}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new $e}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new $e}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ze(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},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 ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new $e},alphaTest:{value:0},uvTransform:{value:new $e}},sprite:{diffuse:{value:new ze(16777215)},opacity:{value:1},center:{value:new xe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new $e},alphaMap:{value:null},alphaMapTransform:{value:new $e},alphaTest:{value:0}}},xi={basic:{uniforms:xn([ve.common,ve.specularmap,ve.envmap,ve.aomap,ve.lightmap,ve.fog]),vertexShader:et.meshbasic_vert,fragmentShader:et.meshbasic_frag},lambert:{uniforms:xn([ve.common,ve.specularmap,ve.envmap,ve.aomap,ve.lightmap,ve.emissivemap,ve.bumpmap,ve.normalmap,ve.displacementmap,ve.fog,ve.lights,{emissive:{value:new ze(0)},envMapIntensity:{value:1}}]),vertexShader:et.meshlambert_vert,fragmentShader:et.meshlambert_frag},phong:{uniforms:xn([ve.common,ve.specularmap,ve.envmap,ve.aomap,ve.lightmap,ve.emissivemap,ve.bumpmap,ve.normalmap,ve.displacementmap,ve.fog,ve.lights,{emissive:{value:new ze(0)},specular:{value:new ze(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:et.meshphong_vert,fragmentShader:et.meshphong_frag},standard:{uniforms:xn([ve.common,ve.envmap,ve.aomap,ve.lightmap,ve.emissivemap,ve.bumpmap,ve.normalmap,ve.displacementmap,ve.roughnessmap,ve.metalnessmap,ve.fog,ve.lights,{emissive:{value:new ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:et.meshphysical_vert,fragmentShader:et.meshphysical_frag},toon:{uniforms:xn([ve.common,ve.aomap,ve.lightmap,ve.emissivemap,ve.bumpmap,ve.normalmap,ve.displacementmap,ve.gradientmap,ve.fog,ve.lights,{emissive:{value:new ze(0)}}]),vertexShader:et.meshtoon_vert,fragmentShader:et.meshtoon_frag},matcap:{uniforms:xn([ve.common,ve.bumpmap,ve.normalmap,ve.displacementmap,ve.fog,{matcap:{value:null}}]),vertexShader:et.meshmatcap_vert,fragmentShader:et.meshmatcap_frag},points:{uniforms:xn([ve.points,ve.fog]),vertexShader:et.points_vert,fragmentShader:et.points_frag},dashed:{uniforms:xn([ve.common,ve.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:et.linedashed_vert,fragmentShader:et.linedashed_frag},depth:{uniforms:xn([ve.common,ve.displacementmap]),vertexShader:et.depth_vert,fragmentShader:et.depth_frag},normal:{uniforms:xn([ve.common,ve.bumpmap,ve.normalmap,ve.displacementmap,{opacity:{value:1}}]),vertexShader:et.meshnormal_vert,fragmentShader:et.meshnormal_frag},sprite:{uniforms:xn([ve.sprite,ve.fog]),vertexShader:et.sprite_vert,fragmentShader:et.sprite_frag},background:{uniforms:{uvTransform:{value:new $e},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:et.background_vert,fragmentShader:et.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new $e}},vertexShader:et.backgroundCube_vert,fragmentShader:et.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:et.cube_vert,fragmentShader:et.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:et.equirect_vert,fragmentShader:et.equirect_frag},distance:{uniforms:xn([ve.common,ve.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:et.distance_vert,fragmentShader:et.distance_frag},shadow:{uniforms:xn([ve.lights,ve.fog,{color:{value:new ze(0)},opacity:{value:1}}]),vertexShader:et.shadow_vert,fragmentShader:et.shadow_frag}};xi.physical={uniforms:xn([xi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new $e},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new $e},clearcoatNormalScale:{value:new xe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new $e},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new $e},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new $e},sheen:{value:0},sheenColor:{value:new ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new $e},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new $e},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new $e},transmissionSamplerSize:{value:new xe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new $e},attenuationDistance:{value:0},attenuationColor:{value:new ze(0)},specularColor:{value:new ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new $e},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new $e},anisotropyVector:{value:new xe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new $e}}]),vertexShader:et.meshphysical_vert,fragmentShader:et.meshphysical_frag};const Pa={r:0,b:0,g:0},Ms=new Xn,__=new Oe;function b_(s,e,t,n,i,r){const o=new ze(0);let a=i===!0?0:1,c,l,d=null,u=0,h=null;function f(y){let _=y.isScene===!0?y.background:null;if(_&&_.isTexture){const v=y.backgroundBlurriness>0;_=e.get(_,v)}
vendor: 14,914 bytes, line 3612
3612return _}function m(y){let _=!1;const v=f(y);v===null?p(o,a):v&&v.isColor&&(p(v,1),_=!0);const M=s.xr.getEnvironmentBlendMode();M==="additive"?t.buffers.color.setClear(0,0,0,1,r):M==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(s.autoClear||_)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function x(y,_){const v=f(_);v&&(v.isCubeTexture||v.mapping===Rc)?(l===void 0&&(l=new Qe(new ei(1,1,1),new pn({name:"BackgroundCubeMaterial",uniforms:Fr(xi.backgroundCube.uniforms),vertexShader:xi.backgroundCube.vertexShader,fragmentShader:xi.backgroundCube.fragmentShader,side:vn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(M,w,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),Ms.copy(_.backgroundRotation),Ms.x*=-1,Ms.y*=-1,Ms.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(Ms.y*=-1,Ms.z*=-1),l.material.uniforms.envMap.value=v,l.material.uniforms.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,l.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(__.makeRotationFromEuler(Ms)),l.material.toneMapped=it.getTransfer(v.colorSpace)!==ut,(d!==v||u!==v.version||h!==s.toneMapping)&&(l.material.needsUpdate=!0,d=v,u=v.version,h=s.toneMapping),l.layers.enableAll(),y.unshift(l,l.geometry,l.material,0,0,null)):v&&v.isTexture&&(c===void 0&&(c=new Qe(new Nc(2,2),new pn({name:"BackgroundMaterial",uniforms:Fr(xi.background.uniforms),vertexShader:xi.background.vertexShader,fragmentShader:xi.background.fragmentShader,side:ii,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=v,c.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,c.material.toneMapped=it.getTransfer(v.colorSpace)!==ut,v.matrixAutoUpdate===!0&&v.updateMatrix(),c.material.uniforms.uvTransform.value.copy(v.matrix),(d!==v||u!==v.version||h!==s.toneMapping)&&(c.material.needsUpdate=!0,d=v,u=v.version,h=s.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function p(y,_){y.getRGB(Pa,am(s)),t.buffers.color.setClear(Pa.r,Pa.g,Pa.b,_,r)}function g(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(y,_=1){o.set(y),a=_,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(y){a=y,p(o,a)},render:m,addToRenderList:x,dispose:g}}function M_(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=h(null);let r=i,o=!1;function a(A,T,I,k,F){let L=!1;const O=u(A,k,I,T);r!==O&&(r=O,l(r.object)),L=f(A,k,I,F),L&&m(A,k,I,F),F!==null&&e.update(F,s.ELEMENT_ARRAY_BUFFER),(L||o)&&(o=!1,v(A,T,I,k),F!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(F).buffer))}function c(){return s.createVertexArray()}function l(A){return s.bindVertexArray(A)}function d(A){return s.deleteVertexArray(A)}function u(A,T,I,k){const F=k.wireframe===!0;let L=n[T.id];L===void 0&&(L={},n[T.id]=L);const O=A.isInstancedMesh===!0?A.id:0;let H=L[O];H===void 0&&(H={},L[O]=H);let W=H[I.id];W===void 0&&(W={},H[I.id]=W);let q=W[F];return q===void 0&&(q=h(c()),W[F]=q),q}function h(A){const T=[],I=[],k=[];for(let F=0;F<t;F++)T[F]=0,I[F]=0,k[F]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:T,enabledAttributes:I,attributeDivisors:k,object:A,attributes:{},index:null}}function f(A,T,I,k){const F=r.attributes,L=T.attributes;let O=0;const H=I.getAttributes();for(const W in H)if(H[W].location>=0){const Z=F[W];let V=L[W];if(V===void 0&&(W==="instanceMatrix"&&A.instanceMatrix&&(V=A.instanceMatrix),W==="instanceColor"&&A.instanceColor&&(V=A.instanceColor)),Z===void 0||Z.attribute!==V||V&&Z.data!==V.data)return!0;O++}return r.attributesNum!==O||r.index!==k}function m(A,T,I,k){const F={},L=T.attributes;let O=0;const H=I.getAttributes();for(const W in H)if(H[W].location>=0){let Z=L[W];Z===void 0&&(W==="instanceMatrix"&&A.instanceMatrix&&(Z=A.instanceMatrix),W==="instanceColor"&&A.instanceColor&&(Z=A.instanceColor));const V={};V.attribute=Z,Z&&Z.data&&(V.data=Z.data),F[W]=V,O++}r.attributes=F,r.attributesNum=O,r.index=k}function x(){const A=r.newAttributes;for(let T=0,I=A.length;T<I;T++)A[T]=0}function p(A){g(A,0)}function g(A,T){const I=r.newAttributes,k=r.enabledAttributes,F=r.attributeDivisors;I[A]=1,k[A]===0&&(s.enableVertexAttribArray(A),k[A]=1),F[A]!==T&&(s.vertexAttribDivisor(A,T),F[A]=T)}function y(){const A=r.newAttributes,T=r.enabledAttributes;for(let I=0,k=T.length;I<k;I++)T[I]!==A[I]&&(s.disableVertexAttribArray(I),T[I]=0)}function _(A,T,I,k,F,L,O){O===!0?s.vertexAttribIPointer(A,T,I,F,L):s.vertexAttribPointer(A,T,I,k,F,L)}function v(A,T,I,k){x();const F=k.attributes,L=I.getAttributes(),O=T.defaultAttributeValues;for(const H in L){const W=L[H];if(W.location>=0){let q=F[H];if(q===void 0&&(H==="instanceMatrix"&&A.instanceMatrix&&(q=A.instanceMatrix),H==="instanceColor"&&A.instanceColor&&(q=A.instanceColor)),q!==void 0){const Z=q.normalized,V=q.itemSize,K=e.get(q);if(K===void 0)continue;const ce=K.buffer,$=K.type,R=K.bytesPerElement,z=$===s.INT||$===s.UNSIGNED_INT||q.gpuType===wd;if(q.isInterleavedBufferAttribute){const Y=q.data,ie=Y.stride,re=q.offset;if(Y.isInstancedInterleavedBuffer){for(let ge=0;ge<W.locationSize;ge++)g(W.location+ge,Y.meshPerAttribute);A.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=Y.meshPerAttribute*Y.count)}else for(let ge=0;ge<W.locationSize;ge++)p(W.location+ge);s.bindBuffer(s.ARRAY_BUFFER,ce);for(let ge=0;ge<W.locationSize;ge++)_(W.location+ge,V/W.locationSize,$,Z,ie*R,(re+V/W.locationSize*ge)*R,z)}else{if(q.isInstancedBufferAttribute){for(let Y=0;Y<W.locationSize;Y++)g(W.location+Y,q.meshPerAttribute);A.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=q.meshPerAttribute*q.count)}else for(let Y=0;Y<W.locationSize;Y++)p(W.location+Y);s.bindBuffer(s.ARRAY_BUFFER,ce);for(let Y=0;Y<W.locationSize;Y++)_(W.location+Y,V/W.locationSize,$,Z,V*R,V/W.locationSize*Y*R,z)}}else if(O!==void 0){const Z=O[H];if(Z!==void 0)switch(Z.length){case 2:s.vertexAttrib2fv(W.location,Z);break;case 3:s.vertexAttrib3fv(W.location,Z);break;case 4:s.vertexAttrib4fv(W.location,Z);break;default:s.vertexAttrib1fv(W.location,Z)}}}}y()}function M(){S();for(const A in n){const T=n[A];for(const I in T){const k=T[I];for(const F in k){const L=k[F];for(const O in L)d(L[O].object),delete L[O];delete k[F]}}delete n[A]}}function w(A){if(n[A.id]===void 0)return;const T=n[A.id];for(const I in T){const k=T[I];for(const F in k){const L=k[F];for(const O in L)d(L[O].object),delete L[O];delete k[F]}}delete n[A.id]}function E(A){for(const T in n){const I=n[T];for(const k in I){const F=I[k];if(F[A.id]===void 0)continue;const L=F[A.id];for(const O in L)d(L[O].object),delete L[O];delete F[A.id]}}}function b(A){for(const T in n){const I=n[T],k=A.isInstancedMesh===!0?A.id:0,F=I[k];if(F!==void 0){for(const L in F){const O=F[L];for(const H in O)d(O[H].object),delete O[H];delete F[L]}delete I[k],Object.keys(I).length===0&&delete n[T]}}}function S(){P(),o=!0,r!==i&&(r=i,l(r.object))}function P(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:a,reset:S,resetDefaultState:P,dispose:M,releaseStatesOfGeometry:w,releaseStatesOfObject:b,releaseStatesOfProgram:E,initAttributes:x,enableAttribute:p,disableUnusedAttributes:y}}function S_(s,e,t){let n;function i(l){n=l}function r(l,d){s.drawArrays(n,l,d),t.update(d,n,1)}function o(l,d,u){u!==0&&(s.drawArraysInstanced(n,l,d,u),t.update(d,n,u))}function a(l,d,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,d,0,u);let f=0;for(let m=0;m<u;m++)f+=d[m];t.update(f,n,1)}function c(l,d,u,h){if(u===0)return;const f=e.get("WEBGL_multi_draw");if(f===null)for(let m=0;m<l.length;m++)o(l[m],d[m],h[m]);else{f.multiDrawArraysInstancedWEBGL(n,l,0,d,0,h,0,u);let m=0;for(let x=0;x<u;x++)m+=d[x]*h[x];t.update(m,n,1)}}this.setMode=i,this.render=r,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function w_(s,e,t,n){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const E=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(E){return!(E!==An&&n.convert(E)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(E){const b=E===Wn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(E!==Nn&&n.convert(E)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&E!==En&&!b)}function c(E){if(E==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const d=c(l);d!==l&&(Ne("WebGLRenderer:",l,"not supported, using",d,"instead."),l=d);const u=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),m=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=s.getParameter(s.MAX_TEXTURE_SIZE),p=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),g=s.getParameter(s.MAX_VERTEX_ATTRIBS),y=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),_=s.getParameter(s.MAX_VARYING_VECTORS),v=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),M=s.getParameter(s.MAX_SAMPLES),w=s.getParameter(s.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:m,maxTextureSize:x,maxCubemapSize:p,maxAttributes:g,maxVertexUniforms:y,maxVaryings:_,maxFragmentUniforms:v,maxSamples:M,samples:w}}function T_(s){const e=this;let t=null,n=0,i=!1,r=!1;const o=new gi,a=new $e,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,h){const f=u.length!==0||h||n!==0||i;return i=h,n=u.length,f},this.beginShadows=function(){r=!0,d(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,h){t=d(u,h,0)},this.setState=function(u,h,f){const m=u.clippingPlanes,x=u.clipIntersection,p=u.clipShadows,g=s.get(u);if(!i||m===null||m.length===0||r&&!p)r?d(null):l();else{const y=r?0:n,_=y*4;let v=g.clippingState||null;c.value=v,v=d(m,h,_,f);for(let M=0;M!==_;++M)v[M]=t[M];g.clippingState=v,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=y}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function d(u,h,f,m){const x=u!==null?u.length:0;let p=null;if(x!==0){if(p=c.value,m!==!0||p===null){const g=f+x*4,y=h.matrixWorldInverse;a.getNormalMatrix(y),(p===null||p.length<g)&&(p=new Float32Array(g));for(let _=0,v=f;_!==x;++_,v+=4)o.copy(u[_]).applyMatrix4(y,a),o.normal.toArray(p,v),p[v+3]=o.constant}c.value=p,c.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,p}}const cs=4,Sf=[.125,.215,.35,.446,.526,.582],Ls=20,E_=256,io=new Jo,wf=new ze;let El=null,Al=0,Cl=0,Rl=!1;const A_=new D;class Ku{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,i=100,r={}){const{size:o=256,position:a=A_}=r;El=this._renderer.getRenderTarget(),Al=this._renderer.getActiveCubeFace(),Cl=this._renderer.getActiveMipmapLevel(),Rl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,i,c,a),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Af(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ef(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(El,Al,Cl),this._renderer.xr.enabled=Rl,e.scissorTest=!1,rr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Os||e.mapping===Dr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),El=this._renderer.getRenderTarget(),Al=this._renderer.getActiveCubeFace(),Cl=this._renderer.getActiveMipmapLevel(),Rl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:It,minFilter:It,generateMipmaps:!1,type:Wn,format:An,colorSpace:mn,depthBuffer:!1},i=Tf(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Tf(e,t,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=C_(r)),this._blurMaterial=P_(r,e,t),this._ggxMaterial=R_(r,e,t)}return i}_compileMaterial(e){const t=new Qe(new vt,e);this._renderer.compile(t,io)}_sceneToCubeUV(e,t,n,i,r){const c=new ln(90,1,t,n),l=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,f=u.toneMapping;u.getClearColor(wf),u.toneMapping=ti,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Qe(new ei,new nn({name:"PMREM.Backgroun
3612d",side:vn,depthWrite:!1,depthTest:!1})));const x=this._backgroundBox,p=x.material;let g=!1;const y=e.background;y?y.isColor&&(p.color.copy(y),e.background=null,g=!0):(p.color.copy(wf),g=!0);for(let _=0;_<6;_++){const v=_%3;v===0?(c.up.set(0,l[_],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+d[_],r.y,r.z)):v===1?(c.up.set(0,0,l[_]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+d[_],r.z)):(c.up.set(0,l[_],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+d[_]));const M=this._cubeSize;rr(i,v*M,_>2?M:0,M,M),u.setRenderTarget(i),g&&u.render(x,c),u.render(e,c)}u.toneMapping=f,u.autoClear=h,e.background=y}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Os||e.mapping===Dr;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Af()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ef());const r=i?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=r;const a=r.uniforms;a.envMap.value=e;const c=this._cubeSize;rr(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(o,io)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){const i=this._renderer,r=this._pingPongRenderTarget,o=this._ggxMaterial,a=this._lodMeshes[n];a.material=o;const c=o.uniforms,l=n/(this._lodMeshes.length-1),d=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-d*d),h=0+l*1.25,f=u*h,{_lodMax:m}=this,x=this._sizeLods[n],p=3*x*(n>m-cs?n-m+cs:0),g=4*(this._cubeSize-x);c.envMap.value=e.texture,c.roughness.value=f,c.mipInt.value=m-t,rr(r,p,g,3*x,2*x),i.setRenderTarget(r),i.render(a,io),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=m-n,rr(e,p,g,3*x,2*x),i.setRenderTarget(e),i.render(a,io)}_blur(e,t,n,i,r){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",r),this._halfBlur(o,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,o,a){const c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&We("blur direction must be either latitudinal or longitudinal!");const d=3,u=this._lodMeshes[i];u.material=l;const h=l.uniforms,f=this._sizeLods[n]-1,m=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Ls-1),x=r/m,p=isFinite(r)?1+Math.floor(d*x):Ls;p>Ls&&Ne(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Ls}`);const g=[];let y=0;for(let E=0;E<Ls;++E){const b=E/x,S=Math.exp(-b*b/2);g.push(S),E===0?y+=S:E<p&&(y+=2*S)}for(let E=0;E<g.length;E++)g[E]=g[E]/y;h.envMap.value=e.texture,h.samples.value=p,h.weights.value=g,h.latitudinal.value=o==="latitudinal",a&&(h.poleAxis.value=a);const{_lodMax:_}=this;h.dTheta.value=m,h.mipInt.value=_-n;const v=this._sizeLods[i],M=3*v*(i>_-cs?i-_+cs:0),w=4*(this._cubeSize-v);rr(t,M,w,3*v,2*v),c.setRenderTarget(t),c.render(u,io)}}function C_(s){const e=[],t=[],n=[];let i=s;const r=s-cs+1+Sf.length;for(let o=0;o<r;o++){const a=Math.pow(2,i);e.push(a);let c=1/a;o>s-cs?c=Sf[o-s+cs-1]:o===0&&(c=0),t.push(c);const l=1/(a-2),d=-l,u=1+l,h=[d,d,u,d,u,u,d,d,u,u,d,u],f=6,m=6,x=3,p=2,g=1,y=new Float32Array(x*m*f),_=new Float32Array(p*m*f),v=new Float32Array(g*m*f);for(let w=0;w<f;w++){const E=w%3*2/3-1,b=w>2?0:-1,S=[E,b,0,E+2/3,b,0,E+2/3,b+1,0,E,b,0,E+2/3,b+1,0,E,b+1,0];y.set(S,x*m*w),_.set(h,p*m*w);const P=[w,w,w,w,w,w];v.set(P,g*m*w)}const M=new vt;M.setAttribute("position",new Rt(y,x)),M.setAttribute("uv",new Rt(_,p)),M.setAttribute("faceIndex",new Rt(v,g)),n.push(new Qe(M,null)),i>cs&&i--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Tf(s,e,t){const n=new On(s,e,t);return n.texture.mapping=Rc,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function rr(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function R_(s,e,t){return new pn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:E_,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Fc(),fragmentShader:` 3613 3614 precision highp float; 3615 precision highp int; 3616 3617 varying vec3 vOutputDirection; 3618 3619 uniform sampler2D envMap; 3620 uniform float roughness; 3621 uniform float mipInt; 3622 3623 #define ENVMAP_TYPE_CUBE_UV 3624 #include <cube_uv_reflection_fragment> 3625 3626 #define PI 3.14159265359 3627 3628 // Van der Corput radical inverse 3629 float radicalInverse_VdC(uint bits) { 3630 bits = (bits << 16u) | (bits >> 16u); 3631 bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); 3632 bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); 3633 bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); 3634 bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); 3635 return float(bits) * 2.3283064365386963e-10; // / 0x100000000 3636 } 3637 3638 // Hammersley sequence 3639 vec2 hammersley(uint i, uint N) { 3640 return vec2(float(i) / float(N), radicalInverse_VdC(i)); 3641 } 3642 3643 // GGX VNDF importance sampling (Eric Heitz 2018) 3644 // "Sampling the GGX Distribution of Visible Normals" 3645 // https://jcgt.org/published/0007/04/01/ 3646 vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { 3647 float alpha = roughness * roughness; 3648 3649 // Section 4.1: Orthonormal basis 3650 vec3 T1 = vec3(1.0, 0.0, 0.0); 3651 vec3 T2 = cross(V, T1); 3652 3653 // Section 4.2: Parameterization of projected area 3654 float r = sqrt(Xi.x); 3655 float phi = 2.0 * PI * Xi.y; 3656 float t1 = r * cos(phi); 3657 float t2 = r * sin(phi); 3658 float s = 0.5 * (1.0 + V.z); 3659 t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; 3660 3661 // Section 4.3: Reprojection onto hemisphere 3662 vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; 3663 3664 // Section 3.4: Transform back to ellipsoid configuration 3665 return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); 3666 } 3667 3668 void main() { 3669 vec3 N = normalize(vOutputDirection); 3670 vec3 V = N; // Assume view direction equals normal for pre-filtering 3671 3672 vec3 prefilteredColor = vec3(0.0); 3673 float totalWeight = 0.0; 3674 3675 // For very low roughness, just sample the environment directly 3676 if (roughness < 0.001) { 3677 gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); 3678 return; 3679 } 3680 3681 // Tangent space basis for VNDF sampling 3682 vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); 3683 vec3 tangent = normalize(cross(up, N)); 3684 vec3 bitangent = cross(N, tangent); 3685
3686 for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { 3687 vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); 3688 3689 // For PMREM, V = N, so in tangent space V is always (0, 0, 1) 3690 vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); 3691 3692 // Transform H back to world space 3693 vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); 3694 vec3 L = normalize(2.0 * dot(V, H) * H - V); 3695 3696 float NdotL = max(dot(N, L), 0.0); 3697 3698 if(NdotL > 0.0) { 3699 // Sample environment at fixed mip level 3700 // VNDF importance sampling handles the distribution filtering 3701 vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); 3702 3703 // Weight by NdotL for the split-sum approximation 3704 // VNDF PDF naturally accounts for the visible microfacet distribution 3705 prefilteredColor += sampleColor * NdotL; 3706 totalWeight += NdotL; 3707 } 3708 } 3709 3710 if (totalWeight > 0.0) { 3711 prefilteredColor = prefilteredColor / totalWeight; 3712 } 3713 3714 gl_FragColor = vec4(prefilteredColor, 1.0); 3715 } 3716 `,blending:bi,depthTest:!1,depthWrite:!1})}function P_(s,e,t){const n=new Float32Array(Ls),i=new D(0,1,0);return new pn({name:"SphericalGaussianBlur",defines:{n:Ls,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Fc(),fragmentShader:` 3717 3718 precision mediump float; 3719 precision mediump int; 3720 3721 varying vec3 vOutputDirection; 3722 3723 uniform sampler2D envMap; 3724 uniform int samples; 3725 uniform float weights[ n ]; 3726 uniform bool latitudinal; 3727 uniform float dTheta; 3728 uniform float mipInt; 3729 uniform vec3 poleAxis; 3730 3731 #define ENVMAP_TYPE_CUBE_UV 3732 #include <cube_uv_reflection_fragment> 3733 3734 vec3 getSample( float theta, vec3 axis ) { 3735 3736 float cosTheta = cos( theta ); 3737 // Rodrigues' axis-angle rotation 3738 vec3 sampleDirection = vOutputDirection * cosTheta 3739 + cross( axis, vOutputDirection ) * sin( theta ) 3740 + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); 3741 3742 return bilinearCubeUV( envMap, sampleDirection, mipInt ); 3743 3744 } 3745 3746 void main() { 3747 3748 vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); 3749 3750 if ( all( equal( axis, vec3( 0.0 ) ) ) ) { 3751 3752 axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); 3753 3754 } 3755 3756 axis = normalize( axis ); 3757 3758 gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); 3759 gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); 3760 3761 for ( int i = 1; i < n; i++ ) { 3762 3763 if ( i >= samples ) { 3764 3765 break; 3766 3767 } 3768 3769 float theta = dTheta * float( i ); 3770 gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); 3771 gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); 3772 3773 } 3774 3775 } 3776 `,blending:bi,depthTest:!1,depthWrite:!1})}function Ef(){return new pn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Fc(),fragmentShader:` 3777 3778 precision mediump float; 3779 precision mediump int; 3780 3781 varying vec3 vOutputDirection; 3782 3783 uniform sampler2D envMap; 3784 3785 #include <common> 3786 3787 void main() { 3788 3789 vec3 outputDirection = normalize( vOutputDirection ); 3790 vec2 uv = equirectUv( outputDirection ); 3791 3792 gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); 3793 3794 } 3795 `,blending:bi,depthTest:!1,depthWrite:!1})}function Af(){return new pn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Fc(),fragmentShader:` 3796 3797 precision mediump float; 3798 precision mediump int; 3799 3800 uniform float flipEnvMap; 3801 3802 varying vec3 vOutputDirection; 3803 3804 uniform samplerCube envMap; 3805 3806 void main() { 3807 3808 gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); 3809 3810 } 3811 `,blending:bi,depthTest:!1,depthWrite:!1})}function Fc(){return` 3812 3813 precision mediump float; 3814 precision mediump int; 3815 3816 attribute float faceIndex; 3817 3818 varying vec3 vOutputDirection; 3819 3820 // RH coordinate system; PMREM face-indexing convention 3821 vec3 getDirection( vec2 uv, float face ) { 3822 3823 uv = 2.0 * uv - 1.0; 3824 3825 vec3 direction = vec3( uv, 1.0 ); 3826 3827 if ( face == 0.0 ) { 3828 3829 direction = direction.zyx; // ( 1, v, u ) pos x 3830 3831 } else if ( face == 1.0 ) { 3832 3833 direction = direction.xzy; 3834 direction.xz *= -1.0; // ( -u, 1, -v ) pos y 3835 3836 } else if ( face == 2.0 ) { 3837 3838 direction.x *= -1.0; // ( -u, v, 1 ) pos z 3839 3840 } else if ( face == 3.0 ) { 3841 3842 direction = direction.zyx; 3843 direction.xz *= -1.0; // ( -1, v, -u ) neg x 3844 3845 } else if ( face == 4.0 ) { 3846 3847 direction = direction.xzy; 3848 direction.xy *= -1.0; // ( -u, -1, v ) neg y 3849 3850 } else if ( face == 5.0 ) { 3851 3852 direction.z *= -1.0; // ( u, v, -1 ) neg z 3853 3854 } 3855 3856 return direction; 3857 3858 } 3859 3860 void main() { 3861 3862 vOutputDirection = getDirection( uv, faceIndex ); 3863 gl_Position = vec4( position, 1.0 ); 3864 3865 } 3866 `}class mm extends On{constructor(e=1,t={}
vendor: 27,052 bytes, lines 3866-3982
3866){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new nm(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` 3867 3868 varying vec3 vWorldDirection; 3869 3870 vec3 transformDirection( in vec3 dir, in mat4 matrix ) { 3871 3872 return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); 3873 3874 } 3875 3876 void main() { 3877 3878 vWorldDirection = transformDirection( position, modelMatrix ); 3879 3880 #include <begin_vertex> 3881 #include <project_vertex> 3882 3883 } 3884 `,fragmentShader:` 3885 3886 uniform sampler2D tEquirect; 3887 3888 varying vec3 vWorldDirection; 3889 3890 #include <common> 3891 3892 void main() { 3893 3894 vec3 direction = normalize( vWorldDirection ); 3895 3896 vec2 sampleUV = equirectUv( direction ); 3897 3898 gl_FragColor = texture2D( tEquirect, sampleUV ); 3899 3900 } 3901 `},i=new ei(5,5,5),r=new pn({name:"CubemapFromEquirect",uniforms:Fr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:vn,blending:bi});r.uniforms.tEquirect.value=t;const o=new Qe(i,r),a=t.minFilter;return t.minFilter===vi&&(t.minFilter=It),new wx(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){const r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(r)}}function L_(s){let e=new WeakMap,t=new WeakMap,n=null;function i(h,f=!1){return h==null?null:f?o(h):r(h)}function r(h){if(h&&h.isTexture){const f=h.mapping;if(f===Wc||f===Xc)if(e.has(h)){const m=e.get(h).texture;return a(m,h.mapping)}else{const m=h.image;if(m&&m.height>0){const x=new mm(m.height);return x.fromEquirectangularTexture(s,h),e.set(h,x),h.addEventListener("dispose",l),a(x.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){const f=h.mapping,m=f===Wc||f===Xc,x=f===Os||f===Dr;if(m||x){let p=t.get(h);const g=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==g)return n===null&&(n=new Ku(s)),p=m?n.fromEquirectangular(h,p):n.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,t.set(h,p),p.texture;if(p!==void 0)return p.texture;{const y=h.image;return m&&y&&y.height>0||x&&y&&c(y)?(n===null&&(n=new Ku(s)),p=m?n.fromEquirectangular(h):n.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,t.set(h,p),h.addEventListener("dispose",d),p.texture):null}}}return h}function a(h,f){return f===Wc?h.mapping=Os:f===Xc&&(h.mapping=Dr),h}function c(h){let f=0;const m=6;for(let x=0;x<m;x++)h[x]!==void 0&&f++;return f===m}function l(h){const f=h.target;f.removeEventListener("dispose",l);const m=e.get(f);m!==void 0&&(e.delete(f),m.dispose())}function d(h){const f=h.target;f.removeEventListener("dispose",d);const m=t.get(f);m!==void 0&&(t.delete(f),m.dispose())}function u(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:i,dispose:u}}function I_(s){const e={};function t(n){if(e[n]!==void 0)return e[n];const i=s.getExtension(n);return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const i=t(n);return i===null&&xc("WebGLRenderer: "+n+" extension not supported."),i}}}function D_(s,e,t,n){const i={},r=new WeakMap;function o(u){const h=u.target;h.index!==null&&e.remove(h.index);for(const m in h.attributes)e.remove(h.attributes[m]);h.removeEventListener("dispose",o),delete i[h.id];const f=r.get(h);f&&(e.remove(f),r.delete(h)),n.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function a(u,h){return i[h.id]===!0||(h.addEventListener("dispose",o),i[h.id]=!0,t.memory.geometries++),h}function c(u){const h=u.attributes;for(const f in h)e.update(h[f],s.ARRAY_BUFFER)}function l(u){const h=[],f=u.index,m=u.attributes.position;let x=0;if(m===void 0)return;if(f!==null){const y=f.array;x=f.version;for(let _=0,v=y.length;_<v;_+=3){const M=y[_+0],w=y[_+1],E=y[_+2];h.push(M,w,w,E,E,M)}}else{const y=m.array;x=m.version;for(let _=0,v=y.length/3-1;_<v;_+=3){const M=_+0,w=_+1,E=_+2;h.push(M,w,w,E,E,M)}}const p=new(m.count>=65535?Qp:Ud)(h,1);p.version=x;const g=r.get(u);g&&e.remove(g),r.set(u,p)}function d(u){const h=r.get(u);if(h){const f=u.index;f!==null&&h.version<f.version&&l(u)}else l(u);return r.get(u)}return{get:a,update:c,getWireframeAttribute:d}}function N_(s,e,t){let n;function i(h){n=h}let r,o;function a(h){r=h.type,o=h.bytesPerElement}function c(h,f){s.drawElements(n,f,r,h*o),t.update(f,n,1)}function l(h,f,m){m!==0&&(s.drawElementsInstanced(n,f,r,h*o,m),t.update(f,n,m))}function d(h,f,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,f,0,r,h,0,m);let p=0;for(let g=0;g<m;g++)p+=f[g];t.update(p,n,1)}function u(h,f,m,x){if(m===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let g=0;g<h.length;g++)l(h[g]/o,f[g],x[g]);else{p.multiDrawElementsInstancedWEBGL(n,f,0,r,h,0,x,0,m);let g=0;for(let y=0;y<m;y++)g+=f[y]*x[y];t.update(g,n,1)}}this.setMode=i,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=d,this.renderMultiDrawInstances=u}function U_(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(t.calls++,o){case s.TRIANGLES:t.triangles+=a*(r/3);break;case s.LINES:t.lines+=a*(r/2);break;case s.LINE_STRIP:t.lines+=a*(r-1);break;case s.LINE_LOOP:t.lines+=a*r;break;case s.POINTS:t.points+=a*r;break;default:We("WebGLInfo: Unknown draw mode:",o);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function O_(s,e,t){const n=new WeakMap,i=new bt;function r(o,a,c){const l=o.morphTargetInfluences,d=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,u=d!==void 0?d.length:0;let h=n.get(a);if(h===void 0||h.count!==u){let P=function(){b.dispose(),n.delete(a),a.removeEventListener("dispose",P)};var f=P;h!==void 0&&h.texture.dispose();const m=a.morphAttributes.position!==void 0,x=a.morphAttributes.normal!==void 0,p=a.morphAttributes.color!==void 0,g=a.morphAttributes.position||[],y=a.morphAttributes.normal||[],_=a.morphAttributes.color||[];let v=0;m===!0&&(v=1),x===!0&&(v=2),p===!0&&(v=3);let M=a.attributes.position.count*v,w=1;M>e.maxTextureSize&&(w=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const E=new Float32Array(M*w*4*u),b=new Zp(E,M,w,u);b.type=En,b.needsUpdate=!0;const S=v*4;for(let A=0;A<u;A++){const T=g[A],I=y[A],k=_[A],F=M*w*4*A;for(let L=0;L<T.count;L++){const O=L*S;m===!0&&(i.fromBufferAttribute(T,L),E[F+O+0]=i.x,E[F+O+1]=i.y,E[F+O+2]=i.z,E[F+O+3]=0),x===!0&&(i.fromBufferAttribute(I,L),E[F+O+4]=i.x,E[F+O+5]=i.y,E[F+O+6]=i.z,E[F+O+7]=0),p===!0&&(i.fromBufferAttribute(k,L),E[F+O+8]=i.x,E[F+O+9]=i.y,E[F+O+10]=i.z,E[F+O+11]=k.itemSize===4?i.w:1)}}h={count:u,texture:b,size:new xe(M,w)},n.set(a,h),a.addEventListener("dispose",P)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(s,"morphTexture",o.morphTexture,t);else{let m=0;for(let p=0;p<l.length;p++)m+=l[p];const x=a.morphTargetsRelative?1:1-m;c.getUniforms().setValue(s,"morphTargetBaseInfluence",x),c.getUniforms().setValue(s,"morphTargetInfluences",l)}c.getUniforms().setValue(s,"morphTargetsTexture",h.texture,t),c.getUniforms().setValue(s,"morphTargetsTextureSize",h.size)}return{update:r}}function F_(s,e,t,n,i){let r=new WeakMap;function o(l){const d=i.render.frame,u=l.geometry,h=e.get(l,u);if(r.get(h)!==d&&(e.update(h),r.set(h,d)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==d&&(t.update(l.instanceMatrix,s.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,s.ARRAY_BUFFER),r.set(l,d))),l.isSkinnedMesh){const f=l.skeleton;r.get(f)!==d&&(f.update(),r.set(f,d))}return h}function a(){r=new WeakMap}function c(l){const d=l.target;d.removeEventListener("dispose",c),n.releaseStatesOfObject(d),t.remove(d.instanceMatrix),d.instanceColor!==null&&t.remove(d.instanceColor)}return{update:o,dispose:a}}const k_={[xd]:"LINEAR_TONE_MAPPING",[yd]:"REINHARD_TONE_MAPPING",[vd]:"CINEON_TONE_MAPPING",[_d]:"ACES_FILMIC_TONE_MAPPING",[Md]:"AGX_TONE_MAPPING",[Sd]:"NEUTRAL_TONE_MAPPING",[bd]:"CUSTOM_TONE_MAPPING"};function B_(s,e,t,n,i){const r=new On(e,t,{type:s,depthBuffer:n,stencilBuffer:i}),o=new On(e,t,{type:Wn,depthBuffer:!1,stencilBuffer:!1}),a=new vt;a.setAttribute("position",new rt([-1,3,0,-1,-1,0,3,-1,0],3)),a.setAttribute("uv",new rt([0,2,0,0,2,0],2));const c=new cm({uniforms:{tDiffuse:{value:null}},vertexShader:` 3902 precision highp float; 3903 3904 uniform mat4 modelViewMatrix; 3905 uniform mat4 projectionMatrix; 3906 3907 attribute vec3 position; 3908 attribute vec2 uv; 3909 3910 varying vec2 vUv; 3911 3912 void main() { 3913 vUv = uv; 3914 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 3915 }`,fragmentShader:` 3916 precision highp float; 3917 3918 uniform sampler2D tDiffuse; 3919 3920 varying vec2 vUv; 3921 3922 #include <tonemapping_pars_fragment> 3923 #include <colorspace_pars_fragment> 3924 3925 void main() { 3926 gl_FragColor = texture2D( tDiffuse, vUv ); 3927 3928 #ifdef LINEAR_TONE_MAPPING 3929 gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); 3930 #elif defined( REINHARD_TONE_MAPPING ) 3931 gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); 3932 #elif defined( CINEON_TONE_MAPPING ) 3933 gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); 3934 #elif defined( ACES_FILMIC_TONE_MAPPING ) 3935 gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); 3936 #elif defined( AGX_TONE_MAPPING ) 3937 gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); 3938 #elif defined( NEUTRAL_TONE_MAPPING ) 3939 gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); 3940 #elif defined( CUSTOM_TONE_MAPPING ) 3941 gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); 3942 #endif 3943 3944 #ifdef SRGB_TRANSFER 3945 gl_FragColor = sRGBTransferOETF( gl_FragColor ); 3946 #endif 3947 }`,depthTest:!1,depthWrite:!1}),l=new Qe(a,c),d=new Jo(-1,1,1,-1,0,1);let u=null,h=null,f=!1,m,x=null,p=[],g=!1;this.setSize=function(y,_){r.setSize(y,_),o.setSize(y,_);for(let v=0;v<p.length;v++){const M=p[v];M.setSize&&M.setSize(y,_)}},this.setEffects=function(y){p=y,g=p.length>0&&p[0].isRenderPass===!0;const _=r.width,v=r.height;for(let M=0;M<p.length;M++){const w=p[M];w.setSize&&w.setSize(_,v)}},this.begin=function(y,_){if(f||y.toneMapping===ti&&p.length===0)return!1;if(x=_,_!==null){const v=_.width,M=_.height;(r.width!==v||r.height!==M)&&this.setSize(v,M)}return g===!1&&y.setRenderTarget(r),m=y.toneMapping,y.toneMapping=ti,!0},this.hasRenderPass=function(){return g},this.end=function(y,_){y.toneMapping=m,f=!0;let v=r,M=o;for(let w=0;w<p.length;w++){const E=p[w];if(E.enabled!==!1&&(E.render(y,M,v,_),E.needsSwap!==!1)){const b=v;v=M,M=b}}if(u!==y.outputColorSpace||h!==y.toneMapping){u=y.outputColorSpace,h=y.toneMapping,c.defines={},it.getTransfer(u)===ut&&(c.defines.SRGB_TRANSFER="");const w=k_[h];w&&(c.defines[w]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=v.texture,y.setRenderTarget(x),y.render(l,d),x=null,f=!1},this.isCompositing=function(){return f},this.dispose=function(){r.dispose(),o.dispose(),a.dispose(),c.dispose()}}const gm=new Ot,Zu=new Go(1,1),xm=new Zp,ym=new d0,vm=new nm,Cf=[],Rf=[],Pf=new Float32Array(16),Lf=new Float32Array(9),If=new Float32Array(4);function qr(s,e,t){const n=s[0];if(n<=0||n>0)return s;const i=e*t;let r=Cf[i];if(r===void 0&&(r=new Float32Array(i),Cf[i]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,s[o].toArray(r,a)}return r}function Wt(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t<n;t++)if(s[t]!==e[t])return!1;return!0}function Xt(s,e){for(let t=0,n=e.length;t<n;t++)s[t]=e[t]}function kc(s,e){let t=Rf[e];t===void 0&&(t=new Int32Array(e),Rf[e]=t);for(let n=0;n!==e;++n)t[n]=s.allocateTextureUnit();return t}function z_(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function V_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Wt(t,e))return;s.uniform2fv(this.addr,e),Xt(t,e)}}function H_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Wt(t,e))return;s.uniform3fv(this.addr,e),Xt(t,e)}}function G_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Wt(t,e))return;s.uniform4fv(this.addr,e),Xt(t,e)}}function W_(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(Wt(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),Xt(t,e)}else{if(Wt(t,n))return;If.set(n),s.uniformMatrix2fv(this.addr,!1,If),Xt(t,n)}}function X_(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(Wt(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),Xt(t,e)}else{if(Wt(t,n))return;Lf.set(n),s.uniformMatrix3fv(this.addr,!1,Lf),Xt(t,n)}}function q_(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(Wt(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),Xt(t,e)}else{if(Wt(t,n))return;Pf.set(n),s.uniformMatrix4fv(this.addr,!1,Pf),Xt(t,n)}}function j_(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function Y_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Wt(t,e))return;s.uniform2iv(this.addr,e),Xt(t,e)}}function K_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Wt(t,e))return;s.uniform3iv(this.addr,e),Xt(t,e)}}function Z_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Wt(t,e))return;s.uniform4iv(this.addr,e),Xt(t,e)}}function J_(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function Q_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Wt(t,e))return;s.uniform2uiv(this.addr,e),Xt(t,e)}}function $_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Wt(t,e))return;s.uniform3uiv(this.addr,e),Xt(t,e)}}function eb(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Wt(t,e))return;s.uniform4uiv(this.addr,e),Xt(t,e)}}function tb(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(Zu.compareFunction=t.isReversedDepthBuffer()?Ld:Pd,r=Zu):r=gm,t.setTexture2D(e||r,i)}function nb(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||ym,i)}function ib(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||vm,i)}function sb(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||xm,i)}function rb(s){switch(s){case 5126:return z_;case 35664:return V_;case 35665:return H_;case 35666:return G_;case 35674:return W_;case 35675:return X_;case 35676:return q_;case 5124:case 35670:return j_;case 35667:case 35671:return Y_;case 35668:case 35672:return K_;case 35669:case 35673:return Z_;case 5125:return J_;case 36294:return Q_;case 36295:return $_;case 36296:return eb;case 35678:case 36198:case 36298:case 36306:case 35682:return tb;case 35679:case 36299:case 36307:return nb;case 35680:case 36300:case 36308:case 36293:return ib;case 36289:case 36303:case 36311:case 36292:return sb}}function ob(s,e){s.uniform1fv(this.addr,e)}function ab(s,e){const t=qr(e,this.size,2);s.uniform2fv(this.addr,t)}function cb(s,e){const t=qr(e,this.size,3);s.uniform3fv(this.addr,t)}function lb(s,e){const t=qr(e,this.size,4);s.uniform4fv(this.addr,t)}function ub(s,e){const t=qr(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function db(s,e){const t=qr(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function hb(s,e){const t=qr(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function fb(s,e){s.uniform1iv(this.addr,e)}function pb(s,e){s.uniform2iv(this.addr,e)}function mb(s,e){s.uniform3iv(this.addr,e)}function gb(s,e){s.uniform4iv(this.addr,e)}function xb(s,e){s.uniform1uiv(this.addr,e)}function yb(s,e){s.uniform2uiv(this.addr,e)}function vb(s,e){s.uniform3uiv(this.addr,e)}function _b(s,e){s.uniform4uiv(this.addr,e)}function bb(s,e,t){const n=this.cache,i=e.length,r=kc(t,i);Wt(n,r)||(s.uniform1iv(this.addr,r),Xt(n,r));let o;this.type===s.SAMPLER_2D_SHADOW?o=Zu:o=gm;for(let a=0;a!==i;++a)t.setTexture2D(e[a]||o,r[a])}function Mb(s,e,t){const n=this.cache,i=e.length,r=kc(t,i);Wt(n,r)||(s.uniform1iv(this.addr,r),Xt(n,r));for(let o=0;o!==i;++o)t.setTexture3D(e[o]||ym,r[o])}function Sb(s,e,t){const n=this.cache,i=e.length,r=kc(t,i);Wt(n,r)||(s.uniform1iv(this.addr,r),Xt(n,r));for(let o=0;o!==i;++o)t.setTextureCube(e[o]||vm,r[o])}function wb(s,e,t){const n=this.cache,i=e.length,r=kc(t,i);Wt(n,r)||(s.uniform1iv(this.addr,r),Xt(n,r));for(let o=0;o!==i;++o)t.setTexture2DArray(e[o]||xm,r[o])}function Tb(s){switch(s){case 5126:return ob;case 35664:return ab;case 35665:return cb;case 35666:return lb;case 35674:return ub;case 35675:return db;case 35676:return hb;case 5124:case 35670:return fb;case 35667:case 35671:return pb;case 35668:case 35672:return mb;case 35669:case 35673:return gb;case 5125:return xb;case 36294:return yb;case 36295:return vb;case 36296:return _b;case 35678:case 36198:case 36298:case 36306:case 35682:return bb;case 35679:case 36299:case 36307:return Mb;case 35680:case 36300:case 36308:case 36293:return Sb;case 36289:case 36303:case 36311:case 36292:return wb}}class Eb{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=rb(t.type)}}class Ab{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Tb(t.type)}}class Cb{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,o=i.length;r!==o;++r){const a=i[r];a.setValue(e,t[a.id],n)}}}const Pl=/(\w+)(\])?(\[|\.)?/g;function Df(s,e){s.seq.push(e),s.map[e.id]=e}function Rb(s,e,t){const n=s.name,i=n.length;for(Pl.lastIndex=0;;){const r=Pl.exec(n),o=Pl.lastIndex;let a=r[1];const c=r[2]==="]",l=r[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===i){Df(t,l===void 0?new Eb(a,s,e):new Ab(a,s,e));break}else{let u=t.map[a];u===void 0&&(u=new Cb(a),Df(t,u)),t=u}}}class ac{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let o=0;o<n;++o){const a=e.getActiveUniform(t,o),c=e.getUniformLocation(t,a.name);Rb(a,c,this)}const i=[],r=[];for(const o of this.seq)o.type===e.SAMPLER_2D_SHADOW||o.type===e.SAMPLER_CUBE_SHADOW||o.type===e.SAMPLER_2D_ARRAY_SHADOW?i.push(o):r.push(o);i.length>0&&(this.seq=i.concat(r))}setValue(e,t,n,i){const r=this.map[t];r!==void 0&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,o=t.length;r!==o;++r){const a=t[r],c=n[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const o=e[i];o.id in t&&n.push(o)}return n}}function Nf(s,e,t){const n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}const Pb=37297;let Lb=0;function Ib(s,e){const t=s.split(` 3948`),n=[],i=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=i;o<r;o++){const a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(` 3949`)}const Uf=new $e;function Db(s){it._getMatrix(Uf,it.workingColorSpace,s);const e=`mat3( ${Uf.elements.map(t=>t.toFixed(4))} )`;switch(it.getTransfer(s)){case mc:return[e,"LinearTransferOETF"];case ut:return[e,"sRGBTransferOETF"];default:return Ne("WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function Of(s,e,t){const n=s.getShaderParameter(e,s.COMPILE_STATUS),r=(s.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";const o=/ERROR: 0:(\d+)/.exec(r);if(o){const a=parseInt(o[1]);return t.toUpperCase()+` 3950 3951`+r+` 3952 3953`+Ib(s.getShaderSource(e),a)}else return r}function Nb(s,e){const t=Db(e);return[`vec4 ${s}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` 3954`)}const Ub={[xd]:"Linear",[yd]:"Reinhard",[vd]:"Cineon",[_d]:"ACESFilmic",[Md]:"AgX",[Sd]:"Neutral",[bd]:"Custom"};function Ob(s,e){const t=Ub[e];return t===void 0?(Ne("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+s+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const La=new D;function Fb(){it.getLuminanceCoefficients(La);const s=La.x.toFixed(4),e=La.y.toFixed(4),t=La.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` 3955`)}function kb(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(yo).join(` 3956`)}function Bb(s){const e=[];for(const t in s){const n=s[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` 3957`)}function zb(s,e){const t={},n=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const r=s.getActiveAttrib(e,i),o=r.name;let a=1;r.type===s.FLOAT_MAT2&&(a=2),r.type===s.FLOAT_MAT3&&(a=3),r.type===s.FLOAT_MAT4&&(a=4),t[o]={type:r.type,location:s.getAttribLocation(e,o),locationSize:a}}return t}function yo(s){return s!==""}function Ff(s,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return s.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function kf(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Vb=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ju(s){return s.replace(Vb,Gb)}const Hb=new Map;function Gb(s,e){let t=et[e];if(t===void 0){const n=Hb.get(e);if(n!==void 0)t=et[n],Ne('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return Ju(t)}const Wb=/#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 Bf(s){return s.replace(Wb,Xb)}function Xb(s,e,t,n){let i="";for(let r=parseInt(e);r<parseInt(t);r++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return i}function zf(s){let e=`precision ${s.precision} float; 3958 precision ${s.precision} int; 3959 precision ${s.precision} sampler2D; 3960 precision ${s.precision} samplerCube; 3961 precision ${s.precision} sampler3D; 3962 precision ${s.precision} sampler2DArray; 3963 precision ${s.precision} sampler2DShadow; 3964 precision ${s.precision} samplerCubeShadow; 3965 precision ${s.precision} sampler2DArrayShadow; 3966 precision ${s.precision} isampler2D; 3967 precision ${s.precision} isampler3D; 3968 precision ${s.precision} isamplerCube; 3969 precision ${s.precision} isampler2DArray; 3970 precision ${s.precision} usampler2D; 3971 precision ${s.precision} usampler3D; 3972 precision ${s.precision} usamplerCube; 3973 precision ${s.precision} usampler2DArray; 3974 `;return s.precision==="highp"?e+=` 3975#define HIGH_PRECISION`:s.precision==="mediump"?e+=` 3976#define MEDIUM_PRECISION`:s.precision==="lowp"&&(e+=` 3977#define LOW_PRECISION`),e}const qb={[So]:"SHADOWMAP_TYPE_PCF",[go]:"SHADOWMAP_TYPE_VSM"};function jb(s){return qb[s.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const Yb={[Os]:"ENVMAP_TYPE_CUBE",[Dr]:"ENVMAP_TYPE_CUBE",[Rc]:"ENVMAP_TYPE_CUBE_UV"};function Kb(s){return s.envMap===!1?"ENVMAP_TYPE_CUBE":Yb[s.envMapMode]||"ENVMAP_TYPE_CUBE"}const Zb={[Dr]:"ENVMAP_MODE_REFRACTION"};function Jb(s){return s.envMap===!1?"ENVMAP_MODE_REFLECTION":Zb[s.envMapMode]||"ENVMAP_MODE_REFLECTION"}const Qb={[kp]:"ENVMAP_BLENDING_MULTIPLY",[Tg]:"ENVMAP_BLENDING_MIX",[Eg]:"ENVMAP_BLENDING_ADD"};function $b(s){return s.envMap===!1?"ENVMAP_BLENDING_NONE":Qb[s.combine]||"ENVMAP_BLENDING_NONE"}function eM(s){const e=s.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function tM(s,e,t,n){const i=s.getContext(),r=t.defines;let o=t.vertexShader,a=t.fragmentShader;const c=jb(t),l=Kb(t),d=Jb(t),u=$b(t),h=eM(t),f=kb(t),m=Bb(r),x=i.createProgram();let p,g,y=t.glslVersion?"#version "+t.glslVersion+` 3978`:"";t.isRawShaderMaterial?(p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(yo).join(` 3979`),p.length>0&&(p+=` 3980`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(yo).join(` 3981`),g.length>0&&(g+=` 3982`)):(p=[zf(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+d:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IR
3982IDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","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","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` 3983`].filter(yo).join(` 3984`),g=[zf(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+d:"",t.envMap?"#define "+u:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IR
3984IDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==ti?"#define TONE_MAPPING":"",t.toneMapping!==ti?et.tonemapping_pars_fragment:"",t.toneMapping!==ti?Ob("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",et.colorspace_pars_fragment,Nb("linearToOutputTexel",t.outputColorSpace),Fb(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` 3985`].filter(yo).join(` 3986`)),o=Ju(o),o=Ff(o,t),o=kf(o,t),a=Ju(a),a=Ff(a,t),a=kf(a,t),o=Bf(o),a=Bf(a),t.isRawShaderMaterial!==!0&&(y=`#version 300 es 3987`,p=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` 3988`)+` 3989`+p,g=["#define varying in",t.glslVersion===Lh?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Lh?"":"#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(` 3990`)+` 3991`+g);const _=y+p+o,v=y+g+a,M=Nf(i,i.VERTEX_SHADER,_),w=Nf(i,i.FRAGMENT_SHADER,v);i.attachShader(x,M),i.attachShader(x,w),t.index0AttributeName!==void 0?i.bindAttribLocation(x,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(x,0,"position"),i.linkProgram(x);function E(A){if(s.debug.checkShaderErrors){const T=i.getProgramInfoLog(x)||"",I=i.getShaderInfoLog(M)||"",k=i.getShaderInfoLog(w)||"",F=T.trim(),L=I.trim(),O=k.trim();let H=!0,W=!0;if(i.getProgramParameter(x,i.LINK_STATUS)===!1)if(H=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(i,x,M,w);else{const q=Of(i,M,"vertex"),Z=Of(i,w,"fragment");We("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(x,i.VALIDATE_STATUS)+` 3992 3993Material Name: `+A.name+` 3994Material Type: `+A.type+` 3995 3996Program Info Log: `+F+` 3997`+q+` 3998`+Z)}else F!==""?Ne("WebGLProgram: Program Info Log:",F):(L===""||O==="")&&(W=!1);W&&(A.diagnostics={runnable:H,programLog:F,vertexShader:{log:L,prefix:p},fragmentShader:{log:O,prefix:g}})}i.deleteShader(M),i.deleteShader(w),b=new ac(i,x),S=zb(i,x)}let b;this.getUniforms=function(){return b===void 0&&E(this),b};let S;this.getAttributes=function(){return S===void 0&&E(this),S};let P=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=i.getProgramParameter(x,Pb)),P},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(x),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Lb++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=M,this.fragmentShader=w,this}let nM=0;class iM{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new sM(e),t.set(e,n)),n}}class sM{constructor(e){this.id=nM++,this.code=e,this.usedTimes=0}}function rM(s,e,t,n,i,r){const o=new Nd,a=new iM,c=new Set,l=[],d=new Map,u=n.logarithmicDepthBuffer;let h=n.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(b){return c.add(b),b===0?"uv":`uv${b}`}function x(b,S,P,A,T){const I=A.fog,k=T.geometry,F=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?A.environment:null,L=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap,O=e.get(b.envMap||F,L),H=O&&O.mapping===Rc?O.image.height:null,W=f[b.type];b.precision!==null&&(h=n.getMaxPrecision(b.precision),h!==b.precision&&Ne("WebGLProgram.getParameters:",b.precision,"not supported, using",h,"instead."));const q=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,Z=q!==void 0?q.length:0;let V=0;k.morphAttributes.position!==void 0&&(V=1),k.morphAttributes.normal!==void 0&&(V=2),k.morphAttributes.color!==void 0&&(V=3);let K,ce,$,R;if(W){const dt=xi[W];K=dt.vertexShader,ce=dt.fragmentShader}else K=b.vertexShader,ce=b.fragmentShader,a.update(b),$=a.getVertexShaderID(b),R=a.getFragmentShaderID(b);const z=s.getRenderTarget(),Y=s.state.buffers.depth.getReversed(),ie=T.isInstancedMesh===!0,re=T.isBatchedMesh===!0,ge=!!b.map,Fe=!!b.matcap,Ie=!!O,He=!!b.aoMap,je=!!b.lightMap,Ke=!!b.bumpMap,Ye=!!b.normalMap,U=!!b.displacementMap,pe=!!b.emissiveMap,Ce=!!b.metalnessMap,Ve=!!b.roughnessMap,_e=b.anisotropy>0,B=b.clearcoat>0,C=b.dispersion>0,X=b.iridescence>0,se=b.sheen>0,oe=b.transmission>0,te=_e&&!!b.anisotropyMap,we=B&&!!b.clearcoatMap,fe=B&&!!b.clearcoatNormalMap,ke=B&&!!b.clearcoatRoughnessMap,le=X&&!!b.iridescenceMap,ae=X&&!!b.iridescenceThicknessMap,ue=se&&!!b.sheenColorMap,me=se&&!!b.sheenRoughnessMap,Pe=!!b.specularMap,Te=!!b.specularColorMap,tt=!!b.specularIntensityMap,G=oe&&!!b.transmissionMap,ye=oe&&!!b.thicknessMap,he
vendor: 2,140 bytes, line 3998
3998=!!b.gradientMap,Ae=!!b.alphaMap,de=b.alphaTest>0,ne=!!b.alphaHash,Re=!!b.extensions;let Ze=ti;b.toneMapped&&(z===null||z.isXRRenderTarget===!0)&&(Ze=s.toneMapping);const _t={shaderID:W,shaderType:b.type,shaderName:b.name,vertexShader:K,fragmentShader:ce,defines:b.defines,customVertexShaderID:$,customFragmentShaderID:R,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:h,batching:re,batchingColor:re&&T._colorsTexture!==null,instancing:ie,instancingColor:ie&&T.instanceColor!==null,instancingMorph:ie&&T.morphTexture!==null,outputColorSpace:z===null?s.outputColorSpace:z.isXRRenderTarget===!0?z.texture.colorSpace:mn,alphaToCoverage:!!b.alphaToCoverage,map:ge,matcap:Fe,envMap:Ie,envMapMode:Ie&&O.mapping,envMapCubeUVHeight:H,aoMap:He,lightMap:je,bumpMap:Ke,normalMap:Ye,displacementMap:U,emissiveMap:pe,normalMapObjectSpace:Ye&&b.normalMapType===Ig,normalMapTangentSpace:Ye&&b.normalMapType===Yp,metalnessMap:Ce,roughnessMap:Ve,anisotropy:_e,anisotropyMap:te,clearcoat:B,clearcoatMap:we,clearcoatNormalMap:fe,clearcoatRoughnessMap:ke,dispersion:C,iridescence:X,iridescenceMap:le,iridescenceThicknessMap:ae,sheen:se,sheenColorMap:ue,sheenRoughnessMap:me,specularMap:Pe,specularColorMap:Te,specularIntensityMap:tt,transmission:oe,transmissionMap:G,thicknessMap:ye,gradientMap:he,opaque:b.transparent===!1&&b.blending===wr&&b.alphaToCoverage===!1,alphaMap:Ae,alphaTest:de,alphaHash:ne,combine:b.combine,mapUv:ge&&m(b.map.channel),aoMapUv:He&&m(b.aoMap.channel),lightMapUv:je&&m(b.lightMap.channel),bumpMapUv:Ke&&m(b.bumpMap.channel),normalMapUv:Ye&&m(b.normalMap.channel),displacementMapUv:U&&m(b.displacementMap.channel),emissiveMapUv:pe&&m(b.emissiveMap.channel),metalnessMapUv:Ce&&m(b.metalnessMap.channel),roughnessMapUv:Ve&&m(b.roughnessMap.channel),anisotropyMapUv:te&&m(b.anisotropyMap.channel),clearcoatMapUv:we&&m(b.clearcoatMap.channel),clearcoatNormalMapUv:fe&&m(b.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ke&&m(b.clearcoatRoughnessMap.channel),iridescenceMapUv:le&&m(b.iridescenceMap.channel),iridescenceThicknessMapUv:ae&&m(b.iridescenceThicknessMap.channel),sheenColorMapUv:ue&&m(b.
vendor: 4,751 bytes, line 3998
3998sheenColorMap.channel),sheenRoughnessMapUv:me&&m(b.sheenRoughnessMap.channel),specularMapUv:Pe&&m(b.specularMap.channel),specularColorMapUv:Te&&m(b.specularColorMap.channel),specularIntensityMapUv:tt&&m(b.specularIntensityMap.channel),transmissionMapUv:G&&m(b.transmissionMap.channel),thicknessMapUv:ye&&m(b.thicknessMap.channel),alphaMapUv:Ae&&m(b.alphaMap.channel),vertexTangents:!!k.attributes.tangent&&(Ye||_e),vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,pointsUvs:T.isPoints===!0&&!!k.attributes.uv&&(ge||Ae),fog:!!I,useFog:b.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:b.wireframe===!1&&(b.flatShading===!0||k.attributes.normal===void 0&&Ye===!1&&(b.isMeshLambertMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isMeshPhysicalMaterial)),sizeAttenuation:b.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:Y,skinning:T.isSkinnedMesh===!0,morphTargets:k.morphAttributes.position!==void 0,morphNormals:k.morphAttributes.normal!==void 0,morphColors:k.morphAttributes.color!==void 0,morphTargetsCount:Z,morphTextureStride:V,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numLightProbes:S.numLightProbes,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:b.dithering,shadowMapEnabled:s.shadowMap.enabled&&P.length>0,shadowMapType:s.shadowMap.type,toneMapping:Ze,decodeVideoTexture:ge&&b.map.isVideoTexture===!0&&it.getTransfer(b.map.colorSpace)===ut,decodeVideoTextureEmissive:pe&&b.emissiveMap.isVideoTexture===!0&&it.getTransfer(b.emissiveMap.colorSpace)===ut,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===Tt,flipSided:b.side===vn,useDepthPacking:b.depthPacking>=0,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionClipCullDistance:Re&&b.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Re&&b.extensions.multiDraw===!0||re)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:b.customProgramCacheKey()};return _t.vertexUv1s=c.has(1),_t.vertexUv2s=c.has(2),_t.vertexUv3s=c.has(3),c.clear(),_t}function p(b){const S=[];if(b.shaderID?S.push(b.shaderID):(S.push(b.customVertexShaderID),S.push(b.customFragmentShaderID)),b.defines!==void 0)for(const P in b.defines)S.push(P),S.push(b.defines[P]);return b.isRawShaderMaterial===!1&&(g(S,b),y(S,b),S.push(s.outputColorSpace)),S.push(b.customProgramCacheKey),S.join()}function g(b,S){b.push(S.precision),b.push(S.outputColorSpace),b.push(S.envMapMode),b.push(S.envMapCubeUVHeight),b.push(S.mapUv),b.push(S.alphaMapUv),b.push(S.lightMapUv),b.push(S.aoMapUv),b.push(S.bumpMapUv),b.push(S.normalMapUv),b.push(S.displacementMapUv),b.push(S.emissiveMapUv),b.push(S.metalnessMapUv),b.push(S.roughnessMapUv),b.push(S.anisotropyMapUv),b.push(S.clearcoatMapUv),b.push(S.clearcoatNormalMapUv),b.push(S.clearcoatRoughnessMapUv),b.push(S.iridescenceMapUv),b.push(S.iridescenceThicknessMapUv),b.push(S.sheenColorMapUv),b.push(S.sheenRoughnessMapUv),b.push(S.specularMapUv),b.push(S.specularColorMapUv),b.push(S.specularIntensityMapUv),b.push(S.transmissionMapUv),b.push(S.thicknessMapUv),b.push(S.combine),b.push(S.fogExp2),b.push(S.sizeAttenuation),b.push(S.morphTargetsCount),b.push(S.morphAttributeCount),b.push(S.numDirLights),b.push(S.numPointLights),b.push(S.numSpotLights),b.push(S.numSpotLightMaps),b.push(S.numHemiLights),b.push(S.numRectAreaLights),b.push(S.numDirLightShadows),b.push(S.numPointLightShadows),b.push(S.numSpotLightShadows),b.push(S.numSpotLightShadowsWithMaps),b.push(S.numLightProbes),b.push(S.shadowMapType),b.push(S.toneMapping),b.push(S.numClippingPlanes),b.push(S.numClipIntersection),b.push(S.depthPacking)}function y(b,S){o.disableAll(),S.instancing&&o.enable(0),S.instancingColor&&o.enable(1),S.instancingMorph&&o.enable(2),S.matcap&&o.enable(3),S.envMap&&o.enable(4),S.normalMapObjectSpace&&o.enable(5),S.normalMapTangentSpace&&o.enable(6),S.clearcoat&&o.enable(7),S.iridescence&&o.enable(8),S.alphaTest&&o.enable(9),S.vertexColors&&o.enable(10),S.vertexAlphas&&o.enable(11),S.vertexUv1s&&o.enable(12),S.vertexUv2s&&o.enable(13),S.vertexUv3s&&o.enable(14),S.vertexTangents&&o.enable(15),S.anisotropy&&o.enable(16),S.alphaHash&&o.enable(17),S.batching&&o.enable(18),S.dispersion&&o.enable(19),S.batchingColor&&o.enable(20),S.gradientMap&&o.enable(21),b.pu
vendor: 9,091 bytes, line 3998
3998sh(o.mask),o.disableAll(),S.fog&&o.enable(0),S.useFog&&o.enable(1),S.flatShading&&o.enable(2),S.logarithmicDepthBuffer&&o.enable(3),S.reversedDepthBuffer&&o.enable(4),S.skinning&&o.enable(5),S.morphTargets&&o.enable(6),S.morphNormals&&o.enable(7),S.morphColors&&o.enable(8),S.premultipliedAlpha&&o.enable(9),S.shadowMapEnabled&&o.enable(10),S.doubleSided&&o.enable(11),S.flipSided&&o.enable(12),S.useDepthPacking&&o.enable(13),S.dithering&&o.enable(14),S.transmission&&o.enable(15),S.sheen&&o.enable(16),S.opaque&&o.enable(17),S.pointsUvs&&o.enable(18),S.decodeVideoTexture&&o.enable(19),S.decodeVideoTextureEmissive&&o.enable(20),S.alphaToCoverage&&o.enable(21),b.push(o.mask)}function _(b){const S=f[b.type];let P;if(S){const A=xi[S];P=Ar.clone(A.uniforms)}else P=b.uniforms;return P}function v(b,S){let P=d.get(S);return P!==void 0?++P.usedTimes:(P=new tM(s,S,b,i),l.push(P),d.set(S,P)),P}function M(b){if(--b.usedTimes===0){const S=l.indexOf(b);l[S]=l[l.length-1],l.pop(),d.delete(b.cacheKey),b.destroy()}}function w(b){a.remove(b)}function E(){a.dispose()}return{getParameters:x,getProgramCacheKey:p,getUniforms:_,acquireProgram:v,releaseProgram:M,releaseShaderCache:w,programs:l,dispose:E}}function oM(){let s=new WeakMap;function e(o){return s.has(o)}function t(o){let a=s.get(o);return a===void 0&&(a={},s.set(o,a)),a}function n(o){s.delete(o)}function i(o,a,c){s.get(o)[a]=c}function r(){s=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:r}}function aM(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.materialVariant!==e.materialVariant?s.materialVariant-e.materialVariant:s.z!==e.z?s.z-e.z:s.id-e.id}function Vf(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function Hf(){const s=[];let e=0;const t=[],n=[],i=[];function r(){e=0,t.length=0,n.length=0,i.length=0}function o(h){let f=0;return h.isInstancedMesh&&(f+=2),h.isSkinnedMesh&&(f+=1),f}function a(h,f,m,x,p,g){let y=s[e];return y===void 0?(y={id:h.id,object:h,geometry:f,material:m,materialVariant:o(h),groupOrder:x,renderOrder:h.renderOrder,z:p,group:g},s[e]=y):(y.id=h.id,y.object=h,y.geometry=f,y.material=m,y.materialVariant=o(h),y.groupOrder=x,y.renderOrder=h.renderOrder,y.z=p,y.group=g),e++,y}function c(h,f,m,x,p,g){const y=a(h,f,m,x,p,g);m.transmission>0?n.push(y):m.transparent===!0?i.push(y):t.push(y)}function l(h,f,m,x,p,g){const y=a(h,f,m,x,p,g);m.transmission>0?n.unshift(y):m.transparent===!0?i.unshift(y):t.unshift(y)}function d(h,f){t.length>1&&t.sort(h||aM),n.length>1&&n.sort(f||Vf),i.length>1&&i.sort(f||Vf)}function u(){for(let h=e,f=s.length;h<f;h++){const m=s[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:n,transparent:i,init:r,push:c,unshift:l,finish:u,sort:d}}function cM(){let s=new WeakMap;function e(n,i){const r=s.get(n);let o;return r===void 0?(o=new Hf,s.set(n,[o])):i>=r.length?(o=new Hf,r.push(o)):o=r[i],o}function t(){s=new WeakMap}return{get:e,dispose:t}}function lM(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new D,color:new ze};break;case"SpotLight":t={position:new D,direction:new D,color:new ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new ze,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new ze,groundColor:new ze};break;case"RectAreaLight":t={color:new ze,position:new D,halfWidth:new D,halfHeight:new D};break}return s[e.id]=t,t}}}function uM(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xe,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let dM=0;function hM(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function fM(s){const e=new lM,t=uM(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new D);const i=new D,r=new Oe,o=new Oe;function a(l){let d=0,u=0,h=0;for(let S=0;S<9;S++)n.probe[S].set(0,0,0);let f=0,m=0,x=0,p=0,g=0,y=0,_=0,v=0,M=0,w=0,E=0;l.sort(hM);for(let S=0,P=l.length;S<P;S++){const A=l[S],T=A.color,I=A.intensity,k=A.distance;let F=null;if(A.shadow&&A.shadow.map&&(A.shadow.map.texture.format===Ur?F=A.shadow.map.texture:F=A.shadow.map.depthTexture||A.shadow.map.texture),A.isAmbientLight)d+=T.r*I,u+=T.g*I,h+=T.b*I;else if(A.isLightProbe){for(let L=0;L<9;L++)n.probe[L].addScaledVector(A.sh.coefficients[L],I);E++}else if(A.isDirectionalLight){const L=e.get(A);if(L.color.copy(A.color).multiplyScalar(A.intensity),A.castShadow){const O=A.shadow,H=t.get(A);H.shadowIntensity=O.intensity,H.shadowBias=O.bias,H.shadowNormalBias=O.normalBias,H.shadowRadius=O.radius,H.shadowMapSize=O.mapSize,n.directionalShadow[f]=H,n.directionalShadowMap[f]=F,n.directionalShadowMatrix[f]=A.shadow.matrix,y++}n.directional[f]=L,f++}else if(A.isSpotLight){const L=e.get(A);L.position.setFromMatrixPosition(A.matrixWorld),L.color.copy(T).multiplyScalar(I),L.distance=k,L.coneCos=Math.cos(A.angle),L.penumbraCos=Math.cos(A.angle*(1-A.penumbra)),L.decay=A.decay,n.spot[x]=L;const O=A.shadow;if(A.map&&(n.spotLightMap[M]=A.map,M++,O.updateMatrices(A),A.castShadow&&w++),n.spotLightMatrix[x]=O.matrix,A.castShadow){const H=t.get(A);H.shadowIntensity=O.intensity,H.shadowBias=O.bias,H.shadowNormalBias=O.normalBias,H.shadowRadius=O.radius,H.shadowMapSize=O.mapSize,n.spotShadow[x]=H,n.spotShadowMap[x]=F,v++}x++}else if(A.isRectAreaLight){const L=e.get(A);L.color.copy(T).multiplyScalar(I),L.halfWidth.set(A.width*.5,0,0),L.halfHeight.set(0,A.height*.5,0),n.rectArea[p]=L,p++}else if(A.isPointLight){const L=e.get(A);if(L.color.copy(A.color).multiplyScalar(A.intensity),L.distance=A.distance,L.decay=A.decay,A.castShadow){const O=A.shadow,H=t.get(A);H.shadowIntensity=O.intensity,H.shadowBias=O.bias,H.shadowNormalBias=O.normalBias,H.shadowRadius=O.radius,H.shadowMapSize=O.mapSize,H.shadowCameraNear=O.camera.near,H.shadowCameraFar=O.camera.far,n.pointShadow[m]=H,n.pointShadowMap[m]=F,n.pointShadowMatrix[m]=A.shadow.matrix,_++}n.point[m]=L,m++}else if(A.isHemisphereLight){const L=e.get(A);L.skyColor.copy(A.color).multiplyScalar(I),L.groundColor.copy(A.groundColor).multiplyScalar(I),n.hemi[g]=L,g++}}p>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ve.LTC_FLOAT_1,n.rectAreaLTC2=ve.LTC_FLOAT_2):(n.rectAreaLTC1=ve.LTC_HALF_1,n.rectAreaLTC2=ve.LTC_HALF_2)),n.ambient[0]=d,n.ambient[1]=u,n.ambient[2]=h;const b=n.hash;(b.directionalLength!==f||b.pointLength!==m||b.spotLength!==x||b.rectAreaLength!==p||b.hemiLength!==g||b.numDirectionalShadows!==y||b.numPointShadows!==_||b.numSpotShadows!==v||b.numSpotMaps!==M||b.numLightProbes!==E)&&(n.directional.length=f,n.spot.length=x,n.rectArea.length=p,n.point.length=m,n.hemi.length=g,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=_,n.pointShadowMap.length=_,n.spotShadow.length=v,n.spotShadowMap.length=v,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=_,n.spotLightMatrix.length=v+M-w,n.spotLightMap.length=M,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=E,b.directionalLength=f,b.pointLength=m,b.spotLength=x,b.rectAreaLength=p,b.hemiLength=g,b.numDirectionalShadows=y,b.numPointShadows=_,b.numSpotShadows=v,b.numSpotMaps=M,b.numLightProbes=E,n.version=dM++)}function c(l,d){let u=0,h=0,f=0,m=0,x=0;const p=d.matrixWorldInverse;for(let g=0,y=l.length;g<y;g++){const _=l[g];if(_.isDirectionalLight){const v=n.directional[u];v.direction.setFromMatrixPosition(_.matrixWorld),i.setFromMatrixPosition(_.target.matrixWorld),v.direction.sub(i),v.direction.transformDirection(p),u++}else if(_.isSpotLight){const v=n.spot[f];v.position.setFromMatrixPosition(_.matrixWorld),v.position.applyMatrix4(p),v.direction.setFromMatrixPosition(_.matrixWorld),i.setFromMatrixPosition(_.target.matrixWorld),v.direction.sub(i),v.direction.transformDirection(p),f++}else if(_.isRectAreaLight){const v=n.rectArea[m];v.position.setFromMatrixPosition(_.matrixWorld),v.position.applyMatrix4(p),o.identity(),r.copy(_.matrixWorld),r.premultiply(
vendor: 5,037 bytes, lines 3998-4025
3998p),o.extractRotation(r),v.halfWidth.set(_.width*.5,0,0),v.halfHeight.set(0,_.height*.5,0),v.halfWidth.applyMatrix4(o),v.halfHeight.applyMatrix4(o),m++}else if(_.isPointLight){const v=n.point[h];v.position.setFromMatrixPosition(_.matrixWorld),v.position.applyMatrix4(p),h++}else if(_.isHemisphereLight){const v=n.hemi[x];v.direction.setFromMatrixPosition(_.matrixWorld),v.direction.transformDirection(p),x++}}}return{setup:a,setupView:c,state:n}}function Gf(s){const e=new fM(s),t=[],n=[];function i(d){l.camera=d,t.length=0,n.length=0}function r(d){t.push(d)}function o(d){n.push(d)}function a(){e.setup(t)}function c(d){e.setupView(t,d)}const l={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:l,setupLights:a,setupLightsView:c,pushLight:r,pushShadow:o}}function pM(s){let e=new WeakMap;function t(i,r=0){const o=e.get(i);let a;return o===void 0?(a=new Gf(s),e.set(i,[a])):r>=o.length?(a=new Gf(s),o.push(a)):a=o[r],a}function n(){e=new WeakMap}return{get:t,dispose:n}}const mM=`void main() { 3999 gl_Position = vec4( position, 1.0 ); 4000}`,gM=`uniform sampler2D shadow_pass; 4001uniform vec2 resolution; 4002uniform float radius; 4003void main() { 4004 const float samples = float( VSM_SAMPLES ); 4005 float mean = 0.0; 4006 float squared_mean = 0.0; 4007 float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); 4008 float uvStart = samples <= 1.0 ? 0.0 : - 1.0; 4009 for ( float i = 0.0; i < samples; i ++ ) { 4010 float uvOffset = uvStart + i * uvStride; 4011 #ifdef HORIZONTAL_PASS 4012 vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; 4013 mean += distribution.x; 4014 squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; 4015 #else 4016 float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; 4017 mean += depth; 4018 squared_mean += depth * depth; 4019 #endif 4020 } 4021 mean = mean / samples; 4022 squared_mean = squared_mean / samples; 4023 float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); 4024 gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); 4025}`,xM=[new D(1,0,0),new D(-1,0,0),new D(0,1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1)],yM=[new D(0,-1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1),new D(0,-1,0),new D(0,-1,0)],Wf=new Oe,so=new D,Ll=new D;function vM(s,e,t){let n=new Hr;const i=new xe,r=new xe,o=new bt,a=new lm,c=new ix,l={},d=t.maxTextureSize,u={[ii]:vn,[vn]:ii,[Tt]:Tt},h=new pn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new xe},radius:{value:4}},vertexShader:mM,fragmentShader:gM}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const m=new vt;m.setAttribute("position",new Rt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new Qe(m,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=So;let g=this.type;this.render=function(w,E,b){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||w.length===0)return;this.type===og&&(Ne("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=So);const S=s.getRenderTarget(),P=s.getActiveCubeFace(),A=s.getActiveMipmapLevel(),T=s.state;T.setBlending(bi),T.buffers.depth.getReversed()===!0?T.buffers.color.setClear(0,0,0,0):T.buffers.color.setClear(1,1,1,1),T.buffers.depth.setTest(!0),T.setScissorTest(!1);const I=g!==this.type;I&&E.traverse(function(k){k.material&&(Array.isArray(k.material)?k.material.forEach(F=>F.needsUpdate=!0):k.material.needsUpdate=!0)});for(let k=0,F=w.length;k<F;k++){const L=w[k],O=L.shadow;if(O===void 0){Ne("WebGLShadowMap:",L,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;i.copy(O.mapSize);const H=O.getFrameExtents();i.multiply(H),r.copy(O.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(r.x=Math.floor(d/H.x),i.x=r.x*H.x,O.mapSize.x=r.x),i.y>d&&(r.y=Math.floor(d/H.y),i.y=r.y*H.y,O.mapSize.y=r.y));const W=s.state.buffers.depth.getReversed();if(O.camera._reversedDepth=W,O.map===null||I===!0){if(O.map!==null&&(O.map.depthTexture!==null&&(O.map.depthTexture.dispose(),O.map.depthTexture=null),O.map.dispose()),this.type===go){if(L.isPointLight){Ne("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}O.map=new On(i.x,i.y,{format:Ur,type:Wn,minFilter:It,magFilter:It,generateMipmaps:!1}),O.map.texture.name=L.name+".shadowMap",O.map.depthTexture=new Go(i.x,i.y,En),O.map.depthTexture.name=L.name+".shadowMapDepth",O.map.depthTexture.format=Gi,O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=Ut,O.map.depthTexture.magFilter=Ut}else L.isPointLight?(O.map=new mm(i.x),O.map.depthTexture=new k0(i.x,si)):(O.map=new On(i.x,i.y),O.map.depthTexture=new Go(i.x,i.y,si)),O.map.depthTexture.name=L.name+".shadowMap",O.map.depthTexture.format=Gi,this.type===So?(O.map.depthTexture.compareFunction=W?Ld:Pd,O.map.depthTexture.minFilter=It,O.map.depthTexture.magFilter=It):(O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=Ut,O.map.depthTexture.magFilter=Ut);O.camera.updateProjectionMatrix()}
vendor: 9,256 bytes, line 4025
4025const q=O.map.isWebGLCubeRenderTarget?6:1;for(let Z=0;Z<q;Z++){if(O.map.isWebGLCubeRenderTarget)s.setRenderTarget(O.map,Z),s.clear();else{Z===0&&(s.setRenderTarget(O.map),s.clear());const V=O.getViewport(Z);o.set(r.x*V.x,r.y*V.y,r.x*V.z,r.y*V.w),T.viewport(o)}if(L.isPointLight){const V=O.camera,K=O.matrix,ce=L.distance||V.far;ce!==V.far&&(V.far=ce,V.updateProjectionMatrix()),so.setFromMatrixPosition(L.matrixWorld),V.position.copy(so),Ll.copy(V.position),Ll.add(xM[Z]),V.up.copy(yM[Z]),V.lookAt(Ll),V.updateMatrixWorld(),K.makeTranslation(-so.x,-so.y,-so.z),Wf.multiplyMatrices(V.projectionMatrix,V.matrixWorldInverse),O._frustum.setFromProjectionMatrix(Wf,V.coordinateSystem,V.reversedDepth)}else O.updateMatrices(L);n=O.getFrustum(),v(E,b,O.camera,L,this.type)}O.isPointLightShadow!==!0&&this.type===go&&y(O,b),O.needsUpdate=!1}g=this.type,p.needsUpdate=!1,s.setRenderTarget(S,P,A)};function y(w,E){const b=e.update(x);h.defines.VSM_SAMPLES!==w.blurSamples&&(h.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new On(i.x,i.y,{format:Ur,type:Wn})),h.uniforms.shadow_pass.value=w.map.depthTexture,h.uniforms.resolution.value=w.mapSize,h.uniforms.radius.value=w.radius,s.setRenderTarget(w.mapPass),s.clear(),s.renderBufferDirect(E,null,b,h,x,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,s.setRenderTarget(w.map),s.clear(),s.renderBufferDirect(E,null,b,f,x,null)}function _(w,E,b,S){let P=null;const A=b.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(A!==void 0)P=A;else if(P=b.isPointLight===!0?c:a,s.localClippingEnabled&&E.clipShadows===!0&&Array.isArray(E.clippingPlanes)&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0||E.map&&E.alphaTest>0||E.alphaToCoverage===!0){const T=P.uuid,I=E.uuid;let k=l[T];k===void 0&&(k={},l[T]=k);let F=k[I];F===void 0&&(F=P.clone(),k[I]=F,E.addEventListener("dispose",M)),P=F}if(P.visible=E.visible,P.wireframe=E.wireframe,S===go?P.side=E.shadowSide!==null?E.shadowSide:E.side:P.side=E.shadowSide!==null?E.shadowSide:u[E.side],P.alphaMap=E.alphaMap,P.alphaTest=E.alphaToCoverage===!0?.5:E.alphaTest,P.map=E.map,P.clipShadows=E.clipShadows,P.clippingPlanes=E.clippingPlanes,P.clipIntersection=E.clipIntersection,P.displacementMap=E.displacementMap,P.displacementScale=E.displacementScale,P.displacementBias=E.displacementBias,P.wireframeLinewidth=E.wireframeLinewidth,P.linewidth=E.linewidth,b.isPointLight===!0&&P.isMeshDistanceMaterial===!0){const T=s.properties.get(P);T.light=b}return P}function v(w,E,b,S,P){if(w.visible===!1)return;if(w.layers.test(E.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&P===go)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,w.matrixWorld);const I=e.update(w),k=w.material;if(Array.isArray(k)){const F=I.groups;for(let L=0,O=F.length;L<O;L++){const H=F[L],W=k[H.materialIndex];if(W&&W.visible){const q=_(w,W,S,P);w.onBeforeShadow(s,w,E,b,I,q,H),s.renderBufferDirect(b,null,I,q,w,H),w.onAfterShadow(s,w,E,b,I,q,H)}}}else if(k.visible){const F=_(w,k,S,P);w.onBeforeShadow(s,w,E,b,I,F,null),s.renderBufferDirect(b,null,I,F,w,null),w.onAfterShadow(s,w,E,b,I,F,null)}}const T=w.children;for(let I=0,k=T.length;I<k;I++)v(T[I],E,b,S,P)}function M(w){w.target.removeEventListener("dispose",M);for(const b in l){const S=l[b],P=w.target.uuid;P in S&&(S[P].dispose(),delete S[P])}}}function _M(s,e){function t(){let G=!1;const ye=new bt;let he=null;const Ae=new bt(0,0,0,0);return{setMask:function(de){he!==de&&!G&&(s.colorMask(de,de,de,de),he=de)},setLocked:function(de){G=de},setClear:function(de,ne,Re,Ze,_t){_t===!0&&(de*=Ze,ne*=Ze,Re*=Ze),ye.set(de,ne,Re,Ze),Ae.equals(ye)===!1&&(s.clearColor(de,ne,Re,Ze),Ae.copy(ye))},reset:function(){G=!1,he=null,Ae.set(-1,0,0,0)}}}function n(){let G=!1,ye=!1,he=null,Ae=null,de=null;return{setReversed:function(ne){if(ye!==ne){const Re=e.get("EXT_clip_control");ne?Re.clipControlEXT(Re.LOWER_LEFT_EXT,Re.ZERO_TO_ONE_EXT):Re.clipControlEXT(Re.LOWER_LEFT_EXT,Re.NEGATIVE_ONE_TO_ONE_EXT),ye=ne;const Ze=de;de=null,this.setClear(Ze)}},getReversed:function(){return ye},setTest:function(ne){ne?z(s.DEPTH_TEST):Y(s.DEPTH_TEST)},setMask:function(ne){he!==ne&&!G&&(s.depthMask(ne),he=ne)},setFunc:function(ne){if(ye&&(ne=Gg[ne]),Ae!==ne){switch(ne){case ru:s.depthFunc(s.NEVER);break;case ou:s.depthFunc(s.ALWAYS);break;case au:s.depthFunc(s.LESS);break;case Ir:s.depthFunc(s.LEQUAL);break;case cu:s.depthFunc(s.EQUAL);break;case lu:s.depthFunc(s.GEQUAL);break;case uu:s.depthFunc(s.GREATER);break;case du:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}Ae=ne}},setLocked:function(ne){G=ne},setClear:function(ne){de!==ne&&(de=ne,ye&&(ne=1-ne),s.clearDepth(ne))},reset:function(){G=!1,he=null,Ae=null,de=null,ye=!1}}}function i(){let G=!1,ye=null,he=null,Ae=null,de=null,ne=null,Re=null,Ze=null,_t=null;return{setTest:function(dt){G||(dt?z(s.STENCIL_TEST):Y(s.STENCIL_TEST))},setMask:function(dt){ye!==dt&&!G&&(s.stencilMask(dt),ye=dt)},setFunc:function(dt,Ti,Ei){(he!==dt||Ae!==Ti||de!==Ei)&&(s.stencilFunc(dt,Ti,Ei),he=dt,Ae=Ti,de=Ei)},setOp:function(dt,Ti,Ei){(ne!==dt||Re!==Ti||Ze!==Ei)&&(s.stencilOp(dt,Ti,Ei),ne=dt,Re=Ti,Ze=Ei)},setLocked:function(dt){G=dt},setClear:function(dt){_t!==dt&&(s.clearStencil(dt),_t=dt)},reset:function(){G=!1,ye=null,he=null,Ae=null,de=null,ne=null,Re=null,Ze=null,_t=null}}}const r=new t,o=new n,a=new i,c=new WeakMap,l=new WeakMap;let d={},u={},h=new WeakMap,f=[],m=null,x=!1,p=null,g=null,y=null,_=null,v=null,M=null,w=null,E=new ze(0,0,0),b=0,S=!1,P=null,A=null,T=null,I=null,k=null;const F=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let L=!1,O=0;const H=s.getParameter(s.VERSION);H.indexOf("WebGL")!==-1?(O=parseFloat(/^WebGL (\d)/.exec(H)[1]),L=O>=1):H.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),L=O>=2);let W=null,q={};const Z=s.getParameter(s.SCISSOR_BOX),V=s.getParameter(s.VIEWPORT),K=new bt().fromArray(Z),ce=new bt().fromArray(V);function $(G,ye,he,Ae){const de=new Uint8Array(4),ne=s.createTexture();s.bindTexture(G,ne),s.texParameteri(G,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(G,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Re=0;Re<he;Re++)G===s.TEXTURE_3D||G===s.TEXTURE_2D_ARRAY?s.texImage3D(ye,0,s.RGBA,1,1,Ae,0,s.RGBA,s.UNSIGNED_BYTE,de):s.texImage2D(ye+Re,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,de);return ne}const R={};R[s.TEXTURE_2D]=$(s.TEXTURE_2D,s.TEXTURE_2D,1),R[s.TEXTURE_CUBE_MAP]=$(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),R[s.TEXTURE_2D_ARRAY]=$(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),R[s.TEXTURE_3D]=$(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),z(s.DEPTH_TEST),o.setFunc(Ir),Ke(!1),Ye(bh),z(s.CULL_FACE),He(bi);function z(G){d[G]!==!0&&(s.enable(G),d[G]=!0)}function Y(G){d[G]!==!1&&(s.disable(G),d[G]=!1)}function ie(G,ye){return u[G]!==ye?(s.bindFramebuffer(G,ye),u[G]=ye,G===s.DRAW_FRAMEBUFFER&&(u[s.FRAMEBUFFER]=ye),G===s.FRAMEBUFFER&&(u[s.DRAW_FRAMEBUFFER]=ye),!0):!1}function re(G,ye){let he=f,Ae=!1;if(G){he=h.get(ye),he===void 0&&(he=[],h.set(ye,he));const de=G.textures;if(he.length!==de.length||he[0]!==s.COLOR_ATTACHMENT0){for(let ne=0,Re=de.length;ne<Re;ne++)he[ne]=s.COLOR_ATTACHMENT0+ne;he.length=de.length,Ae=!0}}else he[0]!==s.BACK&&(he[0]=s.BACK,Ae=!0);Ae&&s.drawBuffers(he)}function ge(G){return m!==G?(s.useProgram(G),m=G,!0):!1}const Fe={[Rs]:s.FUNC_ADD,[cg]:s.FUNC_SUBTRACT,[lg]:s.FUNC_REVERSE_SUBTRACT};Fe[ug]=s.MIN,Fe[dg]=s.MAX;const Ie={[hg]:s.ZERO,[fg]:s.ONE,[pg]:s.SRC_COLOR,[iu]:s.SRC_ALPHA,[_g]:s.SRC_ALPHA_SATURATE,[yg]:s.DST_COLOR,[gg]:s.DST_ALPHA,[mg]:s.ONE_MINUS_SRC_COLOR,[su]:s.ONE_MINUS_SRC_ALPHA,[vg]:s.ONE_MINUS_DST_COLOR,[xg]:s.ONE_MINUS_DST_ALPHA,[bg]:s.CONSTANT_COLOR,[Mg]:s.ONE_MINUS_CONSTANT_COLOR,[Sg]:s.CONSTANT_ALPHA,[wg]:s.ONE_MINUS_CONSTANT_ALPHA};function He(G,ye,he,Ae,de,ne,Re,Ze,_t,dt){if(G===bi){x===!0&&(Y(s.BLEND),x=!1);return}if(x===!1&&(z(s.BLEND),x=!0),G!==ag){if(G!==p||dt!==S){if((g!==Rs||v!==Rs)&&(s.blendEquation(s.FUNC_ADD),g=Rs,v=Rs),dt)switch(G){case wr:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Mh:s.blendFunc(s.ONE,s.ONE);break;case Sh:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case wh:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:We("WebGLState: Invalid blending: ",G);break}else switch(G){case wr:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Mh:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case Sh:We("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case wh:We("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:We("WebGLState: Invalid blending: ",G);break}y=null,_=null,M=null,w=null,E.set(0,0,0),b=0,p=G,S=dt}return}de=de||ye,ne=ne||he,Re=Re||Ae,(ye!==g||de!==v)&&(s.blendEquationSeparate(Fe[ye],Fe[de]),g=ye,v=de),(he!==y||Ae!==_||ne!==M||Re!==w)&&(s.blendFuncSeparate(Ie[he],Ie[Ae],Ie[ne],Ie[Re]),y=he,_=Ae,M=ne,w=Re),(Ze.equals(E)===!1||_t!==b)&&(s.blendColor
vendor: 3,234 bytes, line 4025
4025(Ze.r,Ze.g,Ze.b,_t),E.copy(Ze),b=_t),p=G,S=!1}function je(G,ye){G.side===Tt?Y(s.CULL_FACE):z(s.CULL_FACE);let he=G.side===vn;ye&&(he=!he),Ke(he),G.blending===wr&&G.transparent===!1?He(bi):He(G.blending,G.blendEquation,G.blendSrc,G.blendDst,G.blendEquationAlpha,G.blendSrcAlpha,G.blendDstAlpha,G.blendColor,G.blendAlpha,G.premultipliedAlpha),o.setFunc(G.depthFunc),o.setTest(G.depthTest),o.setMask(G.depthWrite),r.setMask(G.colorWrite);const Ae=G.stencilWrite;a.setTest(Ae),Ae&&(a.setMask(G.stencilWriteMask),a.setFunc(G.stencilFunc,G.stencilRef,G.stencilFuncMask),a.setOp(G.stencilFail,G.stencilZFail,G.stencilZPass)),pe(G.polygonOffset,G.polygonOffsetFactor,G.polygonOffsetUnits),G.alphaToCoverage===!0?z(s.SAMPLE_ALPHA_TO_COVERAGE):Y(s.SAMPLE_ALPHA_TO_COVERAGE)}function Ke(G){P!==G&&(G?s.frontFace(s.CW):s.frontFace(s.CCW),P=G)}function Ye(G){G!==sg?(z(s.CULL_FACE),G!==A&&(G===bh?s.cullFace(s.BACK):G===rg?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):Y(s.CULL_FACE),A=G}function U(G){G!==T&&(L&&s.lineWidth(G),T=G)}function pe(G,ye,he){G?(z(s.POLYGON_OFFSET_FILL),(I!==ye||k!==he)&&(I=ye,k=he,o.getReversed()&&(ye=-ye),s.polygonOffset(ye,he))):Y(s.POLYGON_OFFSET_FILL)}function Ce(G){G?z(s.SCISSOR_TEST):Y(s.SCISSOR_TEST)}function Ve(G){G===void 0&&(G=s.TEXTURE0+F-1),W!==G&&(s.activeTexture(G),W=G)}function _e(G,ye,he){he===void 0&&(W===null?he=s.TEXTURE0+F-1:he=W);let Ae=q[he];Ae===void 0&&(Ae={type:void 0,texture:void 0},q[he]=Ae),(Ae.type!==G||Ae.texture!==ye)&&(W!==he&&(s.activeTexture(he),W=he),s.bindTexture(G,ye||R[G]),Ae.type=G,Ae.texture=ye)}function B(){const G=q[W];G!==void 0&&G.type!==void 0&&(s.bindTexture(G.type,null),G.type=void 0,G.texture=void 0)}function C(){try{s.compressedTexImage2D(...arguments)}catch(G){We("WebGLState:",G)}}function X(){try{s.compressedTexImage3D(...arguments)}catch(G){We("WebGLState:",G)}}function se(){try{s.texSubImage2D(...arguments)}catch(G){We("WebGLState:",G)}}function oe(){try{s.texSubImage3D(...arguments)}catch(G){We("WebGLState:",G)}}function te(){try{s.compressedTexSubImage2D(...arguments)}catch(G){We("WebGLState:",G)}}function we(){try{s.compressedTexSubImage3D(...arguments)}catch(G){We("WebGLState:",G)}}function fe(){try{s.texStorage2D(...arguments)}catch(G){We("WebGLState:",G)}}function ke(){try{s.texStorage3D(...arguments)}catch(G){We("WebGLState:",G)}}function le(){try{s.texImage2D(...arguments)}catch(G){We("WebGLState:",G)}}function ae(){try{s.texImage3D(...arguments)}catch(G){We("WebGLState:",G)}}function ue(G){K.equals(G)===!1&&(s.scissor(G.x,G.y,G.z,G.w),K.copy(G))}function me(G){ce.equals(G)===!1&&(s.viewport(G.x,G.y,G.z,G.w),ce.copy(G))}function Pe(G,ye){let he=l.get(ye);he===void 0&&(he=new WeakMap,l.set(ye,he));let Ae=he.get(G);Ae===void 0&&(Ae=s.getUniformBlockIndex(ye,G.name),he.set(G,Ae))}function Te(G,ye){const Ae=l.get(ye).get(G);c.get(ye)!==Ae&&(s.uniformBlockBinding(ye,Ae,G.__bindingPointIndex),c.set(ye,Ae))}function tt(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor
vendor: 90,269 bytes, lines 4025-4049
4025(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),o.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),d={},W=null,q={},u={},h=new WeakMap,f=[],m=null,x=!1,p=null,g=null,y=null,_=null,v=null,M=null,w=null,E=new ze(0,0,0),b=0,S=!1,P=null,A=null,T=null,I=null,k=null,K.set(0,0,s.canvas.width,s.canvas.height),ce.set(0,0,s.canvas.width,s.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:z,disable:Y,bindFramebuffer:ie,drawBuffers:re,useProgram:ge,setBlending:He,setMaterial:je,setFlipSided:Ke,setCullFace:Ye,setLineWidth:U,setPolygonOffset:pe,setScissorTest:Ce,activeTexture:Ve,bindTexture:_e,unbindTexture:B,compressedTexImage2D:C,compressedTexImage3D:X,texImage2D:le,texImage3D:ae,updateUBOMapping:Pe,uniformBlockBinding:Te,texStorage2D:fe,texStorage3D:ke,texSubImage2D:se,texSubImage3D:oe,compressedTexSubImage2D:te,compressedTexSubImage3D:we,scissor:ue,viewport:me,reset:tt}}function bM(s,e,t,n,i,r,o){const a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new xe,d=new WeakMap;let u;const h=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(B,C){return f?new OffscreenCanvas(B,C):Ho("canvas")}function x(B,C,X){let se=1;const oe=_e(B);if((oe.width>X||oe.height>X)&&(se=X/Math.max(oe.width,oe.height)),se<1)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap||typeof VideoFrame<"u"&&B instanceof VideoFrame){const te=Math.floor(se*oe.width),we=Math.floor(se*oe.height);u===void 0&&(u=m(te,we));const fe=C?m(te,we):u;return fe.width=te,fe.height=we,fe.getContext("2d").drawImage(B,0,0,te,we),Ne("WebGLRenderer: Texture has been resized from ("+oe.width+"x"+oe.height+") to ("+te+"x"+we+")."),fe}else return"data"in B&&Ne("WebGLRenderer: Image in DataTexture is too big ("+oe.width+"x"+oe.height+")."),B;return B}function p(B){return B.generateMipmaps}function g(B){s.generateMipmap(B)}function y(B){return B.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:B.isWebGL3DRenderTarget?s.TEXTURE_3D:B.isWebGLArrayRenderTarget||B.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function _(B,C,X,se,oe=!1){if(B!==null){if(s[B]!==void 0)return s[B];Ne("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let te=C;if(C===s.RED&&(X===s.FLOAT&&(te=s.R32F),X===s.HALF_FLOAT&&(te=s.R16F),X===s.UNSIGNED_BYTE&&(te=s.R8)),C===s.RED_INTEGER&&(X===s.UNSIGNED_BYTE&&(te=s.R8UI),X===s.UNSIGNED_SHORT&&(te=s.R16UI),X===s.UNSIGNED_INT&&(te=s.R32UI),X===s.BYTE&&(te=s.R8I),X===s.SHORT&&(te=s.R16I),X===s.INT&&(te=s.R32I)),C===s.RG&&(X===s.FLOAT&&(te=s.RG32F),X===s.HALF_FLOAT&&(te=s.RG16F),X===s.UNSIGNED_BYTE&&(te=s.RG8)),C===s.RG_INTEGER&&(X===s.UNSIGNED_BYTE&&(te=s.RG8UI),X===s.UNSIGNED_SHORT&&(te=s.RG16UI),X===s.UNSIGNED_INT&&(te=s.RG32UI),X===s.BYTE&&(te=s.RG8I),X===s.SHORT&&(te=s.RG16I),X===s.INT&&(te=s.RG32I)),C===s.RGB_INTEGER&&(X===s.UNSIGNED_BYTE&&(te=s.RGB8UI),X===s.UNSIGNED_SHORT&&(te=s.RGB16UI),X===s.UNSIGNED_INT&&(te=s.RGB32UI),X===s.BYTE&&(te=s.RGB8I),X===s.SHORT&&(te=s.RGB16I),X===s.INT&&(te=s.RGB32I)),C===s.RGBA_INTEGER&&(X===s.UNSIGNED_BYTE&&(te=s.RGBA8UI),X===s.UNSIGNED_SHORT&&(te=s.RGBA16UI),X===s.UNSIGNED_INT&&(te=s.RGBA32UI),X===s.BYTE&&(te=s.RGBA8I),X===s.SHORT&&(te=s.RGBA16I),X===s.INT&&(te=s.RGBA32I)),C===s.RGB&&(X===s.UNSIGNED_INT_5_9_9_9_REV&&(te=s.RGB9_E5),X===s.UNSIGNED_INT_10F_11F_11F_REV&&(te=s.R11F_G11F_B10F)),C===s.RGBA){const we=oe?mc:it.getTransfer(se);X===s.FLOAT&&(te=s.RGBA32F),X===s.HALF_FLOAT&&(te=s.RGBA16F),X===s.UNSIGNED_BYTE&&(te=we===ut?s.SRGB8_ALPHA8:s.RGBA8),X===s.UNSIGNED_SHORT_4_4_4_4&&(te=s.RGBA4),X===s.UNSIGNED_SHORT_5_5_5_1&&(te=s.RGB5_A1)}return(te===s.R16F||te===s.R32F||te===s.RG16F||te===s.RG32F||te===s.RGBA16F||te===s.RGBA32F)&&e.get("EXT_color_buffer_float"),te}function v(B,C){let X;return B?C===null||C===si||C===ko?X=s.DEPTH24_STENCIL8:C===En?X=s.DEPTH32F_STENCIL8:C===Fo&&(X=s.DEPTH24_STENCIL8,Ne("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):C===null||C===si||C===ko?X=s.DEPTH_COMPONENT24:C===En?X=s.DEPTH_COMPONENT32F:C===Fo&&(X=s.DEPTH_COMPONENT16),X}function M(B,C){return p(B)===!0||B.isFramebufferTexture&&B.minFilter!==Ut&&B.minFilter!==It?Math.log2(Math.max(C.width,C.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?C.mipmaps.length:1}function w(B){const C=B.target;C.removeEventListener("dispose",w),b(C),C.isVideoTexture&&d.delete(C)}function E(B){const C=B.target;C.removeEventListener("dispose",E),P(C)}function b(B){const C=n.get(B);if(C.__webglInit===void 0)return;const X=B.source,se=h.get(X);if(se){const oe=se[C.__cacheKey];oe.usedTimes--,oe.usedTimes===0&&S(B),Object.keys(se).length===0&&h.delete(X)}n.remove(B)}function S(B){const C=n.get(B);s.deleteTexture(C.__webglTexture);const X=B.source,se=h.get(X);delete se[C.__cacheKey],o.memory.textures--}function P(B){const C=n.get(B);if(B.depthTexture&&(B.depthTexture.dispose(),n.remove(B.depthTexture)),B.isWebGLCubeRenderTarget)for(let se=0;se<6;se++){if(Array.isArray(C.__webglFramebuffer[se]))for(let oe=0;oe<C.__webglFramebuffer[se].length;oe++)s.deleteFramebuffer(C.__webglFramebuffer[se][oe]);else s.deleteFramebuffer(C.__webglFramebuffer[se]);C.__webglDepthbuffer&&s.deleteRenderbuffer(C.__webglDepthbuffer[se])}else{if(Array.isArray(C.__webglFramebuffer))for(let se=0;se<C.__webglFramebuffer.length;se++)s.deleteFramebuffer(C.__webglFramebuffer[se]);else s.deleteFramebuffer(C.__webglFramebuffer);if(C.__webglDepthbuffer&&s.deleteRenderbuffer(C.__webglDepthbuffer),C.__webglMultisampledFramebuffer&&s.deleteFramebuffer(C.__webglMultisampledFramebuffer),C.__webglColorRenderbuffer)for(let se=0;se<C.__webglColorRenderbuffer.length;se++)C.__webglColorRenderbuffer[se]&&s.deleteRenderbuffer(C.__webglColorRenderbuffer[se]);C.__webglDepthRenderbuffer&&s.deleteRenderbuffer(C.__webglDepthRenderbuffer)}const X=B.textures;for(let se=0,oe=X.length;se<oe;se++){const te=n.get(X[se]);te.__webglTexture&&(s.deleteTexture(te.__webglTexture),o.memory.textures--),n.remove(X[se])}n.remove(B)}let A=0;function T(){A=0}function I(){const B=A;return B>=i.maxTextures&&Ne("WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+i.maxTextures),A+=1,B}function k(B){const C=[];return C.push(B.wrapS),C.push(B.wrapT),C.push(B.wrapR||0),C.push(B.magFilter),C.push(B.minFilter),C.push(B.anisotropy),C.push(B.internalFormat),C.push(B.format),C.push(B.type),C.push(B.generateMipmaps),C.push(B.premultiplyAlpha),C.push(B.flipY),C.push(B.unpackAlignment),C.push(B.colorSpace),C.join()}function F(B,C){const X=n.get(B);if(B.isVideoTexture&&Ce(B),B.isRenderTargetTexture===!1&&B.isExternalTexture!==!0&&B.version>0&&X.__version!==B.version){const se=B.image;if(se===null)Ne("WebGLRenderer: Texture marked for update but no image data found.");else if(se.complete===!1)Ne("WebGLRenderer: Texture marked for update but image is incomplete");else{R(X,B,C);return}}else B.isExternalTexture&&(X.__webglTexture=B.sourceTexture?B.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,X.__webglTexture,s.TEXTURE0+C)}function L(B,C){const X=n.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&X.__version!==B.version){R(X,B,C);return}else B.isExternalTexture&&(X.__webglTexture=B.sourceTexture?B.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,X.__webglTexture,s.TEXTURE0+C)}function O(B,C){const X=n.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&X.__version!==B.version){R(X,B,C);return}t.bindTexture(s.TEXTURE_3D,X.__webglTexture,s.TEXTURE0+C)}function H(B,C){const X=n.get(B);if(B.isCubeDepthTexture!==!0&&B.version>0&&X.__version!==B.version){z(X,B,C);return}t.bindTexture(s.TEXTURE_CUBE_MAP,X.__webglTexture,s.TEXTURE0+C)}const W={[Nr]:s.REPEAT,[yi]:s.CLAMP_TO_EDGE,[pc]:s.MIRRORED_REPEAT},q={[Ut]:s.NEAREST,[zp]:s.NEAREST_MIPMAP_NEAREST,[xo]:s.NEAREST_MIPMAP_LINEAR,[It]:s.LINEAR,[nc]:s.LINEAR_MIPMAP_NEAREST,[vi]:s.LINEAR_MIPMAP_LINEAR},Z={[Dg]:s.NEVER,[kg]:s.ALWAYS,[Ng]:s.LESS,[Pd]:s.LEQUAL,[Ug]:s.EQUAL,[Ld]:s.GEQUAL,[Og]:s.GREATER,[Fg]:s.NOTEQUAL};function V(B,C){if(C.type===En&&e.has("OES_texture_float_linear")===!1&&(C.magFilter===It||C.magFilter===nc||C.magFilter===xo||C.magFilter===vi||C.minFilter===It||C.minFilter===nc||C.minFilter===xo||C.minFilter===vi)&&Ne("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(B,s.TEXTURE_WRAP_S,W[C.wrapS]),s.texParameteri(B,s.TEXTURE_WRAP_T,W[C.wrapT]),(B===s.TEXTURE_3D||B===s.TEXTURE_2D_ARRAY)&&s.texParameteri(B,s.TEXTURE_WRAP_R,W[C.wrapR]),s.texParameteri(B,s.TEXTURE_MAG_FILTER,q[C.magFilter]),s.texParameteri(B,s.TEXTURE_MIN_FILTER,q[C.minFilter]),C.compareFunction&&(s.texParameteri(B,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(B,s.TEXTURE_COMPARE_FUNC,Z[C.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(C.magFilter===Ut||C.minFilter!==xo&&C.minFilter!==vi||C.type===En&&e.has("OES_texture_float_linear")===!1)return;if(C.anisotropy>1||n.get(C).__currentAnisotropy){const X=e.get("EXT_texture_filter_anisotropic");s.texParameterf(B,X.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(C.anisotropy,i.getMaxAnisotropy())),n.get(C).__currentAnisotropy=C.anisotropy}}}function K(B,C){let X=!1;B.__webglInit===void 0&&(B.__webglInit=!0,C.addEventListener("dispose",w));const se=C.source;let oe=h.get(se);oe===void 0&&(oe={},h.set(se,oe));const te=k(C);if(te!==B.__cacheKey){oe[te]===void 0&&(oe[te]={texture:s.createTexture(),usedTimes:0},o.memory.textures++,X=!0),oe[te].usedTimes++;const we=oe[B.__cacheKey];we!==void 0&&(oe[B.__cacheKey].usedTimes--,we.usedTimes===0&&S(C)),B.__cacheKey=te,B.__webglTexture=oe[te].texture}return X}function ce(B,C,X){return Math.floor(Math.floor(B/X)/C)}function $(B,C,X,se){const te=B.updateRanges;if(te.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,C.width,C.height,X,se,C.data);else{te.sort((ae,ue)=>ae.start-ue.start);let we=0;for(let ae=1;ae<te.length;ae++){const ue=te[we],me=te[ae],Pe=ue.start+ue.count,Te=ce(me.start,C.width,4),tt=ce(ue.start,C.width,4);me.start<=Pe+1&&Te===tt&&ce(me.start+me.count-1,C.width,4)===Te?ue.count=Math.max(ue.count,me.start+me.count-ue.start):(++we,te[we]=me)}te.length=we+1;const fe=s.getParameter(s.UNPACK_ROW_LENGTH),ke=s.getParameter(s.UNPACK_SKIP_PIXELS),le=s.getParameter(s.UNPACK_SKIP_ROWS);s.pixelStorei(s.UNPACK_ROW_LENGTH,C.width);for(let ae=0,ue=te.length;ae<ue;ae++){const me=te[ae],Pe=Math.floor(me.start/4),Te=Math.ceil(me.count/4),tt=Pe%C.width,G=Math.floor(Pe/C.width),ye=Te,he=1;s.pixelStorei(s.UNPACK_SKIP_PIXELS,tt),s.pixelStorei(s.UNPACK_SKIP_ROWS,G),t.texSubImage2D(s.TEXTURE_2D,0,tt,G,ye,he,X,se,C.data)}B.clearUpdateRanges(),s.pixelStorei(s.UNPACK_ROW_LENGTH,fe),s.pixelStorei(s.UNPACK_SKIP_PIXELS,ke),s.pixelStorei(s.UNPACK_SKIP_ROWS,le)}}function R(B,C,X){let se=s.TEXTURE_2D;(C.isDataArrayTexture||C.isCompressedArrayTexture)&&(se=s.TEXTURE_2D_ARRAY),C.isData3DTexture&&(se=s.TEXTURE_3D);const oe=K(B,C),te=C.source;t.bindTexture(se,B.__webglTexture,s.TEXTURE0+X);const we=n.get(te);if(te.version!==we.__version||oe===!0){t.activeTexture(s.TEXTURE0+X);const fe=it.getPrimaries(it.workingColorSpace),ke=C.colorSpace===os?null:it.getPrimaries(C.colorSpace),le=C.colorSpace===os||fe===ke?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,C.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,C.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,C.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,le);let ae=x(C.image,!1,i.maxTextureSize);ae=Ve(C,ae);const ue=r.convert(C.format,C.colorSpace),me=r.convert(C.type);let Pe=_(C.internalFormat,ue,me,C.colorSpace,C.isVideoTexture);V(se,C);let Te;const tt=C.mipmaps,G=C.isVideoTexture!==!0,ye=we.__version===void 0||oe===!0,he=te.dataReady,Ae=M(C,ae);if(C.isDepthTexture)Pe=v(C.format===Ds,C.type),ye&&(G?t.texStorage2D(s.TEXTURE_2D,1,Pe,ae.width,ae.height):t.texImage2D(s.TEXTURE_2D,0,Pe,ae.width,ae.height,0,ue,me,null));else if(C.isDataTexture)if(tt.length>0){G&&ye&&t.texStorage2D(s.TEXTURE_2D,Ae,Pe,tt[0].width,tt[0].height);for(let de=0,ne=tt.length;de<ne;de++)Te=tt[de],G?he&&t.texSubImage2D(s.TEXTURE_2D,de,0,0,Te.width,Te.height,ue,me,Te.data):t.texImage2D(s.TEXTURE_2D,de,Pe,Te.width,Te.height,0,ue,me,Te.data);C.generateMipmaps=!1}else G?(ye&&t.texStorage2D(s.TEXTURE_2D,Ae,Pe,ae.width,ae.height),he&&$(C,ae,ue,me)):t.texImage2D(s.TEXTURE_2D,0,Pe,ae.width,ae.height,0,ue,me,ae.data);else if(C.isCompressedTexture)if(C.isCompressedArrayTexture){G&&ye&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Ae,Pe,tt[0].width,tt[0].height,ae.depth);for(let de=0,ne=tt.length;de<ne;de++)if(Te=tt[de],C.format!==An)if(ue!==null)if(G){if(he)if(C.layerUpdates.size>0){const Re=Mf(Te.width,Te.height,C.format,C.type);for(const Ze of C.layerUpdates){const _t=Te.data.subarray(Ze*Re/Te.data.BYTES_PER_ELEMENT,(Ze+1)*Re/Te.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,de,0,0,Ze,Te.width,Te.height,1,ue,_t)}C.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,de,0,0,0,Te.width,Te.height,ae.depth,ue,Te.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,de,Pe,Te.width,Te.height,ae.depth,0,Te.data,0,0);else Ne("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else G?he&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,de,0,0,0,Te.width,Te.height,ae.depth,ue,me,Te.data):t.texImage3D(s.TEXTURE_2D_ARRAY,de,Pe,Te.width,Te.height,ae.depth,0,ue,me,Te.data)}else{G&&ye&&t.texStorage2D(s.TEXTURE_2D,Ae,Pe,tt[0].width,tt[0].height);for(let de=0,ne=tt.length;de<ne;de++)Te=tt[de],C.format!==An?ue!==null?G?he&&t.compressedTexSubImage2D(s.TEXTURE_2D,de,0,0,Te.width,Te.height,ue,Te.data):t.compressedTexImage2D(s.TEXTURE_2D,de,Pe,Te.width,Te.height,0,Te.data):Ne("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):G?he&&t.texSubImage2D(s.TEXTURE_2D,de,0,0,Te.width,Te.height,ue,me,Te.data):t.texImage2D(s.TEXTURE_2D,de,Pe,Te.width,Te.height,0,ue,me,Te.data)}else if(C.isDataArrayTexture)if(G){if(ye&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Ae,Pe,ae.width,ae.height,ae.depth),he)if(C.layerUpdates.size>0){const de=Mf(ae.width,ae.height,C.format,C.type);for(const ne of C.layerUpdates){const Re=ae.data.subarray(ne*de/ae.data.BYTES_PER_ELEMENT,(ne+1)*de/ae.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,ne,ae.width,ae.height,1,ue,me,Re)}C.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,ae.width,ae.height,ae.depth,ue,me,ae.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,Pe,ae.width,ae.height,ae.depth,0,ue,me,ae.data);else if(C.isData3DTexture)G?(ye&&t.texStorage3D(s.TEXTURE_3D,Ae,Pe,ae.width,ae.height,ae.depth),he&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,ae.width,ae.height,ae.depth,ue,me,ae.data)):t.texImage3D(s.TEXTURE_3D,0,Pe,ae.width,ae.height,ae.depth,0,ue,me,ae.data);else if(C.isFramebufferTexture){if(ye)if(G)t.texStorage2D(s.TEXTURE_2D,Ae,Pe,ae.width,ae.height);else{let de=ae.width,ne=ae.height;for(let Re=0;Re<Ae;Re++)t.texImage2D(s.TEXTURE_2D,Re,Pe,de,ne,0,ue,me,null),de>>=1,ne>>=1}}else if(tt.length>0){if(G&&ye){const de=_e(tt[0]);t.texStorage2D(s.TEXTURE_2D,Ae,Pe,de.width,de.height)}for(let de=0,ne=tt.length;de<ne;de++)Te=tt[de],G?he&&t.texSubImage2D(s.TEXTURE_2D,de,0,0,ue,me,Te):t.texImage2D(s.TEXTURE_2D,de,Pe,ue,me,Te);C.generateMipmaps=!1}else if(G){if(ye){const de=_e(ae);t.texStorage2D(s.TEXTURE_2D,Ae,Pe,de.width,de.height)}he&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,ue,me,ae)}else t.texImage2D(s.TEXTURE_2D,0,Pe,ue,me,ae);p(C)&&g(se),we.__version=te.version,C.onUpdate&&C.onUpdate(C)}B.__version=C.version}function z(B,C,X){if(C.image.length!==6)return;const se=K(B,C),oe=C.source;t.bindTexture(s.TEXTURE_CUBE_MAP,B.__webglTexture,s.TEXTURE0+X);const te=n.get(oe);if(oe.version!==te.__version||se===!0){t.activeTexture(s.TEXTURE0+X);const we=it.getPrimaries(it.workingColorSpace),fe=C.colorSpace===os?null:it.getPrimaries(C.colorSpace),ke=C.colorSpace===os||we===fe?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,C.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,C.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,C.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,ke);const le=C.isCompressedTexture||C.image[0].isCompressedTexture,ae=C.image[0]&&C.image[0].isDataTexture,ue=[];for(let ne=0;ne<6;ne++)!le&&!ae?ue[ne]=x(C.image[ne],!0,i.maxCubemapSize):ue[ne]=ae?C.image[ne].image:C.image[ne],ue[ne]=Ve(C,ue[ne]);const me=ue[0],Pe=r.convert(C.format,C.colorSpace),Te=r.convert(C.type),tt=_(C.internalFormat,Pe,Te,C.colorSpace),G=C.isVideoTexture!==!0,ye=te.__version===void 0||se===!0,he=oe.dataReady;let Ae=M(C,me);V(s.TEXTURE_CUBE_MAP,C);let de;if(le){G&&ye&&t.texStorage2D(s.TEXTURE_CUBE_MAP,Ae,tt,me.width,me.height);for(let ne=0;ne<6;ne++){de=ue[ne].mipmaps;for(let Re=0;Re<de.length;Re++){const Ze=de[Re];C.format!==An?Pe!==null?G?he&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Re,0,0,Ze.width,Ze.height,Pe,Ze.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Re,tt,Ze.width,Ze.height,0,Ze.data):Ne("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):G?he&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Re,0,0,Ze.width,Ze.height,Pe,Te,Ze.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Re,tt,Ze.width,Ze.height,0,Pe,Te,Ze.data)}}}else{if(de=C.mipmaps,G&&ye){de.length>0&&Ae++;const ne=_e(ue[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,Ae,tt,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(ae){G?he&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,ue[ne].width,ue[ne].height,Pe,Te,ue[ne].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,tt,ue[ne].width,ue[ne].height,0,Pe,Te,ue[ne].data);for(let Re=0;Re<de.length;Re++){const _t=de[Re].image[ne].image;G?he&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Re+1,0,0,_t.width,_t.height,Pe,Te,_t.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Re+1,tt,_t.width,_t.height,0,Pe,Te,_t.data)}}else{G?he&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Pe,Te,ue[ne]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,tt,Pe,Te,ue[ne]);for(let Re=0;Re<de.length;Re++){const Ze=de[Re];G?he&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Re+1,0,0,Pe,Te,Ze.image[ne]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Re+1,tt,Pe,Te,Ze.image[ne])}}}p(C)&&g(s.TEXTURE_CUBE_MAP),te.__version=oe.version,C.onUpdate&&C.onUpdate(C)}B.__version=C.version}function Y(B,C,X,se,oe,te){const we=r.convert(X.format,X.colorSpace),fe=r.convert(X.type),ke=_(X.internalFormat,we,fe,X.colorSpace),le=n.get(C),ae=n.get(X);if(ae.__renderTarget=C,!le.__hasExternalTextures){const ue=Math.max(1,C.width>>te),me=Math.max(1,C.height>>te);oe===s.TEXTURE_3D||oe===s.TEXTURE_2D_ARRAY?t.texImage3D(oe,te,ke,ue,me,C.depth,0,we,fe,null):t.texImage2D(oe,te,ke,ue,me,0,we,fe,null)}t.bindFramebuffer(s.FRAMEBUFFER,B),pe(C)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,se,oe,ae.__webglTexture,0,U(C)):(oe===s.TEXTURE_2D||oe>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&oe<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,se,oe,ae.__webglTexture,te),t.bindFramebuffer(s.FRAMEBUFFER,null)}function ie(B,C,X){if(s.bindRenderbuffer(s.RENDERBUFFER,B),C.depthBuffer){const se=C.depthTexture,oe=se&&se.isDepthTexture?se.type:null,te=v(C.stencilBuffer,oe),we=C.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;pe(C)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,U(C),te,C.width,C.height):X?s.renderbufferStorageMultisample(s.RENDERBUFFER,U(C),te,C.width,C.height):s.renderbufferStorage(s.RENDERBUFFER,te,C.width,C.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,we,s.RENDERBUFFER,B)}else{const se=C.textures;for(let oe=0;oe<se.length;oe++){const te=se[oe],we=r.convert(te.format,te.colorSpace),fe=r.convert(te.type),ke=_(te.internalFormat,we,fe,te.colorSpace);pe(C)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,U(C),ke,C.width,C.height):X?s.renderbufferStorageMultisample(s.RENDERBUFFER,U(C),ke,C.width,C.height):s.renderbufferStorage(s.RENDERBUFFER,ke,C.width,C.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function re(B,C,X){const se=C.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(s.FRAMEBUFFER,B),!(C.depthTexture&&C.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const oe=n.get(C.depthTexture);if(oe.__renderTarget=C,(!oe.__webglTexture||C.depthTexture.image.width!==C.width||C.depthTexture.image.height!==C.height)&&(C.depthTexture.image.width=C.width,C.depthTexture.image.height=C.height,C.depthTexture.needsUpdate=!0),se){if(oe.__webglInit===void 0&&(oe.__webglInit=!0,C.depthTexture.addEventListener("dispose",w)),oe.__webglTexture===void 0){oe.__webglTexture=s.createTexture(),t.bindTexture(s.TEXTURE_CUBE_MAP,oe.__webglTexture),V(s.TEXTURE_CUBE_MAP,C.depthTexture);const le=r.convert(C.depthTexture.format),ae=r.convert(C.depthTexture.type);let ue;C.depthTexture.format===Gi?ue=s.DEPTH_COMPONENT24:C.depthTexture.format===Ds&&(ue=s.DEPTH24_STENCIL8);for(let me=0;me<6;me++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+me,0,ue,C.width,C.height,0,le,ae,null)}}else F(C.depthTexture,0);const te=oe.__webglTexture,we=U(C),fe=se?s.TEXTURE_CUBE_MAP_POSITIVE_X+X:s.TEXTURE_2D,ke=C.depthTexture.format===Ds?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(C.depthTexture.format===Gi)pe(C)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,ke,fe,te,0,we):s.framebufferTexture2D(s.FRAMEBUFFER,ke,fe,te,0);else if(C.depthTexture.format===Ds)pe(C)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,ke,fe,te,0,we):s.framebufferTexture2D(s.FRAMEBUFFER,ke,fe,te,0);else throw new Error("Unknown depthTexture format")}function ge(B){const C=n.get(B),X=B.isWebGLCubeRenderTarget===!0;if(C.__boundDepthTexture!==B.depthTexture){const se=B.depthTexture;if(C.__depthDisposeCallback&&C.__depthDisposeCallback(),se){const oe=()=>{delete C.__boundDepthTexture,delete C.__depthDisposeCallback,se.removeEventListener("dispose",oe)};se.addEventListener("dispose",oe),C.__depthDisposeCallback=oe}C.__boundDepthTexture=se}if(B.depthTexture&&!C.__autoAllocateDepthBuffer)if(X)for(let se=0;se<6;se++)re(C.__webglFramebuffer[se],B,se);else{const se=B.texture.mipmaps;se&&se.length>0?re(C.__webglFramebuffer[0],B,0):re(C.__webglFramebuffer,B,0)}else if(X){C.__webglDepthbuffer=[];for(let se=0;se<6;se++)if(t.bindFramebuffer(s.FRAMEBUFFER,C.__webglFramebuffer[se]),C.__webglDepthbuffer[se]===void 0)C.__webglDepthbuffer[se]=s.createRenderbuffer(),ie(C.__webglDepthbuffer[se],B,!1);else{const oe=B.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,te=C.__webglDepthbuffer[se];s.bindRenderbuffer(s.RENDERBUFFER,te),s.framebufferRenderbuffer(s.FRAMEBUFFER,oe,s.RENDERBUFFER,te)}}else{const se=B.texture.mipmaps;if(se&&se.length>0?t.bindFramebuffer(s.FRAMEBUFFER,C.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,C.__webglFramebuffer),C.__webglDepthbuffer===void 0)C.__webglDepthbuffer=s.createRenderbuffer(),ie(C.__webglDepthbuffer,B,!1);else{const oe=B.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,te=C.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,te),s.framebufferRenderbuffer(s.FRAMEBUFFER,oe,s.RENDERBUFFER,te)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Fe(B,C,X){const se=n.get(B);C!==void 0&&Y(se.__webglFramebuffer,B,B.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),X!==void 0&&ge(B)}function Ie(B){const C=B.texture,X=n.get(B),se=n.get(C);B.addEventListener("dispose",E);const oe=B.textures,te=B.isWebGLCubeRenderTarget===!0,we=oe.length>1;if(we||(se.__webglTexture===void 0&&(se.__webglTexture=s.createTexture()),se.__version=C.version,o.memory.textures++),te){X.__webglFramebuffer=[];for(let fe=0;fe<6;fe++)if(C.mipmaps&&C.mipmaps.length>0){X.__webglFramebuffer[fe]=[];for(let ke=0;ke<C.mipmaps.length;ke++)X.__webglFramebuffer[fe][ke]=s.createFramebuffer()}else X.__webglFramebuffer[fe]=s.createFramebuffer()}else{if(C.mipmaps&&C.mipmaps.length>0){X.__webglFramebuffer=[];for(let fe=0;fe<C.mipmaps.length;fe++)X.__webglFramebuffer[fe]=s.createFramebuffer()}else X.__webglFramebuffer=s.createFramebuffer();if(we)for(let fe=0,ke=oe.length;fe<ke;fe++){const le=n.get(oe[fe]);le.__webglTexture===void 0&&(le.__webglTexture=s.createTexture(),o.memory.textures++)}if(B.samples>0&&pe(B)===!1){X.__webglMultisampledFramebuffer=s.createFramebuffer(),X.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let fe=0;fe<oe.length;fe++){const ke=oe[fe];X.__webglColorRenderbuffer[fe]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,X.__webglColorRenderbuffer[fe]);const le=r.convert(ke.format,ke.colorSpace),ae=r.convert(ke.type),ue=_(ke.internalFormat,le,ae,ke.colorSpace,B.isXRRenderTarget===!0),me=U(B);s.renderbufferStorageMultisample(s.RENDERBUFFER,me,ue,B.width,B.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+fe,s.RENDERBUFFER,X.__webglColorRenderbuffer[fe])}s.bindRenderbuffer(s.RENDERBUFFER,null),B.depthBuffer&&(X.__webglDepthRenderbuffer=s.createRenderbuffer(),ie(X.__webglDepthRenderbuffer,B,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(te){t.bindTexture(s.TEXTURE_CUBE_MAP,se.__webglTexture),V(s.TEXTURE_CUBE_MAP,C);for(let fe=0;fe<6;fe++)if(C.mipmaps&&C.mipmaps.length>0)for(let ke=0;ke<C.mipmaps.length;ke++)Y(X.__webglFramebuffer[fe][ke],B,C,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+fe,ke);else Y(X.__webglFramebuffer[fe],B,C,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0);p(C)&&g(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(we){for(let fe=0,ke=oe.length;fe<ke;fe++){const le=oe[fe],ae=n.get(le);let ue=s.TEXTURE_2D;(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(ue=B.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(ue,ae.__webglTexture),V(ue,le),Y(X.__webglFramebuffer,B,le,s.COLOR_ATTACHMENT0+fe,ue,0),p(le)&&g(ue)}t.unbindTexture()}else{let fe=s.TEXTURE_2D;if((B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(fe=B.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(fe,se.__webglTexture),V(fe,C),C.mipmaps&&C.mipmaps.length>0)for(let ke=0;ke<C.mipmaps.length;ke++)Y(X.__webglFramebuffer[ke],B,C,s.COLOR_ATTACHMENT0,fe,ke);else Y(X.__webglFramebuffer,B,C,s.COLOR_ATTACHMENT0,fe,0);p(C)&&g(fe),t.unbindTexture()}B.depthBuffer&&ge(B)}function He(B){const C=B.textures;for(let X=0,se=C.length;X<se;X++){const oe=C[X];if(p(oe)){const te=y(B),we=n.get(oe).__webglTexture;t.bindTexture(te,we),g(te),t.unbindTexture()}}}const je=[],Ke=[];function Ye(B){if(B.samples>0){if(pe(B)===!1){const C=B.textures,X=B.width,se=B.height;let oe=s.COLOR_BUFFER_BIT;const te=B.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,we=n.get(B),fe=C.length>1;if(fe)for(let le=0;le<C.length;le++)t.bindFramebuffer(s.FRAMEBUFFER,we.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+le,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,we.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+le,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,we.__webglMultisampledFramebuffer);const ke=B.texture.mipmaps;ke&&ke.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,we.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,we.__webglFramebuffer);for(let le=0;le<C.length;le++){if(B.resolveDepthBuffer&&(B.depthBuffer&&(oe|=s.DEPTH_BUFFER_BIT),B.stencilBuffer&&B.resolveStencilBuffer&&(oe|=s.STENCIL_BUFFER_BIT)),fe){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,we.__webglColorRenderbuffer[le]);const ae=n.get(C[le]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,ae,0)}s.blitFramebuffer(0,0,X,se,0,0,X,se,oe,s.NEAREST),c===!0&&(je.length=0,Ke.length=0,je.push(s.COLOR_ATTACHMENT0+le),B.depthBuffer&&B.resolveDepthBuffer===!1&&(je.push(te),Ke.push(te),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Ke)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,je))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),fe)for(let le=0;le<C.length;le++){t.bindFramebuffer(s.FRAMEBUFFER,we.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+le,s.RENDERBUFFER,we.__webglColorRenderbuffer[le]);const ae=n.get(C[le]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,we.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+le,s.TEXTURE_2D,ae,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,we.__webglMultisampledFramebuffer)}else if(B.depthBuffer&&B.resolveDepthBuffer===!1&&c){const C=B.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[C])}}}function U(B){return Math.min(i.maxSamples,B.samples)}function pe(B){const C=n.get(B);return B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&C.__useRenderToTexture!==!1}function Ce(B){const C=o.render.frame;d.get(B)!==C&&(d.set(B,C),B.update())}function Ve(B,C){const X=B.colorSpace,se=B.format,oe=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||X!==mn&&X!==os&&(it.getTransfer(X)===ut?(se!==An||oe!==Nn)&&Ne("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):We("WebGLTextures: Unsupported texture color space:",X)),C}function _e(B){return typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement?(l.width=B.naturalWidth||B.width,l.height=B.naturalHeight||B.height):typeof VideoFrame<"u"&&B instanceof VideoFrame?(l.width=B.displayWidth,l.height=B.displayHeight):(l.width=B.width,l.height=B.height),l}this.allocateTextureUnit=I,this.resetTextureUnits=T,this.setTexture2D=F,this.setTexture2DArray=L,this.setTexture3D=O,this.setTextureCube=H,this.rebindTextures=Fe,this.setupRenderTarget=Ie,this.updateRenderTargetMipmap=He,this.updateMultisampleRenderTarget=Ye,this.setupDepthRenderbuffer=ge,this.setupFrameBufferTexture=Y,this.useMultisampledRTT=pe,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function MM(s,e){function t(n,i=os){let r;const o=it.getTransfer(i);if(n===Nn)return s.UNSIGNED_BYTE;if(n===Td)return s.UNSIGNED_SHORT_4_4_4_4;if(n===Ed)return s.UNSIGNED_SHORT_5_5_5_1;if(n===Gp)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===Wp)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===Vp)return s.BYTE;if(n===Hp)return s.SHORT;if(n===Fo)return s.UNSIGNED_SHORT;if(n===wd)return s.INT;if(n===si)return s.UNSIGNED_INT;if(n===En)return s.FLOAT;if(n===Wn)return s.HALF_FLOAT;if(n===Xp)return s.ALPHA;if(n===qp)return s.RGB;if(n===An)return s.RGBA;if(n===Gi)return s.DEPTH_COMPONENT;if(n===Ds)return s.DEPTH_STENCIL;if(n===Ad)return s.RED;if(n===Pc)return s.RED_INTEGER;if(n===Ur)return s.RG;if(n===Cd)return s.RG_INTEGER;if(n===Rd)return s.RGBA_INTEGER;if(n===ic||n===sc||n===rc||n===oc)if(o===ut)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===ic)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===sc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===rc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===oc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===ic)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===sc)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===rc)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===oc)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===hu||n===fu||n===pu||n===mu)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===hu)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===fu)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===pu)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===mu)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===gu||n===xu||n===yu||n===vu||n===_u||n===bu||n===Mu)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===gu||n===xu)return o===ut?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===yu)return o===ut?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===vu)return r.COMPRESSED_R11_EAC;if(n===_u)return r.COMPRESSED_SIGNED_R11_EAC;if(n===bu)return r.COMPRESSED_RG11_EAC;if(n===Mu)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Su||n===wu||n===Tu||n===Eu||n===Au||n===Cu||n===Ru||n===Pu||n===Lu||n===Iu||n===Du||n===Nu||n===Uu||n===Ou)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Su)return o===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===wu)return o===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Tu)return o===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Eu)return o===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Au)return o===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Cu)return o===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ru)return o===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Pu)return o===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Lu)return o===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Iu)return o===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Du)return o===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Nu)return o===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Uu)return o===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Ou)return o===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Fu||n===ku||n===Bu)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===Fu)return o===ut?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ku)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Bu)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===zu||n===Vu||n===Hu||n===Gu)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===zu)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Vu)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Hu)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Gu)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===ko?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}const SM=` 4026void main() { 4027 4028 gl_Position = vec4( position, 1.0 ); 4029 4030}`,wM=` 4031uniform sampler2DArray depthColor; 4032uniform float depthWidth; 4033uniform float depthHeight; 4034 4035void main() { 4036 4037 vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); 4038 4039 if ( coord.x >= 1.0 ) { 4040 4041 gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; 4042 4043 } else { 4044 4045 gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; 4046 4047 } 4048 4049}`;class TM{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new sm(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new pn({vertexShader:SM,fragmentShader:wM,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Qe(new Nc(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class EM extends ks{constructor(e,t){super();const n=this;let i=null,r=1,o=null,a="local-floor",c=1,l=null,d=null,u=null,h=null,f=null,m=null;const x=typeof XRWebGLBinding<"u",p=new TM,g={},y=t.getContextAttributes();let _=null,v=null;const M=[],w=[],E=new xe;let b=null;const S=new ln;S.viewport=new bt;const P=new ln;P.viewport=new bt;const A=[S,P],T=new Tx;let I=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(R){let z=M[R];return z===void 0&&(z=new Qc,M[R]=z),z.getTargetRaySpace()},this.getControllerGrip=function(R){let z=M[R];return z===void 0&&(z=new Qc,M[R]=z),z.getGripSpace()},this.getHand=function(R){let z=M[R];return z===void 0&&(z=new Qc,M[R]=z),z.getHandSpace()};function F(R){const z=w.indexOf(R.inputSource);if(z===-1)return;const Y=M[z];Y!==void 0&&(Y.update(R.inputSource,R.frame,l||o),Y.dispatchEvent({type:R.type,data:R.inputSource}))}function L(){i.removeEventListener("select",F),i.removeEventListener("selectstart",F),i.removeEventListener("selectend",F),i.removeEventListener("squeeze",F),i.removeEventListener("squeezestart",F),i.removeEventListener("squeezeend",F),i.removeEventListener("end",L),i.removeEventListener("inputsourceschange",O);for(let R=0;R<M.length;R++){const z=w[R];z!==null&&(w[R]=null,M[R].disconnect(z))}I=null,k=null,p.reset();for(const R in g)delete g[R];e.setRenderTarget(_),f=null,h=null,u=null,i=null,v=null,$.stop(),n.isPresenting=!1,e.setPixelRatio(b),e.setSize(E.width,E.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(R){r=R,n.isPresenting===!0&&Ne("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(R){a=R,n.isPresenting===!0&&Ne("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(R){l=R},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return u===null&&x&&(u=new XRWebGLBinding(i,t)),u},this.getFrame=function(){return m},this.getSession=function(){return i},this.setSession=async function(R){if(i=R,i!==null){if(_=e.getRenderTarget(),i.addEventListener("select",F),i.addEventListener("selectstart",F),i.addEventListener("selectend",F),i.addEventListener("squeeze",F),i.addEventListener("squeezestart",F),i.addEventListener("squeezeend",F),i.addEventListener("end",L),i.addEventListener("inputsourceschange",O),y.xrCompatible!==!0&&await t.makeXRCompatible(),b=e.getPixelRatio(),e.getSize(E),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let Y=null,ie=null,re=null;y.depth&&(re=y.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Y=y.stencil?Ds:Gi,ie=y.stencil?ko:si);const ge={colorFormat:t.RGBA8,depthFormat:re,scaleFactor:r};u=this.getBinding(),h=u.createProjectionLayer(ge),i.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),v=new On(h.textureWidth,h.textureHeight,{format:An,type:Nn,depthTexture:new Go(h.textureWidth,h.textureHeight,ie,void 0,void 0,void 0,void 0,void 0,void 0,Y),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1})}else{const Y={antialias:y.antialias,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,t,Y),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),v=new On(f.framebufferWidth,f.framebufferHeight,{format:An,type:Nn,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}v.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await i.requestReferenceSpace(a),$.setContext(i),$.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return p.getDepthTexture()};function O(R){for(let z=0;z<R.removed.length;z++){const Y=R.removed[z],ie=w.indexOf(Y);ie>=0&&(w[ie]=null,M[ie].disconnect(Y))}for(let z=0;z<R.added.length;z++){const Y=R.added[z];let ie=w.indexOf(Y);if(ie===-1){for(let ge=0;ge<M.length;ge++)if(ge>=w.length){w.push(Y),ie=ge;break}else if(w[ge]===null){w[ge]=Y,ie=ge;break}if(ie===-1)break}const re=M[ie];re&&re.connect(Y)}}const H=new D,W=new D;function q(R,z,Y){H.setFromMatrixPosition(z.matrixWorld),W.setFromMatrixPosition(Y.matrixWorld);const ie=H.distanceTo(W),re=z.projectionMatrix.elements,ge=Y.projectionMatrix.elements,Fe=re[14]/(re[10]-1),Ie=re[14]/(re[10]+1),He=(re[9]+1)/re[5],je=(re[9]-1)/re[5],Ke=(re[8]-1)/re[0],Ye=(ge[8]+1)/ge[0],U=Fe*Ke,pe=Fe*Ye,Ce=ie/(-Ke+Ye),Ve=Ce*-Ke;if(z.matrixWorld.decompose(R.position,R.quaternion,R.scale),R.translateX(Ve),R.translateZ(Ce),R.matrixWorld.compose(R.position,R.quaternion,R.scale),R.matrixWorldInverse.copy(R.matrixWorld).invert(),re[10]===-1)R.projectionMatrix.copy(z.projectionMatrix),R.projectionMatrixInverse.copy(z.projectionMatrixInverse);else{const _e=Fe+Ce,B=Ie+Ce,C=U-Ve,X=pe+(ie-Ve),se=He*Ie/B*_e,oe=je*Ie/B*_e;R.projectionMatrix.makePerspective(C,X,se,oe,_e,B),R.projectionMatrixInverse.copy(R.projectionMatrix).invert()}}function Z(R,z){z===null?R.matrixWorld.copy(R.matrix):R.matrixWorld.multiplyMatrices(z.matrixWorld,R.matrix),R.matrixWorldInverse.copy(R.matrixWorld).invert()}this.updateCamera=function(R){if(i===null)return;let z=R.near,Y=R.far;p.texture!==null&&(p.depthNear>0&&(z=p.depthNear),p.depthFar>0&&(Y=p.depthFar)),T.near=P.near=S.near=z,T.far=P.far=S.far=Y,(I!==T.near||k!==T.far)&&(i.updateRenderState({depthNear:T.near,depthFar:T.far}),I=T.near,k=T.far),T.layers.mask=R.layers.mask|6,S.layers.mask=T.layers.mask&-5,P.layers.mask=T.layers.mask&-3;const ie=R.parent,re=T.cameras;Z(T,ie);for(let ge=0;ge<re.length;ge++)Z(re[ge],ie);re.length===2?q(T,S,P):T.projectionMatrix.copy(S.projectionMatrix),V(R,T,ie)};function V(R,z,Y){Y===null?R.matrix.copy(z.matrixWorld):(R.matrix.copy(Y.matrixWorld),R.matrix.invert(),R.matrix.multiply(z.matrixWorld)),R.matrix.decompose(R.position,R.quaternion,R.scale),R.updateMatrixWorld(!0),R.projectionMatrix.copy(z.projectionMatrix),R.projectionMatrixInverse.copy(z.projectionMatrixInverse),R.isPerspectiveCamera&&(R.fov=Or*2*Math.atan(1/R.projectionMatrix.elements[5]),R.zoom=1)}this.getCamera=function(){return T},this.getFoveation=function(){if(!(h===null&&f===null))return c},this.setFoveation=function(R){c=R,h!==null&&(h.fixedFoveation=R),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=R)},this.hasDepthSensing=function(){return p.texture!==null},this.getDepthSensingMesh=function(){return p.getMesh(T)},this.getCameraTexture=function(R){return g[R]};let K=null;function ce(R,z){if(d=z.getViewerPose(l||o),m=z,d!==null){const Y=d.views;f!==null&&(e.setRenderTargetFramebuffer(v,f.framebuffer),e.setRenderTarget(v));let ie=!1;Y.length!==T.cameras.length&&(T.cameras.length=0,ie=!0);for(let Ie=0;Ie<Y.length;Ie++){const He=Y[Ie];let je=null;if(f!==null)je=f.getViewport(He);else{const Ye=u.getViewSubImage(h,He);je=Ye.viewport,Ie===0&&(e.setRenderTargetTextures(v,Ye.colorTexture,Ye.depthStencilTexture),e.setRenderTarget(v))}let Ke=A[Ie];Ke===void 0&&(Ke=new ln,Ke.layers.enable(Ie),Ke.viewport=new bt,A[Ie]=Ke),Ke.matrix.fromArray(He.transform.matrix),Ke.matrix.decompose(Ke.position,Ke.quaternion,Ke.scale),Ke.projectionMatrix.fromArray(He.projectionMatrix),Ke.projectionMatrixInverse.copy(Ke.projectionMatrix).invert(),Ke.viewport.set(je.x,je.y,je.width,je.height),Ie===0&&(T.matrix.copy(Ke.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale)),ie===!0&&T.cameras.push(Ke)}const re=i.enabledFeatures;if(re&&re.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&x){u=n.getBinding();const Ie=u.getDepthInformation(Y[0]);Ie&&Ie.isValid&&Ie.texture&&p.init(Ie,i.renderState)}if(re&&re.includes("camera-access")&&x){e.state.unbindTexture(),u=n.getBinding();for(let Ie=0;Ie<Y.length;Ie++){const He=Y[Ie].camera;if(He){let je=g[He];je||(je=new sm,g[He]=je);const Ke=u.getCameraImage(He);je.sourceTexture=Ke}}}}for(let Y=0;Y<M.length;Y++){const ie=w[Y],re=M[Y];ie!==null&&re!==void 0&&re.update(ie,z,l||o)}K&&K(R,z),z.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:z}),m=null}const $=new pm;$.setAnimationLoop(ce),this.setAnimationLoop=function(R){K=R},this.dispose=function(){}}}const Ss=new Xn,AM=new Oe;function CM(s,e){function t(p,g){p.matrixAutoUpdate===!0&&p.updateMatrix(),g.value.copy(p.matrix)}function n(p,g){g.color.getRGB(p.fogColor.value,am(s)),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function i(p,g,y,_,v){g.isMeshBasicMaterial?r(p,g):g.isMeshLambertMaterial?(r(p,g),g.envMap&&(p.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(r(p,g),u(p,g)):g.isMeshPhongMaterial?(r(p,g),d(p,g),g.envMap&&(p.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(r(p,g),h(p,g),g.isMeshPhysicalMaterial&&f(p,g,v)):g.isMeshMatcapMaterial?(r(p,g),m(p,g)):g.isMeshDepthMaterial?r(p,g):g.isMeshDistanceMaterial?(r(p,g),x(p,g)):g.isMeshNormalMaterial?r(p,g):g.isLineBasicMaterial?(o(p,g),g.isLineDashedMaterial&&a(p,g)):g.isPointsMaterial?c(p,g,y,_):g.isSpriteMaterial?l(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map,t(g.map,p.mapTransform)),g.alphaMap&&(p.alphaMap.value=g.alphaMap,t(g.alphaMap,p.alphaMapTransform)),g.bumpMap&&(p.bumpMap.value=g.bumpMap,t(g.bumpMap,p.bumpMapTransform),p.bumpScale.value=g.bumpScale,g.side===vn&&(p.bumpScale.value*=-1)),g.normalMap&&(p.normalMap.value=g.normalMap,t(g.normalMap,p.normalMapTransform),p.normalScale.value.copy(g.normalScale),g.side===vn&&p.normalScale.value.negate()),g.displacementMap&&(p.displacementMap.value=g.displacementMap,t(g.displacementMap,p.displacementMapTransform),p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,p.emissiveMapTransform)),g.specularMap&&(p.specularMap.value=g.specularMap,t(g.specularMap,p.specularMapTransform)),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);const y=e.get(g),_=y.envMap,v=y.envMapRotation;_&&(p.envMap.value=_,Ss.copy(v),Ss.x*=-1,Ss.y*=-1,Ss.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(Ss.y*=-1,Ss.z*=-1),p.envMapRotation.value.setFromMatrix4(AM.makeRotationFromEuler(Ss)),p.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap&&(p.lightMap.value=g.lightMap,p.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,p.lightMapTransform)),g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,p.aoMapTransform))}function o(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,g.map&&(p.map.value=g.map,t(g.map,p.mapTransform))}function a(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function c(p,g,y,_){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*y,p.scale.value=_*.5,g.map&&(p.map.value=g.map,t(g.map,p.uvTransform)),g.alphaMap&&(p.alphaMap.value=g.alphaMap,t(g.alphaMap,p.alphaMapTransform)),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest)}function l(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map,t(g.map,p.mapTransform)),g.alphaMap&&(p.alphaMap.value=g.alphaMap,t(g.alphaMap,p.alphaMapTransform)),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest)}function d(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function u(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function h(p,g){p.metalness.value=g.metalness,g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,p.metalnessMapTransform)),p.roughness.value=g.roughness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,p.roughnessMapTransform)),g.envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function f(p,g,y){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,p.sheenColorMapTransform)),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,p.sheenRoughnessMapTransform))),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,p.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(p.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===vn&&p.clearcoatNormalScale.value.negate())),g.dispersion>0&&(p.dispersion.value=g.dispersion),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,p.iridescenceMapTransform)),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,p.transmissionMapTransform)),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(p.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(p.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,p.specularColorMapTransform)),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,p.specularIntensityMapTransform))}function m(p,g){g.matcap&&(p.matcap.value=g.matcap)}function x(p,g){const y=e.get(g).light;p.referencePosition.value.setFromMatrixPosition(y.matrixWorld),p.nearDistance.value=y.shadow.camera.near,p.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function RM(s,e,t,n){let i={},r={},o=[];const a=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,_){const v=_.program;n.uniformBlockBinding(y,v)}function l(y,_){let v=i[y.id];v===void 0&&(m(y),v=d(y),i[y.id]=v,y.addEventListener("dispose",p));const M=_.program;n.updateUBOMapping(y,M);const w=e.render.frame;r[y.id]!==w&&(h(y),r[y.id]=w)}function d(y){const _=u();y.__bindingPointIndex=_;const v=s.createBuffer(),M=y.__size,w=y.usage;return s.bindBuffer(s.UNIFORM_BUFFER,v),s.bufferData(s.UNIFORM_BUFFER,M,w),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,_,v),v}function u(){for(let y=0;y<a;y++)if(o.indexOf(y)===-1)return o.push(y),y;return We("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(y){const _=i[y.id],v=y.uniforms,M=y.__cache;s.bindBuffer(s.UNIFORM_BUFFER,_);for(let w=0,E=v.length;w<E;w++){const b=Array.isArray(v[w])?v[w]:[v[w]];for(let S=0,P=b.length;S<P;S++){const A=b[S];if(f(A,w,S,M)===!0){const T=A.__offset,I=Array.isArray(A.value)?A.value:[A.value];let k=0;for(let F=0;F<I.length;F++){const L=I[F],O=x(L);typeof L=="number"||typeof L=="boolean"?(A.__data[0]=L,s.bufferSubData(s.UNIFORM_BUFFER,T+k,A.__data)):L.isMatrix3?(A.__data[0]=L.elements[0],A.__data[1]=L.elements[1],A.__data[2]=L.elements[2],A.__data[3]=0,A.__data[4]=L.elements[3],A.__data[5]=L.elements[4],A.__data[6]=L.elements[5],A.__data[7]=0,A.__data[8]=L.elements[6],A.__data[9]=L.elements[7],A.__data[10]=L.elements[8],A.__data[11]=0):(L.toArray(A.__data,k),k+=O.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,T,A.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(y,_,v,M){const w=y.value,E=_+"_"+v;if(M[E]===void 0)return typeof w=="number"||typeof w=="boolean"?M[E]=w:M[E]=w.clone(),!0;{const b=M[E];if(typeof w=="number"||typeof w=="boolean"){if(b!==w)return M[E]=w,!0}else if(b.equals(w)===!1)return b.copy(w),!0}return!1}function m(y){const _=y.uniforms;let v=0;const M=16;for(let E=0,b=_.length;E<b;E++){const S=Array.isArray(_[E])?_[E]:[_[E]];for(let P=0,A=S.length;P<A;P++){const T=S[P],I=Array.isArray(T.value)?T.value:[T.value];for(let k=0,F=I.length;k<F;k++){const L=I[k],O=x(L),H=v%M,W=H%O.boundary,q=H+W;v+=W,q!==0&&M-q<O.storage&&(v+=M-q),T.__data=new Float32Array(O.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=v,v+=O.storage}}}const w=v%M;return w>0&&(v+=M-w),y.__size=v,y.__cache={},this}function x(y){const _={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(_.boundary=4,_.storage=4):y.isVector2?(_.boundary=8,_.storage=8):y.isVector3||y.isColor?(_.boundary=16,_.storage=12):y.isVector4?(_.boundary=16,_.storage=16):y.isMatrix3?(_.boundary=48,_.storage=48):y.isMatrix4?(_.boundary=64,_.storage=64):y.isTexture?Ne("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Ne("WebGLRenderer: Unsupported uniform value type.",y),_}function p(y){const _=y.target;_.removeEventListener("dispose",p);const v=o.indexOf(_.__bindingPointIndex);o.splice(v,1),s.deleteBuffer(i[_.id]),delete i[_.id],delete r[_.id]}function g(){for(const y in i)s.deleteBuffer(i[y]);o=[],i={},r={}}return{bind:c,update:l,dispose:g}}const PM=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let di=null;function LM(){return di===null&&(di=new Er(PM,16,16,Ur,Wn),di.name="DFG_LUT",di.minFilter=It,di.magFilter=It,di.wrapS=yi,di.wrapT=yi,di.generateMipmaps=!1,di.needsUpdate=!0),di}class IM{constructor(e={}){const{canvas:t=Vg(),context:n=null,depth:i=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:h=!1,outputBufferType:f=Nn}=e;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=n.getContextAttributes().alpha}else m=o;const x=f,p=new Set([Rd,Cd,Pc]),g=new Set([Nn,si,Fo,ko,Td,Ed]),y=new Uint32Array(4),_=new Int32Array(4);let v=null,M=null;const w=[],E=[];let b=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ti,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const S=this;let P=!1;this._outputColorSpace=At;let A=0,T=0,I=null,k=-1,F=null;const L=new bt,O=new bt;let H=null;const W=new ze(0);let q=0,Z=t.width,V=t.height,K=1,ce=null,$=null;const R=new bt(0,0,Z,V),z=new bt(0,0,Z,V);let Y=!1;const ie=new Hr;let re=!1,ge=!1;const Fe=new Oe,Ie=new D,He=new bt,je={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ke=!1;function Ye(){return I===null?K:1}let U=n;function pe(N,j){return t.getContext(N,j)}try{const N={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:d,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ko}`),t.addEventListener("webglcontextlost",Re,!1),t.addEventListener("webglcontextrestored",Ze,!1),t.addEventListener("webglcontextcreationerror",_t,!1),U===null){const j="webgl2";if(U=pe(j,N),U===null)throw pe(j)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(N){throw We("WebGLRenderer: "+N.message),N}let Ce,Ve,_e,B,C,X,se,oe,te,we,fe,ke,le,ae,ue,me,Pe,Te,tt,G,ye,he,Ae;function de(){Ce=new I_(U),Ce.init(),ye=new MM(U,Ce),Ve=new w_(U,Ce,e,ye),_e=new _M(U,Ce),Ve.reversedDepthBuffer&&h&&_e.buffers.depth.setReversed(!0),B=new U_(U),C=new oM,X=new bM(U,Ce,_e,C,Ve,ye,B),se=new L_(S),oe=new zx(U),he=new M_(U,oe),te=new D_(U,oe,B,he),we=new F_(U,te,oe,he,B),Te=new O_(U,Ve,X),ue=new T_(C),fe=new rM(S,se,Ce,Ve,he,ue),ke=new CM(S,C),le=new cM,ae=new pM(Ce),Pe=new b_(S,se,_e,we,m,c),me=new vM(S,we,Ve),Ae=new RM(U,B,Ve,_e),tt=new S_(U,Ce,B),G=new N_(U,Ce,B),B.programs=fe.programs,S.capabilities=Ve,S.extensions=Ce,S.properties=C,S.renderLists=le,S.shadowMap=me,S.state=_e,S.info=B}de(),x!==Nn&&(b=new B_(x,t.width,t.height,i,r));const ne=new EM(S,U);this.xr=ne,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){const N=Ce.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){const N=Ce.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return K},this.setPixelRatio=function(N){N!==void 0&&(K=N,this.setSize(Z,V,!1))},this.getSize=function(N){return N.set(Z,V)},this.setSize=function(N,j,ee=!0){if(ne.isPresenting){Ne("WebGLRenderer: Can't change size while VR device is presenting.");return}Z=N,V=j,t.width=Math.floor(N*K),t.height=Math.floor(j*K),ee===!0&&(t.style.width=N+"px",t.style.height=j+"px"),b!==null&&b.setSize(t.width,t.height),this.setViewport(0,0,N,j)},this.getDrawingBufferSize=function(N){return N.set(Z*K,V*K).floor()},this.setDrawingBufferSize=function(N,j,ee){Z=N,V=j,K=ee,t.width=Math.floor(N*ee),t.height=Math.floor(j*ee),this.setViewport(0,0,N,j)},this.setEffects=function(N){if(x===Nn){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(N){for(let j=0;j<N.length;j++)if(N[j].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}b.setEffects(N||[])},this.getCurrentViewport=function(N){return N.copy(L)},this.getViewport=function(N){return N.copy(R)},this.setViewport=function(N,j,ee,Q){N.isVector4?R.set(N.x,N.y,N.z,N.w):R.set(N,j,ee,Q),_e.viewport(L.copy(R).multiplyScalar(K).round())},this.getScissor=function(N){return N.copy(z)},this.setScissor=function(N,j,ee,Q){N.isVector4?z.set(N.x,N.y,N.z,N.w):z.set(N,j,ee,Q),_e.scissor(O.copy(z).multiplyScalar(K).round())},this.getScissorTest=function(){return Y},this.setScissorTest=function(N){_e.setScissorTest(Y=N)},this.setOpaqueSort=function(N){ce=N},this.setTransparentSort=function(N){$=N},this.getClearColor=function(N){return N.copy(Pe.getClearColor())},this.setClearColor=function(){Pe.setClearColor(...arguments)},this.getClearAlpha=function(){return Pe.getClearAlpha()},this.setClearAlpha=function(){Pe.setClearAlpha(...arguments)},this.clear=function(N=!0,j=!0,ee=!0){let Q=0;if(N){let J=!1;if(I!==null){const be=I.texture.format;J=p.has(be)}if(J){const be=I.texture.type,Ee=g.has(be),Me=Pe.getClearColor(),Le=Pe.getClearAlpha(),Ue=Me.r,Je=Me.g,nt=Me.b;Ee?(y[0]=Ue,y[1]=Je,y[2]=nt,y[3]=Le,U.clearBufferuiv(U.COLOR,0,y)):(_[0]=Ue,_[1]=Je,_[2]=nt,_[3]=Le,U.clearBufferiv(U.COLOR,0,_))}else Q|=U.COLOR_BUFFER_BIT}j&&(Q|=U.DEPTH_BUFFER_BIT),ee&&(Q|=U.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Q!==0&&U.clear(Q)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Re,!1),t.removeEventListener("webglcontextrestored",Ze,!1),t.removeEventListener("webglcontextcreationerror",_t,!1),Pe.dispose(),le.dispose(),ae.dispose(),C.dispose(),se.dispose(),we.dispose(),he.dispose(),Ae.dispose(),fe.dispose(),ne.dispose(),ne.removeEventListener("sessionstart",fh),ne.removeEventListener("sessionend",ph),ps.stop()};function Re(N){N.preventDefault(),gc("WebGLRenderer: Context Lost."),P=!0}function Ze(){gc("WebGLRenderer: Context Restored."),P=!1;const N=B.autoReset,j=me.enabled,ee=me.autoUpdate,Q=me.needsUpdate,J=me.type;de(),B.autoReset=N,me.enabled=j,me.autoUpdate=ee,me.needsUpdate=Q,me.type=J}function _t(N){We("WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function dt(N){const j=N.target;j.removeEventListener("dispose",dt),Ti(j)}function Ti(N){Ei(N),C.remove(N)}function Ei(N){const j=C.get(N).programs;j!==void 0&&(j.forEach(function(ee){fe.releaseProgram(ee)}),N.isShaderMaterial&&fe.releaseShaderCache(N))}this.renderBufferDirect=function(N,j,ee,Q,J,be){j===null&&(j=je);const Ee=J.isMesh&&J.matrixWorld.determinant()<0,Me=Qm(N,j,ee,Q,J);_e.setMaterial(Q,Ee);let Le=ee.index,Ue=1;if(Q.wireframe===!0){if(Le=te.getWireframeAttribute(ee),Le===void 0)return;Ue=2}const Je=ee.drawRange,nt=ee.attributes.position;let Be=Je.start*Ue,mt=(Je.start+Je.count)*Ue;be!==null&&(Be=Math.max(Be,be.start*Ue),mt=Math.min(mt,(be.start+be.count)*Ue)),Le!==null?(Be=Math.max(Be,0),mt=Math.min(mt,Le.count)):nt!=null&&(Be=Math.max(Be,0),mt=Math.min(mt,nt.count));const Dt=mt-Be;if(Dt<0||Dt===1/0)return;he.setup(J,Q,Me,ee,Le);let Pt,gt=tt;if(Le!==null&&(Pt=oe.get(Le),gt=G,gt.setIndex(Pt)),J.isMesh)Q.wireframe===!0?(_e.setLineWidth(Q.wireframeLinewidth*Ye()),gt.setMode(U.LINES)):gt.setMode(U.TRIANGLES);else if(J.isLine){let rn=Q.linewidth;rn===void 0&&(rn=1),_e.setLineWidth(rn*Ye()),J.isLineSegments?gt.setMode(U.LINES):J.isLineLoop?gt.setMode(U.LINE_LOOP):gt.setMode(U.LINE_STRIP)}else J.isPoints?gt.setMode(U.POINTS):J.isSprite&>.setMode(U.TRIANGLES);if(J.isBatchedMesh)if(J._multiDrawInstances!==null)xc("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),gt.renderMultiDrawInstances(J._multiDrawStarts,J._multiDrawCounts,J._multiDrawCount,J._multiDrawInstances);else if(Ce.get("WEBGL_multi_draw"))gt.renderMultiDraw(J._multiDrawStarts,J._multiDrawCounts,J._multiDrawCount);else{const rn=J._multiDrawStarts,De=J._multiDrawCounts,Pn=J._multiDrawCount,lt=Le?oe.get(Le).bytesPerElement:1,jn=C.get(Q).currentProgram.getUniforms();for(let ai=0;ai<Pn;ai++)jn.setValue(U,"_gl_DrawID",ai),gt.render(rn[ai]/lt,De[ai])}else if(J.isInstancedMesh)gt.renderInstances(Be,Dt,J.count);else if(ee.isInstancedBufferGeometry){const rn=ee._maxInstanceCount!==void 0?ee._maxInstanceCount:1/0,De=Math.min(ee.instanceCount,rn);gt.renderInstances(Be,Dt,De)}else gt.render(Be,Dt)};function hh(N,j,ee){N.transparent===!0&&N.side===Tt&&N.forceSinglePass===!1?(N.side=vn,N.needsUpdate=!0,$o(N,j,ee),N.side=ii,N.needsUpdate=!0,$o(N,j,ee),N.side=Tt):$o(N,j,ee)}this.compile=function(N,j,ee=null){ee===null&&(ee=N),M=ae.get(ee),M.init(j),E.push(M),ee.traverseVisible(function(J){J.isLight&&J.layers.test(j.layers)&&(M.pushLight(J),J.castShadow&&M.pushShadow(J))}),N!==ee&&N.traverseVisible(function(J){J.isLight&&J.layers.test(j.layers)&&(M.pushLight(J),J.castShadow&&M.pushShadow(J))}),M.setupLights();const Q=new Set;return N.traverse(function(J){if(!(J.isMesh||J.isPoints||J.isLine||J.isSprite))return;const be=J.material;if(be)if(Array.isArray(be))for(let Ee=0;Ee<be.length;Ee++){const Me=be[Ee];hh(Me,ee,J),Q.add(Me)}else hh(be,ee,J),Q.add(be)}),M=E.pop(),Q},this.compileAsync=function(N,j,ee=null){const Q=this.compile(N,j,ee);return new Promise(J=>{function be(){if(Q.forEach(function(Ee){C.get(Ee).currentProgram.isReady()&&Q.delete(Ee)}),Q.size===0){J(N);return}setTimeout(be,10)}Ce.get("KHR_parallel_shader_compile")!==null?be():setTimeout(be,10)})};let Hc=null;function Jm(N){Hc&&Hc(N)}function fh(){ps.stop()}function ph(){ps.start()}const ps=new pm;ps.setAnimationLoop(Jm),typeof self<"u"&&ps.setContext(self),this.setAnimationLoop=function(N){Hc=N,ne.setAnimationLoop(N),N===null?ps.stop():ps.start()},ne.addEventListener("sessionstart",fh),ne.addEventListener("sessionend",ph),this.render=function(N,j){if(j!==void 0&&j.isCamera!==!0){We("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;const ee=ne.enabled===!0&&ne.isPresenting===!0,Q=b!==null&&(I===null||ee)&&b.begin(S,I);if(N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),j.parent===null&&j.matrixWorldAutoUpdate===!0&&j.updateMatrixWorld(),ne.enabled===!0&&ne.isPresenting===!0&&(b===null||b.isCompositing()===!1)&&(ne.cameraAutoUpdate===!0&&ne.updateCamera(j),j=ne.getCamera()),N.isScene===!0&&N.onBeforeRender(S,N,j,I),M=ae.get(N,E.length),M.init(j),E.push(M),Fe.multiplyMatrices(j.projectionMatrix,j.matrixWorldInverse),ie.setFromProjectionMatrix(Fe,$n,j.reversedDepth),ge=this.localClippingEnabled,re=ue.init(this.clippingPlanes,ge),v=le.get(N,w.length),v.init(),w.push(v),ne.enabled===!0&&ne.isPresenting===!0){const Ee=S.xr.getDepthSensingMesh();Ee!==null&&Gc(Ee,j,-1/0,S.sortObjects)}Gc(N,j,0,S.sortObjects),v.finish(),S.sortObjects===!0&&v.sort(ce,$),Ke=ne.enabled===!1||ne.isPresenting===!1||ne.hasDepthSensing()===!1,Ke&&Pe.addToRenderList(v,N),this.info.render.frame++,re===!0&&ue.beginShadows();const J=M.state.shadowsArray;if(me.render(J,N,j),re===!0&&ue.endShadows(),this.info.autoReset===!0&&this.info.reset(),(Q&&b.hasRenderPass())===!1){const Ee=v.opaque,Me=v.transmissive;if(M.setupLights(),j.isArrayCamera){const Le=j.cameras;if(Me.length>0)for(let Ue=0,Je=Le.length;Ue<Je;Ue++){const nt=Le[Ue];gh(Ee,Me,N,nt)}Ke&&Pe.render(N);for(let Ue=0,Je=Le.length;Ue<Je;Ue++){const nt=Le[Ue];mh(v,N,nt,nt.viewport)}}else Me.length>0&&gh(Ee,Me,N,j),Ke&&Pe.render(N),mh(v,N,j)}I!==null&&T===0&&(X.updateMultisampleRenderTarget(I),X.updateRenderTargetMipmap(I)),Q&&b.end(S),N.isScene===!0&&N.onAfterRender(S,N,j),he.resetDefaultState(),k=-1,F=null,E.pop(),E.length>0?(M=E[E.length-1],re===!0&&ue.setGlobalState(S.clippingPlanes,M.state.camera)):M=null,w.pop(),w.length>0?v=w[w.length-1]:v=null};function Gc(N,j,ee,Q){if(N.visible===!1)return;if(N.layers.test(j.layers)){if(N.isGroup)ee=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(j);else if(N.isLight)M.pushLight(N),N.castShadow&&M.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||ie.intersectsSprite(N)){Q&&He.setFromMatrixPosition(N.matrixWorld).applyMatrix4(Fe);const Ee=we.update(N),Me=N.material;Me.visible&&v.push(N,Ee,Me,ee,He.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(!N.frustumCulled||ie.intersectsObject(N))){const Ee=we.update(N),Me=N.material;if(Q&&(N.boundingSphere!==void 0?(N.boundingSphere===null&&N.computeBoundingSphere(),He.copy(N.boundingSphere.center)):(Ee.boundingSphere===null&&Ee.computeBoundingSphere(),He.copy(Ee.boundingSphere.center)),He.applyMatrix4(N.matrixWorld).applyMatrix4(Fe)),Array.isArray(Me)){const Le=Ee.groups;for(let Ue=0,Je=Le.length;Ue<Je;Ue++){const nt=Le[Ue],Be=Me[nt.materialIndex];Be&&Be.visible&&v.push(N,Ee,Be,ee,He.z,nt)}}else Me.visible&&v.push(N,Ee,Me,ee,He.z,null)}}const be=N.children;for(let Ee=0,Me=be.length;Ee<Me;Ee++)Gc(be[Ee],j,ee,Q)}function mh(N,j,ee,Q){const{opaque:J,transmissive:be,transparent:Ee}=N;M.setupLightsView(ee),re===!0&&ue.setGlobalState(S.clippingPlanes,ee),Q&&_e.viewport(L.copy(Q)),J.length>0&&Qo(J,j,ee),be.length>0&&Qo(be,j,ee),Ee.length>0&&Qo(Ee,j,ee),_e.buffers.depth.setTest(!0),_e.buffers.depth.setMask(!0),_e.buffers.color.setMask(!0),_e.setPolygonOffset(!1)}function gh(N,j,ee,Q){if((ee.isScene===!0?ee.overrideMaterial:null)!==null)return;if(M.state.transmissionRenderTarget[Q.id]===void 0){const Be=Ce.has("EXT_color_buffer_half_float")||Ce.has("EXT_color_buffer_float");M.state.transmissionRenderTarget[Q.id]=new On(1,1,{generateMipmaps:!0,type:Be?Wn:Nn,minFilter:vi,samples:Math.max(4,Ve.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:it.workingColorSpace})}const be=M.state.transmissionRenderTarget[Q.id],Ee=Q.viewport||L;be.setSize(Ee.z*S.transmissionResolutionScale,Ee.w*S.transmissionResolutionScale);const Me=S.getRenderTarget(),Le=S.getActiveCubeFace(),Ue=S.getActiveMipmapLevel();S.setRenderTarget(be),S.getClearColor(W),q=S.getClearAlpha(),q<1&&S.setClearColor(16777215,.5),S.clear(),Ke&&Pe.render(ee);const Je=S.toneMapping;S.toneMapping=ti;const nt=Q.viewport;if(Q.viewport!==void 0&&(Q.viewport=void 0),M.setupLightsView(Q),re===!0&&ue.setGlobalState(S.clippingPlanes,Q),Qo(N,ee,Q),X.updateMultisampleRenderTarget(be),X.updateRenderTargetMipmap(be),Ce.has("WEBGL_multisampled_render_to_texture")===!1){let Be=!1;for(let mt=0,Dt=j.length;mt<Dt;mt++){const Pt=j[mt],{object:gt,geometry:rn,material:De,group:Pn}=Pt;if(De.side===Tt&>.layers.test(Q.layers)){const lt=De.side;De.side=vn,De.needsUpdate=!0,xh(gt,ee,Q,rn,De,Pn),De.side=lt,De.needsUpdate=!0,Be=!0}}Be===!0&&(X.updateMultisampleRenderTarget(be),X.updateRenderTargetMipmap(be))}S.setRenderTarget(Me,Le,Ue),S.setClearColor(W,q),nt!==void 0&&(Q.viewport=nt),S.toneMapping=Je}function Qo(N,j,ee){const Q=j.isScene===!0?j.overrideMaterial:null;for(let J=0,be=N.length;J<be;J++){const Ee=N[J],{object:Me,geometry:Le,group:Ue}=Ee;let Je=Ee.material;Je.allowOverride===!0&&Q!==null&&(Je=Q),Me.layers.test(ee.layers)&&xh(Me,j,ee,Le,Je,Ue)}}function xh(N,j,ee,Q,J,be){N.onBeforeRender(S,j,ee,Q,J,be),N.modelViewMatrix.multiplyMatrices(ee.matrixWorldInverse,N.matrixWorld),N.normalMatrix.getNormalMatrix(N.modelViewMatrix),J.onBeforeRender(S,j,ee,Q,N,be),J.transparent===!0&&J.side===Tt&&J.forceSinglePass===!1?(J.side=vn,J.needsUpdate=!0,S.renderBufferDirect(ee,j,Q,J,N,be),J.side=ii,J.needsUpdate=!0,S.renderBufferDirect(ee,j,Q,J,N,be),J.side=Tt):S.renderBufferDirect(ee,j,Q,J,N,be),N.onAfterRender(S,j,ee,Q,J,be)}function $o(N,j,ee){j.isScene!==!0&&(j=je);const Q=C.get(N),J=M.state.lights,be=M.state.shadowsArray,Ee=J.state.version,Me=fe.getParameters(N,J.state,be,j,ee),Le=fe.getProgramCacheKey(Me);let Ue=Q.programs;Q.environment=N.isMeshStandardMaterial||N.isMeshLambertMaterial||N.isMeshPhongMaterial?j.environment:null,Q.fog=j.fog;const Je=N.isMeshStandardMaterial||N.isMeshLambertMaterial&&!N.envMap||N.isMeshPhongMaterial&&!N.envMap;Q.envMap=se.get(N.envMap||Q.environment,Je),Q.envMapRotation=Q.environment!==null&&N.envMap===null?j.environmentRotation:N.envMapRotation,Ue===void 0&&(N.addEventListener("dispose",dt),Ue=new Map,Q.programs=Ue);let nt=Ue.get(Le);if(nt!==void 0){if(Q.currentProgram===nt&&Q.lightsStateVersion===Ee)return vh(N,Me),nt}else Me.uniforms=fe.getUniforms(N),N.onBeforeCompile(Me,S),nt=fe.acquireProgram(Me,Le),Ue.set(Le,nt),Q.uniforms=Me.uniforms;const Be=Q.uniforms;return(!N.isShaderMaterial&&!N.isRawShaderMaterial||N.clipping===!0)&&(Be.clippingPlanes=ue.uniform),vh(N,Me),Q.needsLights=eg(N),Q.lightsStateVersion=Ee,Q.needsLights&&(Be.ambientLightColor.value=J.state.ambient,Be.lightProbe.value=J.state.probe,Be.directionalLights.value=J.state.directional,Be.directionalLightShadows.value=J.state.directionalShadow,Be.spotLights.value=J.state.spot,Be.spotLightShadows.value=J.state.spotShadow,Be.rectAreaLights.value=J.state.rectArea,Be.ltc_1.value=J.state.rectAreaLTC1,Be.ltc_2.value=J.state.rectAreaLTC2,Be.pointLights.value=J.state.point,Be.pointLightShadows.value=J.state.pointShadow,Be.hemisphereLights.value=J.state.hemi,Be.directionalShadowMatrix.value=J.state.directionalShadowMatrix,Be.spotLightMatrix.value=J.state.spotLightMatrix,Be.spotLightMap.value=J.state.spotLightMap,Be.pointShadowMatrix.value=J.state.pointShadowMatrix),Q.currentProgram=nt,Q.uniformsList=null,nt}function yh(N){if(N.uniformsList===null){const j=N.currentProgram.getUniforms();N.uniformsList=ac.seqWithValue(j.seq,N.uniforms)}return N.uniformsList}function vh(N,j){const ee=C.get(N);ee.outputColorSpace=j.outputColorSpace,ee.batching=j.batching,ee.batchingColor=j.batchingColor,ee.instancing=j.instancing,ee.instancingColor=j.instancingColor,ee.instancingMorph=j.instancingMorph,ee.skinning=j.skinning,ee.morphTargets=j.morphTargets,ee.morphNormals=j.morphNormals,ee.morphColors=j.morphColors,ee.morphTargetsCount=j.morphTargetsCount,ee.numClippingPlanes=j.numClippingPlanes,ee.numIntersection=j.numClipIntersection,ee.vertexAlphas=j.vertexAlphas,ee.vertexTangents=j.vertexTangents,ee.toneMapping=j.toneMapping}function Qm(N,j,ee,Q,J){j.isScene!==!0&&(j=je),X.resetTextureUnits();const be=j.fog,Ee=Q.isMeshStandardMaterial||Q.isMeshLambertMaterial||Q.isMeshPhongMaterial?j.environment:null,Me=I===null?S.outputColorSpace:I.isXRRenderTarget===!0?I.texture.colorSpace:mn,Le=Q.isMeshStandardMaterial||Q.isMeshLambertMaterial&&!Q.envMap||Q.isMeshPhongMaterial&&!Q.envMap,Ue=se.get(Q.envMap||Ee,Le),Je=Q.vertexColors===!0&&!!ee.attributes.color&&ee.attributes.color.itemSize===4,nt=!!ee.attributes.tangent&&(!!Q.normalMap||Q.anisotropy>0),Be=!!ee.morphAttributes.position,mt=!!ee.morphAttributes.normal,Dt=!!ee.morphAttributes.color;let Pt=ti;Q.toneMapped&&(I===null||I.isXRRenderTarget===!0)&&(Pt=S.toneMapping);const gt=ee.morphAttributes.position||ee.morphAttributes.normal||ee.morphAttributes.color,rn=gt!==void 0?gt.length:0,De=C.get(Q),Pn=M.state.lights;if(re===!0&&(ge===!0||N!==F)){const qt=N===F&&Q.id===k;ue.setState(Q,N,qt)}let lt=!1;Q.version===De.__version?(De.needsLights&&De.lightsStateVersion!==Pn.state.version||De.outputColorSpace!==Me||J.isBatchedMesh&&De.batching===!1||!J.isBatchedMesh&&De.batching===!0||J.isBatchedMesh&&De.batchingColor===!0&&J.colorTexture===null||J.isBatchedMesh&&De.batchingColor===!1&&J.colorTexture!==null||J.isInstancedMesh&&De.instancing===!1||!J.isInstancedMesh&&De.instancing===!0||J.isSkinnedMesh&&De.skinning===!1||!J.isSkinnedMesh&&De.skinning===!0||J.isInstancedMesh&&De.instancingColor===!0&&J.instanceColor===null||J.isInstancedMesh&&De.instancingColor===!1&&J.instanceColor!==null||J.isInstancedMesh&&De.instancingMorph===!0&&J.morphTexture===null||J.isInstancedMesh&&De.instancingMorph===!1&&J.morphTexture!==null||De.envMap!==Ue||Q.fog===!0&&De.fog!==be||De.numClippingPlanes!==void 0&&(De.numClippingPlanes!==ue.numPlanes||De.numIntersection!==ue.numIntersection)||De.vertexAlphas!==Je||De.vertexTangents!==nt||De.morphTargets!==Be||De.morphNormals!==mt||De.morphColors!==Dt||De.toneMapping!==Pt||De.morphTargetsCount!==rn)&&(lt=!0):(lt=!0,De.__version=Q.version);let jn=De.currentProgram;lt===!0&&(jn=$o(Q,j,J));let ai=!1,ms=!1,zs=!1;const yt=jn.getUniforms(),Qt=De.uniforms;if(_e.useProgram(jn.program)&&(ai=!0,ms=!0,zs=!0),Q.id!==k&&(k=Q.id,ms=!0),ai||F!==N){_e.buffers.depth.getReversed()&&N.reversedDepth!==!0&&(N._reversedDepth=!0,N.updateProjectionMatrix()),yt.setValue(U,"projectionMatrix",N.projectionMatrix),yt.setValue(U,"viewMatrix",N.matrixWorldInverse);const Yi=yt.map.cameraPosition;Yi!==void 0&&Yi.setValue(U,Ie.setFromMatrixPosition(N.matrixWorld)),Ve.logarithmicDepthBuffer&&yt.setValue(U,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),(Q.isMeshPhongMaterial||Q.isMeshToonMaterial||Q.isMeshLambertMaterial||Q.isMeshBasicMaterial||Q.isMeshStandardMaterial||Q.isShaderMaterial)&&yt.setValue(U,"isOrthographic",N.isOrthographicCamera===!0),F!==N&&(F=N,ms=!0,zs=!0)}if(De.needsLights&&(Pn.state.directionalShadowMap.length>0&&yt.setValue(U,"directionalShadowMap",Pn.state.directionalShadowMap,X),Pn.state.spotShadowMap.length>0&&yt.setValue(U,"spotShadowMap",Pn.state.spotShadowMap,X),Pn.state.pointShadowMap.length>0&&yt.setValue(U,"pointShadowMap",Pn.state.pointShadowMap,X)),J.isSkinnedMesh){yt.setOptional(U,J,"bindMatrix"),yt.setOptional(U,J,"bindMatrixInverse");const qt=J.skeleton;qt&&(qt.boneTexture===null&&qt.computeBoneTexture(),yt.setValue(U,"boneTexture",qt.boneTexture,X))}J.isBatchedMesh&&(yt.setOptional(U,J,"batchingTexture"),yt.setValue(U,"batchingTexture",J._matricesTexture,X),yt.setOptional(U,J,"batchingIdTexture"),yt.setValue(U,"batchingIdTexture",J._indirectTexture,X),yt.setOptional(U,J,"batchingColorTexture"),J._colorsTexture!==null&&yt.setValue(U,"batchingColorTexture",J._colorsTexture,X));const ji=ee.morphAttributes;if((ji.position!==void 0||ji.normal!==void 0||ji.color!==void 0)&&Te.update(J,ee,jn),(ms||De.receiveShadow!==J.receiveShadow)&&(De.receiveShadow=J.receiveShadow,yt.setValue(U,"receiveShadow",J.receiveShadow)),(Q.isMeshStandardMaterial||Q.isMeshLambertMaterial||Q.isMeshPhongMaterial)&&Q.envMap===null&&j.environment!==null&&(Qt.envMapIntensity.value=j.environmentIntensity),Qt.dfgLUT!==void 0&&(Qt.dfgLUT.value=LM()),ms&&(yt.setValue(U,"toneMappingExposure",S.toneMappingExposure),De.needsLights&&$m(Qt,zs),be&&Q.fog===!0&&ke.refreshFogUniforms(Qt,be),ke.refreshMaterialUniforms(Qt,Q,K,V,M.state.transmissionRenderTarget[N.id]),ac.upload(U,yh(De),Qt,X)),Q.isShaderMaterial&&Q.uniformsNeedUpdate===!0&&(ac.upload(U,yh(De),Qt,X),Q.uniformsNeedUpdate=!1),Q.isSpriteMaterial&&yt.setValue(U,"center",J.center),yt.setValue(U,"modelViewMatrix",J.modelViewMatrix),yt.setValue(U,"normalMatrix",J.normalMatrix),yt.setValue(U,"modelMatrix",J.matrixWorld),Q.isShaderMaterial||Q.isRawShaderMaterial){const qt=Q.uniformsGroups;for(let Yi=0,Vs=qt.length;Yi<Vs;Yi++){const _h=qt[Yi];Ae.update(_h,jn),Ae.bind(_h,jn)}}return jn}function $m(N,j){N.ambientLightColor.needsUpdate=j,N.lightProbe.needsUpdate=j,N.directionalLights.needsUpdate=j,N.directionalLightShadows.needsUpdate=j,N.pointLights.needsUpdate=j,N.pointLightShadows.needsUpdate=j,N.spotLights.needsUpdate=j,N.spotLightShadows.needsUpdate=j,N.rectAreaLights.needsUpdate=j,N.hemisphereLights.needsUpdate=j}function eg(N){return N.isMeshLambertMaterial||N.isMeshToonMaterial||N.isMeshPhongMaterial||N.isMeshStandardMaterial||N.isShadowMaterial||N.isShaderMaterial&&N.lights===!0}this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return I},this.setRenderTargetTextures=function(N,j,ee){const Q=C.get(N);Q.__autoAllocateDepthBuffer=N.resolveDepthBuffer===!1,Q.__autoAllocateDepthBuffer===!1&&(Q.__useRenderToTexture=!1),C.get(N.texture).__webglTexture=j,C.get(N.depthTexture).__webglTexture=Q.__autoAllocateDepthBuffer?void 0:ee,Q.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(N,j){const ee=C.get(N);ee.__webglFramebuffer=j,ee.__useDefaultFramebuffer=j===void 0};const tg=U.createFramebuffer();this.setRenderTarget=function(N,j=0,ee=0){I=N,A=j,T=ee;let Q=null,J=!1,be=!1;if(N){const Me=C.get(N);if(Me.__useDefaultFramebuffer!==void 0){_e.bindFramebuffer(U.FRAMEBUFFER,Me.__webglFramebuffer),L.copy(N.viewport),O.copy(N.scissor),H=N.scissorTest,_e.viewport(L),_e.scissor(O),_e.setScissorTest(H),k=-1;return}else if(Me.__webglFramebuffer===void 0)X.setupRenderTarget(N);else if(Me.__hasExternalTextures)X.rebindTextures(N,C.get(N.texture).__webglTexture,C.get(N.depthTexture).__webglTexture);else if(N.depthBuffer){const Je=N.depthTexture;if(Me.__boundDepthTexture!==Je){if(Je!==null&&C.has(Je)&&(N.width!==Je.image.width||N.height!==Je.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");X.setupDepthRenderbuffer(N)}}const Le=N.texture;(Le.isData3DTexture||Le.isDataArrayTexture||Le.isCompressedArrayTexture)&&(be=!0);const Ue=C.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(Array.isArray(Ue[j])?Q=Ue[j][ee]:Q=Ue[j],J=!0):N.samples>0&&X.useMultisampledRTT(N)===!1?Q=C.get(N).__webglMultisampledFramebuffer:Array.isArray(Ue)?Q=Ue[ee]:Q=Ue,L.copy(N.viewport),O.copy(N.scissor),H=N.scissorTest}else L.copy(R).multiplyScalar(K).floor(),O.copy(z).multiplyScalar(K).floor(),H=Y;if(ee!==0&&(Q=tg),_e.bindFramebuffer(U.FRAMEBUFFER,Q)&&_e.drawBuffers(N,Q),_e.viewport(L),_e.scissor(O),_e.setScissorTest(H),J){const Me=C.get(N.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_CUBE_MAP_POSITIVE_X+j,Me.__webglTexture,ee)}else if(be){const Me=j;for(let Le=0;Le<N.textures.length;Le++){const Ue=C.get(N.textures[Le]);U.framebufferTextureLayer(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0+Le,Ue.__webglTexture,ee,Me)}}else if(N!==null&&ee!==0){const Me=C.get(N.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,Me.__webglTexture,ee)}k=-1},this.readRenderTargetPixels=function(N,j,ee,Q,J,be,Ee,Me=0){if(!(N&&N.isWebGLRenderTarget)){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Le=C.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&Ee!==void 0&&(Le=Le[Ee]),Le){_e.bindFramebuffer(U.FRAMEBUFFER,Le);try{const Ue=N.textures[Me],Je=Ue.format,nt=Ue.type;if(N.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+Me),!Ve.textureFormatReadable(Je)){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ve.textureTypeReadable(nt)){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}j>=0&&j<=N.width-Q&&ee>=0&&ee<=N.height-J&&U.readPixels(j,ee,Q,J,ye.convert(Je),ye.convert(nt),be)}finally{const Ue=I!==null?C.get(I).__webglFramebuffer:null;_e.bindFramebuffer(U.FRAMEBUFFER,Ue)}}},this.readRenderTargetPixelsAsync=async function(N,j,ee,Q,J,be,Ee,Me=0){if(!(N&&N.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Le=C.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&Ee!==void 0&&(Le=Le[Ee]),Le)if(j>=0&&j<=N.width-Q&&ee>=0&&ee<=N.height-J){_e.bindFramebuffer(U.FRAMEBUFFER,Le);const Ue=N.textures[Me],Je=Ue.format,nt=Ue.type;if(N.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+Me),!Ve.textureFormatReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ve.textureTypeReadable(nt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Be=U.createBuffer();U.bindBuffer(U.PIXEL_PACK_BUFFER,Be),U.bufferData(U.PIXEL_PACK_BUFFER,be.byteLength,U.STREAM_READ),U.readPixels(j,ee,Q,J,ye.convert(Je),ye.convert(nt),0);const mt=I!==null?C.get(I).__webglFramebuffer:null;_e.bindFramebuffer(U.FRAMEBUFFER,mt);const Dt=U.fenceSync(U.SYNC_GPU_COMMANDS_COMPLETE,0);return U.flush(),await Hg(U,Dt,4),U.bindBuffer(U.PIXEL_PACK_BUFFER,Be),U.getBufferSubData(U.PIXEL_PACK_BUFFER,0,be),U.deleteBuffer(Be),U.deleteSync(Dt),be}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(N,j=null,ee=0){const Q=Math.pow(2,-ee),J=Math.floor(N.image.width*Q),be=Math.floor(N.image.height*Q),Ee=j!==null?j.x:0,Me=j!==null?j.y:0;X.setTexture2D(N,0),U.copyTexSubImage2D(U.TEXTURE_2D,ee,0,0,Ee,Me,J,be),_e.unbindTexture()};const ng=U.createFramebuffer(),ig=U.createFramebuffer();this.copyTextureToTexture=function(N,j,ee=null,Q=null,J=0,be=0){let Ee,Me,Le,Ue,Je,nt,Be,mt,Dt;const Pt=N.isCompressedTexture?N.mipmaps[be]:N.image;if(ee!==null)Ee=ee.max.x-ee.min.x,Me=ee.max.y-ee.min.y,Le=ee.isBox3?ee.max.z-ee.min.z:1,Ue=ee.min.x,Je=ee.min.y,nt=ee.isBox3?ee.min.z:0;else{const Qt=Math.pow(2,-J);Ee=Math.floor(Pt.width*Qt),Me=Math.floor(Pt.height*Qt),N.isDataArrayTexture?Le=Pt.depth:N.isData3DTexture?Le=Math.floor(Pt.depth*Qt):Le=1,Ue=0,Je=0,nt=0}Q!==null?(Be=Q.x,mt=Q.y,Dt=Q.z):(Be=0,mt=0,Dt=0);const gt=ye.convert(j.format),rn=ye.convert(j.type);let De;j.isData3DTexture?(X.setTexture3D(j,0),De=U.TEXTURE_3D):j.isDataArrayTexture||j.isCompressedArrayTexture?(X.setTexture2DArray(j,0),De=U.TEXTURE_2D_ARRAY):(X.setTexture2D(j,0),De=U.TEXTURE_2D),U.pixelStorei(U.UNPACK_FLIP_Y_WEBGL,j.flipY),U.pixelStorei(U.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),U.pixelStorei(U.UNPACK_ALIGNMENT,j.unpackAlignment);const Pn=U.getParameter(U.UNPACK_ROW_LENGTH),lt=U.getParameter(U.UNPACK_IMAGE_HEIGHT),jn=U.getParameter(U.UNPACK_SKIP_PIXELS),ai=U.getParameter(U.UNPACK_SKIP_ROWS),ms=U.getParameter(U.UNPACK_SKIP_IMAGES);U.pixelStorei(U.UNPACK_ROW_LENGTH,Pt.width),U.pixelStorei(U.UNPACK_IMAGE_HEIGHT,Pt.height),U.pixelStorei(U.UNPACK_SKIP_PIXELS,Ue),U.pixelStorei(U.UNPACK_SKIP_ROWS,Je),U.pixelStorei(U.UNPACK_SKIP_IMAGES,nt);const zs=N.isDataArrayTexture||N.isData3DTexture,yt=j.isDataArrayTexture||j.isData3DTexture;if(N.isDepthTexture){const Qt=C.get(N),ji=C.get(j),qt=C.get(Qt.__renderTarget),Yi=C.get(ji.__renderTarget);_e.bindFramebuffer(U.READ_FRAMEBUFFER,qt.__webglFramebuffer),_e.bindFramebuffer(U.DRAW_FRAMEBUFFER,Yi.__webglFramebuffer);for(let Vs=0;Vs<Le;Vs++)zs&&(U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,C.get(N).__webglTexture,J,nt+Vs),U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,C.get(j).__webglTexture,be,Dt+Vs)),U.blitFramebuffer(Ue,Je,Ee,Me,Be,mt,Ee,Me,U.DEPTH_BUFFER_BIT,U.NEAREST);_e.bindFramebuffer(U.READ_FRAMEBUFFER,null),_e.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else if(J!==0||N.isRenderTargetTexture||C.has(N)){const Qt=C.get(N),ji=C.get(j);_e.bindFramebuffer(U.READ_FRAMEBUFFER,ng),_e.bindFramebuffer(U.DRAW_FRAMEBUFFER,ig);for(let qt=0;qt<Le;qt++)zs?U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,Qt.__webglTexture,J,nt+qt):U.framebufferTexture2D(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,Qt.__webglTexture,J),yt?U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,ji.__webglTexture,be,Dt+qt):U.framebufferTexture2D(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,ji.__webglTexture,be),J!==0?U.blitFramebuffer(Ue,Je,Ee,Me,Be,mt,Ee,Me,U.COLOR_BUFFER_BIT,U.NEAREST):yt?U.copyTexSubImage3D(De,be,Be,mt,Dt+qt,Ue,Je,Ee,Me):U.copyTexSubImage2D(De,be,Be,mt,Ue,Je,Ee,Me);_e.bindFramebuffer(U.READ_FRAMEBUFFER,null),_e.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else yt?N.isDataTexture||N.isData3DTexture?U.texSubImage3D(De,be,Be,mt,Dt,Ee,Me,Le,gt,rn,Pt.data):j.isCompressedArrayTexture?U.compressedTexSubImage3D(De,be,Be,mt,Dt,Ee,Me,Le,gt,Pt.data):U.texSubImage3D(De,be,Be,mt,Dt,Ee,Me,Le,gt,rn,Pt):N.isDataTexture?U.texSubImage2D(U.TEXTURE_2D,be,Be,mt,Ee,Me,gt,rn,Pt.data):N.isCompressedTexture?U.compressedTexSubImage2D(U.TEXTURE_2D,be,Be,mt,Pt.width,Pt.height,gt,Pt.data):U.texSubImage2D(U.TEXTURE_2D,be,Be,mt,Ee,Me,gt,rn,Pt);U.pixelStorei(U.UNPACK_ROW_LENGTH,Pn),U.pixelStorei(U.UNPACK_IMAGE_HEIGHT,lt),U.pixelStorei(U.UNPACK_SKIP_PIXELS,jn),U.pixelStorei(U.UNPACK_SKIP_ROWS,ai),U.pixelStorei(U.UNPACK_SKIP_IMAGES,ms),be===0&&j.generateMipmaps&&U.generateMipmap(De),_e.unbindTexture()},this.initRenderTarget=function(N){C.get(N).__webglFramebuffer===void 0&&X.setupRenderTarget(N)},this.initTexture=function(N){N.isCubeTexture?X.setTextureCube(N,0):N.isData3DTexture?X.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?X.setTexture2DArray(N,0):X.setTexture2D(N,0),_e.unbindTexture()},this.resetState=function(){A=0,T=0,I=null,_e.reset(),he.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return $n}get outputColorSpace(){return this._outputColorSpace}
4049set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=it._getDrawingBufferColorSpace(e),t.unpackColorSpace=it._getUnpackColorSpace()}}function _m(s,e=!1){const t=s[0].index!==null,n=new Set(Object.keys(s[0].attributes)),i=new Set(Object.keys(s[0].morphAttributes)),r={},o={},a=s[0].morphTargetsRelative,c=new vt;let l=0;for(let d=0;d<s.length;++d){const u=s[d];let h=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const f in u.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;r[f]===void 0&&(r[f]=[]),r[f].push(u.attributes[f]),h++}if(h!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in u.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(u.morphAttributes[f])}if(e){let f;if(t)f=u.index.count;else if(u.attributes.position!==void 0)f=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(l,f,d),l+=f}}if(t){let d=0;const u=[];for(let h=0;h<s.length;++h){const f=s[h].index;for(let m=0;m<f.count;++m)u.push(f.getX(m)+d);d+=s[h].attributes.position.count}c.setIndex(u)}for(const d in r){const u=Xf(r[d]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,u)}for(const d in o){const u=o[d][0].length;if(u===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let h=0;h<u;++h){const f=[];for(let x=0;x<o[d].length;++x)f.push(o[d][x][h]);const m=Xf(f);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(m)}}return c}function Xf(s){let e,t,n,i=-1,r=0;for(let l=0;l<s.length;++l){const d=s[l];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=d.itemSize),t!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=d.normalized),n!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=d.count*t}const o=new e(r),a=new Rt(o,t,n);let c=0;for(let l=0;l<s.length;++l){const d=s[l];if(d.isInterleavedBufferAttribute){const u=c/t;for(let h=0,f=d.count;h<f;h++)for(let m=0;m<t;m++){const x=d.getComponent(h,m);a.setComponent(h+u,m,x)}}else o.set(d.array,c);c+=d.count*t}return i!==void 0&&(a.gpuType=i),a}function qf(s,e){if(e===Rg)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===Wu||e===jp){let t=s.getIndex();if(t===null){const o=[],a=s.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);s.setIndex(o),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const n=t.count-2,i=[];if(e===Wu)for(let o=1;o<=n;o++)i.push(t.getX(0)),i.push(t.getX(o)),i.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(i.push(t.getX(o)),i.push(t.getX(o+1)),i.push(t.getX(o+2))):(i.push(t.getX(o+2)),i.push(t.getX(o+1)),i.push(t.getX(o)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=s.clone();return r.setIndex(i),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}function DM(s){const e=new Map,t=new Map,n=s.clone();return bm(s,n,function(i,r){e.set(r,i),t.set(i,r)}),n.traverse(function(i){if(!i.isSkinnedMesh)return;const r=i,o=e.get(i),a=o.skeleton.bones;r.skeleton=o.skeleton.clone(),r.bindMatrix.copy(o.bindMatrix),r.skeleton.bones=a.map(function(c){return t.get(c)}),r.bind(r.skeleton,r.bindMatrix)}),n}function bm(s,e,t){t(s,e);for(let n=0;n<s.children.length;n++)bm(s.children[n],e.children[n],t)}class NM extends Bs{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new BM(t)}),this.register(function(t){return new zM(t)}),this.register(function(t){return new KM(t)}),this.register(function(t){return new ZM(t)}),this.register(function(t){return new JM(t)}),this.register(function(t){return new HM(t)}),this.register(function(t){return new GM(t)}),this.register(function(t){return new WM(t)}),this.register(function(t){return new XM(t)}),this.register(function(t){return new kM(t)}),this.register(function(t){return new qM(t)}),this.register(function(t){return new VM(t)}),this.register(function(t){return new YM(t)}),this.register(function(t){return new jM(t)}),this.register(function(t){return new OM(t)}),this.register(function(t){return new jf(t,st.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new jf(t,st.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new QM(t)})}load(e,t,n,i){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const l=Co.extractUrlBase(e);o=Co.resolveURL(l,this.path)}else o=Co.extractUrlBase(e);this.manager.itemStart(e);const a=function(l){i?i(l):console.error(l),r.manager.itemError(e),r.manager.itemEnd(e)},c=new bc(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{r.parse(l,o,function(d){t(d),r.manager.itemEnd(e)},a)}catch(d){a(d)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const o={},a={},c=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===Mm){try{o[st.KHR_BINARY_GLTF]=new $M(e)}catch(u){i&&i(u);return}r=JSON.parse(o[st.KHR_BINARY_GLTF].content)}else r=JSON.parse(c.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new hS(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const u=this.pluginCallbacks[d](l);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(r.extensionsUsed)for(let d=0;d<r.extensionsUsed.length;++d){const u=r.extensionsUsed[d],h=r.extensionsRequired||[];switch(u){case st.KHR_MATERIALS_UNLIT:o[u]=new FM;break;case st.KHR_DRACO_MESH_COMPRESSION:o[u]=new eS(r,this.dracoLoader);break;case st.KHR_TEXTURE_TRANSFORM:o[u]=new tS;break;case st.KHR_MESH_QUANTIZATION:o[u]=new nS;break;default:h.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function UM(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}function Ft(s,e,t){const n=s.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}const st={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_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class OM{constructor(e){this.parser=e,this.name=st.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let l;const d=new ze(16777215);c.color!==void 0&&d.setRGB(c.color[0],c.color[1],c.color[2],mn);const u=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new Zd(d),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new bx(d),l.distance=u;break;case"spot":l=new vx(d),l.distance=u,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),pi(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),i=Promise.resolve(l),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return n._getNodeRef(t.cache,a,c)})}}class FM{constructor(){this.name=st.KHR_MATERIALS_UNLIT}getMaterialType(){return nn}extendParams(e,t,n){const i=[];e.color=new ze(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],mn),e.opacity=o[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",r.baseColorTexture,At))}return Promise.all(i)}}class kM{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}}class BM{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new xe(r,r)}return Promise.all(i)}}class zM{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}}class VM{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(i)}}class HM{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_SHEEN}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(t.sheenColor=new ze(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){const r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],mn)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,At)),n.sheenRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(i)}}class GM{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(i)}}class WM{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_VOLUME}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;const r=n.attenuationColor||[1,1,1];return t.attenuationColor=new ze().setRGB(r[0],r[1],r[2],mn),Promise.all(i)}}class XM{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_IOR}getMaterialType(e){return F
4049t(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5),Promise.resolve()}}class qM{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));const r=n.specularColorFactor||[1,1,1];return t.specularColor=new ze().setRGB(r[0],r[1],r[2],mn),n.specularColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,At)),Promise.all(i)}}class jM{constructor(e){this.parser=e,this.name=st.EXT_MATERIALS_BUMP}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(i)}}class YM{constructor(e){this.parser=e,this.name=st.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(i)}}class KM{constructor(e){this.parser=e,this.name=st.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}}class ZM{constructor(e){this.parser=e,this.name=st.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let c=n.textureLoader;if(a.uri){const l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(e,o.source,c)}}class JM{constructor(e){this.parser=e,this.name=st.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let c=n.textureLoader;if(a.uri){const l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(e,o.source,c)}}class jf{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const c=i.byteOffset||0,l=i.byteLength||0,d=i.count,u=i.byteStride,h=new Uint8Array(a,c,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(d,u,h,i.mode,i.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(d*u);return o.decodeGltfBuffer(new Uint8Array(f),d,u,h,i.mode,i.filter),f})})}else return null}}class QM{constructor(e){this.name=st.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const l of i.primitives)if(l.mode!==Hn.TRIANGLES&&l.mode!==Hn.TRIANGLE_STRIP&&l.mode!==Hn.TRIANGLE_FAN&&l.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],c={};for(const l in o)a.push(this.parser.getDependency("accessor",o[l]).then(d=>(c[l]=d,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const d=l.pop(),u=d.isGroup?d.children:[d],h=l[0].count,f=[];for(const m of u){const x=new Oe,p=new D,g=new kn,y=new D(1,1,1),_=new Fd(m.geometry,m.material,h);for(let v=0;v<h;v++)c.TRANSLATION&&p.fromBufferAttribute(c.TRANSLATION,v),c.ROTATION&&g.fromBufferAttribute(c.ROTATION,v),c.SCALE&&y.fromBufferAttribute(c.SCALE,v),_.setMatr
vendor: 7,883 bytes, line 4049
4049ixAt(v,x.compose(p,g,y));for(const v in c)if(v==="_COLOR_0"){const M=c[v];_.instanceColor=new qu(M.array,M.itemSize,M.normalized)}else v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"&&m.geometry.setAttribute(v,c[v]);Et.prototype.copy.call(_,m),this.parser.assignFinalMaterial(_),f.push(_)}return d.isGroup?(d.clear(),d.add(...f),d):f[0]}))}}const Mm="glTF",ro=12,Yf={JSON:1313821514,BIN:5130562};class $M{constructor(e){this.name=st.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ro),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Mm)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-ro,r=new DataView(e,ro);let o=0;for(;o<i;){const a=r.getUint32(o,!0);o+=4;const c=r.getUint32(o,!0);if(o+=4,c===Yf.JSON){const l=new Uint8Array(e,ro+o,a);this.content=n.decode(l)}else if(c===Yf.BIN){const l=ro+o;this.body=e.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class eS{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=st.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},c={},l={};for(const d in o){const u=Qu[d]||d.toLowerCase();a[u]=o[d]}for(const d in e.attributes){const u=Qu[d]||d.toLowerCase();if(o[d]!==void 0){const h=n.accessors[e.attributes[d]],f=Cr[h.componentType];l[u]=f.name,c[u]=h.normalized===!0}}return t.getDependency("bufferView",r).then(function(d){return new Promise(function(u,h){i.decodeDracoFile(d,function(f){for(const m in f.attributes){const x=f.attributes[m],p=c[m];p!==void 0&&(x.normalized=p)}u(f)},a,l,mn,h)})})}}class tS{constructor(){this.name=st.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class nS{constructor(){this.name=st.KHR_MESH_QUANTIZATION}}class Sm extends Gr{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let o=0;o!==i;o++)t[o]=n[r+o];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,d=i-t,u=(n-t)/d,h=u*u,f=h*u,m=e*l,x=m-l,p=-2*f+3*h,g=f-h,y=1-p,_=g-h+u;for(let v=0;v!==a;v++){const M=o[x+v+a],w=o[x+v+c]*d,E=o[m+v+a],b=o[m+v]*d;r[v]=y*M+_*w+p*E+g*b}return r}}const iS=new kn;class sS extends Sm{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return iS.fromArray(r).normalize().toArray(r),r}}const Hn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Cr={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Kf={9728:Ut,9729:It,9984:zp,9985:nc,9986:xo,9987:vi},Zf={33071:yi,33648:pc,10497:Nr},Il={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Qu={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},ts={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},rS={CUBICSPLINE:void 0,LINEAR:zo,STEP:Bo},Dl={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function oS(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new Un({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ii})),s.DefaultMaterial}function ws(s,e,t){for(const n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function pi(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function aS(s,e,t){let n=!1,i=!1,r=!1;for(let l=0,d=e.length;l<d;l++){const u=e[l];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(i=!0),u.COLOR_0!==void 0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(s);const o=[],a=[],c=[];for(let l=0,d=e.length;l<d;l++){const u=e[l];if(n){const h=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):s.attributes.position;o.push(h)}if(i){const h=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):s.attributes.normal;a.push(h)}if(r){const h=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):s.attributes.color;c.push(h)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){const d=l[0],u=l[1],h=l[2];return n&&(s.morphAttributes.position=d),i&&(s.morphAttributes.normal=u),r&&(s.morphAttributes.color=h),s.morphTargetsRelative=!0,s})}function cS(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function lS(s){let e;const t=s.extensions&&s.extensions[st.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Nl(t.attributes):e=s.indices+":"+Nl(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+Nl(s.targets[n]);return e}function Nl(s){let e="";const t=Object.keys(s).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+s[t[n]]+";";return e}function $u(s){switch(s){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function uS(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const dS=new Oe;class hS{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new UM,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const c=a.match(/Version\/(\d+)/);i=n&&c?parseInt(c[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||r&&o<98?this.textureLoader=new xx(this.options.manager):this.textureLoader=new Sx(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new bc(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()}
vendor: 10,964 bytes, line 4049
4049)).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return ws(r,a,i),pi(a,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(const c of a.scenes)c.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){const o=t[i].joints;for(let a=0,c=o.length;a<c;a++)e[o[a]].isBone=!0}for(let i=0,r=e.length;i<r;i++){const o=e[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),r=(o,a)=>{const c=this.associations.get(o);c!=null&&this.associations.set(a,c);for(const[l,d]of o.children.entries())r(d,a.children[l])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[st.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(r,o){n.load(Co.resolveURL(t.uri,i.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const o=Il[i.type],a=Cr[i.componentType],c=i.normalized===!0,l=new a(i.count*o);return Promise.resolve(new Rt(l,o,c))}const r=[];return i.bufferView!==void 0?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),i.sparse!==void 0&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(o){const a=o[0],c=Il[i.type],l=Cr[i.componentType],d=l.BYTES_PER_ELEMENT,u=d*c,h=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,m=i.normalized===!0;let x,p;if(f&&f!==u){const g=Math.floor(h/f),y="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+g+":"+i.count;let _=t.cache.get(y);_||(x=new l(a,g*f,i.count*f/d),_=new $p(x,f/d),t.cache.add(y,_)),p=new Lc(_,c,h%f/d,m)}else a===null?x=new l(i.count*c):x=new l(a,h,i.count*c),p=new Rt(x,c,m);if(i.sparse!==void 0){const g=Il.SCALAR,y=Cr[i.sparse.indices.componentType],_=i.sparse.indices.byteOffset||0,v=i.sparse.values.byteOffset||0,M=new y(o[1],_,i.sparse.count*g),w=new l(o[2],v,i.sparse.count*c);a!==null&&(p=new Rt(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let E=0,b=M.length;E<b;E++){const S=M[E];if(p.setX(S,w[E*c]),c>=2&&p.setY(S,w[E*c+1]),c>=3&&p.setZ(S,w[E*c+2]),c>=4&&p.setW(S,w[E*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=m}return p})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,o=t.images[r];let a=this.textureLoader;if(o.uri){const c=n.manager.getHandler(o.uri);c!==null&&(a=c)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){const i=this,r=this.json,o=r.textures[e],a=r.images[t],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(d){d.flipY=!1,d.name=o.name||a.name||"",d.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(d.name=a.uri);const h=(r.samplers||{})[o.sampler]||{};return d.magFilter=Kf[h.magFilter]||It,d.minFilter=Kf[h.minFilter]||vi,d.wrapS=Zf[h.wrapS]||Nr,d.wrapT=Zf[h.wrapT]||Nr,d.generateMipmaps=!d.isCompressedTexture&&d.minFilter!==Ut&&d.minFilter!==It,i.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=i.images[e],a=self.URL||self.webkitURL;let c=o.uri||"",l=!1;if(o.bufferView!==void 0)c=n.getDependency("bufferView",o.bufferView).then(function(u){l=!0;const h=new Blob([u],{type:o.mimeType});return c=a.createObjectURL(h),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(c).then(function(u){return new Promise(function(h,f){let m=h;t.isImageBitmapLoader===!0&&(m=function(x){const p=new Ot(x);p.needsUpdate=!0,h(p)}),t.load(Co.resolveURL(u,r.path),m,void 0,f)})}).then(function(u){return l===!0&&a.revokeObjectURL(c),pi(u,o),u.userData.mimeType=o.mimeType||uS(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=d,d}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[st.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[st.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=r.associations.get(o);o=r.extensions[st.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,c)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new Vd,Mi.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new tm,Mi.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(i||r||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),r&&(c.vertexColors=!0),o&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return Un}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let o;const a={},c=r.extensions||{},l=[];if(c[st.KHR_MATERIALS_UNLIT]){const u=i[st.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),l.push(u.extendParams(a,r,t))}else{const u=r.pbrMetallicRoughness||{};if(a.color=new ze(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const h=u.baseColorFactor;a.color.setRGB(h[0],h[1],h[2],mn),a.opacity=h[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",u.baseColorTexture,At)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=Tt);const d=r.alphaMode||Dl.OPAQUE;if(d===Dl.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,d===Dl.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==nn&&(l.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new xe(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&o!==nn&&(l.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==nn){const u=r.emissiveFactor;a.emissive=new ze().setRGB(u[0],u[1],u[2],mn)}return r.emissiveTexture!==void 0&&o!==nn&&l.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,At)),Promise.all(l).then(function(){const u=new o(a);return r.name&&(u.name=r.name),pi(u,r),t.associations.set(u,{materials:e}),r.extensions&&ws(i,u,r),u})}createUniqueName(e){const t=ft.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(a){return n[st.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return Jf(c,a,t)})}const o=[];for(let a=0,c=e.length;a<c;a++){const l=e[a],d=lS(l),u=i[d];if(u)o.push(u.promise);else{let h;l.extensions&&l.extensions[st.KHR_DRACO_MESH_COMPRESSION]?h=r(l):h=Jf(new vt,l,t),i[d]={primitive:l,promise:h},o.push(h)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],o=r.primitives,a=[];for(let c=0,l=o.length;c<l;c++){const d=o[c].material===void 0?oS(this.cache):this.getDependency("material",o[c].material);a.push(d)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(c){const l=c.slice(0,c.length-1),d=c[c.length-1],u=[];for(let f=0,m=d.length;f<m;f++){const x=d[f],p=o[f];let g;const y=l[f];
vendor: 4,272 bytes, line 4049
4049if(p.mode===Hn.TRIANGLES||p.mode===Hn.TRIANGLE_STRIP||p.mode===Hn.TRIANGLE_FAN||p.mode===void 0)g=r.isSkinnedMesh===!0?new em(x,y):new Qe(x,y),g.isSkinnedMesh===!0&&g.normalizeSkinWeights(),p.mode===Hn.TRIANGLE_STRIP?g.geometry=qf(g.geometry,jp):p.mode===Hn.TRIANGLE_FAN&&(g.geometry=qf(g.geometry,Wu));else if(p.mode===Hn.LINES)g=new Bd(x,y);else if(p.mode===Hn.LINE_STRIP)g=new Zo(x,y);else if(p.mode===Hn.LINE_LOOP)g=new zd(x,y);else if(p.mode===Hn.POINTS)g=new Dc(x,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+p.mode);Object.keys(g.geometry.morphAttributes).length>0&&cS(g,r),g.name=t.createUniqueName(r.name||"mesh_"+e),pi(g,r),p.extensions&&ws(i,g,p),t.assignFinalMaterial(g),u.push(g)}for(let f=0,m=u.length;f<m;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return r.extensions&&ws(i,u[0],r),u[0];const h=new Kt;r.extensions&&ws(i,h,r),t.associations.set(h,{meshes:e});for(let f=0,m=u.length;f<m;f++)h.add(u[f]);return h})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new ln(Ct.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new Jo(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),pi(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const r=i.pop(),o=i,a=[],c=[];for(let l=0,d=o.length;l<d;l++){const u=o[l];if(u){a.push(u);const h=new Oe;r!==null&&h.fromArray(r.array,l*16),c.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new Ic(a,c)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,o=[],a=[],c=[],l=[],d=[];for(let u=0,h=i.channels.length;u<h;u++){const f=i.channels[u],m=i.samplers[f.sampler],x=f.target,p=x.node,g=i.parameters!==void 0?i.parameters[m.input]:m.input,y=i.parameters!==void 0?i.parameters[m.output]:m.output;x.node!==void 0&&(o.push(this.getDependency("node",p)),a.push(this.getDependency("accessor",g)),c.push(this.getDependency("accessor",y)),l.push(m),d.push(x))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(d)]).then(function(u){const h=u[0],f=u[1],m=u[2],x=u[3],p=u[4],g=[];for(let _=0,v=h.length;_<v;_++){const M=h[_],w=f[_],E=m[_],b=x[_],S=p[_];if(M===void 0)continue;M.updateMatrix&&M.updateMatrix();const P=n._createAnimationTracks(M,w,E,b,S);if(P)for(let A=0;A<P.length;A++)g.push(P[A])}const y=new ux(r,void 0,g);return pi(y,i),y})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(r){const o=n._getNodeRef(n.meshCache,i.mesh,r);return i.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let c=0,l=i.weights.length;c<l;c++)a.morphTargetInfluences[c]=i.weights[c]}),o})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),o=[],a=i.children||[];for(let l=0,d=a.length;l<d;l++)o.push(n.getDependency("node",a[l]));const c=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(o),c]).then(function(l){const d=l[0],u=l[1],h=l[2];h!==null&&d.traverse(function(f){f.isSkinnedMesh&&f.bind(h,dS)});for(let f=0,m=u.length;f<m;f++)d.add(u[f]);if(d.userData.pivot!==void 0&&u.length>0){const f=d.userData.pivot,m=u[0];d.pivot=new D().fromArray(f),d.position.x-=f[0],d.position.y-=f[1],d.position.z-=f[2],m.position.set(0,0,0),delete d.userData.pivot}return d})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],o=r.name?i.createUniqueName(r.name):"",a=[],c=i._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),r.camera!==void 0&&a.push(i.getDependency("camera",r.camera).then(function(l){return i._getNodeRef(i.cameraCache,r.camera,l)})),i._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}
vendor: 9,406 bytes, lines 4049-4050
4049).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let d;if(r.isBone===!0?d=new Od:l.length>1?d=new Kt:l.length===1?d=l[0]:d=new Et,d!==l[0])for(let u=0,h=l.length;u<h;u++)d.add(l[u]);if(r.name&&(d.userData.name=r.name,d.name=o),pi(d,r),r.extensions&&ws(n,d,r),r.matrix!==void 0){const u=new Oe;u.fromArray(r.matrix),d.applyMatrix4(u)}else r.translation!==void 0&&d.position.fromArray(r.translation),r.rotation!==void 0&&d.quaternion.fromArray(r.rotation),r.scale!==void 0&&d.scale.fromArray(r.scale);if(!i.associations.has(d))i.associations.set(d,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){const u=i.associations.get(d);i.associations.set(d,{...u})}return i.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new Kt;n.name&&(r.name=i.createUniqueName(n.name)),pi(r,n),n.extensions&&ws(t,r,n);const o=n.nodes||[],a=[];for(let c=0,l=o.length;c<l;c++)a.push(i.getDependency("node",o[c]));return Promise.all(a).then(function(c){for(let d=0,u=c.length;d<u;d++){const h=c[d];h.parent!==null?r.add(DM(h)):r.add(h)}const l=d=>{const u=new Map;for(const[h,f]of i.associations)(h instanceof Mi||h instanceof Ot)&&u.set(h,f);return d.traverse(h=>{const f=i.associations.get(h);f!=null&&u.set(h,f)}),u};return i.associations=l(r),r})}_createAnimationTracks(e,t,n,i,r){const o=[],a=e.name?e.name:e.uuid,c=[];ts[r.path]===ts.weights?e.traverse(function(h){h.morphTargetInfluences&&c.push(h.name?h.name:h.uuid)}):c.push(a);let l;switch(ts[r.path]){case ts.weights:l=kr;break;case ts.rotation:l=Br;break;case ts.translation:case ts.scale:l=zr;break;default:n.itemSize===1?l=kr:l=zr;break}const d=i.interpolation!==void 0?rS[i.interpolation]:zo,u=this._getArrayFromAccessor(n);for(let h=0,f=c.length;h<f;h++){const m=new l(c[h]+"."+ts[r.path],t.array,u,d);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=$u(t.constructor),i=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof Br?sS:Sm;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function fS(s,e,t){const n=e.attributes,i=new ct;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(i.set(new D(c[0],c[1],c[2]),new D(l[0],l[1],l[2])),a.normalized){const d=$u(Cr[a.componentType]);i.min.multiplyScalar(d),i.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const a=new D,c=new D;for(let l=0,d=r.length;l<d;l++){const u=r[l];if(u.POSITION!==void 0){const h=t.json.accessors[u.POSITION],f=h.min,m=h.max;if(f!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),h.normalized){const x=$u(Cr[h.componentType]);c.multiplyScalar(x)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}s.boundingBox=i;const o=new fn;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=o}function Jf(s,e,t){const n=e.attributes,i=[];function r(o,a){return t.getDependency("accessor",o).then(function(c){s.setAttribute(a,c)})}for(const o in n){const a=Qu[o]||o.toLowerCase();a in s.attributes||i.push(r(n[o],a))}if(e.indices!==void 0&&!s.index){const o=t.getDependency("accessor",e.indices).then(function(a){s.setIndex(a)});i.push(o)}return it.workingColorSpace!==mn&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${it.workingColorSpace}" not supported.`),pi(s,e),fS(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?aS(s,e.targets,t):s})}const Ul=new WeakMap;class pS extends Bs{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const r=new bc(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,o=>{this.parse(o,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,At,n).catch(n)}decodeDracoFile(e,t,n,i,r=mn,o=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,a).then(t).catch(o)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Ul.has(e)){const c=Ul.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(r,o).then(c=>(i=c,new Promise((l,d)=>{i._callbacks[r]={resolve:l,reject:d},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return a.catch(()=>!0).then(()=>{i&&r&&this._releaseTask(i,r)}),Ul.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new vt;e.index&&t.setIndex(new Rt(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:r,itemSize:o,stride:a,vertexColorSpace:c}=e.attributes[n];let l;if(o===a)l=new Rt(r,o);else{const d=new $p(r,a);l=new Lc(d,o,0)}i==="color"&&(this._assignVertexColorSpace(l,c),l.normalized=!(r instanceof Float32Array)),t.setAttribute(i,l)}return t}_assignVertexColorSpace(e,t){if(t!==At)return;const n=new ze;for(let i=0,r=e.count;i<r;i++)n.fromBufferAttribute(e,i),it.colorSpaceToWorking(n,At),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new bc(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,r)=>{n.load(e,i,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const r=mS.toString(),o=["/* draco decoder */",i,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(` 4050`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(r){const o=r.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,r){return i._taskLoad>r._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function mS(){let s,e;onmessage=function(o){const a=o.data;switch(a.type){case"init":s=a.decoderConfig,e=new Promise(function(d){s.onModuleLoaded=function(u){d({draco:u})},DracoDecoderModule(s)});break;case"decode":const c=a.buffer,l=a.taskConfig;e.then(d=>{const u=d.draco,h=new u.Decoder;try{const f=t(u,h,new Int8Array(c),l),m=f.attributes.map(x=>x.array.buffer);f.index&&m.push(f.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:f},m)}catch(f){console.error(f),self.postMessage({type:"error",id:a.id,error:f.message})}finally{u.destroy(h)}});break}};function t(o,a,c,l){const d=l.attributeIDs,u=l.attributeTypes;let h,f;const m=a.GetEncodedGeometryType(c);if(m===o.TRIANGULAR_MESH)h=new o.Mesh,f=a.DecodeArrayToMesh(c,c.byteLength,h);else if(m===o.POINT_CLOUD)h=new o.PointCloud,f=a.DecodeArrayToPointCloud(c,c.byteLength,h);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||h.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const x={index:null,attributes:[]};for(const p in d){const g=self[u[p]];let y,_;if(l.useUniqueIDs)_=d[p],y=a.GetAttributeByUniqueId(h,_);else{if(_=a.GetAttributeId(h,o[d[p]]),_===-1)continue;y=a.GetAttribute(h,_)}const v=i(o,a,h,p,g,y);
4050p==="color"&&(v.vertexColorSpace=l.vertexColorSpace),x.attributes.push(v)}return m===o.TRIANGULAR_MESH&&(x.index=n(o,a,h)),o.destroy(h),x}function n(o,a,c){const d=c.num_faces()*3,u=d*4,h=o._malloc(u);a.GetTrianglesUInt32Array(c,u,h);const f=new Uint32Array(o.HEAPF32.buffer,h,d).slice();return o._free(h),{array:f,itemSize:1}}function i(o,a,c,l,d,u){const h=c.num_points(),f=u.num_components(),m=r(o,d),x=f*d.BYTES_PER_ELEMENT,p=Math.ceil(x/4)*4,g=p/d.BYTES_PER_ELEMENT,y=h*x,_=h*p,v=o._malloc(y);a.GetAttributeDataArrayForAllPoints(c,u,m,y,v);const M=new d(o.HEAPF32.buffer,v,y/d.BYTES_PER_ELEMENT);let w;if(x===p)w=M.slice();else{w=new d(_/d.BYTES_PER_ELEMENT);let E=0;for(let b=0,S=M.length;b<S;b++){for(let P=0;P<f;P++)w[E+P]=M[b*f+P];E+=g}}return o._free(v),{name:l,count:h,itemSize:f,array:w,stride:g}}function r(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}const wm=0,gS=1,xS=2,Qf=2,Ol=1.25,$f=1,dn=32,Vt=dn/4,Tm=65535,cc=Math.pow(2,-24),$d=Symbol("SKIP_GENERATION"),Em={strategy:wm,maxDepth:40,targetLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[$d]:!1};function Lt(s,e,t){return t.min.x=e[s],t.min.y=e[s+1],t.min.z=e[s+2],t.max.x=e[s+3],t.max.y=e[s+4],t.max.z=e[s+5],t}function ed(s){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=s[n+3]-s[n];i>t&&(t=i,e=n)}return e}function ep(s,e){e.set(s)}function tp(s,e,t){let n,i;for(let r=0;r<3;r++){const o=r+3;n=s[r],i=e[r],t[r]=n<i?n:i,n=s[o],i=e[o],t[o]=n>i?n:i}}function Ia(s,e,t){for(let n=0;n<3;n++){const i=e[s+2*n],r=e[s+2*n+1],o=i-r,a=i+r;o<t[n]&&(t[n]=o),a>t[n+3]&&(t[n+3]=a)}}function oo(s){const e=s[3]-s[0],t=s[4]-s[1],n=s[5]-s[2];return 2*(e*t+t*n+n*e)}function Nt(s,e){return e[s+15]===Tm}function Zt(s,e){return e[s+6]}function hn(s,e){return e[s+14]}function Ht(s){return s+Vt}function Gt(s,e){const t=e[s+6];return s+t*Vt}function eh(s,e){return e[s+7]}function Fl(s,e,t,n,i){let r=1/0,o=1/0,a=1/0,c=-1/0,l=-1/0,d=-1/0,u=1/0,h=1/0,f=1/0,m=-1/0,x=-1/0,p=-1/0;const g=s.offset||0;for(let y=(e-g)*6,_=(e+t-g)*6;y<_;y+=6){const v=s[y+0],M=s[y+1],w=v-M,E=v+M;w<r&&(r=w),E>c&&(c=E),v<u&&(u=v),v>m&&(m=v);const b=s[y+2],S=s[y+3],P=b-S,A=b+S;P<o&&(o=P),A>l&&(l=A),b<h&&(h=b),b>x&&(x=b);const T=s[y+4],I=s[y+5],k=T-I,F=T+I;k<a&&(a=k),F>d&&(d=F),T<f&&(f=T),T>p&&(p=T)}n[0]=r,n[1]=o,n[2]=a,n[3]=c,n[4]=l,n[5]=d,i[0]=u,i[1]=h,i[2]=f,i[3]=m,i[4]=x,i[5]=p}const Ni=32,yS=(s,e)=>s.candidate-e.candidate,ns=new Array(Ni).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Da=new Float32Array(6);function vS(s,e,t,n,i,r){let o=-1,a=0;if(r===wm)o=ed(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(r===gS)o=ed(s),o!==-1&&(a=_S(t,n,i,o));else if(r===xS){const c=oo(s);let l=Ol*i;const d=t.offset||0,u=(n-d)*6,h=(n+i-d)*6;for(let f=0;f<3;f++){const m=e[f],g=(e[f+3]-m)/Ni;if(i<Ni/4){const y=[...ns];y.length=i;let _=0;for(let M=u;M<h;M+=6,_++){const w=y[_];w.candidate=t[M+2*f],w.count=0;const{bounds:E,leftCacheBounds:b,rightCacheBounds:S}=w;for(let P=0;P<3;P++)S[P]=1/0,S[P+3]=-1/0,b[P]=1/0,b[P+3]=-1/0,E[P]=1/0,E[P+3]=-1/0;Ia(M,t,E)}y.sort(yS);let v=i;for(let M=0;M<v;M++){const w=y[M];for(;M+1<v&&y[M+1].candidate===w.candidate;)y.splice(M+1,1),v--}for(let M=u;M<h;M+=6){const w=t[M+2*f];for(let E=0;E<v;E++){const b=y[E];w>=b.candidate?Ia(M,t,b.rightCacheBounds):(Ia(M,t,b.leftCacheBounds),b.count++)}}for(let M=0;M<v;M++){const w=y[M],E=w.count,b=i-w.count,S=w.leftCacheBounds,P=w.rightCacheBounds;let A=0;E!==0&&(A=oo(S)/c);let T=0;b!==0&&(T=oo(P)/c);const I=$f+Ol*(A*E+T*b);I<l&&(o=f,l=I,a=w.candidate)}}else{for(let v=0;v<Ni;v++){const M=ns[v];M.count=0,M.candidate=m+g+v*g;const w=M.bounds;for(let E=0;E<3;E++)w[E]=1/0,w[E+3]=-1/0}for(let v=u;v<h;v+=6){let E=~~((t[v+2*f]-m)/g);E>=Ni&&(E=Ni-1);const b=ns[E];b.count++,Ia(v,t,b.bounds)}const y=ns[Ni-1];ep(y.bounds,y.rightCacheBounds);for(let v=Ni-2;v>=0;v--){const M=ns[v],w=ns[v+1];
vendor: 1,549 bytes, line 4050
4050tp(M.bounds,w.rightCacheBounds,M.rightCacheBounds)}let _=0;for(let v=0;v<Ni-1;v++){const M=ns[v],w=M.count,E=M.bounds,S=ns[v+1].rightCacheBounds;w!==0&&(_===0?ep(E,Da):tp(E,Da,Da)),_+=w;let P=0,A=0;_!==0&&(P=oo(Da)/c);const T=i-_;T!==0&&(A=oo(S)/c);const I=$f+Ol*(P*_+A*T);I<l&&(o=f,l=I,a=M.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${r} used.`);return{axis:o,pos:a}}function _S(s,e,t,n){let i=0;const r=s.offset;for(let o=e,a=e+t;o<a;o++)i+=s[(o-r)*6+n*2];return i/t}class kl{constructor(){this.boundingData=new Float32Array(6)}}function bS(s,e,t,n,i,r){let o=n,a=n+i-1;const c=r.pos,l=r.axis*2,d=t.offset||0;for(;;){for(;o<=a&&t[(o-d)*6+l]<c;)o++;for(;o<=a&&t[(a-d)*6+l]>=c;)a--;if(o<a){for(let u=0;u<e;u++){let h=s[o*e+u];s[o*e+u]=s[a*e+u],s[a*e+u]=h}for(let u=0;u<6;u++){const h=o-d,f=a-d,m=t[h*6+u];t[h*6+u]=t[f*6+u],t[f*6+u]=m}o++,a--}else return o}}let Am,lc,td,Cm;const MS=Math.pow(2,32);function nd(s){return"count"in s?1:1+nd(s.left)+nd(s.right)}function SS(s,e,t){return Am=new Float32Array(t),lc=new Uint32Array(t),td=new Uint16Array(t),Cm=new Uint8Array(t),id(s,e)}function id(s,e){const t=s/4,n=s/2,i="count"in e,r=e.boundingData;for(let o=0;o<6;o++)Am[t+o]=r[o];if(i)return e.buffer?(Cm.set(new Uint8Array(e.buffer),s),s+e.buffer.byteLength):(lc[t+6]=e.offset,td[n+14]=e.count,td[n+15]=Tm,s+dn);{const{left:o,right:a,splitAxis:c}=e,l=s+dn;let d=id(l,o);const u=s/dn,f=d/dn-u;if(f>MS)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return lc[t+6]=f,lc[t+7]=c,id(d,a)}}
4050function wS(s,e,t,n,i,r){const{maxDepth:o,verbose:a,targetLeafSize:c,_strictLeafSize:l=1/0,strategy:d,onProgress:u}=i,h=s.primitiveBuffer,f=s.primitiveBufferStride,m=new Float32Array(6);let x=!1;const p=new kl;return Fl(e,t,n,p.boundingData,m),y(p,t,n,m),p;function g(_){u&&u((_-r.offset)/r.count)}function y(_,v,M,w=null,E=0){!x&&E>=o&&(x=!0,a&&console.warn(`BVH: Max depth of ${o} reached when generating BVH. Consider increasing maxDepth.`));const b=M>l;if(M<=c&&!b||E>=o)return g(v+M),_.offset=v,_.count=M,_;const S=vS(_.boundingData,w,e,v,M,d);let P=S.axis===-1?-1:bS(h,f,e,v,M,S);if(S.axis===-1||P===v||P===v+M){if(!b)return g(v+M),_.offset=v,_.count=M,_;S.axis=Math.max(0,ed(_.boundingData)),P=v+Math.max(1,Math.floor(M/2))}_.splitAxis=S.axis;const A=new kl,T=v,I=P-v;_.left=A,Fl(e,T,I,A.boundingData,m),y(A,T,I,m,E+1);const k=new kl,F=P,L=M-I;return _.right=k,Fl(e,F,L,k.boundingData,m),y(k,F,L,m,E+1),_}}function TS(s,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=s.getRootRanges(e.range),i=n[0],r=n[n.length-1],o={offset:i.offset,count:r.offset+r.count-i.offset},a=new Float32Array(6*o.count);a.offset=o.offset,s.computePrimitiveBounds(o.offset,o.count,a),s._roots=n.map(c=>{const l=wS(s,a,c.offset,c.count,e,o),d=nd(l),u=new t(dn*d);return SS(0,l,u),u})}class th{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class ES{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const St=new ES;let ls,br;const or=[],Na=new th(()=>new ct);function AS(s,e,t,n,i,r){ls=Na.getPrimitive(),br=Na.getPrimitive(),or.push(ls,br),St.setBuffer(s._roots[e]);const o=sd(0,s.geometry,t,n,i,r);St.clearBuffer(),Na.releasePrimitive(ls),Na.releasePrimitive(br),or.pop(),or.pop();const a=or.length;return a>0&&(br=or[a-1],ls=or[a-2]),o}function sd(s,e,t,n,i=null,r=0,o=0){const{float32Array:a,uint16Array:c,uint32Array:l}=St;let d=s*2;if(Nt(d,c)){const m=Zt(s,l),x=hn(d,c);return Lt(s,a,ls),n(m,x,!1,o,r+s/Vt,ls)}else{let T=function(k){const{uint16Array:F,uint32Array:L}=St;let O=k*2;for(;!Nt(O,F);)k=Ht(k),O=k*2;return Zt(k,L)},I=function(k){const{uint16Array:F,uint32Array:L}=St;let O=k*2;for(;!Nt(O,F);)k=Gt(k,L),O=k*2;return Zt(k,L)+hn(O,F)};var h=T,f=I;const m=Ht(s),x=Gt(s,l);let p=m,g=x,y,_,v,M;if(i&&(v=ls,M=br,Lt(p,a,v),Lt(g,a,M),y=i(v),_=i(M),_<y)){p=x,g=m;const k=y;y=_,_=k,v=M}v||(v=ls,Lt(p,a,v));const w=Nt(p*2,c),E=t(v,w,y,o+1,r+p/Vt);let b;if(E===Qf){const k=T(p),L=I(p)-k;b=n(k,L,!0,o+1,r+p/Vt,v)}else b=E&&sd(p,e,t,n,i,r,o+1);if(b)return!0;M=br,Lt(g,a,M);const S=Nt(g*2,c),P=t(M,S,_,o+1,r+g/Vt);let A;if(P===Qf){const k=T(g),L=I(g)-k;A=n(k,L,!0,o+1,r+g/Vt,M)}else A=P&&sd(g,e,t,n,i,r,o+1);return!!A}}const Ro=new St.constructor,Mc=new St.constructor,rs=new th(()=>new ct),ar=new ct,cr=new ct,Bl=new ct,zl=new ct;let Vl=!1;function CS(s,e,t,n){if(Vl)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Vl=!0;const i=s._roots,r=e._roots;let o,a=0,c=0;const l=new Oe().copy(t).invert();for(let d=0,u=i.length;d<u;d++){Ro.setBuffer(i[d]),c=0;const h=rs.getPrimitive();Lt(0,Ro.float32Array,h),h.applyMatrix4(l);for(let f=0,m=r.length;f<m&&(Mc.setBuffer(r[f]),o=Jn(0,0,t,l,n,a,c,0,0,h),Mc.clearBuffer(),c+=r[f].byteLength/dn,!o);f++);if(rs.releasePrimitive(h),Ro.clearBuffer(),a+=i[d].byteLength/dn,o)break}return Vl=!1,o}function Jn(s,e,t,n,i,r=0,o=0,a=0,c=0,l=null,d=!1){let u,h;d?(u=Mc,h=Ro):(u=Ro,h=Mc);const f=u.float32Array,m=u.uint32Array,x=u.uint16Array,p=h.float32Array,g=h.uint32Array,y=h.uint16Array,_=s*2,v=e*2,M=Nt(_,x),w=Nt(v,y);let E=!1;if(w&&M)d?E=i(Zt(e,g),hn(e*2,y),Zt(s,m),hn(s*2,x),c,o+e/Vt,a,r+s/Vt):E=i(Zt(s,m),hn(s*2,x),Zt(e,g),hn(e*2,y),a,r+s/Vt,c,o+e/Vt);else if(w){const b=rs.getPrimitive();
4050Lt(e,p,b),b.applyMatrix4(t);const S=Ht(s),P=Gt(s,m);Lt(S,f,ar),Lt(P,f,cr);const A=b.intersectsBox(ar),T=b.intersectsBox(cr);E=A&&Jn(e,S,n,t,i,o,r,c,a+1,b,!d)||T&&Jn(e,P,n,t,i,o,r,c,a+1,b,!d),rs.releasePrimitive(b)}else{const b=Ht(e),S=Gt(e,g);Lt(b,p,Bl),Lt(S,p,zl);const P=l.intersectsBox(Bl),A=l.intersectsBox(zl);if(P&&A)E=Jn(s,b,t,n,i,r,o,a,c+1,l,d)||Jn(s,S,t,n,i,r,o,a,c+1,l,d);else if(P)if(M)E=Jn(s,b,t,n,i,r,o,a,c+1,l,d);else{const T=rs.getPrimitive();T.copy(Bl).applyMatrix4(t);const I=Ht(s),k=Gt(s,m);Lt(I,f,ar),Lt(k,f,cr);const F=T.intersectsBox(ar),L=T.intersectsBox(cr);E=F&&Jn(b,I,n,t,i,o,r,c,a+1,T,!d)||L&&Jn(b,k,n,t,i,o,r,c,a+1,T,!d),rs.releasePrimitive(T)}else if(A)if(M)E=Jn(s,S,t,n,i,r,o,a,c+1,l,d);else{const T=rs.getPrimitive();T.copy(zl).applyMatrix4(t);const I=Ht(s),k=Gt(s,m);Lt(I,f,ar),Lt(k,f,cr);const F=T.intersectsBox(ar),L=T.intersectsBox(cr);E=F&&Jn(S,I,n,t,i,o,r,c,a+1,T,!d)||L&&Jn(S,k,n,t,i,o,r,c,a+1,T,!d),rs.releasePrimitive(T)}}return E}const Hl=new class{constructor(){let s=null,e=null,t=null,n=!1;this.root=null,this.buffer=null,this.uint32Array=null,this.uint16Array=null,this.setBVH=(r,o)=>{if(n)throw new Error("BVHTraversalHelper: cannot call setBVH during an active traversal.");this.root=o,this.buffer=s=r._roots[o],this.uint16Array=t=new Uint16Array(s),this.uint32Array=e=new Uint32Array(s)},this.reset=()=>{this.root=null,this.buffer=s=null,this.uint16Array=t=null,this.uint32Array=e=null},this.getRangeStart=r=>{let o=r*2;for(;!Nt(o,t);)r=Ht(r),o=r*2;return Zt(r,e)},this.getRangeEnd=r=>{let o=r*2;for(;!Nt(o,t);)r=Gt(r,e),o=r*2;return Zt(r,e)+hn(o,t)};const i=(r,o,a)=>{const c=o*2,l=Nt(c,t);if(!r(a,l,o)&&!l){const u=Ht(o),h=Gt(o,e);i(r,u,a+1),i(r,h,a+1)}};this.traverseBuffer=r=>{if(n)throw new Error("BVHTraversalHelper: cannot start a traversal during an active traversal.");n=!0;try{i(r,0,0)}finally{n=!1}},this.traverse=r=>{this.traverseBuffer((o,a,c)=>{if(a){const l=c*2,d=e[c+6],u=t[l+14];return r(o,a,new Float32Array(s,c*4,6),d,u)}else{const l=eh(c,e);return r(o,a,new Float32Array(s,c*4,6),l)}})}}},np=new ct,lr=new Float32Array(6);class RS{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){e={...Em,...e},"maxLeafSize"in e&&(console.warn('BVH: "maxLeafSize" option has been deprecated. Use "targetLeafSize", instead.'),e={...e,targetLeafSize:e.maxLeafSize}),TS(this,e)}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(e,t,n,i){let r=1/0,o=1/0,a=1/0,c=-1/0,l=-1/0,d=-1/0;for(let u=e,h=e+t;u<h;u++){this.writePrimitiveBounds(u,lr,0);const[f,m,x,p,g,y]=lr;f<r&&(r=f),p>c&&(c=p),m<o&&(o=m),g>l&&(l=g),x<a&&(a=x),y>d&&(d=y)}return n[i+0]=r,n[i+1]=o,n[i+2]=a,n[i+3]=c,n[i+4]=l,n[i+5]=d,n}computePrimitiveBounds(e,t,n){const i=n.offset||0;for(let r=e,o=e+t;r<o;r++){this.writePrimitiveBounds(r,lr,0);const[a,c,l,d,u,h]=lr,f=(a+d)/2,m=(c+u)/2,x=(l+h)/2,p=(d-a)/2,g=(u-c)/2,y=(h-l)/2,_=(r-i)*6;n[_+0]=f,n[_+1]=p+(Math.abs(f)+p)*cc,n[_+2]=m,n[_+3]=g+(Math.abs(m)+g)*cc,n[_+4]=x,n[_+5]=y+(Math.abs(x)+y)*cc}return n}shiftPrimitiveOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const n=this._roots;for(let i=0;i<n.length;i++){const r=n[i],o=new Uint32Array(r),a=new Uint16Array(r),c=r.byteLength/dn;for(let l=0;l<c;l++){const d=Vt*l,u=2*d;Nt(u,a)&&(o[d+6]+=e)}}}}traverse(e,t=0){Hl.setBVH(this,t),Hl.traverse(e),Hl.reset()}refit(){const e=this._roots;for(let t=0,n=e.length;t<n;t++){const i=e[t],r=new Uint32Array(i),o=new Uint16Array(i),a=new Float32Array(i),c=i.byteLength/dn;for(let l=c-1;l>=0;l--){const d=l*Vt,u=d*2;if(Nt(u,o)){const f=Zt(d,r),m=hn(u,o);this.writePrimitiveRangeBounds(f,m,lr,0),a.set(lr,d)}else{const f=Ht(d),m=Gt(d,r);for(let x=0;x<3;x++){const p=a[f+x],g=a[f+x+3],y=a[m+x],_=a[m+x+3];a[d+x]=p<y?p:y,a[d+x+3]=g>_?g:_}}}}}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{Lt(0,new Float32Array(n),np),e.union(np)}),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:n,intersectsRange:i,intersectsPrimitive:r,scratchPrimitive:o,iterate:a}=e;if(i&&r){const u=i;i=(h,f,m,x,p)=>u(h,f,m,x,p)?!0:a(h,f,this,r,m,x,o)}else i||(r?i=(u,h,f,m)=>a(u,h,this,r,f,m,o):i=(u,h,f)=>f);let c=!1,l=0;const d=this._roots;for(let u=0,h=d.length;u<h;u++){const f=d[u];if(c=AS(this,u,n,i,t,l),c)break;l+=f.byteLength/dn}return c}bvhcast(e,t,n){let{intersectsRanges:i}=n;return CS(this,e,t,i)}}function PS(){return typeof SharedArrayBuffer<"u"}function nh(s){return s.index?s.index.count:s.attributes.position.count}function Bc(s){return nh(s)/3}function LS(s,e=ArrayBuffer){return s>65535?new Uint32Array(new e(4*s)):new Uint16Array(new e(2*s))}function IS(s,e){if(!s.index){const t=s.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=LS(t,n);s.setIndex(new Rt(i,1));for(let r=0;r<t;r++)i[r]=r}}function DS(s,e,t){const n=nh(s)/t,i=e||s.drawRange,r=i.start/t,o=(i.start+i.count)/t,a=Math.max(0,r),c=Math.min(n,o)-a;
vendor: 31,082 bytes, line 4050
4050return{offset:Math.floor(a),count:Math.floor(c)}}function NS(s,e){return s.groups.map(t=>({offset:t.start/e,count:t.count/e}))}function ip(s,e,t){const n=DS(s,e,t),i=NS(s,t);if(!i.length)return[n];const r=[],o=n.offset,a=n.offset+n.count,c=nh(s)/t,l=[];for(const h of i){const{offset:f,count:m}=h,x=f,p=isFinite(m)?m:c-f,g=f+p;x<a&&g>o&&(l.push({pos:Math.max(o,x),isStart:!0}),l.push({pos:Math.min(a,g),isStart:!1}))}l.sort((h,f)=>h.pos!==f.pos?h.pos-f.pos:h.type==="end"?-1:1);let d=0,u=null;for(const h of l){const f=h.pos;d!==0&&f!==u&&r.push({offset:u,count:f-u}),d+=h.isStart?1:-1,u=f}return r}function US(s,e){const t=s[s.length-1],n=t.offset+t.count>2**16,i=s.reduce((l,d)=>l+d.count,0),r=n?4:2,o=e?new SharedArrayBuffer(i*r):new ArrayBuffer(i*r),a=n?new Uint32Array(o):new Uint16Array(o);let c=0;for(let l=0;l<s.length;l++){const{offset:d,count:u}=s[l];for(let h=0;h<u;h++)a[c+h]=d+h;c+=u}return a}class OS extends RS{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(e){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(e){}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("BVH: Only BufferGeometries are supported.");if(t.useSharedArrayBuffer&&!PS())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=e,this.resolvePrimitiveIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,t={...Em,...t},t[$d]||this.init(t)}init(e){const{geometry:t,primitiveStride:n}=this;if(e.indirect){const i=ip(t,e.range,n),r=US(i,e.useSharedArrayBuffer);this._indirectBuffer=r}else IS(t,e);super.init(e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new ct))}getRootRanges(e){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:ip(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class Wi{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let r=0,o=e.length;r<o;r++){const c=e[r][t];n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let r=0,o=t.length;r<o;r++){const a=t[r],c=e.dot(a);n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}Wi.prototype.setFromBox=(function(){const s=new D;return function(t,n){const i=n.min,r=n.max;let o=1/0,a=-1/0;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let d=0;d<=1;d++){s.x=i.x*c+r.x*(1-c),s.y=i.y*l+r.y*(1-l),s.z=i.z*d+r.z*(1-d);const u=t.dot(s);o=Math.min(u,o),a=Math.max(u,a)}this.min=o,this.max=a}})();const FS=(function(){const s=new D,e=new D,t=new D;return function(i,r,o){const a=i.start,c=s,l=r.start,d=e;t.subVectors(a,l),s.subVectors(i.end,i.start),e.subVectors(r.end,r.start);const u=t.dot(d),h=d.dot(c),f=d.dot(d),m=t.dot(c),p=c.dot(c)*f-h*h;let g,y;p!==0?g=(u*h-m*f)/p:g=0,y=(u+g*h)/f,o.x=g,o.y=y}})(),ih=(function(){const s=new xe,e=new D,t=new D;return function(i,r,o,a){FS(i,r,s);let c=s.x,l=s.y;if(c>=0&&c<=1&&l>=0&&l<=1){i.at(c,o),r.at(l,a);return}else if(c>=0&&c<=1){l<0?r.at(0,a):r.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(l>=0&&l<=1){c<0?i.at(0,o):i.at(1,o),r.closestPointToPoint(o,!0,a);return}else{let d;c<0?d=i.start:d=i.end;let u;l<0?u=r.start:u=r.end;const h=e,f=t;if(i.closestPointToPoint(u,!0,e),r.closestPointToPoint(d,!0,t),h.distanceToSquared(u)<=f.distanceToSquared(d)){o.copy(h),a.copy(u);return}else{o.copy(d),a.copy(f);return}}}})(),kS=(function(){const s=new D,e=new D,t=new gi,n=new wi;return function(r,o){const{radius:a,center:c}=r,{a:l,b:d,c:u}=o;if(n.start=l,n.end=d,n.closestPointToPoint(c,!0,s).distanceTo(c)<=a||(n.start=l,n.end=u,n.closestPointToPoint(c,!0,s).distanceTo(c)<=a)||(n.start=d,n.end=u,n.closestPointToPoint(c,!0,s).distanceTo(c)<=a))return!0;const x=o.getPlane(t);if(Math.abs(x.distanceToPoint(c))<=a){const g=x.projectPoint(c,e);if(o.containsPoint(g))return!0}return!1}})(),BS=["x","y","z"],Ui=1e-15,sp=Ui*Ui;function zn(s){return Math.abs(s)<Ui}class ri extends tn{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new D),this.satBounds=new Array(4).fill().map(()=>new Wi),this.points=[this.a,this.b,this.c],this.plane=new gi,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new wi,this.needsUpdate=!0}intersectsSphere(e){return kS(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,r=this.satAxes,o=this.satBounds,a=r[0],c=o[0];this.getNormal(a),c.setFromPoints(a,i);const l=r[1],d=o[1];l.subVectors(e,t),d.setFromPoints(l,i);const u=r[2],h=o[2];u.subVectors(t,n),h.setFromPoints(u,i);const f=r[3],m=o[3];f.subVectors(n,e),m.setFromPoints(f,i);const x=l.length(),p=u.length(),g=f.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,x<Ui?p<Ui||g<Ui?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):p<Ui?g<Ui?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):g<Ui&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}ri.prototype.closestPointToSegment=(function(){const s=new D,e=new D,t=new wi;return function(i,r=null,o=null){const{start:a,end:c}=i,l=this.points;let d,u=1/0;for(let h=0;h<3;h++){const f=(h+1)%3;t.start.copy(l[h]),t.end.copy(l[f]),ih(t,i,s,e),d=s.distanceToSquared(e),d<u&&(u=d,r&&r.copy(s),o&&o.copy(e))}return this.closestPointToPoint(a,s),d=a.distanceToSquared(s),d<u&&(u=d,r&&r.copy(s),o&&o.copy(a)),this.closestPointToPoint(c,s),d=c.distanceToSquared(s),d<u&&(u=d,r&&r.copy(s),o&&o.copy(c)),Math.sqrt(u)}})();ri.prototype.intersectsTriangle=(function(){const s=new ri,e=new Wi,t=new Wi,n=new D,i=new D,r=new D,o=new D,a=new wi,c=new wi,l=new D,d=new xe,u=new xe;function h(_,v,M,w){const E=n;!_.isDegenerateIntoPoint&&!_.isDegenerateIntoSegment?E.copy(_.plane.normal):E.copy(v.plane.normal);const b=_.satBounds,S=_.satAxes;for(let T=1;T<4;T++){const I=b[T],k=S[T];if(e.setFromPoints(k,v.points),I.isSeparated(e)||(o.copy(E).cross(k),e.setFromPoints(o,_.points),t.setFromPoints(o,v.points),e.isSeparated(t)))return!1}const P=v.satBounds,A=v.satAxes;for(let T=1;T<4;T++){const I=P[T],k=A[T];if(e.setFromPoints(k,_.points),I.isSeparated(e)||(o.crossVectors(E,k),e.setFromPoints(o,_.points),t.setFromPoints(o,v.points),e.isSeparated(t)))return!1}return M&&(w||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),M.start.set(0,0,0),M.end.set(0,0,0)),!0}function f(_,v,M,w,E,b,S,P,A,T,I){let k=S/(S-P);T.x=w+(E-w)*k,I.start.subVectors(v,_).multiplyScalar(k).add(_),k=S/(S-A),T.y=w+(b-w)*k,I.end.subVectors(M,_).multiplyScalar(k).add(_)}function m(_,v,M,w,E,b,S,P,A,T,I){if(E>0)f(_.c,_.a,_.b,w,v,M,A,S,P,T,I);else if(b>0)f(_.b,_.a,_.c,M,v,w,P,S,A,T,I);else if(P*A>0||S!=0)f(_.a,_.b,_.c,v,M,w,S,P,A,T,I);else if(P!=0)f(_.b,_.a,_.c,M,v,w,P,S,A,T,I);else if(A!=0)f(_.c,_.a,_.b,w,v,M,A,S,P,T,I);else return!0;return!1}function x(_,v,M,w){const E=v.degenerateSegment,b=_.plane.distanceToPoint(E.start),S=_.plane.distanceToPoint(E.end);return zn(b)?zn(S)?h(_,v,M,w):(M&&(M.start.copy(E.start),M.end.copy(E.start)),_.containsPoint(E.start)):zn(S)?(M&&(M.start.copy(E.end),M.end.copy(E.end)),_.containsPoint(E.end)):_.plane.intersectLine(E,n)!=null?(M&&(M.start.copy(n),M.end.copy(n)),_.containsPoint(n)):!1}function p(_,v,M){const w=v.a;return zn(_.plane.distanceToPoint(w))&&_.containsPoint(w)?(M&&(M.start.copy(w),M.end.copy(w)),!0):!1}function g(_,v,M){const w=_.degenerateSegment,E=v.a;return w.closestPointToPoint(E,!0,n),E.distanceToSquared(n)<sp?(M&&(M.start.copy(E),M.end.copy(E)),!0):!1}function y(_,v,M,w){if(_.isDegenerateIntoSegment)if(v.isDegenerateIntoSegment){const E=_.degenerateSegment,b=v.degenerateSegment,S=i,P=r;E.delta(S),b.delta(P);const A=n.subVectors(b.start,E.start),T=S.x*P.y-S.y*P.x;if(zn(T))return!1;const I=(A.x*P.y-A.y*P.x)/T,k=-(S.x*A.y-S.y*A.x)/T;if(I<0||I>1||k<0||k>1)return!1;const F=E.start.z+S.z*I,L=b.start.z+P.z*k;return zn(F-L)?(M&&(M.start.copy(E.start).addScaledVector(S,I),M.end.copy(E.start).addScaledVector(S,I)),!0):!1}else return v.isDegenerateIntoPoint?g(_,v,M):x(v,_,M,w);else{if(_.isDegenerateIntoPoint)return v.isDegenerateIntoPoint?v.a.distanceToSquared(_.a)<sp?(M&&(M.start.copy(_.a),M.end.copy(_.a)),!0):!1:v.isDegenerateIntoSegment?g(v,_,M):p(v,_,M);if(v.isDegenerateIntoPoint)return p(_,v,M);if(v.isDegenerateIntoSegment)return x(_,v,M,w)}}return function(v,M=null,w=!1){this.needsUpdate&&this.update(),v.isExtendedTriangle?v.needsUpdate&&v.update():(s.copy(v),s.update(),v=s);const E=y(this,v,M,w);if(E!==void 0)return E;const b=this.plane,S=v.plane;let P=S.distanceToPoint(this.a),A=S.distanceToPoint(this.b),T=S.distanceToPoint(this.c);zn(P)&&(P=0),zn(A)&&(A=0),zn(T)&&(T=0);const I=P*A,k=P*T;if(I>0&&k>0)return!1;let F=b.distanceToPoint(v.a),L=b.distanceToPoint(v.b),O=b.distanceToPoint(v.c);zn(F)&&(F=0),zn(L)&&(L=0),zn(O)&&(O=0);const H=F*L,W=F*O;if(H>0&&W>0)return!1;i.copy(b.normal),r.copy(S.normal);const q=i.cross(r);let Z=0,V=Math.abs(q.x);const K=Math.abs(q.y);K>V&&(V=K,Z=1),Math.abs(q.z)>V&&(Z=2);const $=BS[Z],R=this.a[$],z=this.b[$],Y=this.c[$],ie=v.a[$],re=v.b[$],ge=v.c[$];if(m(this,R,z,Y,I,k,P,A,T,d,a))return h(this,v,M,w);if(m(v,ie,re,ge,H,W,F,L,O,u,c))return h(this,v,M,w);if(d.y<d.x){const Fe=d.y;d.y=d.x,d.x=Fe,l.copy(a.start),a.start.copy(a.end),a.end.copy(l)}if(u.y<u.x){const Fe=u.y;u.y=u.x,u.x=Fe,l.copy(c.start),c.start.copy(c.end),c.end.copy(l)}return d.y<u.x||u.y<d.x?!1:(M&&(u.x>d.x?M.start.copy(c.start):M.start.copy(a.start),u.y<d.y?M.end.copy(c.end):M.end.copy(a.end)),!0)}})();ri.prototype.distanceToPoint=(function(){const s=new D;return function(t){return this.closestPointToPoint(t,s),t.distanceTo(s)}})();ri.prototype.distanceToTriangle=(function(){const s=new D,e=new D,t=["a","b","c"],n=new wi,i=new wi;return function(o,a=null,c=null){const l=a||c?n:null;if(this.intersectsTriangle(o,l,!0))return(a||c)&&(a&&l.getCenter(a),c&&l.getCenter(c)),0;let d=1/0;for(let u=0;u<3;u++){let h;const f=t[u],m=o[f];this.closestPointToPoint(m,s),h=m.distanceToSquared(s),h<d&&(d=h,a&&a.copy(s),c&&c.copy(m));const x=this[f];o.closestPointToPoint(x,s),h=x.distanceToSquared(s),h<d&&(d=h,a&&a.copy(x),c&&c.copy(s))}for(let u=0;u<3;u++){const h=t[u],f=t[(u+1)%3];n.set(this[h],this[f]);for(let m=0;m<3;m++){const x=t[m],p=t[(m+1)%3];i.set(o[x],o[p]),ih(n,i,s,e);const g=s.distanceToSquared(e);g<d&&(d=g,a&&a.copy(s),c&&c.copy(e))}}return Math.sqrt(d)}})();class bn{constructor(e,t,n){this.isOrientedBox=!0,this.min=new D,this.max=new D,this.matrix=new Oe,this.invMatrix=new Oe,this.points=new Array(8).fill().map(()=>new D),this.satAxes=new Array(3).fill().map(()=>new D),this.satBounds=new Array(3).fill().map(()=>new Wi),this.alignedSatBounds=new Array(3).fill().map(()=>new Wi),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}bn.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let l=0;l<=1;l++)for(let d=0;d<=1;d++)for(let u=0;u<=1;u++){const h=1*l|2*d|4*u,f=i[h];f.x=l?n.x:t.x,f.y=d?n.y:t.y,f.z=u?n.z:t.z,f.applyMatrix4(e)}const r=this.satBounds,o=this.satAxes,a=i[0];for(let l=0;l<3;l++){const d=o[l],u=r[l],h=1<<l,f=i[h];d.subVectors(a,f),u.setFromPoints(d,i)}const c=this.alignedSatBounds;c[0].setFromPointsField(i,"x"),c[1].setFromPointsField(i,"y"),c[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})();bn.prototype.intersectsBox=(function(){const s=new Wi;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,r=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(s.min=n.x,s.max=i.x,a[0].isSeparated(s)||(s.min=n.y,s.max=i.y,a[1].isSeparated(s))||(s.min=n.z,s.max=i.z,a[2].isSeparated(s)))return!1;for(let c=0;c<3;c++){const l=o[c],d=r[c];if(s.setFromBox(l,t),d.isSeparated(s))return!1}return!0}})();bn.prototype.intersectsTriangle=(function(){const s=new ri,e=new Array(3),t=new Wi,n=new Wi,i=new D;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(s.copy(o),s.update(),o=s);const a=this.satBounds,c=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let h=0;h<3;h++){const f=a[h],m=c[h];if(t.setFromPoints(m,e),f.isSeparated(t))return!1}const l=o.satBounds,d=o.satAxes,u=this.points;for(let h=0;h<3;h++){const f=l[h],m=d[h];if(t.setFromPoints(m,u),f.isSeparated(t))return!1}for(let h=0;h<3;h++){const f=c[h];for(let m=0;m<4;m++){const x=d[m];if(i.crossVectors(f,x),t.setFromPoints(i,e),n.setFromPoints(i,u),t.isSeparated(n))return!1}}return!0}})();bn.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})();bn.prototype.distanceToPoint=(function(){const s=new D;return function(t){return this.closestPointToPoint(t,s),t.distanceTo(s)}})();bn.prototype.distanceToBox=(function(){const s=["x","y","z"],e=new Array(12).fill().map(()=>new wi),t=new Array(12).fill().map(()=>new wi),n=new D,i=new D;return function(o,a=0,c=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(c||l)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),c&&c.copy(n),l&&l.copy(i)),0;const d=a*a,u=o.min,h=o.max,f=this.points;let m=1/0;for(let p=0;p<8;p++){const g=f[p];i.copy(g).clamp(u,h);const y=g.distanceToSquared(i);if(y<m&&(m=y,c&&c.copy(g),l&&l.copy(i),y<d))return Math.sqrt(y)}let x=0;for(let p=0;p<3;p++)for(let g=0;g<=1;g++)for(let y=0;y<=1;y++){const _=(p+1)%3,v=(p+2)%3,M=g<<_|y<<v,w=1<<p|g<<_|y<<v,E=f[M],b=f[w];e[x].set(E,b);const P=s[p],A=s[_],T=s[v],I=t[x],k=I.start,F=I.end;k[P]=u[P],k[A]=g?u[A]:h[A],k[T]=y?u[T]:h[A],F[P]=h[P],F[A]=g?u[A]:h[A],F[T]=y?u[T]:h[A],x++}for(let p=0;p<=1;p++)for(let g=0;g<=1;g++)for(let y=0;y<=1;y++){i.x=p?h.x:u.x,i.y=g?h.y:u.y,i.z=y?h.z:u.z,this.closestPointToPoint(i,n);const _=i.distanceToSquared(n);if(_<m&&(m=_,c&&c.copy(n),l&&l.copy(i),_<d))return Math.sqrt(_)}for(let p=0;p<12;p++){const g=e[p];for(let y=0;y<12;y++){const _=t[y];ih(g,_,n,i);const v=n.distanceToSquared(i);if(v<m&&(m=v,c&&c.copy(n),l&&l.copy(i),v<d))return Math.sqrt(v)}}return Math.sqrt(m)}})();class zS extends th{constructor(){super(()=>new ri)}}const Gn=new zS,ao=new D,Gl=new D;function VS(s,e,t={},n=0,i=1/0){const r=n*n,o=i*i;let a=1/0,c=null;if(s.shapecast({boundsTraverseOrder:d=>(ao.copy(e).clamp(d.min,d.max),ao.distanceToSquared(e)),intersectsBounds:(d,u,h)=>h<a&&h<o,intersectsTriangle:(d,u)=>{d.closestPointToPoint(e,ao);const h=e.distanceToSquared(ao);return h<a&&(Gl.copy(ao),a=h,c=u),h<r}}),a===1/0)return null;const l=Math.sqrt(a);return t.point?t.point.copy(Gl):t.point=Gl.clone(),t.distance=l,t.faceIndex=c,t}const Ua=parseInt(Ko)>=169,HS=parseInt(Ko)<=161,Ts=new D,Es=new D,As=new D,Oa=new xe,Fa=new xe,ka=new xe,rp=new D,op=new D,ap=new D,co=new D;function GS(s,e,t,n,i,r,o,a){let c;if(r===vn?c=s.intersectTriangle(n,t,e,!0,i):c=s.intersectTriangle(e,t,n,r!==Tt,i),c===null)return null;const l=s.origin.distanceTo(i);return l<o||l>a?null:{distance:l,point:i.clone()}}function cp(s,e,t,n,i,r,o,a,c,l,d){Ts.fromBufferAttribute(e,r),Es.fromBufferAttribute(e,o),As.fromBufferAttribute(e,a);const u=GS(s,Ts,Es,As,co,c,l,d);if(u){if(n){Oa.fromBufferAttribute(n,r),Fa.fromBufferAttribute(n,o),ka.fromBufferAttribute(n,a),u.uv=new xe;const f=tn.getInterpolation(co,Ts,Es,As,Oa,Fa,ka,u.uv);Ua||(u.uv=f)}if(i){Oa.fromBufferAttribute(i,r),Fa.fromBufferAttribute(i,o),ka.fromBufferAttribute(i,a),u.uv1=new xe;const f=tn.getInterpolation(co,Ts,Es,As,Oa,Fa,ka,u.uv1);Ua||(u.uv1=f),HS&&(u.uv2=u.uv1)}if(t){rp.fromBufferAttribute(t,r),op.fromBufferAttribute(t,o),ap.fromBufferAttribute(t,a),u.normal=new D;const f=tn.getInterpolation(co,Ts,Es,As,rp,op,ap,u.normal);u.normal.dot(s.direction)>0&&u.normal.multiplyScalar(-1),Ua||(u.normal=f)}const h={a:r,b:o,c:a,normal:new D,materialIndex:0};if(tn.getNormal(Ts,Es,As,h.normal),u.face=h,u.faceIndex=r,Ua){const f=new D;tn.getBarycoord(co,Ts,Es,As,f),u.barycoord=f}}return u}function lp(s){return s&&s.isMaterial?s.side:s}function zc(s,e,t,n,i,r,o){const a=n*3;let c=a+0,l=a+1,d=a+2;const{index:u,groups:h}=s;s.index&&(c=u.getX(c),l=u.getX(l),d=u.getX(d));const{position:f,normal:m,uv:x,uv1:p}=s.attributes;if(Array.isArray(e)){const g=n*3;for(let y=0,_=h.length;y<_;y++){const{start:v,count:M,materialIndex:w}=h[y];if(g>=v&&g<v+M){const E=lp(e[w]),b=cp(t,f,m,x,p,c,l,d,E,r,o);if(b)if(b.faceIndex=n,b.face.materialIndex=w,i)i.push(b);else return b}}}else{const g=lp(e),y=cp(t,f,m,x,p,c,l,d,g,r,o);if(y)if(y.faceIndex=n,y.face.materialIndex=0,i)i.push(y);else return y}return null}function Bt(s,e,t,n){const i=s.a,r=s.b,o=s.c;let a=e,c=e+1,l=e+2;t&&(a=t.getX(a),c=t.getX(c),l=t.getX(l)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),r.x=n.getX(c),r.y=n.getY(c),r.z=n.getZ(c),o.x=n.getX(l),o.y=n.getY(l),o.z=n.getZ(l)}function WS(s,e,t,n,i,r,o,a){const{geometry:c,_indirectBuffer:l}=s;for(let d=n,u=n+i;d<u;d++)zc(c,e,t,d,r,o,a)}function XS(s,e,t,n,i,r,o){const{geometry:a,_indirectBuffer:c}=s;let l=1/0,d=null;for(let u=n,h=n+i;u<h;u++){let f;f=zc(a,e,t,u,null,r,o),f&&f.distance<l&&(d=f,l=f.distance)}return d}function qS(s,e,t,n,i,r,o){const{geometry:a}=t,{index:c}=a,l=a.attributes.position;for(let d=s,u=e+s;d<u;d++){let h;if(h=d,Bt(o,h*3,c,l),o.needsUpdate=!0,n(o,h,i,r))return!0}return!1}function jS(s,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=s.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let r,o,a,c,l=0;const d=s._roots;for(let h=0,f=d.length;h<f;h++)r=d[h],o=new Uint32Array(r),a=new Uint16Array(r),c=new Float32Array(r),u(0,l),l+=r.byteLength;function u(h,f,m=!1){const x=h*2;if(Nt(x,a)){const p=Zt(h,o),g=hn(x,a);let y=1/0,_=1/0,v=1/0,M=-1/0,w=-1/0,E=-1/0;for(let b=3*p,S=3*(p+g);b<S;b++){let P=n[b];const A=i.getX(P),T=i.getY(P),I=i.getZ(P);A<y&&(y=A),A>M&&(M=A),T<_&&(_=T),T>w&&(w=T),I<v&&(v=I),I>E&&(E=I)}return c[h+0]!==y||c[h+1]!==_||c[h+2]!==v||c[h+3]!==M||c[h+4]!==w||c[h+5]!==E?(c[h+0]=y,c[h+1]=_,c[h+2]=v,c[h+3]=M,c[h+4]=w,c[h+5]=E,!0):!1}else{const p=Ht(h),g=Gt(h,o);let y=m,_=!1,v=!1;if(e){if(!y){const P=p/Vt+f/dn,A=g/Vt+f/dn;_=e.has(P),v=e.has(A),y=!_&&!v}}else _=!0,v=!0;const M=y||_,w=y||v;let E=!1;M&&(E=u(p,f,y));let b=!1;w&&(b=u(g,f,y));const S=E||b;if(S)for(let P=0;P<3;P++){const A=p+P,T=g+P,I=c[A],k=c[A+3],F=c[T],L=c[T+3];c[h+P]=I<F?I:F,c[h+P+3]=k>L?k:L}return S}}}function fs(s,e,t,n,i){let r,o,a,c,l,d;const u=1/t.direction.x,h=1/t.direction.y,f=1/t.direction.z,m=t.origin.x,x=t.origin.y,p=t.origin.z;let g=e[s],y=e[s+3],_=e[s+1],v=e[s+3+1],M=e[s+2],w=e[s+3+2];return u>=0?(r=(g-m)*u,o=(y-m)*u):(r=(y-m)*u,o=(g-m)*u),h>=0?(a=(_-x)*h,c=(v-x)*h):(a=(v-x)*h,c=(_-x)*h),r>c||a>o||((a>r||isNaN(r))&&(r=a),(c<o||isNaN(o))&&(o=c),f>=0?(l=(M-p)*f,d=(w-p)*f):(l=(w-p)*f,d=(M-p)*f),r>d||l>o)?!1:((l>r||r!==r)&&(r=l),(d<o||o!==o)&&(o=d),r<=i&&o>=n)}function YS(s,e,t,n,i,r,o,a){const{geometry:c,_indirectBuffer:l}=s;for(let d=n,u=n+i;d<u;d++){let h=l?l[d]:d;zc(c,e,t,h,r,o,a)}}function KS(s,e,t,n,i,r,o){const{geometry:a,_indirectBuffer:c}=s;let l=1/0,d=null;for(let u=n,h=n+i;u<h;u++){let f;f=zc(a,e,t,c?c[u]:u,null,r,o),f&&f.distance<l&&(d=f,l=f.distance)}return d}function ZS(s,e,t,n,i,r,o){const{geometry:a}=t,{index:c}=a,l=a.attributes.position;for(let d=s,u=e+s;d<u;d++){let h;if(h=t.resolveTriangleIndex(d),Bt(o,h*3,c,l),o.needsUpdate=!0,n(o,h,i,r))return!0}return!1}function JS(s,e,t,n,i,r,o){St.setBuffer(s._roots[e]),rd(0,s,t,n,i,r,o),St.clearBuffer()}function rd(s,e,t,n,i,r,o){const{float32Array:a,uint16Array:c,uint32Array:l}=St,d=s*2;if(Nt(d,c)){const h=Zt(s,l),f=hn(d,c);WS(e,t,n,h,f,i,r,o)}else{const h=Ht(s);fs(h,a,n,r,o)&&rd(h,e,t,n,i,r,o);const f=Gt(s,l);fs(f,a,n,r,o)&&rd(f,e,t,n,i,r,o)}}const QS=["x","y","z"];function $S(s,e,t,n,i,r){St.setBuffer(s._roots[e]);const o=od(0,s,t,n,i,r);return St.clearBuffer(),o}function od(s,e,t,n,i,r){const{float32Array:o,uint16Array:a,uint32Array:c}=St;let l=s*2;if(Nt(l,a)){const u=Zt(s,c),h=hn(l,a);return XS(e,t,n,u,h,i,r)}else{const u=eh(s,c),h=QS[u],m=n.direction[h]>=0;let x,p;m?(x=Ht(s),p=Gt(s,c)):(x=Gt(s,c),p=Ht(s));const y=fs(x,o,n,i,r)?od(x,e,t,n,i,r):null;if(y){const M=y.point[h];if(m?M<=o[p+u]:M>=o[p+u+3])return y}const v=fs(p,o,n,i,r)?od(p,e,t,n,i,r):null;return y&&v?y.distance<=v.distance?y:v:y||v||null}}const Ba=new ct,ur=new ri,dr=new ri,lo=new Oe,up=new bn,za=new bn;function ew(s,e,t,n){St.setBuffer(s._roots[e]);const i=ad(0,s,t,n);return St.clearBuffer(),i}function ad(s,e,t,n,i=null){const{float32Array:r,uint16Array:o,uint32Array:a}=St;let c=s*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),up.set(t.boundingBox.min,t.boundingBox.max,n),i=up),Nt(c,o)){const d=e.geometry,u=d.index,h=d.attributes.position,f=t.index,m=t.attributes.position,x=Zt(s,a),p=hn(c,o);if(lo.copy(n).invert(),t.boundsTree)return Lt(s,r,za),za.matrix.copy(lo),za.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>za.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(n),y.b.applyMatrix4(n),y.c.applyMatrix4(n),y.needsUpdate=!0;for(let _=x*3,v=(p+x)*3;_<v;_+=3)if(Bt(dr,_,u,h),dr.needsUpdate=!0,y.intersectsTriangle(dr))return!0;return!1}});{const g=Bc(t);for(let y=x*3,_=(p+x)*3;y<_;y+=3){Bt(ur,y,u,h),ur.a.applyMatrix4(lo),ur.b.applyMatrix4(lo),ur.c.applyMatrix4(lo),ur.needsUpdate=!0;for(let v=0,M=g*3;v<M;v+=3)if(Bt(dr,v,f,m),dr.needsUpdate=!0,ur.intersectsTriangle(dr))return!0}}}else{const d=Ht(s),u=Gt(s,a);return Lt(d,r,Ba),!!(i.intersectsBox(Ba)&&ad(d,e,t,n,i)||(Lt(u,r,Ba),i.intersectsBox(Ba)&&ad(u,e,t,n,i)))}}const Va=new Oe,Wl=new bn,uo=new bn,tw=new D,nw=new D,iw=new D,sw=new D;function rw(s,e,t,n={},i={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Wl.set(e.boundingBox.min,e.boundingBox.max,t),Wl.needsUpdate=!0;const a=s.geometry,c=a.attributes.position,l=a.index,d=e.attributes.position,u=e.index,h=Gn.getPrimitive(),f=Gn.getPrimitive();let m=tw,x=nw,p=null,g=null;i&&(p=iw,g=sw);let y=1/0,_=null,v=null;return Va.copy(t).invert(),uo.matrix.copy(Va),s.shapecast({boundsTraverseOrder:M=>Wl.distanceToBox(M),intersectsBounds:(M,w,E)=>E<y&&E<o?(w&&(uo.min.copy(M.min),uo.max.copy(M.max),uo.needsUpdate=!0),!0):!1,intersectsRange:(M,w)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:b=>uo.distanceToBox(b),intersectsBounds:(b,S,P)=>P<y&&P<o,intersectsRange:(b,S)=>{for(let P=b,A=b+S;P<A;P++){Bt(f,3*P,u,d),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let T=M,I=M+w;T<I;T++){Bt(h,3*T,l,c),h.needsUpdate=!0;const k=h.distanceToTriangle(f,m,p);if(k<y&&(x.copy(m),g&&g.copy(p),y=k,_=T,v=P),k<r)return!0}}}});{const E=Bc(e);for(let b=0,S=E;b<S;b++){Bt(f,3*b,u,d),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let P=M,A=M+w;P<A;P++){Bt(h,3*P,l,c),h.needsUpdate=!0;const T=h.distanceToTriangle(f,m,p);if(T<y&&(x.copy(m),g&&g.copy(p),y=T,_=P,v=b),T<r)return!0}}}}}),Gn.releasePrimitive(h),Gn.releasePrimitive(f),y===1/0?null:(n.point?n.point.copy(x):n.point=x.clone(),n.distance=y,n.faceIndex=_,i&&(i.point?i.point.copy(g):i.point=g.clone(),i.point.applyMatrix4(Va),x.applyMatrix4(Va),i.distance=x.sub(i.point).length(),i.faceIndex=v),n)}function ow(s,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=s.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let r,o,a,c,l=0;const d=s._roots;for(let h=0,f=d.length;h<f;h++)r=d[h],o=new Uint32Array(r),a=new Uint16Array(r),c=new Float32Array(r),u(0,l),l+=r.byteLength;function u(h,f,m=!1){const x=h*2;if(Nt(x,a)){const p=Zt(h,o),g=hn(x,a);let y=1/0,_=1/0,v=1/0,M=-1/0,w=-1/0,E=-1/0;for(let b=p,S=p+g;b<S;b++){const P=3*s.resolveTriangleIndex(b);for(let A=0;A<3;A++){let T=P+A;T=n?n[T]:T;const I=i.getX(T),k=i.getY(T),F=i.getZ(T);I<y&&(y=I),I>M&&(M=I),k<_&&(_=k),k>w&&(w=k),F<v&&(v=F),F>E&&(E=F)}}return c[h+0]!==y||c[h+1]!==_||c[h+2]!==v||c[h+3]!==M||c[h+4]!==w||c[h+5]!==E?(c[h+0]=y,c[h+1]=_,c[h+2]=v,c[h+3]=M,c[h+4]=w,c[h+5]=E,!0):!1}else{const p=Ht(h),g=Gt(h,o);let y=m,_=!1,v=!1;if(e){if(!y){const P=p/Vt+f/dn,A=g/Vt+f/dn;_=e.has(P),v=e.has(A),y=!_&&!v}}else _=!0,v=!0;const M=y||_,w=y||v;let E=!1;M&&(E=u(p,f,y));let b=!1;w&&(b=u(g,f,y));const S=E||b;if(S)for(let P=0;P<3;P++){const A=p+P,T=g+P,I=c[A],k=c[A+3],F=c[T],L=c[T+3];c[h+P]=I<F?I:F,c[h+P+3]=k>L?k:L}return S}}}function aw(s,e,t,n,i,r,o){St.setBuffer(s._roots[e]),cd(0,s,t,n,i,r,o),St.clearBuffer()}function cd(s,e,t,n,i,r,o){const{float32Array:a,uint16Array:c,uint32Array:l}=St,d=s*2;if(Nt(d,c)){const h=Zt(s,l),f=hn(d,c);YS(e,t,n,h,f,i,r,o)}else{const h=Ht(s);fs(h,a,n,r,o)&&cd(h,e,t,n,i,r,o);const f=Gt(s,l);fs(f,a,n,r,o)&&cd(f,e,t,n,i,r,o)}}const cw=["x","y","z"];function lw(s,e,t,n,i,r){St.setBuffer(s._roots[e]);const o=ld(0,s,t,n,i,r);return St.clearBuffer(),o}function ld(s,e,t,n,i,r){const{float32Array:o,uint16Array:a,uint32Array:c}=St;let l=s*2;if(Nt(l,a)){const u=Zt(s,c),h=hn(l,a);return KS(e,t,n,u,h,i,r)}else{const u=eh(s,c),h=cw[u],m=n.direction[h]>=0;let x,p;m?(x=Ht(s),p=Gt(s,c)):(x=Gt(s,c),p=Ht(s));const y=fs(x,o,n,i,r)?ld(x,e,t,n,i,r):null;if(y){const M=y.point[h];if(m?M<=o[p+u]:M>=o[p+u+3])return y}const v=fs(p,o,n,i,r)?ld(p,e,t,n,i,r):null;return y&&v?y.distance<=v.distance?y:v:y||v||null}}const Ha=new ct,hr=new ri,fr=new ri,ho=new Oe,dp=new bn,Ga=new bn;function uw(s,e,t,n){St.setBuffer(s._roots[e]);const i=ud(0,s,t,n);return St.clearBuffer(),i}function ud(s,e,t,n,i=null){const{float32Array:r,uint16Array:o,uint32Array:a}=St;let c=s*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),dp.set(t.boundingBox.min,t.boundingBox.max,n),i=dp),Nt(c,o)){const d=e.geometry,u=d.index,h=d.attributes.position,f=t.index,m=t.attributes.position,x=Zt(s,a),p=hn(c,o);if(ho.copy(n).invert(),t.boundsTree)return Lt(s,r,Ga),Ga.matrix.copy(ho),Ga.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>Ga.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(n),y.b.applyMatrix4(n),y.c.applyMatrix4(n),y.needsUpdate=!0;for(let _=x,v=p+x;_<v;_++)if(Bt(fr,3*e.resolveTriangleIndex(_),u,h),fr.needsUpdate=!0,y.intersectsTriangle(fr))return!0;return!1}});{const g=Bc(t);for(let y=x,_=p+x;y<_;y++){const v=e.resolveTriangleIndex(y);Bt(hr,3*v,u,h),hr.a.applyMatrix4(ho),hr.b.applyMatrix4(ho),hr.c.applyMatrix4(ho),hr.needsUpdate=!0;for(let M=0,w=g*3;M<w;M+=3)if(Bt(fr,M,f,m),fr.needsUpdate=!0,hr.intersectsTriangle(fr))return!0}}}else{const d=Ht(s),u=Gt(s,a);return Lt(d,r,Ha),!!(i.intersectsBox(Ha)&&ud(d,e,t,n,i)||(Lt(u,r,Ha),i.intersectsBox(Ha)&&ud(u,e,t,n,i)))}}const Wa=new Oe,Xl=new bn,fo=new bn,dw=new D,hw=new D,fw=new D,pw=new D;function mw(s,e,t,n={},i={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Xl.set(e.boundingBox.min,e.boundingBox.max,t),Xl.needsUpdate=!0;const a=s.geometry,c=a.attributes.position,l=a.index,d=e.attributes.position,u=e.index,h=Gn.getPrimitive(),f=Gn.getPrimitive();let m=dw,x=hw,p=null,g=null;i&&(p=fw,g=pw);let y=1/0,_=null,v=null;return Wa.copy(t).invert(),fo.matrix.copy(Wa),s.shapecast({boundsTraverseOrder:M=>Xl.distanceToBox(M),intersectsBounds:(M,w,E)=>E<y&&E<o?(w&&(fo.min.copy(M.min),fo.max.copy(M.max),fo.needsUpdate=!0),!0):!1,intersectsRange:(M,w)=>{if(e.boundsTree){const E=e.boundsTree;return E.shapecast({boundsTraverseOrder:b=>fo.distanceToBox(b),intersectsBounds:(b,S,P)=>P<y&&P<o,intersectsRange:(b,S)=>{for(let P=b,A=b+S;P<A;P++){const T=E.resolveTriangleIndex(P);Bt(f,3*T,u,d),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let I=M,k=M+w;I<k;I++){const F=s.resolveTriangleIndex(I);Bt(h,3*F,l,c),h.needsUpdate=!0;const L=h.distanceToTriangle(f,m,p);if(L<y&&(x.copy(m),g&&g.copy(p),y=L,_=I,v=P),L<r)return!0}}}})}else{const E=Bc(e);for(let b=0,S=E;b<S;b++){Bt(f,3*b,u,d),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let P=M,A=M+w;P<A;P++){const T=s.resolveTriangleIndex(P);Bt(h,3*T,l,c),h.needsUpdate=!0;const I=h.distanceToTriangle(f,m,p);if(I<y&&(x.copy(m),g&&g.copy(p),y=I,_=P,v=b),I<r)return!0}}}}}),Gn.releasePrimitive(h),Gn.releasePrimitive(f),y===1/0?null:(n.point?n.point.copy(x):n.point=x.clone(),n.distance=y,n.faceIndex=_,i&&(i.point?i.point.copy(g):i.point=g.clone(),i.point.applyMatrix4(Wa),x.applyMatrix4(Wa),i.distance=x.sub(i.point).length(),i.faceIndex=v),n)}function hp(s,e,t){return s===null?null:(s.point.applyMatrix4(e.matrixWorld),s.distance=s.point.distanceTo(t.ray.origin),s.object=e,s)}const Xa=new bn,qa=new Si,fp=new D,pp=new Oe,mp=new D,ql=["getX","getY","getZ"];class Sc extends OS{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,r=e._indirectBuffer,o=n.getIndex(),a={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(a.roots=i.map(c=>c.slice()),a.index=o?o.array.slice():null,a.indirectBuffer=r?r.slice():null):(a.roots=i,a.index=o?o.array:null,a.indirectBuffer=r),a}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:r,indirectBuffer:o}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),c(r));const a=new Sc(t,{...n,[$d]:!0});if(a._roots=r,a._indirectBuffer=o||null,n.setIndex){const l=t.getIndex();if(l===null){const d=new Rt(e.index,1,!1);t.setIndex(d)}else l.array!==i&&(l.array.set(i),l.needsUpdate=!0)}return a;function c(l){for(let d=0;d<l.length;d++){const u=l[d],h=new Uint32Array(u),f=new Uint16Array(u);for(let m=0,x=u.byteLength/dn;m<x;m++){const p=Vt*m,g=2*p;Nt(g,f)||(h[p+6]=h[p+6]/Vt-m)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(e,t={}){t.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use "targetLeafSize", instead.'),t={...t,targetLeafSize:t.maxLeafTris}),super(e,t)}shiftTriangleOffsets(e){return super.shiftPrimitiveOffsets(e)}writePrimitiveBounds(e,t,n){const i=this.geometry,r=this._indirectBuffer,o=i.attributes.position,a=i.index?i.index.array:null,l=(r?r[e]:e)*3;let d=l+0,u=l+1,h=l+2;a&&(d=a[d],u=a[u],h=a[h]);for(let f=0;f<3;f++){const m=o[ql[f]](d),x=o[ql[f]](u),p=o[ql[f]](h);let g=m;x<g&&(g=x),p<g&&(g=p);let y=m;x>y&&(y=x),p>y&&(y=p),t[n+f]=g,t[n+f+3]=y}return t}computePrimitiveBounds(e,t,n){const i=this.geometry,r=this._indirectBuffer,o=i.attributes.position,a=i.index?i.index.array:null,c=o.normalized;if(e<0||t+e-n.offset>n.length/6)throw new Error("MeshBVH: compute triangle bounds range is invali
4050d.");const l=o.array,d=o.offset||0;let u=3;o.isInterleavedBufferAttribute&&(u=o.data.stride);const h=["getX","getY","getZ"],f=n.offset;for(let m=e,x=e+t;m<x;m++){const g=(r?r[m]:m)*3,y=(m-f)*6;let _=g+0,v=g+1,M=g+2;a&&(_=a[_],v=a[v],M=a[M]),c||(_=_*u+d,v=v*u+d,M=M*u+d);for(let w=0;w<3;w++){let E,b,S;c?(E=o[h[w]](_),b=o[h[w]](v),S=o[h[w]](M)):(E=l[_+w],b=l[v+w],S=l[M+w]);let P=E;b<P&&(P=b),S<P&&(P=S);let A=E;b>A&&(A=b),S>A&&(A=S);const T=(A-P)/2,I=w*2;n[y+I+0]=P+T,n[y+I+1]=T+(Math.abs(P)+T)*cc}}return n}raycastObject3D(e,t,n=[]){const{material:i}=e;if(i===void 0)return;pp.copy(e.matrixWorld).invert(),qa.copy(t.ray).applyMatrix4(pp),mp.setFromMatrixScale(e.matrixWorld),fp.copy(qa.direction).multiply(mp);const r=fp.length(),o=t.near/r,a=t.far/r;if(t.firstHitOnly===!0){let c=this.raycastFirst(qa,i,o,a);c=hp(c,e,t),c&&n.push(c)}else{const c=this.raycast(qa,i,o,a);for(let l=0,d=c.length;l<d;l++){const u=hp(c[l],e,t);u&&n.push(u)}}return n}refit(e=null){return(this.indirect?ow:jS)(this,e)}raycast(e,t=ii,n=0,i=1/0){const r=this._roots,o=[],a=this.indirect?aw:JS;for(let c=0,l=r.length;c<l;c++)a(this,c,t,e,o,n,i);return o}raycastFirst(e,t=ii,n=0,i=1/0){const r=this._roots;let o=null;const a=this.indirect?lw:$S;for(let c=0,l=r.length;c<l;c++){const d=a(this,c,t,e,n,i);d!=null&&(o==null||d.distance<o.distance)&&(o=d)}return o}intersectsGeometry(e,t){let n=!1;const i=this._roots,r=this.indirect?uw:ew;for(let o=0,a=i.length;o<a&&(n=r(this,o,e,t),!n);o++);return n}shapecast(e){const t=Gn.getPrimitive(),n=super.shapecast({...e,intersectsPrimitive:e.intersectsTriangle,scratchPrimitive:t,iterate:this.indirect?ZS:qS});return Gn.releasePrimitive(t),n}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:r}=n;const o=Gn.getPrimitive(),a=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?m=>{const x=this.resolveTriangleIndex(m);Bt(o,x*3,a,c)}:m=>{Bt(o,m*3,a,c)},d=Gn.getPrimitive(),u=e.geometry.index,h=e.geometry.attributes.position,f=e.indirect?m=>{const x=e.resolveTriangleIndex(m);Bt(d,x*3,u,h)}:m=>{Bt(d,m*3,u,h)};if(r){if(!(e instanceof Sc))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const m=(x,p,g,y,_,v,M,w)=>{for(let E=g,b=g+y;E<b;E++){f(E),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let S=x,P=x+p;S<P;S++)if(l(S),o.needsUpdate=!0,r(o,d,S,E,_,v,M,w))return!0}return!1};if(i){const x=i;i=function(p,g,y,_,v,M,w,E){return x(p,g,y,_,v,M,w,E)?!0:m(p,g,y,_,v,M,w,E)}}else i=m}return super.bvhcast(e,t,{intersectsRanges:i})}intersectsBox(e,t){return Xa.set(e.min,e.max,t),Xa.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Xa.intersectsBox(n),intersectsTriangle:n=>Xa.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},r=0,o=1/0){return(this.indirect?mw:rw)(this,e,t,n,i,r,o)}closestPointToPoint(e,t={},n=0,i=1/0){return VS(this,e,t,n,i)}}const xr={Mesh:Qe.prototype.raycast,Line:Zo.prototype.raycast,LineSegments:Bd.prototype.raycast,LineLoop:zd.prototype.raycast,Points:Dc.prototype.raycast,BatchedMesh:F0.prototype.raycast},$t=new Qe,ja=[];function gw(s,e){if(this.isBatchedMesh)xw.call(this,s,e);else{const{geometry:t}=this;if(t.boundsTree)t.boundsTree.raycastObject3D(this,s,e);else{let n;if(this instanceof Qe)n=xr.Mesh;else if(this instanceof Bd)n=xr.LineSegments;else if(this instanceof zd)n=xr.LineLoop;else if(this instanceof Zo)n=xr.Line;else if(this instanceof Dc)n=xr.Points;else throw new Error("BVH: Fallback raycast function not found.");n.call(this,s,e)}}}function xw(s,e){if(this.boundsTrees){const t=this.boundsTrees,n=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,r=this.matrixWorld;$t.material=this.material,$t.geometry=this.geometry;const o=$t.geometry.boundsTree,a=$t.geometry.drawRange;$t.geometry.boundingSphere===null&&($t.geometry.boundingSphere=new fn);for(let c=0,l=n.length;c<l;c++){if(!this.getVisibleAt(c))continue;const d=n[c].geometryIndex;if($t.geometry.boundsTree=t[d],this.getMatrixAt(c,$t.matrixWorld).premultiply(r),!$t.geometry.boundsTree){this.getBoundingBoxAt(d,$t.geometry.boundingBox),this.getBoundingSphereAt(d,$t.geometry.boundingSphere);const u=i[d];$t.geometry.setDrawRange(u.start,u.count)}$t.raycast(s,ja);for(let u=0,h=ja.length;u<h;u++){const f=ja[u];f.object=this,f.batchId=c,e.push(f)}ja.length=0}$t.geometry.boundsTree=o,$t.geometry.drawRange=a,$t.material=null,$t.geometry=null}else xr.BatchedMesh.call(this,s,e)}function yw(s={}){const{type:e=Sc}=s;return this.boundsTree=new e(this,s),this.boundsTree}const sn={github:{label:"GitHub",detail:"Code, projects & open source",href:"https://github.com/dorlugasigal"}
4050,linkedin:{label:"LinkedIn",detail:"The professional side",href:"https://www.linkedin.com/in/dor-lugasi-gal/"},microsoft:{label:"Microsoft blog",detail:"Engineering stories & lessons",href:"https://devblogs.microsoft.com/ise/author/dorlugasigal/"},medium:{label:"Medium",detail:"Notes, ideas & things learned",href:"https://medium.com/@dorlugasigal"},stackoverflow:{label:"Stack Overflow",detail:"Questions worth sharing",href:"https://stackoverflow.com/users/9615185/dor-lugasi-gal?tab=profile"},youtube:{label:"YouTube",detail:"A different kind of making",href:"https://www.youtube.com/channel/UCM-rav7cI8i8KFQ6HgjKszA"},instagram:{label:"Instagram",detail:"Life beyond the screen",href:"https://www.instagram.com/dorlugasigal/"},email:{label:"Email me",detail:"[email protected]",href:"mailto:[email protected]"},whatsapp:{label:"WhatsApp",detail:"Start a conversation",href:"https://api.whatsapp.com/send?phone=972526889753&text=Hi%20Dor!"},cv:{label:"Request my CV",detail:"Want my CV? Send me an email.",href:"mailto:[email protected]?subject=CV%20request"}},Rm={monitor:{sections:[{id:"main",title:"Find me online",links:[sn.github,sn.linkedin]},{id:"legacy",title:"Legacy mode",links:[sn.stackoverflow]}]}};async function wc(s,e,t){const n=await fetch(s,{...e===void 0?{}:{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},credentials:"same-origin",cache:"no-store",referrerPolicy:"no-referrer",signal:t?AbortSignal.any([t,AbortSignal.timeout(2e4)]):AbortSignal.timeout(2e4)});if(!(n.headers.get("content-type")||"").includes("application/json"))throw new Error("The analytics service returned an unexpected response.");const r=await n.json();if(!n.ok)throw Object.assign(new Error(r.error||`HTTP ${n.status}`),{status:n.status});return r}const Pm={github:["GitHub","Profiles"],linkedin:["LinkedIn","Profiles"],stackoverflow:["Stack Overflow","Profiles"],youtube:["YouTube","Profiles"],medium:["Medium","Profiles"],microsoft:["Microsoft blog","Profiles"],instagram:["Instagram","Profiles"],cv:["CV request","Contact"],email:["Email","Contact"],whatsapp:["WhatsApp","Contact"],desk_stand:["Raise desk","Room actions"],desk_sit:["Lower desk","Room actions"],tube_blue_color:["Blue tube color","Room actions"],tube_orange_color:["Orange tube color","Room actions"],songbook_page:["Change tune","Music"],songbook_play:["Play jazz book","Music"],roach_startle:["Startle cockroach","Room actions"],roach_pop:["Cockroach pop","Room actions"],app_legacy:["Legacy app","Apps"],app_terminal:["Terminal app","Apps"]},vw={home:"Overview",desk:"Desk seat",music:"Piano seat",monitor:"Monitor",cv:"CV",songbook:"Jazz book",books:"Bookshelf",phone:"Phone",entry:"Entrance",walk:"Walking",piano:"Play piano"};for(const[s,e]of Object.entries(vw))Pm[`view_${s}`]=[e,"Navigation"];function Lm(s){const[e,t]=Pm[s]||[s,"Other"];return{target:s,label:e,category:t}}function _w(s,e="All",t="",n="clicks"){const i=t.trim().toLowerCase();return s.map(r=>({...r,...Lm(r.target)})).filter(r=>(e==="All"||r.category===e)&&`${r.label} ${r.target}`.toLowerCase().includes(i)).sort((r,o)=>n==="name"?r.label.localeCompare(o.label):o.clicks-r.clicks||r.label.localeCompare(o.label))}function po(s){if(!Number.isFinite(s)||s<0)return"â";const e=Math.round(s/1e3);return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function uc(s,e=Date.now()){if(s==="all")return{from:"",to:""};const t=new Date(e).toISOString().slice(0,10),n=Date.parse(t+"T00:00:00Z")-(Number(s)-1)*864e5;return{from:new Date(n).toISOString().slice(0,10),to:t}}function bw(s,e){if(!s.length&&!e.from)return[];const t=Date.parse((e.from||s[0].day)+"T00:00:00Z"),n=Date.parse((e.to||s.at(-1).day)+"T00:00:00Z"),i=Math.round((n-t)/864e5)+1,r=Math.max(1,Math.ceil(i/45)),o=Array.from({length:Math.ceil(i/r)},(a,c)=>({day:new Date(t+c*r*864e5).toISOString().slice(0,10),end:new Date(Math.min(n,t+(c+1)*r*864e5-864e5)).toISOString().slice(0,10),views:0,clicks:0,activeMs:0}));for(const a of s){const c=Math.floor((Date.parse(a.day+"T00:00:00Z")-t)/(r*864e5));if(o[c])for(const l of["views","clicks","activeMs"])o[c][l]+=a[l]}return o}const dd=["Workspace terminal","login / stats","Owner statistics open in a private dashboard."];function Mw(s){const e=s.trim().toLowerCase();return e==="login"?"login":e==="stats"||e==="atats"?"stats":"joke"}function Sw(s){return/\bhack|sudo|root|admin/i.test(s)?"Access to the mainframe denied. The mainframe is a desk.":/coffee|brew/i.test(s)?"Coffee endpoint unavailable. Please use the actual kitchen.":/help|ls|dir|clear|logout/i.test(s)?"Minimalism won. Only login and stats survived the cleanup.":"Nice command. Unfortunately this terminal only majored in login and stats."}
4050function ww(s,{openDashboard:e,dashboardOpen:t}){const n=document.querySelector("#terminal-form"),i=document.querySelector("#terminal-command"),r=document.querySelector("#terminal-accessible");let o=!1,a=!1,c=0,l;window.visualViewport?.addEventListener("resize",()=>{document.documentElement.style.setProperty("--terminal-height",`${visualViewport.height}px`)});const d=(...f)=>{s.write(...f),r.textContent=f.join(` 4051`)};function u(){i.value="",s.terminal.input="",s.terminal.secret=o,i.type=o?"password":"text",i.autocomplete=o?"current-password":"off",i.setAttribute("aria-label",o?"Owner password":"Monitor terminal command"),s.draw()}async function h(f,m,x){if(o){if(o=!1,u(),await wc("/api/admin/login",{password:f},x),m!==c)return;d("Signed in. Type stats to open your dashboard.");return}const p=Mw(f);if(p==="joke"){d(Sw(f));return}if(d("$ "+p),p==="login"){o=!0,u(),d("Owner password (hidden and never tracked):");return}const g=await wc("/api/stats?"+new URLSearchParams(uc(30)),void 0,x);m===c&&(d("Dashboard opened. Private data stays out of the terminal."),i.blur(),e(g))}return i.addEventListener("input",()=>{s.terminal.input=i.value,s.draw()}),i.addEventListener("focus",()=>{s.terminal.focused=!0,document.body.dataset.terminalInput="true",document.documentElement.style.setProperty("--terminal-height",`${window.visualViewport?.height||innerHeight}px`),s.draw()}),i.addEventListener("blur",()=>{s.terminal.focused=!1,document.body.dataset.terminalInput="false",s.draw()}),i.addEventListener("keydown",f=>{["PageUp","PageDown"].includes(f.code)&&(f.preventDefault(),s.terminal.offset=Math.max(0,Math.min(Math.max(0,s.terminal.lines.length-9),s.terminal.offset+(f.code==="PageUp"?7:-7))),s.draw())}),n.addEventListener("submit",async f=>{if(f.preventDefault(),a||!i.value.trim())return;const m=i.value,x=c;l=new AbortController;const p=l.signal;a=!0,u(),i.readOnly=!0;try{await h(m,x,p)}catch(g){if(p.aborted||x!==c)return;g.status===401?(s.terminal.lines=[],d("Owner sign-in required. Type login to continue.")):d("Terminal: "+g.message)}finally{a=!1,i.readOnly=!1,!n.hidden&&document.body.dataset.paused!=="true"&&!t()&&i.focus({preventScroll:!0})}}),{focus(){i.focus({preventScroll:!0})},signedOut(){o=!1,s.terminal.lines=[...dd],u(),d("Owner session closed. Type login to sign in again."),n.hidden||i.focus({preventScroll:!0})},visible(f){n.hidden=!f,f?i.focus({preventScroll:!0}):(c++,l?.abort(),document.body.dataset.terminalInput="false",o=!1,s.terminal.lines=[...dd],u())}}}async function Tw(s,e,t=!1){const n=new Image;n.src=s,await n.decode();const i=document.createElement("canvas"),r=3840,o=1080,a=t?.5:1;i.width=r*a,i.height=o*a;const c=i.getContext("2d");if(!c)throw new Error("The monitor canvas is not available.");c.scale(a,a);const l=Object.fromEntries(await Promise.all(Object.entries({github:["github","#24292f"],linkedin:["linkedin","#0a66c2"],stackoverflow:["stack-overflow","#dc8436"]}).map(async([v,[M,w]])=>{const E=new Image;E.src=`/icons/${M}.svg`,await E.decode();const b=document.createElement("canvas");b.width=b.height=160;const S=b.getContext("2d");if(!S)throw new Error("The platform icon canvas is not available.");const P=Math.min(160/E.naturalWidth,160/E.naturalHeight),A=E.naturalWidth*P,T=E.naturalHeight*P;return S.drawImage(E,(160-A)/2,(160-T)/2,A,T),S.globalCompositeOperation="source-in",S.fillStyle=w,S.fillRect(0,0,160,160),[v,b]}))),d=new im(i);d.colorSpace=At,d.flipY=!1,t&&(d.generateMipmaps=!1,d.minFilter=It);const u={texture:d,open:!1,section:"main",regions:[],terminal:{lines:[...dd],input:"",secret:!1,offset:0,focused:!1}};function h(v,M,w,E,b,S){c.fillStyle=S,c.beginPath(),c.roundRect(v,M,w,E,b),c.fill()}function f(v,M,w,E,b="#28313c",S=400,P=!1){c.font=`${S} ${E}px ${P?"Menlo, Consolas, monospace":'"Avenir Next", sans-serif'}`,c.fillStyle=b,c.fillText(v,M,w)}function m(v,M,w,E,b,S){u.regions.push({id:v,x:M,y:w,w:E,h:b,action:S})}function x(v,M){v==="terminal"?(h(3560,M,144,142,17,"#17231f"),f(">_",3580,M+98,70,"#d6e2c9",500,!0)):v==="legacy"?(h(3560,M,144,142,12,"#333d3b"),h(3586,M+7,88,56,3,"#c4c9bd"),h(3651,M+15,13,38,0,"#52675c"),h(3584,M+80,97,62,3,"#eee8d6"),c.drawImage(l.stackoverflow,3613,M+86,42,48)):(h(3557,M+12,83,44,11,"#9bd0ee"),h(3557,M+40,150,102,12,"#6baed9"),h(3565,M+49,134,81,8,"#87c2e6")),c.save(),c.shadowColor="#102233",c.shadowBlur=12,f(v==="legacy"?"legacy/":v==="terminal"?"Terminal":"Profiles",3544,M+203,39,"#ffffff",500,v!=="main"),c.restore(
4051),m("desktop-"+(v==="main"?"profiles":v),3505,M-15,280,238,{type:"section",section:v})}function p(v,M){["#ef6860","#edbf51","#61bf65"].forEach((w,E)=>{c.beginPath(),c.fillStyle=w,c.arc(v+E*64,M,20,0,Math.PI*2),c.fill()}),m("close",v-44,M-44,88,88,{type:"close"})}function g(){c.save(),c.shadowColor="#10223955",c.shadowBlur=50,c.shadowOffsetY=18,h(410,125,3020,785,28,"#f6f7fbee"),c.restore(),h(410,125,3020,785,28,"#f6f7fbee"),h(410,125,3020,133,28,"#e7e9ed"),c.fillStyle="#e7e9ed",c.fillRect(410,205,3020,53),p(485,191),f("Dor / Profiles",1510,214,58,"#515a65",500),f("~/workspace",500,377,43,"#6b7780",400,!0),f("Current work",500,475,59,"#344b57",500),f("Code. People.",500,559,43,"#78848c"),f("Still shipping.",500,622,43,"#78848c"),f("Find me online",1140,378,70,"#28313c",500),Rm.monitor.sections[0].links.forEach((v,M)=>{const w=1140+M*1120;h(w,431,1050,284,20,"#ffffff"),c.drawImage(M===0?l.github:l.linkedin,w+53,473,120,120),f(v.label,w+203,550,81,"#23354d",500),f("Open profile â",w+60,646,54,"#5c6c80"),m(v.label,w,431,1050,284,{type:"link",link:v})}),f("Need the compatibility layer? Open legacy/ â",1140,827,45,"#687482"),m("legacy",1100,760,2200,110,{type:"section",section:"legacy"})}function y(){c.save(),c.shadowColor="#0a151b88",c.shadowBlur=60,c.shadowOffsetY=20,h(450,125,2980,790,25,"#f2eee6f2"),c.restore(),h(450,125,2980,124,25,"#d8d9d6"),c.fillStyle="#d8d9d6",c.fillRect(450,200,2980,49),p(523,187),f("legacy/ â out for coffee",1160,208,45,"#56656a",400,!0),c.save(),c.strokeStyle="#aaa399",c.lineWidth=8,c.lineCap="round";for(const v of[900,990,1080])c.beginPath(),c.moveTo(v,376),c.bezierCurveTo(v-45,338,v+45,310,v,270),c.stroke();c.fillStyle="#d8d0c5",c.beginPath(),c.ellipse(990,700,246,25,0,0,Math.PI*2),c.fill(),c.strokeStyle="#fefbf4",c.lineWidth=36,c.beginPath(),c.ellipse(1180,535,76,78,0,0,Math.PI*2),c.stroke(),h(812,405,360,283,42,"#fffdf7"),c.fillStyle="#765c45",c.beginPath(),c.ellipse(992,423,156,28,0,0,Math.PI*2),c.fill(),c.drawImage(l.stackoverflow,925,497,134,134),c.restore(),f("Stack Overflow",1430,420,105,"#344a52",600),f("Back in 5 minutes.",1430,528,66,"#53676c",400),f("Developer minutes.",1430,610,43,"#94816f",400),h(575,756,1280,110,
405116,"#344f58"),f("Visit old answers â",632,830,47,"#f9f8ef",500),m("Stack Overflow",575,756,1280,110,{type:"link",link:sn.stackoverflow}),f("Back to work â",2340,827,47,"#53676c",400),m("main",2260,756,1060,110,{type:"section",section:"main"})}function _(){h(450,125,2980,790,25,"#142019"),h(450,125,2980,110,25,"#34423c"),c.fillStyle="#34423c",c.fillRect(450,190,2980,45),p(523,181),f("Terminal â workspace",1360,208,46,"#d6dfd1",400,!0);const v=u.terminal.lines.length-u.terminal.offset;u.terminal.lines.slice(Math.max(0,v-9),Math.max(0,v)).forEach((E,b)=>f(E.slice(0,91),560,310+b*54,39,"#c3d8ba",400,!0));const w=u.terminal.secret?"â¢".repeat(Math.min(32,u.terminal.input.length)):u.terminal.input;f((u.terminal.secret?"password: ":"$ ")+w+(u.terminal.focused?"_":""),560,850,45,"#f1edd3",400,!0),!u.terminal.focused&&!w&&f("click here to type",730,850,35,"#91a589",400,!0),m("terminal-input",530,775,2350,120,{type:"terminal-input"}),f("PgUp / PgDn",3e3,850,30,"#879e83",400,!0)}return u.write=(...v)=>{u.terminal.lines.push(...v),u.terminal.lines=u.terminal.lines.slice(-160),u.terminal.offset=0,u.draw()},u.draw=()=>{u.regions=[],c.drawImage(n,0,0,r,o),x("main",90),x("legacy",355),x("terminal",620),u.open&&(u.section==="terminal"?_():u.section==="legacy"?y():g()),d.needsUpdate=!0,e()},u.hit=v=>{const M=v.x*r,w=v.y*o;return u.regions.find(E=>M>=E.x&&M<=E.x+E.w&&w>=E.y&&w<=E.y+E.h)?.action},u.draw(),u}const gp={type:"change"},sh={type:"start"},Im={type:"end"},Ya=new Si,xp=new gi,Ew=Math.cos(70*Ct.DEG2RAD),zt=new D,Sn=2*Math.PI,xt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},jl=1e-6;class Aw extends fm{constructor(e,t=null){super(e,t),this.state=xt.NONE,this.target=new D,this.cursor=new D,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:hs.ROTATE,MIDDLE:hs.DOLLY,RIGHT:hs.PAN},this.touches={ONE:Oi.ROTATE,TWO:Oi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new D,this._lastQuaternion=new kn,this._lastTargetPosition=new D,this._quat=new kn().setFromUnitVectors(e.up,new D(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new _f,this._sphericalDelta=new _f,this._scale=1,this._panOffset=new D,this._rotateStart=new xe,this._rotateEnd=new xe,this._rotateDelta=new xe,this._panStart=new xe,this._panEnd=new xe,this._panDelta=new xe,this._dollyStart=new xe,this._dollyEnd=new xe,this._dollyDelta=new xe,this._dollyDirection=new D,this._mouse=new xe,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Rw.bind(this),this._onPointerDown=Cw.bind(this),this._onPointerUp=Pw.bind(this),this._onContextMenu=Fw.bind(this),this._onMouseWheel=Dw.bind(this),this._onKeyDown=Nw.bind(this),this._onTouchStart=Uw.bind(this),this._onTouchMove=Ow.bind(this),this._onMouseDown=Lw.bind(this),this._onMouseMove=Iw.bind(this),this._interceptControlDown=kw.bind(this),this._interceptControlUp=Bw.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(gp),this.update(),this.state=xt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;zt.copy(t).sub(this.target),zt.applyQuaternion(this._quat),this._spherical.setFromVector3(zt),this.autoRotate&&this.state===xt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=Sn:n>Math.PI&&(n-=Sn),i<-Math.PI?i+=Sn:i>
vendor: 14,618 bytes, line 4051
4051Math.PI&&(i-=Sn),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(zt.setFromSpherical(this._spherical),zt.applyQuaternion(this._quatInverse),t.copy(this.target).add(zt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=zt.length();o=this._clampDistance(a*this._scale);const c=a-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),r=!!c}else if(this.object.isOrthographicCamera){const a=new D(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=c!==this.object.zoom;const l=new D(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(a),this.object.updateMatrixWorld(),o=zt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Ya.origin.copy(this.object.position),Ya.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ya.direction))<Ew?this.object.lookAt(this.target):(xp.setFromNormalAndCoplanarPoint(this.object.up,this.target),Ya.intersectPlane(xp,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>jl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>jl||this._lastTargetPosition.distanceToSquared(this.target)>jl?(this.dispatchEvent(gp),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Sn/60*this.autoRotateSpeed*e:Sn/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){zt.setFromMatrixColumn(t,0),zt.multiplyScalar(-e),this._panOffset.add(zt)}_panUp(e,t){this.screenSpacePanning===!0?zt.setFromMatrixColumn(t,1):(zt.setFromMatrixColumn(t,0),zt.crossVectors(this.object.up,zt)),zt.multiplyScalar(e),this._panOffset.add(zt)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;zt.copy(i).sub(this.target);let r=zt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,o=n.width,a=n.height;this._mouse.x=i/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Sn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Sn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Sn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Sn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Sn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Sn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Sn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Sn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new xe,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Cw(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function Rw(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function Pw(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Im),this.state=xt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Lw(s){let e;switch(s.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case hs.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=xt.DOLLY;break;case hs.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=xt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=xt.ROTATE}break;case hs.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=xt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=xt.PAN}break;default:this.state=xt.NONE}this.state!==xt.NONE&&this.dispatchEvent(sh)}function Iw(s){switch(this.state){case xt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case xt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case xt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function Dw(s){this.enabled===!1||this.enableZoom===!1||this.state!==xt.NONE||(s.preventDefault(),this.dispatchEvent(sh),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(Im))}function Nw(s){this.enabled!==!1&&this._handleKeyDown(s)}function Uw(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case Oi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=xt.TOUCH_ROTATE;break;case Oi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=xt.TOUCH_PAN;break;default:this.state=xt.NONE}break;case 2:switch(this.touches.TWO){case Oi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=xt.TOUCH_DOLLY_PAN;break;case Oi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=xt.TOUCH_DOLLY_ROTATE;break;default:this.state=xt.NONE}break;default:this.state=xt.NONE}this.state!==xt.NONE&&this.dispatchEvent(sh)}function Ow(s){switch(this._trackPointer(s),this.state){case xt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case xt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case xt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case xt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=xt.NONE}}function Fw(s){this.enabled!==!1&&s.preventDefault()}function kw(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Bw(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}
4051const pr=new Xn(0,0,0,"YXZ"),mr=new D,zw={type:"change"},Vw={type:"lock"},Hw={type:"unlock"},yp=.002,vp=Math.PI/2;class Gw extends fm{constructor(e,t=null){super(e,t),this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,this._onMouseMove=Ww.bind(this),this._onPointerlockChange=Xw.bind(this),this._onPointerlockError=qw.bind(this),this.domElement!==null&&this.connect(this.domElement)}connect(e){super.connect(e),this.domElement.ownerDocument.addEventListener("mousemove",this._onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this._onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this._onPointerlockError)}disconnect(){this.domElement.ownerDocument.removeEventListener("mousemove",this._onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this._onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this._onPointerlockError)}dispose(){this.disconnect()}getDirection(e){return e.set(0,0,-1).applyQuaternion(this.object.quaternion)}moveForward(e){if(this.enabled===!1)return;const t=this.object;mr.setFromMatrixColumn(t.matrix,0),mr.crossVectors(t.up,mr),t.position.addScaledVector(mr,e)}moveRight(e){if(this.enabled===!1)return;const t=this.object;mr.setFromMatrixColumn(t.matrix,0),t.position.addScaledVector(mr,e)}lock(e=!1){this.domElement.requestPointerLock({unadjustedMovement:e})}unlock(){this.domElement.ownerDocument.exitPointerLock()}}function Ww(s){if(this.enabled===!1||this.isLocked===!1)return;const e=this.object;pr.setFromQuaternion(e.quaternion),pr.y-=s.movementX*yp*this.pointerSpeed,pr.x-=s.movementY*yp*this.pointerSpeed,pr.x=Math.max(vp-this.maxPolarAngle,Math.min(vp-this.minPolarAngle,pr.x)),e.quaternion.setFromEuler(pr),this.dispatchEvent(zw)}function Xw(){this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(Vw),this.isLocked=!0):(this.dispatchEvent(Hw),this.isLocked=!1)}function qw(){console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}const hd=1.45;function jw(){let s=0,e=0;const t={x:0,z:0};return{step(n,i,r){const o=i||r?16:22,a=Math.exp(-o*n);return t.x=i*n+(s-i)*(1-a)/o,t.z=r*n+(e-r)*(1-a)/o,s=i+(s-i)*a,e=r+(e-r)*a,!i&&Math.abs(s)<.001&&(s=0),!r&&Math.abs(e)<.001&&(e=0),t},stop(){s=e=0},get moving(){return s!==0||e!==0}}}function Yw(){let s=0,e=2.66,t=1.2,n=1.2,i=!1,r=!1,o=0,a=0;return{reset(c){t=n=c,i=r=!1,o=a=0},setWorld(c,l){s=c,e=l},stand(){i=!0},shift(c){t+=c,n+=c},crouch(c){r=c,i=!0},jump(){return o>.001||a!==0||r?!1:(i=!0,a=3,!0)},step(c,l=!1){const d=Math.min(.05,Math.max(0,c)),u=t+o;l&&(i=!0);const h=i?s+(r?.96:hd):n;return t+=(Math.min(h,e-.13)-t)*(1-Math.exp(-d*12)),Math.abs(t-h)<1e-4&&(t=h),(a!==0||o>0)&&(a-=9.8*d,o+=a*d,t+o>e-.13&&(o=Math.max(0,e-.13-t),a=Math.min(0,a)),o<=0&&(o=0,a=0)),Math.abs(t+o-u)>1e-6||a!==0},get height(){return t+o},get crouched(){return r},get seated(){return!i},get grounded(){return o===0&&a===0},get lift(){return o}}}const fd=.75;function Kw(s,e,t,n,i,r){const o=new Aw(s,e),a=s.clone(),c=new Gw(a,e),l=matchMedia("(prefers-reduced-motion: reduce)"),d=new Set,u=new xe,h=new Map,f=new D,m=new D,x=new Xn(0,0,0,"YXZ"),p=Yw(),g=jw();let y="orbit",_,v=!1,M=!1,w=0,E=1,b,S=[],P=0,A=!1,T=!1,I=1;o.enabled=!1,o.enablePan=!0,o.rotateSpeed=.85,o.panSpeed=.85,o.zoomSpeed=.85,o.dampingFactor=.14,o.enableDamping=!l.matches,o.zoomToCursor=!0,o.minPolarAngle=.12,o.maxPolarAngle=Math.PI/2-.02,o.touches.TWO=Oi.DOLLY_PAN,c.enabled=!1,c.pointerSpeed=1.1,c.minPolarAngle=.12,c.maxPolarAngle=Math.PI-.12,e.style.touchAction="none";function k(){s.getWorldDirection(f),o.target.copy(s.position).add(f)}function F(){d.clear(),g.stop(),u.set(0,0),h.clear(),P=0,p.crouched&&p.crouch(!1)}function L(){document.pointerLockElement===e&&(T=!0,c.unlock())}function O(){_&&(s.position.copy(_.position),_.freeLook||(s.quaternion.copy(_.quaternion),a.quaternion.copy(s.quaternion)),s.fov=_.fov,s.zoom=_.zoom,o.target.copy(_.target),s.updateProjectionMatrix(),_=null,o.enabled=v&&!M&&y!=="look"&&y!=="piano",c.enabled=v&&!M&&y==="look",y==="look"?k():y!=="piano"&&o.update())}
4051function H(R){if(!(!v||M)){if(O(),n(),y==="look")s.zoom=Ct.clamp(s.zoom*R,fd,3.5),s.updateProjectionMatrix();else{const z=s.position.clone().sub(o.target),Y=Ct.clamp(z.length()/R,o.minDistance,o.maxDistance);s.position.copy(o.target).add(z.setLength(Y)),y==="piano"?s.lookAt(o.target):o.update()}t()}}function W(R,z){_&&y==="look"&&(_.freeLook=!0),x.setFromQuaternion(a.quaternion,"YXZ"),x.y-=R,x.x=Ct.clamp(x.x-z,-Math.PI/2+.12,Math.PI/2-.12),a.quaternion.setFromEuler(x),t()}function q(){F(),w=0}o.addEventListener("change",t),o.addEventListener("start",()=>{O(),n()}),c.addEventListener("change",()=>{_&&y==="look"&&(_.freeLook=!0),t()}),c.addEventListener("lock",()=>{A=!1,T=!1,c.enabled=v&&!M&&y==="look",e.focus({preventScroll:!0}),i(!0)}),c.addEventListener("unlock",()=>{const R=!T;T=!1,q(),i(!1,R)}),document.addEventListener("pointerlockerror",()=>{A&&(A=!1,r("Mouse capture was blocked. Click the room to retry, or use arrow keys."))}),e.addEventListener("contextmenu",R=>R.preventDefault()),e.addEventListener("pointerdown",R=>{if(!(!v||M||y!=="look"||c.isLocked||R.button!==0||R.pointerType==="mouse")&&(O(),n(),e.focus({preventScroll:!0}),h.set(R.pointerId,{x:R.clientX,y:R.clientY}),e.setPointerCapture(R.pointerId),h.size===2)){const[z,Y]=[...h.values()];P=Math.hypot(z.x-Y.x,z.y-Y.y)}}),e.addEventListener("pointermove",R=>{const z=h.get(R.pointerId);if(!z||y!=="look"||c.isLocked)return;const Y=R.clientX-z.x,ie=R.clientY-z.y;if(h.set(R.pointerId,{x:R.clientX,y:R.clientY}),h.size===2){const[re,ge]=[...h.values()],Fe=Math.hypot(re.x-ge.x,re.y-ge.y);P>0&&Fe>0&&H(Fe/P),P=Fe}else P||W(Y*.003*I,ie*.003*I)});const Z=R=>{h.delete(R.pointerId),h.size||(P=0)};e.addEventListener("pointerup",Z),e.addEventListener("pointercancel",Z),e.addEventListener("lostpointercapture",Z),e.addEventListener("wheel",R=>{if(R.ctrlKey||R.metaKey){R.stopImmediatePropagation();return}v&&y==="look"&&(R.preventDefault(),R.stopImmediatePropagation(),H(Math.exp(-R.deltaY*(R.deltaMode===1?.025:.0015))))},{passive:!1,capture:!0});function V(R){!v||M||y!=="look"||R.ctrlKey||R.metaKey||R.altKey||(R.code==="Space"&&(R.preventDefault(),R.repeat||(p.jump(),t())),R.code==="KeyC"&&(R.preventDefault(),p.crouch(!0),t()),["KeyW","KeyA","KeyS","KeyD","ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(R.code)&&(R.preventDefault(),O(),d.add(R.code),t()))}window.addEventListener("keyup",R=>{d.delete(R.code),R.code==="KeyC"&&y==="look"&&(p.crouch(!1),t())}),window.addEventListener("blur",q),e.addEventListener("blur",q),document.addEventListener("visibilitychange",()=>{document.hidden&&q()}),l.addEventListener("change",()=>{o.enableDamping=!l.matches,l.matches&&O(),t()});function K(R,z){return b&&R>=b.min.x+.12&&R<=b.max.x-.12&&z>=b.min.z+.12&&z<=b.max.z-.12&&!S.some(Y=>R>=Y.min.x-.1&&R<=Y.max.x+.1&&z>=Y.min.z-.1&&z<=Y.max.z+.1)}function ce(R){const z=d.size>0||u.lengthSq()>=.001,Y=Number(d.has("ArrowRight"))-Number(d.has("ArrowLeft")),ie=Number(d.has("ArrowDown"))-Number(d.has("ArrowUp"));(Y||ie)&&W(Y*R*1.1,ie*R*1.1);const re=!s.quaternion.equals(a.quaternion);re&&s.quaternion.copy(a.quaternion);const ge=Number(d.has("KeyW"))-Number(d.has("KeyS"))-u.y,Fe=Number(d.has("KeyD"))-Number(d.has("KeyA"))+u.x;s.getWorldDirection(f),f.y=0,f.normalize(),m.crossVectors(f,s.up).normalize();const Ie=f.multiplyScalar(ge).addScaledVector(m,Fe);Ie.lengthSq()>1&&Ie.normalize(),Ie.multiplyScalar(p.crouched?.45:1.05);const He=g.step(R,Ie.x,Ie.z),je=p.step(R,Ie.lengthSq()>.001);return s.position.y=p.height,K(s.position.x+He.x,s.position.z)&&(s.position.x+=He.x),K(s.position.x,s.position.z+He.z)&&(s.position.z+=He.z),(z||je||g.moving||re)&&k(),z||je||g.moving||re}async function $(){if(!(!v||M||y!=="look"||document.pointerLockElement===e||A)){if(typeof e.requestPointerLock!="function"){r("Mouse capture is unavailable in this browser. Use arrow keys or touch controls.");return}A=!0;try{try{await e.requestPointerLock({unadjustedMovement:!0})}catch(R){if(R.name!=="NotSupportedError")throw R;A=!0,await e.requestPointerLock()}}catch(R){A=!1,console.info("Pointer capture was declined:",R.message),r("Mouse capture was blocked. Click the room to retry, or use arrow keys.")}}}return{get mode(){return y},get target(){return o.target},get transitioning(){return!!_},get locked(){return document.pointerLockElement===e},get zoomLevel(){return y==="look"?s.zoom:E/s.position.distanceTo(o.target)},get moving(){return d.size>0||u.lengthSq()>=.001||g.moving},get grounded(){return p.grounded},get crouched(){return p.crouched},get seated(){return p.seated},get jumpHeight(){return p.lift},get lookSensitivity(){return I},setLookSensitivity(R){if(!Number.isFinite(R)||R<.5||R>2)throw new RangeError("Look sensitivity must be between 0.5 and 2");I=R,c.pointerSpeed=1.1*R},stand(){p.stand(),t()},shift(R){if(s.position.y+=R,o.target.y+=R,p.shift(R),_)for(const z of["position","target","fromPosition","fromTarget"])_[z].y+=R;t()},finish:O,keyDown:V,jump(){v&&!M&&y==="look"&&(O(),p.jump(),t())},crouch(R){v&&!M&&y==="look"&&(O(),p.crouch(R),t())},setMoveVector(R,z){y!=="look"||!v||M||(u.set(R,z).clampLength(0,1),t())},setWorld(R,z){b=R,S=z,p.setWorld(R.min.y,R.max.y)},setPaused(R){M!==R&&(w=0),M=R,R&&(O(),q(),L()),o.enabled=v&&!M&&y!=="look"&&y!=="piano"&&!_,c.enabled=v&&!M&&y==="look"},go(R,z,Y=!1){if(R.zoom!==void 0&&(!Number.isFinite(R.zoom)||R.zoom<=0))throw new Error("Invalid viewpoint zoom");q(),z!=="look"&&L(),y!=="look"&&y!=="piano"&&v&&(o.enableDamping=!1,o.update());const ie=new D(...R.position),re=new D(...R.target),ge=new kn().setFromRotationMatrix(new Oe().lookAt(ie,re,s.up));y=z,M=!1,v=!0,E=ie.distanceTo(re),p.reset(ie.y),R.standing&&p.stand(),a.quaternion.copy(s.quaternion),o.enabled=!1,c.enabled=z==="look"&&document.pointerLockElement===e,o.enableRotate=y==="orbit",o.enableDamping=!l.matches,o.mouseButtons.LEFT=y==="inspect"?hs.PAN:hs.ROTATE,o.touches.ONE=y==="inspect"?Oi.PAN:Oi.ROTATE,o.minDistance=y==="inspect"||y==="piano"?.075:1.3,o.maxDistance=y==="inspect"||y==="piano"?E*2:Math.max(16,E*1.5),o.maxPolarAngle=y==="inspect"?Math.PI-.02:Math.PI/2-.02,o.minPolarAngle=.02,o.cursor.copy(re),o.maxTargetRadius=y==="inspect"?.5:2.3,_={start:performance.now(),duration:Y||l.matches?0:950,fromPosition:s.position.clone(),fromQuaternion:s.quaternion.clone(),fromTarget:
4051o.target.clone(),fromFov:s.fov,fromZoom:s.zoom,position:ie,quaternion:ge,target:re,fov:R.fov||45,zoom:z==="look"?Ct.clamp(R.zoom??1,fd,3.5):1},_.duration||O(),t()},update(R){const z=Math.min(.05,Math.max(0,(R-(w||R-16))/1e3));if(w=R,_){const Y=Math.min(1,(R-_.start)/_.duration),ie=Y*Y*(3-2*Y);return s.position.lerpVectors(_.fromPosition,_.position,ie),_.freeLook?s.quaternion.copy(a.quaternion):(s.quaternion.slerpQuaternions(_.fromQuaternion,_.quaternion,ie),a.quaternion.copy(s.quaternion)),o.target.lerpVectors(_.fromTarget,_.target,ie),s.fov=Ct.lerp(_.fromFov,_.fov,ie),s.zoom=Ct.lerp(_.fromZoom,_.zoom,ie),s.updateProjectionMatrix(),_.freeLook&&y==="look"&&k(),Y===1&&O(),!0}return!v||M?!1:y==="look"?ce(z):y==="piano"?!1:o.update()},zoom:H,stop:q,unlock:L,captureLook:$,async toggleLock(){if(!(!v||y!=="look")){if(O(),c.isLocked)return L();await $()}},disable(){v=!1,_=null,o.enabled=!1,c.enabled=!1,q(),L()}}}const Zw=96*1024*1024,Jw=1e6;function Qw(s,e,t){return Math.min(t,1.5,Math.sqrt(Jw/Math.max(1,s*e)))}function $w({width:s,coarsePointer:e,deviceMemory:t}){return e||s<=900||Number.isFinite(t)&&t<=4}function eT(s,e){if(!e)return{url:s.modelUrl,version:s.version,bytes:s.model.bytes,profile:"desktop"};const t=s.mobileModel;if(!t||t.url!=="/models/room-mobile.glb"||!/^[a-f0-9]{16}$/.test(t.version)||t.sourceVersion!==s.version||!Number.isSafeInteger(t.bytes)||t.bytes<=0||t.bytes>12*1024*1024||!Number.isSafeInteger(t.textureBytes)||t.textureBytes<=0||t.textureBytes>Zw||!Number.isSafeInteger(t.triangles)||t.triangles<=0||t.triangles>75e4||!Number.isSafeInteger(t.maxTextureSize)||t.maxTextureSize>1024)throw new Error("The mobile room is unavailable or exceeds the device resource budget. Portfolio links remain available.");return{...t,profile:"mobile"}}const tT={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` 4052 4053 varying vec2 vUv; 4054 4055 void main() { 4056 4057 vUv = uv; 4058 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 4059 4060 }`,fragmentShader:` 4061 4062 uniform float opacity; 4063 4064 uniform sampler2D tDiffuse; 4065 4066 varying vec2 vUv; 4067 4068 void main() { 4069 4070 vec4 texel = texture2D( tDiffuse, vUv ); 4071 gl_FragColor = opacity * texel; 4072 4073 4074 }`};class jr{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const nT=new Jo(-1,1,1,-1,0,1);class iT extends vt{constructor(){super(),this.setAttribute("position",new rt([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new rt([0,2,0,0,2,0],2))}}const sT=new iT;class rh{constructor(e){this._mesh=new Qe(sT,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,nT)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class rT extends jr{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof pn?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Ar.clone(e.uniforms),this.material=new pn({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new rh(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class _p extends jr{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const i=e.getContext(),r=e.state;r.buffers.color.setMask(!1),r.buffers.depth.setMask(!1),r.buffers.color.setLocked(!0),r.buffers.depth.setLocked(!0);let o,a;this.inverse?(o=0,a=1):(o=1,a=0),r.buffers.stencil.setTest(!0),r.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),r.buffers.stencil.setFunc(i.ALWAYS,o,4294967295),r.buffers.stencil.setClear(a),r.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),r.buffers.color.setLocked(!1),r.buffers.depth.setLocked(!1),r.buffers.color.setMask(!0),r.buffers.depth.setMask(!0),r.buffers.stencil.setLocked(!1),r.buffers.stencil.setFunc(i.EQUAL,1,4294967295),r.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),r.buffers.stencil.setLocked(!0)}}class oT extends jr{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class aT{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new xe);this._width=n.width,this._height=n.height,t=new On(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Wn}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new rT(tT),this.copyPass.material.blending=bi,this.timer=new Ex}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}
vendor: 2,752 bytes, lines 4074-4081
4074render(e){this.timer.update(),e===void 0&&(e=this.timer.getDelta());const t=this.renderer.getRenderTarget();let n=!1;for(let i=0,r=this.passes.length;i<r;i++){const o=this.passes[i];if(o.enabled!==!1){if(o.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),o.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),o.needsSwap){if(n){const a=this.renderer.getContext(),c=this.renderer.state.buffers.stencil;c.setFunc(a.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),c.setFunc(a.EQUAL,1,4294967295)}this.swapBuffers()}_p!==void 0&&(o instanceof _p?n=!0:o instanceof oT&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new xe);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget1.setSize(n,i),this.renderTarget2.setSize(n,i);for(let r=0;r<this.passes.length;r++)this.passes[r].setSize(n,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class bp extends jr{constructor(e,t,n=null,i=null,r=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=r,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new ze}render(e,t,n){const i=e.autoClear;e.autoClear=!1;let r,o;this.overrideMaterial!==null&&(o=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(r=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(r),this.overrideMaterial!==null&&(this.scene.overrideMaterial=o),e.autoClear=i}}const Ka={defines:{SMAA_THRESHOLD:"0.1"},uniforms:{tDiffuse:{value:null},resolution:{value:new xe(1/1024,1/512)}},vertexShader:` 4075 4076 uniform vec2 resolution; 4077 4078 varying vec2 vUv; 4079 varying vec4 vOffset[ 3 ]; 4080 4081 void SMAAEdgeDetectionVS( vec2 texcoord ) {
4082 vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component 4083 vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component 4084 vOffset[ 2 ] = texcoord.xyxy + resolution.xyxy * vec4( -2.0, 0.0, 0.0, 2.0 ); // WebGL port note: Changed sign in W component 4085 } 4086 4087 void main() { 4088 4089 vUv = uv; 4090 4091 SMAAEdgeDetectionVS( vUv ); 4092 4093 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 4094 4095 }`,fragmentShader:` 4096 4097 uniform sampler2D tDiffuse; 4098 4099 varying vec2 vUv; 4100 varying vec4 vOffset[ 3 ]; 4101 4102 vec4 SMAAColorEdgeDetectionPS( vec2 texcoord, vec4 offset[3], sampler2D colorTex ) { 4103 vec2 threshold = vec2( SMAA_THRESHOLD, SMAA_THRESHOLD ); 4104 4105 // Calculate color deltas: 4106 vec4 delta; 4107 vec3 C = texture2D( colorTex, texcoord ).rgb; 4108 4109 vec3 Cleft = texture2D( colorTex, offset[0].xy ).rgb; 4110 vec3 t = abs( C - Cleft ); 4111 delta.x = max( max( t.r, t.g ), t.b ); 4112 4113 vec3 Ctop = texture2D( colorTex, offset[0].zw ).rgb; 4114 t = abs( C - Ctop ); 4115 delta.y = max( max( t.r, t.g ), t.b ); 4116 4117 // We do the usual threshold: 4118 vec2 edges = step( threshold, delta.xy ); 4119 4120 // Then discard if there is no edge: 4121 if ( dot( edges, vec2( 1.0, 1.0 ) ) == 0.0 ) 4122 discard; 4123 4124 // Calculate right and bottom deltas: 4125 vec3 Cright = texture2D( colorTex, offset[1].xy ).rgb; 4126 t = abs( C - Cright ); 4127 delta.z = max( max( t.r, t.g ), t.b ); 4128 4129 vec3 Cbottom = texture2D( colorTex, offset[1].zw ).rgb; 4130 t = abs( C - Cbottom ); 4131 delta.w = max( max( t.r, t.g ), t.b ); 4132 4133 // Calculate the maximum delta in the direct neighborhood: 4134 float maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w ); 4135 4136 // Calculate left-left and top-top deltas: 4137 vec3 Cleftleft = texture2D( colorTex, offset[2].xy ).rgb; 4138 t = abs( C - Cleftleft ); 4139 delta.z = max( max( t.r, t.g ), t.b ); 4140 4141 vec3 Ctoptop = texture2D( colorTex, offset[2].zw ).rgb; 4142 t = abs( C - Ctoptop ); 4143 delta.w = max( max( t.r, t.g ), t.b ); 4144 4145 // Calculate the final maximum delta: 4146 maxDelta = max( max( maxDelta, delta.z ), delta.w ); 4147 4148 // Local contrast adaptation in action: 4149 edges.xy *= step( 0.5 * maxDelta, delta.xy ); 4150 4151 return vec4( edges, 0.0, 0.0 ); 4152 } 4153 4154 void main() { 4155 4156 gl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse ); 4157 4158 }`},Za={defines:{SMAA_MAX_SEARCH_STEPS:"8",SMAA_AREATEX_MAX_DISTANCE:"16",SMAA_AREATEX_PIXEL_SIZE:"( 1.0 / vec2( 160.0, 560.0 ) )",SMAA_AREATEX_SUBTEX_SIZE:"( 1.0 / 7.0 )"},uniforms:{tDiffuse:{value:null},tArea:{value:null},tSearch:{value:null},resolution:{value:new xe(1/1024,1/512)}},vertexShader:` 4159 4160 uniform vec2 resolution; 4161 4162 varying vec2 vUv; 4163 varying vec4 vOffset[ 3 ]; 4164 varying vec2 vPixcoord; 4165 4166 void SMAABlendingWeightCalculationVS( vec2 texcoord ) { 4167 vPixcoord = texcoord / resolution; 4168 4169 // We will use these offsets for the searches later on (see @PSEUDO_GATHER4):
4170 vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.25, 0.125, 1.25, 0.125 ); // WebGL port note: Changed sign in Y and W components 4171 vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.125, 0.25, -0.125, -1.25 ); // WebGL port note: Changed sign in Y and W components 4172 4173 // And these for the searches, they indicate the ends of the loops: 4174 vOffset[ 2 ] = vec4( vOffset[ 0 ].xz, vOffset[ 1 ].yw ) + vec4( -2.0, 2.0, -2.0, 2.0 ) * resolution.xxyy * float( SMAA_MAX_SEARCH_STEPS ); 4175 4176 } 4177 4178 void main() { 4179 4180 vUv = uv; 4181 4182 SMAABlendingWeightCalculationVS( vUv ); 4183 4184 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 4185 4186 }`,fragmentShader:` 4187 4188 #define SMAASampleLevelZeroOffset( tex, coord, offset ) texture2D( tex, coord + float( offset ) * resolution, 0.0 ) 4189 4190 uniform sampler2D tDiffuse; 4191 uniform sampler2D tArea; 4192 uniform sampler2D tSearch; 4193 uniform vec2 resolution; 4194 4195 varying vec2 vUv; 4196 varying vec4 vOffset[3]; 4197 varying vec2 vPixcoord; 4198 4199 #if __VERSION__ == 100 4200 vec2 round( vec2 x ) { 4201 return sign( x ) * floor( abs( x ) + 0.5 ); 4202 } 4203 #endif 4204 4205 float SMAASearchLength( sampler2D searchTex, vec2 e, float bias, float scale ) { 4206 // Not required if searchTex accesses are set to point: 4207 // float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0); 4208 // e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE + 4209 // e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE; 4210 e.r = bias + e.r * scale; 4211 return 255.0 * texture2D( searchTex, e, 0.0 ).r; 4212 } 4213 4214 float SMAASearchXLeft( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) { 4215 /** 4216 * @PSEUDO_GATHER4 4217 * This texcoord has been offset by (-0.25, -0.125) in the vertex shader to 4218 * sample between edge, thus fetching four edges in a row. 4219 * Sampling with different offsets in each direction allows to disambiguate 4220 * which edges are active from the four fetched ones. 4221 */ 4222 vec2 e = vec2( 0.0, 1.0 ); 4223 4224 for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for 4225 e = texture2D( edgesTex, texcoord, 0.0 ).rg; 4226 texcoord -= vec2( 2.0, 0.0 ) * resolution; 4227 if ( ! ( texcoord.x > end && e.g > 0.8281 && e.r == 0.0 ) ) break; 4228 } 4229 4230 // We correct the previous (-0.25, -0.125) offset we applied: 4231 texcoord.x += 0.25 * resolution.x; 4232 4233 // The searches are bias by 1, so adjust the coords accordingly: 4234 texcoord.x += resolution.x; 4235 4236 // Disambiguate the length added by the last step: 4237 texcoord.x += 2.0 * resolution.x; // Undo last step 4238 texcoord.x -= resolution.x * SMAASearchLength(searchTex, e, 0.0, 0.5); 4239 4240 return texcoord.x; 4241 } 4242 4243 float SMAASearchXRight( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) { 4244 vec2 e = vec2( 0.0, 1.0 ); 4245 4246 for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for 4247 e = texture2D( edgesTex, texcoord, 0.0 ).rg; 4248 texcoord += vec2( 2.0, 0.0 ) * resolution; 4249 if ( ! ( texcoord.x < end && e.g > 0.8281 && e.r == 0.0 ) ) break; 4250 } 4251 4252 texcoord.x -= 0.25 * resolution.x; 4253 texcoord.x -= resolution.x; 4254 texcoord.x -= 2.0 * resolution.x; 4255 texcoord.x += resolution.x * SMAASearchLength( searchTex, e, 0.5, 0.5 ); 4256 4257 return texcoord.x; 4258 } 4259 4260 float SMAASearchYUp( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) { 4261 vec2 e = vec2( 1.0, 0.0 ); 4262 4263 for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for 4264 e = texture2D( edgesTex, texcoord, 0.0 ).rg; 4265 texcoord += vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign 4266 if ( ! ( texcoord.y > end && e.r > 0.8281 && e.g == 0.0 ) ) break; 4267 } 4268 4269 texcoord.y -= 0.25 * resolution.y; // WebGL port note: Changed sign 4270 texcoord.y -= resolution.y; // WebGL port note: Changed sign 4271 texcoord.y -= 2.0 * resolution.y; // WebGL port note: Changed sign 4272 texcoord.y += resolution.y * SMAASearchLength( searchTex, e.gr, 0.0, 0.5 ); // WebGL port note: Changed sign 4273 4274 return texcoord.y; 4275 } 4276 4277 float SMAASearchYDown( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) { 4278 vec2 e = vec2( 1.0, 0.0 ); 4279 4280 for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for 4281 e = texture2D( edgesTex, texcoord, 0.0 ).rg; 4282 texcoord -= vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign 4283 if ( ! ( texcoord.y < end && e.r > 0.8281 && e.g == 0.0 ) ) break; 4284 } 4285 4286 texcoord.y += 0.25 * resolution.y; // WebGL port note: Changed sign 4287 texcoord.y += resolution.y; // WebGL port note: Changed sign 4288 texcoord.y += 2.0 * resolution.y; // WebGL port note: Changed sign 4289 texcoord.y -= resolution.y * SMAASearchLength( searchTex, e.gr, 0.5, 0.5 ); // WebGL port note: Changed sign 4290 4291 return texcoord.y; 4292 } 4293 4294 vec2 SMAAArea( sampler2D areaTex, vec2 dist, float e1, float e2, float offset ) { 4295 // Rounding prevents precision errors of bilinear filtering: 4296 vec2 texcoord = float( SMAA_AREATEX_MAX_DISTANCE ) * round( 4.0 * vec2( e
42961, e2 ) ) + dist; 4297 4298 // We do a scale and bias for mapping to texel space: 4299 texcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + ( 0.5 * SMAA_AREATEX_PIXEL_SIZE ); 4300 4301 // Move to proper place, according to the subpixel offset: 4302 texcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset; 4303 4304 return texture2D( areaTex, texcoord, 0.0 ).rg; 4305 } 4306 4307 vec4 SMAABlendingWeightCalculationPS( vec2 texcoord, vec2 pixcoord, vec4 offset[ 3 ], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices ) { 4308 vec4 weights = vec4( 0.0, 0.0, 0.0, 0.0 ); 4309 4310 vec2 e = texture2D( edgesTex, texcoord ).rg; 4311 4312 if ( e.g > 0.0 ) { // Edge at north 4313 vec2 d; 4314 4315 // Find the distance to the left: 4316 vec2 coords; 4317 coords.x = SMAASearchXLeft( edgesTex, searchTex, offset[ 0 ].xy, offset[ 2 ].x ); 4318 coords.y = offset[ 1 ].y; // offset[1].y = texcoord.y - 0.25 * resolution.y (@CROSSING_OFFSET) 4319 d.x = coords.x; 4320 4321 // Now fetch the left crossing edges, two at a time using bilinear 4322 // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to 4323 // discern what value each edge has: 4324 float e1 = texture2D( edgesTex, coords, 0.0 ).r; 4325 4326 // Find the distance to the right: 4327 coords.x = SMAASearchXRight( edgesTex, searchTex, offset[ 0 ].zw, offset[ 2 ].y ); 4328 d.y = coords.x; 4329 4330 // We want the distances to be in pixel units (doing this here allow to 4331 // better interleave arithmetic and memory accesses): 4332 d = d / resolution.x - pixcoord.x; 4333 4334 // SMAAArea below needs a sqrt, as the areas texture is compressed 4335 // quadratically: 4336 vec2 sqrt_d = sqrt( abs( d ) ); 4337 4338 // Fetch the right crossing edges: 4339 coords.y -= 1.0 * resolution.y; // WebGL port note: Added 4340 float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 1, 0 ) ).r; 4341 4342 // Ok, we know how this pattern looks like, now it is time for getting 4343 // the actual area: 4344 weights.rg = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.y ) ); 4345 } 4346 4347 if ( e.r > 0.0 ) { // Edge at west 4348 vec2 d; 4349 4350 // Find the distance to the top: 4351 vec2 coords; 4352 4353 coords.y = SMAASearchYUp( edgesTex, searchTex, offset[ 1 ].xy, offset[ 2 ].z ); 4354 coords.x = offset[ 0 ].x; // offset[1].x = texcoord.x - 0.25 * resolution.x; 4355 d.x = coords.y; 4356 4357 // Fetch the top crossing edges: 4358 float e1 = texture2D( edgesTex, coords, 0.0 ).g; 4359 4360 // Find the distance to the bottom: 4361 coords.y = SMAASearchYDown( edgesTex, searchTex, offset[ 1 ].zw, offset[ 2 ].w ); 4362 d.y = coords.y; 4363 4364 // We want the distances to be in pixel units: 4365 d = d / resolution.y - pixcoord.y; 4366 4367 // SMAAArea below needs a sqrt, as the areas texture is compressed 4368 // quadratically: 4369 vec2 sqrt_d = sqrt( abs( d ) ); 4370 4371 // Fetch the bottom crossing edges: 4372 coords.y -= 1.0 * resolution.y; // WebGL port note: Added 4373 float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 0, 1 ) ).g; 4374 4375 // Get the area for this direction: 4376 weights.ba = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.x ) ); 4377 } 4378 4379 return weights; 4380 } 4381 4382 void main() { 4383 4384 gl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) ); 4385 4386 }`},Yl={uniforms:{tDiffuse:{value:null},tColor:{value:null},resolution:{value:new xe(1/1024,1/512)}},vertexShader:` 4387 4388 uniform vec2 resolution; 4389 4390 varying vec2 vUv; 4391 varying vec4 vOffset[ 2 ]; 4392 4393 void SMAANeighborhoodBlendingVS( vec2 texcoord ) {
4394 vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component 4395 vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component 4396 } 4397 4398 void main() { 4399 4400 vUv = uv; 4401 4402 SMAANeighborhoodBlendingVS( vUv ); 4403 4404 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 4405 4406 }`,fragmentShader:` 4407 4408 uniform sampler2D tDiffuse; 4409 uniform sampler2D tColor; 4410 uniform vec2 resolution; 4411 4412 varying vec2 vUv; 4413 varying vec4 vOffset[ 2 ]; 4414 4415 vec4 SMAANeighborhoodBlendingPS( vec2 texcoord, vec4 offset[ 2 ], sampler2D colorTex, sampler2D blendTex ) { 4416 // Fetch the blending weights for current pixel: 4417 vec4 a; 4418 a.xz = texture2D( blendTex, texcoord ).xz; 4419 a.y = texture2D( blendTex, offset[ 1 ].zw ).g; 4420 a.w = texture2D( blendTex, offset[ 1 ].xy ).a; 4421 4422 // Is there any blending weight with a value greater than 0.0? 4423 if ( dot(a, vec4( 1.0, 1.0, 1.0, 1.0 )) < 1e-5 ) { 4424 return texture2D( colorTex, texcoord, 0.0 ); 4425 } else { 4426 // Up to 4 lines can be crossing a pixel (one through each edge). We 4427 // favor blending by choosing the line with the maximum weight for each 4428 // direction: 4429 vec2 offset; 4430 offset.x = a.a > a.b ? a.a : -a.b; // left vs. right 4431 offset.y = a.g > a.r ? -a.g : a.r; // top vs. bottom // WebGL port note: Changed signs 4432 4433 // Then we go in the direction that has the maximum weight: 4434 if ( abs( offset.x ) > abs( offset.y )) { // horizontal vs. vertical 4435 offset.y = 0.0; 4436 } else { 4437 offset.x = 0.0; 4438 } 4439 4440 // Fetch the opposite color and lerp by hand: 4441 vec4 C = texture2D( colorTex, texcoord, 0.0 ); 4442 texcoord += sign( offset ) * resolution; 4443 vec4 Cop = texture2D( colorTex, texcoord, 0.0 ); 4444 float s = abs( offset.x ) > abs( offset.y ) ? abs( offset.x ) : abs( offset.y ); 4445 4446 // WebGL port note: Added gamma correction 4447 C.xyz = pow(C.xyz, vec3(2.2)); 4448 Cop.xyz = pow(Cop.xyz, vec3(2.2)); 4449 vec4 mixed = mix(C, Cop, s); 4450 mixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2)); 4451 4452 return mixed; 4453 } 4454 } 4455 4456 void main() { 4457 4458 gl_FragColor = SMAANeighborhoodBlendingPS( vUv, vOffset, tColor, tDiffuse ); 4459 4460 }`};class cT extends jr{constructor(){super(),this._edgesRT=new On(1,1,{depthBuffer:!1,type:Wn}),this._edgesRT.texture.name="SMAAPass.edges",this._weightsRT=new On(1,1,{depthBuffer:!1,type:Wn}),this._weightsRT.texture.name="SMAAPass.weights";const e=this,t=new Image;t.src=this._getAreaTexture(),t.onload=function(){e._areaTexture.needsUpdate=!0},this._areaTexture=new Ot,this._areaTexture.name="SMAAPass.area",this._areaTexture.image=t,this._areaTexture.minFilter=It,this._areaTexture.generateMipmaps=!1,this._areaTexture.flipY=!1;const n=new Image;n.src=this._getSearchTexture(),n.onload=function(){e._searchTexture.needsUpdate=!0},this._searchTexture=new Ot,this._searchTexture.name="SMAAPass.search",this._searchTexture.image=n,this._searchTexture.magFilter=Ut,this._searchTexture.minFilter=Ut,this._searchTexture.generateMipmaps=!1,this._searchTexture.flipY=!1,this._uniformsEdges=Ar.clone(Ka.uniforms),this._materialEdges=new pn({defines:Object.assign({},Ka.defines),uniforms:this._uniformsEdges,vertexShader:Ka.vertexShader,fragmentShader:Ka.fragmentShader}),this._uniformsWeights=Ar.clone(Za.uniforms),this._uniformsWeights.tDiffuse.value=this._edgesRT.texture,this._uniformsWeights.tArea.value=this._areaTexture,this._uniformsWeights.tSearch.value=this._searchTexture,this._materialWeights=new pn({defines:Object.assign({},Za.defines),uniforms:this._uniformsWeights,vertexShader:Za.vertexShader,fragmentShader:Za.fragmentShader}),this._uniformsBlend=Ar.clone(Yl.uniforms),this._uniformsBlend.tDiffuse.value=this._weightsRT.texture,this._materialBlend=new pn({uniforms:this._uniformsBlend,vertexShader:Yl.vertexShader,fragmentShader:Yl.fragmentShader}),this._fsQuad=new rh(null)}render(e,t,n){this._uniformsEdges.tDiffuse.value=n.texture,this._fsQuad.material=this._materialEdges,e.setRenderTarget(this._edgesRT),this.clear&&e.clear(),this._fsQuad.render(e),this._fsQuad.material=this._materialWeights,e.setRenderTarget(this._weightsRT),this.clear&&e.clear(),this._fsQuad.render(e),this._uniformsBlend.tColor.value=n.texture,this._fsQuad.material=this._materialBlend,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(),this._fsQuad.render(e))}setSize(e,t){this._edgesRT.setSize(e,t),this._weightsRT.setSize(e,t),this._materialEdges.uniforms.resolution.value.set(1/e,1/t),this._materialWeights.uniforms.resolution.value.set(1/e,1/t),this._materialBlend.uniforms.resolution.value.set(1/e,1/t)}dispose(){this._edgesRT.dispose(),this._weightsRT.dispose(),this._areaTexture.dispose(),this._searchTexture.dispose(),this._materialEdges.dispose(),this._materialWeights.dispose(),this._materialBlend.dispose(),this._fsQuad.dispose()}_getAreaTexture
vendor: 44,306 bytes, line 4460
4460(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAIAAACOVPcQAACBeklEQVR42u39W4xlWXrnh/3WWvuciIzMrKxrV8/0rWbY0+SQFKcb4owIkSIFCjY9AC1BT/LYBozRi+EX+cV+8IMsYAaCwRcBwjzMiw2jAWtgwC8WR5Q8mDFHZLNHTarZGrLJJllt1W2qKrsumZWZcTvn7L3W54e1vrXX3vuciLPPORFR1XE2EomorB0nVuz//r71re/y/1eMvb4Cb3N11xV/PP/2v4UBAwJG/7H8urx6/25/Gf8O5hypMQ0EEEQwAqLfoN/Z+97f/SW+/NvcgQk4sGBJK6H7N4PFVL+K+e0N11yNfkKvwUdwdlUAXPHHL38oa15f/i/46Ih6SuMSPmLAYAwyRKn7dfMGH97jaMFBYCJUgotIC2YAdu+LyW9vvubxAP8kAL8H/koAuOKP3+q6+xGnd5kdYCeECnGIJViwGJMAkQKfDvB3WZxjLKGh8VSCCzhwEWBpMc5/kBbjawT4HnwJfhr+pPBIu7uu+OOTo9vsmtQcniMBGkKFd4jDWMSCRUpLjJYNJkM+IRzQ+PQvIeAMTrBS2LEiaiR9b/5PuT6Ap/AcfAFO4Y3dA3DFH7/VS+M8k4baEAQfMI4QfbVDDGIRg7GKaIY52qAjTAgTvGBAPGIIghOCYAUrGFNgzA7Q3QhgCwfwAnwe5vDejgG44o/fbm1C5ZlYQvQDARPAIQGxCWBM+wWl37ZQESb4gImexGMDouhGLx1Cst0Saa4b4AqO4Hk4gxo+3DHAV/nx27p3JziPM2pVgoiia5MdEzCGULprIN7gEEeQ5IQxEBBBQnxhsDb5auGmAAYcHMA9eAAz8PBol8/xij9+C4Djlim4gJjWcwZBhCBgMIIYxGAVIkH3ZtcBuLdtRFMWsPGoY9rN+HoBji9VBYdwD2ZQg4cnO7OSq/z4rU5KKdwVbFAjNojCQzTlCLPFSxtamwh2jMUcEgg2Wm/6XgErIBhBckQtGN3CzbVacERgCnfgLswhnvqf7QyAq/z4rRZm1YglYE3affGITaZsdIe2FmMIpnOCap25I6jt2kCwCW0D1uAD9sZctNGXcQIHCkINDQgc78aCr+zjtw3BU/ijdpw3zhCwcaONwBvdeS2YZKkJNJsMPf2JKEvC28RXxxI0ASJyzQCjCEQrO4Q7sFArEzjZhaFc4cdv+/JFdKULM4px0DfUBI2hIsy06BqLhGTQEVdbfAIZXYMPesq6VoCHICzUyjwInO4Y411//LYLs6TDa9wvg2CC2rElgAnpTBziThxaL22MYhzfkghz6GAs2VHbbdM91VZu1MEEpupMMwKyVTb5ij9+u4VJG/5EgEMMmFF01cFai3isRbKbzb+YaU/MQbAm2XSMoUPAmvZzbuKYRIFApbtlrfFuUGd6vq2hXNnH78ZLh/iFhsQG3T4D1ib7k5CC6vY0DCbtrohgLEIClXiGtl10zc0CnEGIhhatLBva7NP58Tvw0qE8yWhARLQ8h4+AhQSP+I4F5xoU+VilGRJs6wnS7ruti/4KvAY/CfdgqjsMy4pf8fodQO8/gnuX3f/3xi3om1/h7THr+co3x93PP9+FBUfbNUjcjEmhcrkT+8K7ml7V10Jo05mpIEFy1NmCJWx9SIKKt+EjAL4Ez8EBVOB6havuT/rByPvHXK+9zUcfcbb254+9fydJknYnRr1oGfdaiAgpxu1Rx/Rek8KISftx3L+DfsLWAANn8Hvw0/AFeAGO9DFV3c6D+CcWbL8Dj9e7f+T1k8AZv/d7+PXWM/Z+VvdCrIvuAKO09RpEEQJM0Ci6+B4xhTWr4cZNOvhktabw0ta0rSJmqz3Yw5/AKXwenod7cAhTmBSPKf6JBdvH8IP17h95pXqw50/+BFnj88fev4NchyaK47OPhhtI8RFSvAfDSNh0Ck0p2gLxGkib5NJj/JWCr90EWQJvwBzO4AHcgztwAFN1evHPUVGwfXON+0debT1YeGON9Yy9/63X+OguiwmhIhQhD7l4sMqlG3D86Suc3qWZ4rWjI1X7u0Ytw6x3rIMeIOPDprfe2XzNgyj6PahhBjO4C3e6puDgXrdg+/5l948vF3bqwZetZ+z9Rx9zdIY5pInPK4Nk0t+l52xdK2B45Qd87nM8fsD5EfUhIcJcERw4RdqqH7Yde5V7m1vhNmtedkz6EDzUMF/2jJYWbC+4fzzA/Y+/8PPH3j9dcBAPIRP8JLXd5BpAu03aziOL3VVHZzz3CXWDPWd+SH2AnxIqQoTZpo9Ckc6HIrFbAbzNmlcg8Ag8NFDDAhbJvTBZXbC94P7t68EXfv6o+21gUtPETU7bbkLxvNKRFG2+KXzvtObonPP4rBvsgmaKj404DlshFole1Glfh02fE7bYR7dZ82oTewIBGn1Md6CG6YUF26X376oevOLzx95vhUmgblI6LBZwTCDY7vMq0op5WVXgsObOXJ+1x3qaBl9j1FeLxbhU9w1F+Wiba6s1X/TBz1LnUfuYDi4r2C69f1f14BWfP+p+W2GFKuC9phcELMYRRLur9DEZTUdEH+iEqWdaM7X4WOoPGI+ZYD2+wcQ+y+ioHUZ9dTDbArzxmi/bJI9BND0Ynd6lBdve/butBw8+f/T9D3ABa3AG8W3VPX4hBin+bj8dMMmSpp5pg7fJ6xrBFE2WQQEWnV8Qg3FbAWzYfM1rREEnmvkN2o1+acG2d/9u68GDzx91v3mAjb1zkpqT21OipPKO0b9TO5W0nTdOmAQm0TObts3aBKgwARtoPDiCT0gHgwnbArzxmtcLc08HgF1asN0C4Ms/fvD5I+7PhfqyXE/b7RbbrGyRQRT9ARZcwAUmgdoz0ehJ9Fn7QAhUjhDAQSw0bV3T3WbNa59jzmiP6GsWbGXDX2ytjy8+f9T97fiBPq9YeLdBmyuizZHaqXITnXiMUEEVcJ7K4j3BFPurtB4bixW8wTpweL8DC95szWMOqucFYGsWbGU7p3TxxxefP+r+oTVktxY0v5hbq3KiOKYnY8ddJVSBxuMMVffNbxwIOERShst73HZ78DZrHpmJmH3K6sGz0fe3UUj0eyRrSCGTTc+rjVNoGzNSv05srAxUBh8IhqChiQgVNIIBH3AVPnrsnXQZbLTm8ammv8eVXn/vWpaTem5IXRlt+U/LA21zhSb9cye6jcOfCnOwhIAYXAMVTUNV0QhVha9xjgA27ODJbLbmitt3tRN80lqG6N/khgot4ZVlOyO4WNg3OIMzhIZQpUEHieg2im6F91hB3I2tubql6BYNN9Hj5S7G0G2tahslBWKDnOiIvuAEDzakDQKDNFQT6gbn8E2y4BBubM230YIpBnDbMa+y3dx0n1S0BtuG62lCCXwcY0F72T1VRR3t2ONcsmDjbmzNt9RFs2LO2hQNyb022JisaI8rAWuw4HI3FuAIhZdOGIcdjLJvvObqlpqvWTJnnQbyi/1M9O8UxWhBs//H42I0q1Yb/XPGONzcmm+ri172mHKvZBpHkJaNJz6v9jxqiklDj3U4CA2ugpAaYMWqNXsdXbmJNd9egCnJEsphXNM+MnK3m0FCJ5S1kmJpa3DgPVbnQnPGWIDspW9ozbcO4K/9LkfaQO2KHuqlfFXSbdNzcEcwoqNEFE9zcIXu9/6n/ym/BC/C3aJLzEKPuYVlbFnfhZ8kcWxV3dbv4bKl28566wD+8C53aw49lTABp9PWbsB+knfc/Li3eVizf5vv/xmvnPKg5ihwKEwlrcHqucuVcVOxEv8aH37E3ZqpZypUulrHEtIWKUr+txHg+ojZDGlwnqmkGlzcVi1dLiNSJiHjfbRNOPwKpx9TVdTn3K05DBx4psIk4Ei8aCkJahRgffk4YnEXe07T4H2RR1u27E6wfQsBDofUgjFUFnwC2AiVtA+05J2zpiDK2Oa0c5fmAecN1iJzmpqFZxqYBCYhFTCsUNEmUnIcZ6aEA5rQVhEywG6w7HSW02XfOoBlQmjwulOFQAg66SvJblrTEX1YtJ3uG15T/BH1OfOQeuR8g/c0gdpT5fx2SKbs9EfHTKdM8A1GaJRHLVIwhcGyydZsbifAFVKl5EMKNU2Hryo+06BeTgqnxzYjThVySDikbtJPieco75lYfKAJOMEZBTjoITuWHXXZVhcUDIS2hpiXHV9Ku4u44bN5OYLDOkJo8w+xJSMbhBRHEdEs9JZUCkQrPMAvaHyLkxgkEHxiNkx/x2YB0mGsQ8EUWj/stW5YLhtS5SMu+/YBbNPDCkGTUybN8krRLBGPlZkVOA0j+a1+rkyQKWGaPHPLZOkJhioQYnVZ2hS3zVxMtgC46KuRwbJNd9nV2PHgb36F194ecf/Yeu2vAFe5nm/bRBFrnY4BauE8ERmZRFUn0k8hbftiVYSKMEme2dJCJSCGYAlNqh87bXOPdUkGy24P6d1ll21MBqqx48Fvv8ZHH8HZFY7j/uAq1xMJUFqCSUlJPmNbIiNsmwuMs/q9CMtsZsFO6SprzCS1Z7QL8xCQClEelpjTduDMsmWD8S1PT152BtvmIGvUeDA/yRn83u/x0/4qxoPHjx+PXY9pqX9bgMvh/Nz9kpP4pOe1/fYf3axUiMdHLlPpZCNjgtNFAhcHEDxTumNONhHrBduW+vOyY++70WWnPXj98eA4kOt/mj/5E05l9+O4o8ePx67HFqyC+qSSnyselqjZGaVK2TadbFLPWAQ4NBhHqDCCV7OTpo34AlSSylPtIdd2AJZlyzYQrDJ5lcWGNceD80CunPLGGzsfD+7wRb95NevJI5docQ3tgCyr5bGnyaPRlmwNsFELViOOx9loebGNq2moDOKpHLVP5al2cymWHbkfzGXL7kfRl44H9wZy33tvt+PB/Xnf93e+nh5ZlU18wCiRUa9m7kib9LYuOk+hudQNbxwm0AQqbfloimaB2lM5fChex+ylMwuTbfmXQtmWlenZljbdXTLuOxjI/fDDHY4Hjx8/Hrse0zXfPFxbUN1kKqSCCSk50m0Ajtx3ub9XHBKHXESb8iO6E+qGytF4nO0OG3SXzbJlhxBnKtKyl0NwybjvYCD30aMdjgePHz8eu56SVTBbgxJMliQ3Oauwg0QHxXE2Ez/EIReLdQj42Gzb4CLS0YJD9xUx7bsi0vJi5mUbW1QzL0h0PFk17rtiIPfJk52MB48fPx67npJJwyrBa2RCCQRTbGZSPCxTPOiND4G2pYyOQ4h4jINIJh5wFU1NFZt+IsZ59LSnDqBjZ2awbOku+yInunLcd8VA7rNnOxkPHj9+PGY9B0MWJJNozOJmlglvDMXDEozdhQWbgs/U6oBanGzLrdSNNnZFjOkmbi5bNt1lX7JLLhn3vXAg9/h4y/Hg8ePHI9dzQMEkWCgdRfYykYKnkP7D4rIujsujaKPBsB54vE2TS00ccvFY/Tth7JXeq1hz+qgVy04sAJawTsvOknHfCwdyT062HA8eP348Zj0vdoXF4pilKa2BROed+9fyw9rWRXeTFXESMOanvDZfJuJaSXouQdMdDJZtekZcLLvEeK04d8m474UDuaenW44Hjx8/Xns9YYqZpszGWB3AN/4VHw+k7WSFtJ3Qicuqb/NlVmgXWsxh570xg2UwxUw3WfO6B5nOuO8aA7lnZxuPB48fPx6znm1i4bsfcbaptF3zNT78eFPtwi1OaCNOqp1x3zUGcs/PN++AGD1+fMXrSVm2baTtPhPahbPhA71wIHd2bXzRa69nG+3CraTtPivahV/55tXWg8fyRY/9AdsY8VbSdp8V7cKrrgdfM//z6ILQFtJ2nxHtwmuoB4/kf74+gLeRtvvMaBdeSz34+vifx0YG20jbfTa0C6+tHrwe//NmOG0L8EbSdp8R7cLrrQe/996O+ai3ujQOskpTNULa7jOjXXj99eCd8lHvoFiwsbTdZ0a78PrrwTvlo966pLuRtB2fFe3Cm6oHP9kNH/W2FryxtN1nTLvwRurBO+Kj3pWXHidtx2dFu/Bm68Fb81HvykuPlrb7LGkX3mw9eGs+6h1Y8MbSdjegXcguQLjmevDpTQLMxtJ2N6NdyBZu9AbrwVvwUW+LbteULUpCdqm0HTelXbhNPe8G68Gb8lFvVfYfSNuxvrTdTWoXbozAzdaDZzfkorOj1oxVxlIMlpSIlpLrt8D4hrQL17z+c3h6hU/wv4Q/utps4+bm+6P/hIcf0JwQ5oQGPBL0eKPTYEXTW+eL/2DKn73J9BTXYANG57hz1cEMviVf/4tf5b/6C5pTQkMIWoAq7hTpOJjtAM4pxKu5vg5vXeUrtI09/Mo/5H+4z+Mp5xULh7cEm2QbRP2tFIKR7WM3fPf/jZ3SWCqLM2l4NxID5zB72HQXv3jj/8mLR5xXNA5v8EbFQEz7PpRfl1+MB/hlAN65qgDn3wTgH13hK7T59bmP+NIx1SHHU84nLOITt3iVz8mNO+lPrjGAnBFqmioNn1mTyk1ta47R6d4MrX7tjrnjYUpdUbv2rVr6YpVfsGG58AG8Ah9eyUN8CX4WfgV+G8LVWPDGb+Zd4cU584CtqSbMKxauxTg+dyn/LkVgA+IR8KHtejeFKRtTmLLpxN6mYVLjYxwXf5x2VofiZcp/lwKk4wGOpYDnoIZPdg/AAbwMfx0+ge9dgZvYjuqKe4HnGnykYo5TvJbG0Vj12JagRhwKa44H95ShkZa5RyLGGdfYvG7aw1TsF6iapPAS29mNS3NmsTQZCmgTzFwgL3upCTgtBTRwvGMAKrgLn4evwin8+afJRcff+8izUGUM63GOOuAs3tJkw7J4kyoNreqrpO6cYLQeFUd7TTpr5YOTLc9RUUogUOVJQ1GYJaFLAW0oTmKyYS46ZooP4S4EON3xQ5zC8/CX4CnM4c1PE8ApexpoYuzqlP3d4S3OJP8ZDK7cKWNaTlqmgDiiHwl1YsE41w1zT4iRTm3DBqxvOUsbMKKDa/EHxagtnta072ejc3DOIh5ojvh8l3tk1JF/AV6FU6jh3U8HwEazLgdCLYSQ+MYiAI2ltomkzttUb0gGHdSUUgsIYjTzLG3mObX4FBRaYtpDVNZrih9TgTeYOBxsEnN1gOCTM8Bsw/ieMc75w9kuAT6A+/AiHGvN/+Gn4KRkiuzpNNDYhDGFndWRpE6SVfm8U5bxnSgVV2jrg6JCKmneqey8VMFgq2+AM/i4L4RUbfSi27lNXZ7R7W9RTcq/q9fk4Xw3AMQd4I5ifAZz8FcVtm9SAom/dyN4lczJQW/kC42ZrHgcCoIf1oVMKkVItmMBi9cOeNHGLqOZk+QqQmrbc5YmYgxELUUN35z2iohstgfLIFmcMV7s4CFmI74L9+EFmGsi+tGnAOD4Yk9gIpo01Y4cA43BWGygMdr4YZekG3OBIUXXNukvJS8tqa06e+lSDCtnqqMFu6hWHXCF+WaYt64m9QBmNxi7Ioy7D+fa1yHw+FMAcPt7SysFLtoG4PXAk7JOA3aAxBRqUiAdU9Yp5lK3HLSRFtOim0sa8euEt08xvKjYjzeJ2GU7YawexrnKI9tmobInjFXCewpwriY9+RR4aaezFhMhGCppKwom0ChrgFlKzyPKkGlTW1YQrE9HJqu8hKGgMc6hVi5QRq0PZxNfrYNgE64utmRv6KKHRpxf6VDUaOvNP5jCEx5q185My/7RKz69UQu2im5k4/eownpxZxNLwiZ1AZTO2ZjWjkU9uaB2HFn6Q3u0JcsSx/qV9hTEApRzeBLDJQXxYmTnq7bdLa3+uqFrxLJ5w1TehnNHx5ECvCh2g2c3hHH5YsfdaSKddztfjQ6imKFGSyFwlLzxEGPp6r5IevVjk1AMx3wMqi1NxDVjLBiPs9tbsCkIY5we5/ML22zrCScFxnNtzsr9Wcc3CnD+pYO+4VXXiDE0oc/vQQ/fDK3oPESJMYXNmJa/DuloJZkcTpcYE8lIH8Dz8DJMiynNC86Mb2lNaaqP/+L7f2fcE/yP7/Lde8xfgSOdMxvOixZf/9p3+M4hT1+F+zApxg9XfUvYjc8qX2lfOOpK2gNRtB4flpFu9FTKCp2XJRgXnX6olp1zyYjTKJSkGmLE2NjUr1bxFM4AeAAHBUFIeSLqXR+NvH/M9fOnfHzOD2vCSyQJKzfgsCh+yi/Mmc35F2fUrw7miW33W9hBD1vpuUojFphIyvg7aTeoymDkIkeW3XLHmguMzbIAJejN6B5MDrhipE2y6SoFRO/AK/AcHHZHNIfiWrEe/C6cr3f/yOvrQKB+zMM55/GQdLDsR+ifr5Fiuu+/y+M78LzOE5dsNuXC3PYvYWd8NXvphLSkJIasrlD2/HOqQ+RjcRdjKTGWYhhVUm4yxlyiGPuMsZR7sMCHUBeTuNWA7if+ifXgc/hovftHXs/DV+Fvwe+f8shzMiMcweFgBly3//vwJfg5AN4450fn1Hd1Rm1aBLu22Dy3y3H2+OqMemkbGZ4jozcDjJf6596xOLpC0eMTHbKnxLxH27uZ/bMTGs2jOaMOY4m87CfQwF0dw53oa1k80JRuz/XgS+8fX3N9Af4qPIMfzKgCp4H5TDGe9GGeFPzSsZz80SlPTxXjgwJmC45njzgt2vbQ4b4OAdUK4/vWhO8d8v6EE8fMUsfakXbPpFJeLs2ubM/qdm/la3WP91uWhxXHjoWhyRUq2iJ/+5mA73zwIIo+LoZ/SgvIRjAd1IMvvn98PfgOvAJfhhm8scAKVWDuaRaK8aQ9f7vuPDH6Bj47ZXau7rqYJ66mTDwEDU6lLbCjCK0qTXyl5mnDoeNRxanj3FJbaksTk0faXxHxLrssgPkWB9LnA/MFleXcJozzjwsUvUG0X/QCve51qkMDXp9mtcyOy3rwBfdvVJK7D6/ACSzg3RoruIq5UDeESfEmVclDxnniU82vxMLtceD0hGZWzBNPMM/jSPne2OVatiTKUpY5vY7gc0LdUAWeWM5tH+O2I66AOWw9xT2BuyRVLGdoDHUsVRXOo/c+ZdRXvFfnxWyIV4upFLCl9eAL7h8Zv0QH8Ry8pA2cHzQpGesctVA37ZtklBTgHjyvdSeKY/RZw/kJMk0Y25cSNRWSigQtlULPTw+kzuJPeYEkXjQRpoGZobYsLF79pyd1dMRHInbgFTZqNLhDqiIsTNpoex2WLcy0/X6rHcdMMQvFSd5dWA++4P7xv89deACnmr36uGlL69bRCL6BSZsS6c0TU2TKK5gtWCzgAOOwQcurqk9j8whvziZSMLcq5hbuwBEsYjopUBkqw1yYBGpLA97SRElEmx5MCInBY5vgLk94iKqSWmhIGmkJ4Bi9m4L645J68LyY4wsFYBfUg5feP/6gWWm58IEmKQM89hq7KsZNaKtP5TxxrUZZVkNmMJtjbKrGxLNEbHPJxhqy7lAmbC32ZqeF6lTaknRWcYaFpfLUBh/rwaQycCCJmW15Kstv6jRHyJFry2C1ahkkIW0LO75s61+owxK1y3XqweX9m5YLM2DPFeOjn/iiqCKJ+yKXF8t5Yl/kNsqaSCryxPq5xWTFIaP8KSW0RYxqupaUf0RcTNSSdJZGcKYdYA6kdtrtmyBckfKXwqk0pHpUHlwWaffjNRBYFPUDWa8e3Lt/o0R0CdisKDM89cX0pvRHEfM8ca4t0s2Xx4kgo91MPQJ/0c9MQYq0co8MBh7bz1fio0UUHLR4aAIOvOmoYO6kwlEVODSSTliWtOtH6sPkrtctF9ZtJ9GIerBskvhdVS5cFNv9s1BU0AbdUgdK4FG+dRnjFmDTzniRMdZO1QhzMK355vigbdkpz9P6qjUGE5J2qAcXmwJ20cZUiAD0z+pGMx6xkzJkmEf40Hr4qZfVg2XzF9YOyoV5BjzVkUJngKf8lgNYwKECEHrCNDrWZzMlflS3yBhr/InyoUgBc/lKT4pxVrrC6g1YwcceK3BmNxZcAtz3j5EIpqguh9H6wc011YN75cKDLpFDxuwkrPQmUwW4KTbj9mZTwBwLq4aQMUZbHm1rylJ46dzR0dua2n3RYCWZsiHROeywyJGR7mXKlpryyCiouY56sFkBWEnkEB/raeh/Sw4162KeuAxMQpEkzy5alMY5wamMsWKKrtW2WpEWNnReZWONKWjrdsKZarpFjqCslq773PLmEhM448Pc3+FKr1+94vv/rfw4tEcu+lKTBe4kZSdijBrykwv9vbCMPcLQTygBjzVckSLPRVGslqdunwJ4oegtFOYb4SwxNgWLCmD7T9kVjTv5YDgpo0XBmN34Z/rEHp0sgyz7lngsrm4lvMm2Mr1zNOJYJ5cuxuQxwMGJq/TP5emlb8fsQBZviK4t8hFL+zbhtlpwaRSxQRWfeETjuauPsdGxsBVdO7nmP4xvzSoT29pRl7kGqz+k26B3Oy0YNV+SXbbQas1ctC/GarskRdFpKczVAF1ZXnLcpaMuzVe6lZ2g/1ndcvOVgRG3sdUAY1bKD6achijMPdMxV4muKVorSpiDHituH7rSTs7n/4y5DhRXo4FVBN4vO/zbAcxhENzGbHCzU/98Mcx5e7a31kWjw9FCe/zNeYyQjZsWb1uc7U33pN4Mji6hCLhivqfa9Ss6xLg031AgfesA/l99m9fgvnaF9JoE6bYKmkGNK3aPbHB96w3+DnxFm4hs0drLsk7U8kf/N/CvwQNtllna0rjq61sH8L80HAuvwH1tvBy2ChqWSCaYTaGN19sTvlfzFD6n+iKTbvtayfrfe9ueWh6GJFoxLdr7V72a5ZpvHcCPDzma0wTO4EgbLyedxstO81n57LYBOBzyfsOhUKsW1J1BB5vr/tz8RyqOFylQP9Tvst2JALsC5lsH8PyQ40DV4ANzYa4dedNiKNR1s+x2wwbR7q4/4cTxqEk4LWDebfisuo36JXLiWFjOtLrlNWh3K1rRS4xvHcDNlFnNmWBBAl5SWaL3oPOfnvbr5pdjVnEaeBJSYjuLEkyLLsWhKccadmOphZkOPgVdalj2QpSmfOsADhMWE2ZBu4+EEJI4wKTAuCoC4xwQbWXBltpxbjkXJtKxxabo9e7tyhlgb6gNlSbUpMh+l/FaqzVwewGu8BW1Zx7pTpQDJUjb8tsUTW6+GDXbMn3mLbXlXJiGdggxFAoUrtPS3wE4Nk02UZG2OOzlk7fRs7i95QCLo3E0jtrjnM7SR3uS1p4qtS2nJ5OwtQVHgOvArLBFijZUV9QtSl8dAY5d0E0hM0w3HS2DpIeB6m/A1+HfhJcGUq4sOxH+x3f5+VO+Ds9rYNI7zPXOYWPrtf8bYMx6fuOAX5jzNR0PdsuON+X1f7EERxMJJoU6GkTEWBvVolVlb5lh3tKCg6Wx1IbaMDdJ+9sUCc5KC46hKGCk3IVOS4TCqdBNfUs7Kd4iXf2RjnT/LLysJy3XDcHLh/vde3x8DoGvwgsa67vBk91G5Pe/HbOe7xwym0NXbtiuuDkGO2IJDh9oQvJ4cY4vdoqLDuoH9Zl2F/ofsekn8lkuhIlhQcffUtSjytFyp++p6NiE7Rqx/lodgKVoceEp/CP4FfjrquZaTtj2AvH5K/ywpn7M34K/SsoYDAdIN448I1/0/wveW289T1/lX5xBzc8N5IaHr0XMOQdHsIkDuJFifj20pBm5jzwUv9e2FhwRsvhAbalCIuIw3bhJihY3p6nTFFIZgiSYjfTf3aXuOjmeGn4bPoGvwl+CFzTRczBIuHBEeImHc37/lGfwZR0cXzVDOvaKfNHvwe+suZ771K/y/XcBlsoN996JpBhoE2toYxOznNEOS5TJc6Id5GEXLjrWo+LEWGNpPDU4WAwsIRROu+1vM+0oW37z/MBN9kqHnSArwPfgFJ7Cq/Ai3Ie7g7ncmI09v8sjzw9mzOAEXoIHxURueaAce5V80f/DOuuZwHM8vsMb5wBzOFWM7wymTXPAEvm4vcFpZ2ut0VZRjkiP2MlmLd6DIpbGSiHOjdnUHN90hRYmhTnmvhzp1iKDNj+b7t5hi79lWGwQ+HN9RsfFMy0FXbEwhfuczKgCbyxYwBmcFhhvo/7a44v+i3XWcwDP86PzpGQYdWh7csP5dBvZ1jNzdxC8pBGuxqSW5vw40nBpj5JhMwvOzN0RWqERHMr4Lv1kWX84xLR830G3j6yqZ1a8UstTlW+qJPOZ+sZ7xZPKTJLhiNOAFd6tk+jrTH31ncLOxid8+nzRb128HhUcru/y0Wn6iT254YPC6FtVSIMoW2sk727AhvTtrWKZTvgsmckfXYZWeNRXx/3YQ2OUxLDrbHtN11IwrgXT6c8dATDwLniYwxzO4RzuQqTKSC5gAofMZ1QBK3zQ4JWobFbcvJm87FK+6JXrKahLn54m3p+McXzzYtP8VF/QpJuh1OwieElEoI1pRxPS09FBrkq2tWCU59+HdhNtTIqKm8EBrw2RTOEDpG3IKo2Y7mFdLm3ZeVjYwVw11o/oznceMve4CgMfNym/utA/d/ILMR7gpXzRy9eDsgLcgbs8O2Va1L0zzIdwGGemTBuwROHeoMShkUc7P+ISY3KH5ZZeWqO8mFTxQYeXTNuzvvK5FGPdQfuu00DwYFY9dyhctEt+OJDdnucfpmyhzUJzfsJjr29l8S0bXBfwRS9ZT26tmMIdZucch5ZboMz3Nio3nIOsYHCGoDT4kUA9MiXEp9Xsui1S8th/kbWIrMBxDGLodWUQIWcvnXy+9M23xPiSMOiRPqM+YMXkUN3gXFrZJwXGzUaMpJfyRS9ZT0lPe8TpScuRlbMHeUmlaKDoNuy62iWNTWNFYjoxFzuJs8oR+RhRx7O4SVNSXpa0ZJQ0K1LAHDQ+D9IepkMXpcsq5EVCvClBUIzDhDoyKwDw1Lc59GbTeORivugw1IcuaEOaGWdNm+Ps5fQ7/tm0DjMegq3yM3vb5j12qUId5UZD2oxDSEWOZMSqFl/W+5oynWDa/aI04tJRQ2eTXusg86SQVu/nwSYwpW6wLjlqIzwLuxGIvoAvul0PS+ZNz0/akp/pniO/8JDnGyaCkzbhl6YcqmK/69prxPqtpx2+Km9al9sjL+rwMgHw4jE/C8/HQ3m1vBuL1fldbzd8mOueVJ92syqdEY4KJjSCde3mcRw2TA6szxedn+zwhZMps0XrqEsiUjnC1hw0TELC2Ek7uAAdzcheXv1BYLagspxpzSAoZZUsIzIq35MnFQ9DOrlNB30jq3L4pkhccKUAA8/ocvN1Rzx9QyOtERs4CVsJRK/DF71kPYrxYsGsm6RMh4cps5g1DOmM54Ly1ii0Hd3Y/BMk8VWFgBVmhqrkJCPBHAolwZaWzLR9Vb7bcWdX9NyUYE+uB2BKfuaeBUcjDljbYVY4DdtsVWvzRZdWnyUzDpjNl1Du3aloAjVJTNDpcIOVVhrHFF66lLfJL1zJr9PQ2nFJSBaKoDe+sAvLufZVHVzYh7W0h/c6AAZ+7Tvj6q9j68G/cTCS/3n1vLKHZwNi+P+pS0WkZNMBMUl+LDLuiE4omZy71r3UFMwNJV+VJ/GC5ixVUkBStsT4gGKh0Gm4Oy3qvq7Lbmq24nPdDuDR9deR11XzP4vFu3TYzfnIyiSVmgizUYGqkIXNdKTY9pgb9D2Ix5t0+NHkVzCdU03suWkkVZAoCONCn0T35gAeW38de43mf97sMOpSvj4aa1KYUm58USI7Wxxes03bAZdRzk6UtbzMaCQ6IxO0dy7X+XsjoD16hpsBeGz9dfzHj+R/Hp8nCxZRqkEDTaCKCSywjiaoMJ1TITE9eg7Jqnq8HL6gDwiZb0u0V0Rr/rmvqjxKuaLCX7ZWXTvAY+uvm3z8CP7nzVpngqrJpZKwWnCUjIviYVlirlGOzPLI3SMVyp/elvBUjjDkNhrtufFFErQ8pmdSlbK16toBHlt/HV8uHMX/vEGALkV3RJREiSlopxwdMXOZPLZ+ix+kAHpMKIk8UtE1ygtquttwxNhphrIZ1IBzjGF3IIGxGcBj6q8bHJBG8T9vdsoWrTFEuebEZuVxhhClH6P5Zo89OG9fwHNjtNQTpD0TG9PJLEYqvEY6Rlxy+ZZGfL0Aj62/bnQCXp//eeM4KzfQVJbgMQbUjlMFIm6TpcfWlZje7NBSV6IsEVmumWIbjiloUzQX9OzYdo8L1wjw2PrrpimONfmfNyzKklrgnEkSzT5QWYQW40YShyzqsRmMXbvVxKtGuYyMKaU1ugenLDm5Ily4iT14fP11Mx+xJv+zZ3MvnfdFqxU3a1W/FTB4m3Qfsyc1XUcdVhDeUDZXSFHHLQj/Y5jtC7ZqM0CXGwB4bP11i3LhOvzPGygYtiUBiwQV/4wFO0majijGsafHyRLu0yG6q35cL1rOpVxr2s5cM2jJYMCdc10Aj6q/blRpWJ//+dmm5psMl0KA2+AFRx9jMe2WbC4jQxnikd4DU8TwUjRVacgdlhmr3bpddzuJ9zXqr2xnxJfzP29RexdtjDVZqzkqa6PyvcojGrfkXiJ8SEtml/nYskicv0ivlxbqjemwUjMw5evdg8fUX9nOiC/lf94Q2i7MURk9nW1MSj5j8eAyV6y5CN2S6qbnw3vdA1Iwq+XOSCl663udN3IzLnrt+us25cI1+Z83SXQUldqQq0b5XOT17bGpLd6ssN1VMPf8c+jG8L3NeCnMdF+Ra3fRa9dft39/LuZ/3vwHoHrqGmQFafmiQw6eyzMxS05K4bL9uA+SKUQzCnSDkqOGokXyJvbgJ/BHI+qvY69//4rl20NsmK2ou2dTsyIALv/91/8n3P2Aao71WFGi8KKv1fRC5+J67Q/507/E/SOshqN5TsmYIjVt+kcjAx98iz/4SaojbIV1rexE7/C29HcYD/DX4a0rBOF5VTu7omsb11L/AWcVlcVZHSsqGuXLLp9ha8I//w3Mv+T4Ew7nTBsmgapoCrNFObIcN4pf/Ob/mrvHTGqqgAupL8qWjWPS9m/31jAe4DjA+4+uCoQoT/zOzlrNd3qd4SdphFxsUvYwGWbTWtISc3wNOWH+kHBMfc6kpmpwPgHWwqaSUG2ZWWheYOGQGaHB+eQ/kn6b3pOgLV+ODSn94wDvr8Bvb70/LLuiPPEr8OGVWfDmr45PZyccEmsVXZGe1pRNX9SU5+AVQkNTIVPCHF/jGmyDC9j4R9LfWcQvfiETmgMMUCMN1uNCakkweZsowdYobiMSlnKA93u7NzTXlSfe+SVbfnPQXmg9LpYAQxpwEtONyEyaueWM4FPjjyjG3uOaFmBTWDNgBXGEiQpsaWhnAqIijB07Dlsy3fUGeP989xbWkyf+FF2SNEtT1E0f4DYYVlxFlbaSMPIRMk/3iMU5pME2SIWJvjckciebkQuIRRyhUvkHg/iUljG5kzVog5hV7vIlCuBrmlhvgPfNHQM8lCf+FEGsYbMIBC0qC9a0uuy2wLXVbLBaP5kjHokCRxapkQyzI4QEcwgYHRZBp+XEFTqXFuNVzMtjXLJgX4gAid24Hjwc4N3dtVSe+NNiwTrzH4WVUOlDobUqr1FuAgYllc8pmzoVrELRHSIW8ViPxNy4xwjBpyR55I6J220qQTZYR4guvUICJiSpr9gFFle4RcF/OMB7BRiX8sSfhpNSO3lvEZCQfLUVTKT78Ek1LRLhWN+yLyTnp8qWUZ46b6vxdRGXfHVqx3eI75YaLa4iNNiK4NOW7wPW6lhbSOF9/M9qw8e/aoB3d156qTzxp8pXx5BKAsYSTOIIiPkp68GmTq7sZtvyzBQaRLNxIZ+paozHWoLFeExIhRBrWitHCAHrCF7/thhD8JhYz84wg93QRV88wLuLY8zF8sQ36qF1J455bOlgnELfshKVxYOXKVuKx0jaj22sczTQqPqtV/XDgpswmGTWWMSDw3ssyUunLLrVPGjYRsH5ggHeHSWiV8kT33ycFSfMgkoOK8apCye0J6VW6GOYvffgU9RWsukEi2kUV2nl4dOYUzRik9p7bcA4ggdJ53LxKcEe17B1R8eqAd7dOepV8sTXf5lhejoL85hUdhDdknPtKHFhljOT+bdq0hxbm35p2nc8+Ja1Iw+tJykgp0EWuAAZYwMVwac5KzYMslhvgHdHRrxKnvhTYcfKsxTxtTETkjHO7rr3zjoV25lAQHrqpV7bTiy2aXMmUhTBnKS91jhtR3GEoF0oLnWhWNnYgtcc4N0FxlcgT7yz3TgNIKkscx9jtV1ZKpWW+Ub1tc1eOv5ucdgpx+FJy9pgbLE7xDyXb/f+hLHVGeitHOi6A7ybo3sF8sS7w7cgdk0nJaOn3hLj3uyD0Zp5pazFIUXUpuTTU18d1EPkDoX8SkmWTnVIozEdbTcZjoqxhNHf1JrSS/AcvHjZ/SMHhL/7i5z+POsTUh/8BvNfYMTA8n+yU/MlTZxSJDRStqvEuLQKWwDctMTQogUDyQRoTQG5Kc6oQRE1yV1jCA7ri7jdZyK0sYTRjCR0Hnnd+y7nHxNgTULqw+8wj0mQKxpYvhjm9uSUxg+TTy7s2GtLUGcywhXSKZN275GsqlclX90J6bRI1aouxmgL7Q0Nen5ziM80SqMIo8cSOo+8XplT/5DHNWsSUr/6lLN/QQ3rDyzLruEW5enpf7KqZoShEduuSFOV7DLX7Ye+GmXb6/hnNNqKsVXuMDFpb9Y9eH3C6NGEzuOuI3gpMH/I6e+zDiH1fXi15t3vA1czsLws0TGEtmPEJdiiFPwlwKbgLHAFk4P6ZyPdymYYHGE0dutsChQBl2JcBFlrEkY/N5bQeXQ18gjunuMfMfsBlxJSx3niO485fwO4fGD5T/+3fPQqkneWVdwnw/3bMPkW9Wbqg+iC765Zk+xcT98ibKZc2EdgHcLoF8cSOo/Oc8fS+OyEULF4g4sJqXVcmfMfsc7A8v1/yfGXmL9I6Fn5pRwZhsPv0TxFNlAfZCvG+Oohi82UC5f/2IsJo0cTOm9YrDoKhFPEUr/LBYTUNht9zelHXDqwfPCIw4owp3mOcIQcLttWXFe3VZ/j5H3cIc0G6oPbCR+6Y2xF2EC5cGUm6wKC5tGEzhsWqw5hNidUiKX5gFWE1GXh4/Qplw4sVzOmx9QxU78g3EF6wnZlEN4FzJ1QPSLEZz1KfXC7vd8ssGdIbNUYpVx4UapyFUHzJoTOo1McSkeNn1M5MDQfs4qQuhhX5vQZFw8suwWTcyYTgioISk2YdmkhehG4PkE7w51inyAGGaU+uCXADabGzJR1fn3lwkty0asIo8cROm9Vy1g0yDxxtPvHDAmpu+PKnM8Ix1wwsGw91YJqhteaWgjYBmmQiebmSpwKKzE19hx7jkzSWOm66oPbzZ8Yj6kxVSpYjVAuvLzYMCRo3oTQecOOjjgi3NQ4l9K5/hOGhNTdcWVOTrlgYNkEXINbpCkBRyqhp+LdRB3g0OU6rMfW2HPCFFMV9nSp+uB2woepdbLBuJQyaw/ZFysXrlXwHxI0b0LovEkiOpXGA1Ijagf+KUNC6rKNa9bQnLFqYNkEnMc1uJrg2u64ELPBHpkgWbmwKpJoDhMwNbbGzAp7Yg31wS2T5rGtzit59PrKhesWG550CZpHEzpv2NGRaxlNjbMqpmEIzygJqQfjypycs2pg2cS2RY9r8HUqkqdEgKTWtWTKoRvOBPDYBltja2SO0RGjy9UHtxwRjA11ujbKF+ti5cIR9eCnxUg6owidtyoU5tK4NLji5Q3HCtiyF2IqLGYsHViOXTXOYxucDqG0HyttqYAKqYo3KTY1ekyDXRAm2AWh9JmsVh/ccg9WJ2E8YjG201sPq5ULxxX8n3XLXuMInbft2mk80rRGjCGctJ8/GFdmEQ9Ug4FlE1ll1Y7jtiraqm5Fe04VV8lvSVBL8hiPrfFVd8+7QH3Qbu2ipTVi8cvSGivc9cj8yvH11YMHdNSERtuOslM97feYFOPKzGcsI4zW0YGAbTAOaxCnxdfiYUmVWslxiIblCeAYr9VYR1gM7GmoPrilunSxxeT3DN/2eBQ9H11+nk1adn6VK71+5+Jfct4/el10/7KBZfNryUunWSCPxPECk1rdOv1WVSrQmpC+Tl46YD3ikQYcpunSQgzVB2VHFhxHVGKDgMEY5GLlQnP7FMDzw7IacAWnO6sBr12u+XanW2AO0wQ8pknnFhsL7KYIqhkEPmEXFkwaN5KQphbkUmG72wgw7WSm9RiL9QT925hkjiVIIhphFS9HKI6/8QAjlpXqg9W2C0apyaVDwKQwrwLY3j6ADR13ZyUNByQXHQu6RY09Hu6zMqXRaNZGS/KEJs0cJEe9VH1QdvBSJv9h09eiRmy0V2uJcqHcShcdvbSNg5fxkenkVprXM9rDVnX24/y9MVtncvbKY706anNl3ASll9a43UiacVquXGhvq4s2FP62NGKfQLIQYu9q1WmdMfmUrDGt8eDS0cXozH/fjmUH6Jruvm50hBDSaEU/2Ru2LEN/dl006TSc/g7tfJERxGMsgDUEr104pfWH9lQaN+M4KWQjwZbVc2rZVNHsyHal23wZtIs2JJqtIc/WLXXRFCpJkfE9jvWlfFbsNQ9pP5ZBS0zKh4R0aMFj1IjTcTnvi0Zz2rt7NdvQb2mgbju1plsH8MmbnEk7KbK0b+wC2iy3aX3szW8xeZvDwET6hWZYwqTXSSG+wMETKum0Dq/q+x62gt2ua2ppAo309TRk9TPazfV3qL9H8z7uhGqGqxNVg/FKx0HBl9OVUORn8Q8Jx9gFttGQUDr3tzcXX9xGgN0EpzN9mdZ3GATtPhL+CjxFDmkeEU6x56kqZRusLzALXVqkCN7zMEcqwjmywDQ6OhyUe0Xao1Qpyncrg6wKp9XfWDsaZplElvQ/b3sdweeghorwBDlHzgk1JmMc/wiERICVy2VJFdMjFuLQSp3S0W3+sngt2njwNgLssFGVQdJ0tu0KH4ky1LW4yrbkuaA6Iy9oz/qEMMXMMDWyIHhsAyFZc2peV9hc7kiKvfULxCl9iddfRK1f8kk9qvbdOoBtOg7ZkOZ5MsGrSHsokgLXUp9y88smniwWyuFSIRVmjplga3yD8Uij5QS1ZiM4U3Qw5QlSm2bXjFe6jzzBFtpg+/YBbLAWG7OPynNjlCw65fukGNdkJRf7yM1fOxVzbxOJVocFoYIaGwH22mIQkrvu1E2nGuebxIgW9U9TSiukPGU+Lt++c3DJPKhyhEEbXCQLUpae2exiKy6tMPe9mDRBFCEMTWrtwxN8qvuGnt6MoihKWS5NSyBhbH8StXoAz8PLOrRgLtOT/+4vcu+7vDLnqNvztOq7fmd8sMmY9Xzn1zj8Dq8+XVdu2Nv0IIySgEdQo3xVHps3Q5i3fLFsV4aiqzAiBhbgMDEd1uh8qZZ+lwhjkgokkOIv4xNJmyncdfUUzgB4oFMBtiu71Xumpz/P+cfUP+SlwFExwWW62r7b+LSPxqxn/gvMZ5z9C16t15UbNlq+jbGJtco7p8wbYlL4alSyfWdeuu0j7JA3JFNuVAwtst7F7FhWBbPFNKIUORndWtLraFLmMu7KFVDDOzqkeaiN33YAW/r76wR4XDN/yN1z7hejPau06EddkS/6XThfcz1fI/4K736fO48vlxt2PXJYFaeUkFS8U15XE3428xdtn2kc8GQlf1vkIaNRRnOMvLTWrZbElEHeLWi1o0dlKPAh1MVgbbVquPJ5+Cr8LU5/H/+I2QlHIU2ClXM9G8v7Rr7oc/hozfUUgsPnb3D+I+7WF8kNO92GY0SNvuxiE+2Bt8prVJTkzE64sfOstxuwfxUUoyk8VjcTlsqe2qITSFoSj6Epd4KsT6BZOWmtgE3hBfir8IzZDwgV4ZTZvD8VvPHERo8v+vL1DASHTz/i9OlKueHDjK5Rnx/JB1Vb1ioXdBra16dmt7dgik10yA/FwJSVY6XjA3oy4SqM2frqDPPSRMex9qs3XQtoWxMj7/Er8GWYsXgjaVz4OYumP2+9kbxvny/6kvWsEBw+fcb5bInc8APdhpOSs01tEqIkoiZjbAqKMruLbJYddHuHFRIyJcbdEdbl2sVLaySygunutBg96Y2/JjKRCdyHV+AEFtTvIpbKIXOamknYSiB6KV/0JetZITgcjjk5ZdaskBtWO86UF0ap6ozGXJk2WNiRUlCPFir66lzdm/SLSuK7EUdPz8f1z29Skq6F1fXg8+5UVR6bszncP4Tn4KUkkdJ8UFCY1zR1i8RmL/qQL3rlei4THG7OODlnKko4oI01kd3CaM08Ia18kC3GNoVaO9iDh+hWxSyTXFABXoau7Q6q9OxYg/OVEMw6jdbtSrJ9cBcewGmaZmg+bvkUnUUaGr+ZfnMH45Ivevl61hMcXsxYLFTu1hTm2zViCp7u0o5l+2PSUh9bDj6FgYypufBDhqK2+oXkiuHFHR3zfj+9PtA8oR0xnqX8qn+sx3bFODSbbF0X8EUvWQ8jBIcjo5bRmLOljDNtcqNtOe756h3l0VhKa9hDd2l1eqmsnh0MNMT/Cqnx6BInumhLT8luljzQ53RiJeA/0dxe5NK0o2fA1+GLXr6eNQWHNUOJssQaTRlGpLHKL9fD+IrQzTOMZS9fNQD4AnRNVxvTdjC+fJdcDDWQcyB00B0t9BDwTxXgaAfzDZ/DBXzRnfWMFRwuNqocOmX6OKNkY63h5n/fFcB28McVHqnXZVI27K0i4rDLNE9lDKV/rT+udVbD8dFFu2GGZ8mOt0kAXcoX3ZkIWVtw+MNf5NjR2FbivROHmhV1/pj2egv/fMGIOWTIWrV3Av8N9imV9IWml36H6cUjqEWNv9aNc+veb2sH46PRaHSuMBxvtW+twxctq0z+QsHhux8Q7rCY4Ct8lqsx7c6Sy0dl5T89rIeEuZKoVctIk1hNpfavER6yyH1Vvm3MbsUHy4ab4hWr/OZPcsRBphnaV65/ZcdYPNNwsjN/djlf9NqCw9U5ExCPcdhKxUgLSmfROpLp4WSUr8ojdwbncbvCf+a/YzRaEc6QOvXcGO256TXc5Lab9POvB+AWY7PigWYjzhifbovuunzRawsO24ZqQQAqguBtmpmPB7ysXJfyDDaV/aPGillgz1MdQg4u5MYaEtBNNHFjkRlSpd65lp4hd2AVPTfbV7FGpyIOfmNc/XVsPfg7vzaS/3nkvLL593ANLvMuRMGpQIhiF7kUEW9QDpAUbTWYBcbp4WpacHHY1aacqQyjGZS9HI3yCBT9kUZJhVOD+zUDvEH9ddR11fzPcTDQ5TlgB0KwqdXSavk9BC0pKp0WmcuowSw07VXmXC5guzSa4p0UvRw2lbDiYUx0ExJJRzWzi6Gm8cnEkfXXsdcG/M/jAJa0+bmCgdmQ9CYlNlSYZOKixmRsgiFxkrmW4l3KdFKv1DM8tk6WxPYJZhUUzcd8Kdtgrw/gkfXXDT7+avmfVak32qhtkg6NVdUS5wgkru1YzIkSduTW1FDwVWV3JQVJVuieTc0y4iDpFwc7/BvSalvKdQM8sv662cevz/+8sQVnjVAT0W2wLllw1JiMhJRxgDjCjLQsOzSFSgZqx7lAW1JW0e03yAD3asC+GD3NbQhbe+mN5GXH1F83KDOM4n/e5JIuH4NpdQARrFPBVptUNcjj4cVMcFSRTE2NpR1LEYbYMmfWpXgP9KejaPsLUhuvLCsVXznAG9dfx9SR1ud/3hZdCLHb1GMdPqRJgqDmm76mHbvOXDtiO2QPUcKo/TWkQ0i2JFXpBoo7vij1i1Lp3ADAo+qvG3V0rM//vFnnTE4hxd5Ka/Cor5YEdsLVJyKtDgVoHgtW11pWSjolPNMnrlrVj9Fv2Qn60twMwKPqr+N/wvr8z5tZcDsDrv06tkqyzESM85Ycv6XBWA2birlNCXrI6VbD2lx2L0vQO0QVTVVLH4SE67fgsfVXv8n7sz7/85Z7cMtbE6f088wSaR4kCkCm10s6pKbJhfqiUNGLq+0gLWC6eUAZFPnLjwqtKd8EwGvWX59t7iPW4X/eAN1svgRVSY990YZg06BD1ohLMtyFTI4pKTJsS9xREq9EOaPWiO2gpms7397x6nQJkbh+Fz2q/rqRROX6/M8bJrqlVW4l6JEptKeUFuMYUbtCQ7CIttpGc6MY93x1r1vgAnRXvY5cvwWPqb9uWQm+lP95QxdNMeWhOq1x0Db55C7GcUv2ZUuN6n8iKzsvOxibC//Yfs9Na8r2Rlz02vXXDT57FP/zJi66/EJSmsJKa8QxnoqW3VLQ+jZVUtJwJ8PNX1NQCwfNgdhhHD9on7PdRdrdGPF28rJr1F+3LBdeyv+8yYfLoMYet1vX4upNAjVvwOUWnlNXJXlkzk5Il6kqeoiL0C07qno+/CYBXq/+utlnsz7/Mzvy0tmI4zm4ag23PRN3t/CWryoUVJGm+5+K8RJ0V8Hc88/XHUX/HfiAq7t+BH+x6v8t438enWmdJwFA6ZINriLGKv/95f8lT9/FnyA1NMVEvQyaXuu+gz36f/DD73E4pwqpLcvm/o0Vle78n//+L/NPvoefp1pTJye6e4A/D082FERa5/opeH9zpvh13cNm19/4v/LDe5xMWTi8I0Ta0qKlK27AS/v3/r+/x/2GO9K2c7kVMonDpq7//jc5PKCxeNPpFVzaRr01wF8C4Pu76hXuX18H4LduTr79guuFD3n5BHfI+ZRFhY8w29TYhbbLi/bvBdqKE4fUgg1pBKnV3FEaCWOWyA+m3WpORZr/j+9TKJtW8yBTF2/ZEODI9/QavHkVdGFp/Pjn4Q+u5hXapsP5sOH+OXXA1LiKuqJxiMNbhTkbdJTCy4llEt6NnqRT4dhg1V3nbdrm6dYMecA1yTOL4PWTE9L5VzPFlLBCvlG58AhehnN4uHsAYinyJ+AZ/NkVvELbfOBUuOO5syBIEtiqHU1k9XeISX5bsimrkUUhnGDxourN8SgUsCZVtKyGbyGzHXdjOhsAvOAswSRyIBddRdEZWP6GZhNK/yjwew9ehBo+3jEADu7Ay2n8mDc+TS7awUHg0OMzR0LABhqLD4hJEh/BEGyBdGlSJoXYXtr+3HS4ijzVpgi0paWXtdruGTknXBz+11qT1Q2inxaTzQCO46P3lfLpyS4fou2PH/PupwZgCxNhGlj4IvUuWEsTkqMWm6i4xCSMc9N1RDQoCVcuGItJ/MRWefais+3synowi/dESgJjkilnWnBTGvRWmaw8oR15257t7CHmCf8HOn7cwI8+NQBXMBEmAa8PMRemrNCEhLGEhDQKcGZWS319BX9PFBEwGTbRBhLbDcaV3drFcDqk5kCTd2JF1Wp0HraqBx8U0wwBTnbpCadwBA/gTH/CDrcCs93LV8E0YlmmcyQRQnjBa8JESmGUfIjK/7fkaDJpmD2QptFNVJU1bbtIAjjWQizepOKptRjbzR9Kag6xZmMLLjHOtcLT3Tx9o/0EcTT1XN3E45u24AiwEypDJXihKjQxjLprEwcmRKclaDNZCVqr/V8mYWyFADbusiY5hvgFoU2vio49RgJLn5OsReRFN6tabeetiiy0V7KFHT3HyZLx491u95sn4K1QQSPKM9hNT0wMVvAWbzDSVdrKw4zRjZMyJIHkfq1VAVCDl/bUhNKlGq0zGr05+YAceXVPCttVk0oqjVwMPt+BBefx4yPtGVkUsqY3CHDPiCM5ngupUwCdbkpd8kbPrCWHhkmtIKLEetF2499eS1jZlIPGYnlcPXeM2KD9vLS0bW3ktYNqUllpKLn5ZrsxlIzxvDu5eHxzGLctkZLEY4PgSOg2IUVVcUONzUDBEpRaMoXNmUc0tFZrTZquiLyKxrSm3DvIW9Fil+AkhXu5PhEPx9mUNwqypDvZWdKlhIJQY7vn2OsnmBeOWnYZ0m1iwbbw1U60by5om47iHRV6fOgzjMf/DAZrlP40Z7syxpLK0lJ0gqaAK1c2KQKu7tabTXkLFz0sCftuwX++MyNeNn68k5Buq23YQhUh0SNTJa1ioQ0p4nUG2y0XilF1JqODqdImloPS4Bp111DEWT0jJjVv95uX9BBV7eB3bUWcu0acSVM23YZdd8R8UbQUxJ9wdu3oMuhdt929ME+mh6JXJ8di2RxbTi6TbrDquqV4aUKR2iwT6aZbyOwEXN3DUsWr8Hn4EhwNyHuXHh7/pdaUjtR7vnDh/d8c9xD/s5f501eQ1+CuDiCvGhk1AN/4Tf74RfxPwD3toLarR0zNtsnPzmS64KIRk861dMWCU8ArasG9T9H0ZBpsDGnjtAOM2+/LuIb2iIUGXNgl5ZmKD/Tw8TlaAuihaFP5yrw18v4x1898zIdP+DDAX1bM3GAMvPgRP/cJn3zCW013nrhHkrITyvYuwOUkcHuKlRSW5C6rzIdY4ppnF7J8aAJbQepgbJYBjCY9usGXDKQxq7RZfh9eg5d1UHMVATRaD/4BHK93/1iAgYZ/+jqPn8Dn4UExmWrpa3+ZOK6MvM3bjwfzxNWA2dhs8+51XHSPJiaAhGSpWevEs5xHLXcEGFXYiCONySH3fPWq93JIsBiSWvWyc3CAN+EcXoT7rCSANloPPoa31rt/5PUA/gp8Q/jDD3hyrjzlR8VkanfOvB1XPubt17vzxAfdSVbD1pzAnfgyF3ycadOTOTXhpEUoLC1HZyNGW3dtmjeXgr2r56JNmRwdNNWaQVBddd6rh4MhviEB9EFRD/7RGvePvCbwAL4Mx/D6M541hHO4D3e7g6PafdcZVw689z7NGTwo5om7A8sPhccT6qKcl9NJl9aM/9kX+e59Hh1yPqGuCCZxuITcsmNaJ5F7d0q6J3H48TO1/+M57085q2icdu2U+W36Ldllz9Agiv4YGljoEN908EzvDOrBF98/vtJwCC/BF2AG75xxEmjmMIcjxbjoaxqOK3/4hPOZzhMPBpYPG44CM0dTVm1LjLtUWWVz1Bcf8tEx0zs8O2A2YVHRxKYOiy/aOVoAaMu0i7ubu43njjmd4ibMHU1sIDHaQNKrZND/FZYdk54oCXetjq7E7IVl9eAL7t+oHnwXXtLx44czzoRFHBztYVwtH1d+NOMkupZ5MTM+gUmq90X+Bh9zjRlmaQ+m7YMqUL/veemcecAtOJ0yq1JnVlN27di2E0+Klp1tAJ4KRw1eMI7aJjsO3R8kPSI3fUFXnIOfdQe86sIIVtWDL7h//Ok6vj8vwDk08NEcI8zz7OhBy+WwalzZeZ4+0XniRfst9pAJqQHDGLzVQ2pheZnnv1OWhwO43/AgcvAEXEVVpa4db9sGvNK8wjaENHkfFQ4Ci5i7dqnQlPoLQrHXZDvO3BIXZbJOBrOaEbML6sFL798I4FhKihjHMsPjBUZYCMFr6nvaArxqXPn4lCa+cHfSa2cP27g3Z3ziYTRrcbQNGLQmGF3F3cBdzzzX7AILx0IB9rbwn9kx2G1FW3Inic+ZLIsVvKR8Zwfj0l1fkqo8LWY1M3IX14OX3r9RKTIO+d9XzAI8qRPGPn/4NC2n6o4rN8XJ82TOIvuVA8zLKUHRFgBCetlDZlqR1gLKjS39xoE7Bt8UvA6BxuEDjU3tFsEijgA+615tmZkXKqiEENrh41iLDDZNq4pKTWR3LZfnos81LOuNa15cD956vLMsJd1rqYp51gDUQqMYm2XsxnUhD2jg1DM7SeuJxxgrmpfISSXVIJIS5qJJSvJPEQ49DQTVIbYWJ9QWa/E2+c/oPK1drmC7WSfJRNKBO5Yjvcp7Gc3dmmI/Xh1kDTEuiSnWqQf37h+fTMhGnDf6dsS8SQfQWlqqwXXGlc/PEZ/SC5mtzIV0nAshlQdM/LvUtYutrEZ/Y+EAFtq1k28zQhOwLr1AIeANzhF8t9qzTdZf2qRKO6MWE9ohBYwibbOmrFtNmg3mcS+tB28xv2uKd/agYCvOP+GkSc+0lr7RXzyufL7QbkUpjLjEWFLqOIkAGu2B0tNlO9Eau2W1qcOUvVRgKzypKIQZ5KI3q0MLzqTNRYqiZOqmtqloIRlmkBHVpHmRYV6/HixbO6UC47KOFJnoMrVyr7wYz+SlW6GUaghYbY1I6kkxA2W1fSJokUdSh2LQ1GAimRGm0MT+uu57H5l7QgOWxERpO9moLRPgTtquWCfFlGlIjQaRly9odmzMOWY+IBO5tB4sW/0+VWGUh32qYk79EidWKrjWuiLpiVNGFWFRJVktyeXWmbgBBzVl8anPuXyNJlBJOlKLTgAbi/EYHVHxWiDaVR06GnHQNpJcWcK2jJtiCfG2sEHLzuI66sGrMK47nPIInPnu799935aOK2cvmvubrE38ZzZjrELCmXM2hM7UcpXD2oC3+ECVp7xtIuxptJ0jUr3sBmBS47TVxlvJ1Sqb/E0uLdvLj0lLr29ypdd/eMX3f6lrxGlKwKQxEGvw0qHbkbwrF3uHKwVENbIV2wZ13kNEF6zD+x24aLNMfDTCbDPnEikZFyTNttxWBXDaBuM8KtI2rmaMdUY7cXcUPstqTGvBGSrFWIpNMfbdea990bvAOC1YX0qbc6smDS1mPxSJoW4fwEXvjMmhlijDRq6qale6aJEuFGoppYDoBELQzLBuh/mZNx7jkinv0EtnUp50lO9hbNK57lZaMAWuWR5Yo9/kYwcYI0t4gWM47Umnl3YmpeBPqSyNp3K7s2DSAS/39KRuEN2bS4xvowV3dFRMx/VFcp2Yp8w2nTO9hCXtHG1kF1L4KlrJr2wKfyq77R7MKpFKzWlY9UkhYxyHWW6nBWPaudvEAl3CGcNpSXPZ6R9BbBtIl6cHL3gIBi+42CYXqCx1gfGWe7Ap0h3luyXdt1MKy4YUT9xSF01G16YEdWsouW9mgDHd3veyA97H+Ya47ZmEbqMY72oPztCGvK0onL44AvgC49saZKkWRz4veWljE1FHjbRJaWv6ZKKtl875h4CziFCZhG5rx7tefsl0aRT1bMHZjm8dwL/6u7wCRysaQblQoG5yAQN5zpatMNY/+yf8z+GLcH/Qn0iX2W2oEfXP4GvwQHuIL9AYGnaO3zqAX6946nkgqZNnUhx43DIdQtMFeOPrgy/y3Yd85HlJWwjLFkU3kFwq28xPnuPhMWeS+tDLV9Otllq7pQCf3uXJDN9wFDiUTgefHaiYbdfi3b3u8+iY6TnzhgehI1LTe8lcd7s1wJSzKbahCRxKKztTLXstGAiu3a6rPuQs5pk9TWAan5f0BZmGf7Ylxzzk/A7PAs4QPPPAHeFQ2hbFHszlgZuKZsJcUmbDC40sEU403cEjczstOEypa+YxevL4QBC8oRYqWdK6b7sK25tfE+oDZgtOQ2Jg8T41HGcBE6fTWHn4JtHcu9S7uYgU5KSCkl/mcnq+5/YBXOEr6lCUCwOTOM1taOI8mSxx1NsCXBEmLKbMAg5MkwbLmpBaFOPrNSlO2HnLiEqW3tHEwd8AeiQLmn+2gxjC3k6AxREqvKcJbTEzlpLiw4rNZK6oJdidbMMGX9FULKr0AkW+2qDEPBNNm5QAt2Ik2nftNWHetubosHLo2nG4vQA7GkcVCgVCgaDixHqo9UUn1A6OshapaNR/LPRYFV8siT1cCtJE0k/3WtaNSuUZYKPnsVIW0xXWnMUxq5+En4Kvw/MqQmVXnAXj9Z+9zM98zM/Agy7F/qqj2Nh67b8HjFnPP3iBn/tkpdzwEJX/whIcQUXOaikeliCRGUk7tiwF0rItwMEhjkZ309hikFoRAmLTpEXWuHS6y+am/KB/fM50aLEhGnSMwkpxzOov4H0AvgovwJ1iGzDLtJn/9BU+fAINfwUe6FHSLhu83viV/+/HrOePX+STT2B9uWGbrMHHLldRBlhS/CJQmcRxJFqZica01XixAZsYiH1uolZxLrR/SgxVIJjkpQP4PE9sE59LKLr7kltSBogS5tyszzH8Fvw8/AS8rNOg0xUS9fIaHwb+6et8Q/gyvKRjf5OusOzGx8evA/BP4IP11uN/grca5O0lcsPLJ5YjwI4QkJBOHa0WdMZYGxPbh2W2nR9v3WxEWqgp/G3+6VZbRLSAAZ3BhdhAaUL33VUSw9yjEsvbaQ9u4A/gGXwZXoEHOuU1GSj2chf+Mo+f8IcfcAxfIKVmyunRbYQVnoevwgfw3TXXcw++xNuP4fhyueEUNttEduRVaDttddoP0eSxLe2LENk6itYxlrxBNBYrNNKSQmeaLcm9c8UsaB5WyO6675yyQIAWSDpBVoA/gxmcwEvwoDv0m58UE7gHn+fJOa8/Ywan8EKRfjsopF83eCglX/Sfr7OeaRoQfvt1CGvIDccH5BCvw1sWIzRGC/66t0VTcLZQZtm6PlAasbOJ9iwWtUo7biktTSIPxnR24jxP1ZKaqq+2RcXM9OrBAm/AAs7hDJ5bNmGb+KIfwCs8a3jnjBrOFeMjHSCdbKr+2uOLfnOd9eiA8Hvvwwq54VbP2OqwkB48Ytc4YEOiH2vTXqodabfWEOzso4qxdbqD5L6tbtNPECqbhnA708DZH4QOJUXqScmUlks7Ot6FBuZw3n2mEbaUX7kDzxHOOQk8nKWMzAzu6ZZ8sOFw4RK+6PcuXo9tB4SbMz58ApfKDXf3szjNIIbGpD5TKTRxGkEMLjLl+K3wlWXBsCUxIDU+jbOiysESqAy1MGUJpXgwbTWzNOVEziIXZrJ+VIztl1PUBxTSo0dwn2bOmfDRPD3TRTGlfbCJvO9KvuhL1hMHhB9wPuPRLGHcdOWG2xc0U+5bQtAJT0nRTewXL1pgk2+rZAdeWmz3jxAqfNQQdzTlbF8uJ5ecEIWvTkevAHpwz7w78QujlD/Lr491bD8/1vhM2yrUQRrWXNQY4fGilfctMWYjL72UL/qS9eiA8EmN88nbNdour+PBbbAjOjIa4iBhfFg6rxeKdEGcL6p3EWR1Qq2Qkhs2DrnkRnmN9tG2EAqmgPw6hoL7Oza7B+3SCrR9tRftko+Lsf2F/mkTndN2LmzuMcKTuj/mX2+4Va3ki16+nnJY+S7MefpkidxwnV+4wkXH8TKnX0tsYzYp29DOOoSW1nf7nTh2akYiWmcJOuTidSaqESrTYpwjJJNVGQr+rLI7WsqerHW6Kp/oM2pKuV7T1QY9gjqlZp41/WfKpl56FV/0kvXQFRyeQ83xaTu5E8p5dNP3dUF34ihyI3GSpeCsywSh22ZJdWto9winhqifb7VRvgktxp13vyjrS0EjvrRfZ62uyqddSWaWYlwTPAtJZ2oZ3j/Sgi/mi+6vpzesfAcWNA0n8xVyw90GVFGuZjTXEQy+6GfLGLMLL523f5E0OmxVjDoOuRiH91RKU+vtoCtH7TgmvBLvtFXWLW15H9GTdVw8ow4IlRLeHECN9ym1e9K0I+Cbnhgv4Yu+aD2HaQJ80XDqOzSGAV4+4yCqBxrsJAX6ZTIoX36QnvzhhzzMfFW2dZVLOJfo0zbce5OvwXMFaZ81mOnlTVXpDZsQNuoYWveketKb5+6JOOsgX+NTm7H49fUTlx+WLuWL7qxnOFh4BxpmJx0p2gDzA/BUARuS6phR+pUsY7MMboAHx5xNsSVfVZcYSwqCKrqon7zM+8ecCkeS4nm3rINuaWvVNnMRI1IRpxTqx8PZUZ0Br/UEduo3B3hNvmgZfs9gQPj8vIOxd2kndir3awvJ6BLvoUuOfFWNYB0LR1OQJoUySKb9IlOBx74q1+ADC2G6rOdmFdJcD8BkfualA+BdjOOzP9uUhGUEX/TwhZsUduwRr8wNuXKurCixLBgpQI0mDbJr9dIqUuV+92ngkJZ7xduCk2yZKbfWrH1VBiTg9VdzsgRjW3CVXCvAwDd+c1z9dWw9+B+8MJL/eY15ZQ/HqvTwVdsZn5WQsgRRnMaWaecu3jFvMBEmgg+FJFZsnSl0zjB9OqPYaBD7qmoVyImFvzi41usesV0julaAR9dfR15Xzv9sEruRDyk1nb+QaLU67T885GTls6YgcY+UiMa25M/pwGrbCfzkvR3e0jjtuaFtnwuagHTSb5y7boBH119HXhvwP487jJLsLJ4XnUkHX5sLbS61dpiAXRoZSCrFJ+EjpeU3puVfitngYNo6PJrAigKktmwjyQdZpfq30mmtulaAx9Zfx15Xzv+cyeuiBFUs9zq8Kq+XB9a4PVvph3GV4E3y8HENJrN55H1X2p8VyqSKwVusJDKzXOZzplWdzBUFK9e+B4+uv468xvI/b5xtSAkBHQaPvtqWzllVvEOxPbuiE6+j2pvjcKsbvI7txnRErgfH7LdXqjq0IokKzga14GzQ23SSbCQvO6r+Or7SMIr/efOkkqSdMnj9mBx2DRsiY29Uj6+qK9ZrssCKaptR6HKURdwUYeUWA2kPzVKQO8ku2nU3Anhs/XWkBx3F/7wJtCTTTIKftthue1ty9xvNYLY/zo5KSbIuKbXpbEdSyeRyYdAIwKY2neyoc3+k1XUaufYga3T9daMUx/r8z1s10ITknIO0kuoMt+TB8jK0lpayqqjsJ2qtXAYwBU932zinimgmd6mTRDnQfr88q36NAI+tv24E8Pr8zxtasBqx0+xHH9HhlrwsxxNUfKOHQaZBITNf0uccj8GXiVmXAuPEAKSdN/4GLHhs/XWj92dN/uetNuBMnVR+XWDc25JLjo5Mg5IZIq226tmCsip2zZliL213YrTlL2hcFjpCduyim3M7/eB16q/blQsv5X/esDRbtJeabLIosWy3ycavwLhtxdWzbMmHiBTiVjJo6lCLjXZsi7p9PEPnsq6X6wd4bP11i0rD5fzPm/0A6brrIsllenZs0lCJlU4abakR59enZKrKe3BZihbTxlyZ2zl1+g0wvgmA166/bhwDrcn/7Ddz0eWZuJvfSESug6NzZsox3Z04FIxz0mUjMwVOOVTq1CQ0AhdbBGVdjG/CgsfUX7esJl3K/7ytWHRv683praW/8iDOCqWLLhpljDY1ZpzK75QiaZoOTpLKl60auHS/97oBXrv+umU9+FL+5+NtLFgjqVLCdbmj7pY5zPCPLOHNCwXGOcLquOhi8CmCWvbcuO73XmMUPab+ug3A6/A/78Bwe0bcS2+tgHn4J5pyS2WbOck0F51Vq3LcjhLvZ67p1ABbaL2H67bg78BfjKi/jr3+T/ABV3ilLmNXTI2SpvxWBtt6/Z//D0z/FXaGbSBgylzlsEGp+5//xrd4/ae4d8DUUjlslfIYS3t06HZpvfQtvv0N7AHWqtjP2pW08QD/FLy//da38vo8PNlKHf5y37Dxdfe/oj4kVIgFq3koLReSR76W/bx//n9k8jonZxzWTANVwEniDsg87sOSd/z7//PvMp3jQiptGVWFX2caezzAXwfgtzYUvbr0iozs32c3Uge7varH+CNE6cvEYmzbPZ9hMaYDdjK4V2iecf6EcEbdUDVUARda2KzO/JtCuDbNQB/iTeL0EG1JSO1jbXS+nLxtPMDPw1fh5+EPrgSEKE/8Gry5A73ui87AmxwdatyMEBCPNOCSKUeRZ2P6Myb5MRvgCHmA9ywsMifU+AYXcB6Xa5GibUC5TSyerxyh0j6QgLVpdyhfArRTTLqQjwe4HOD9s92D4Ap54odXAPBWLAwB02igG5Kkc+piN4lvODIFGAZgT+EO4Si1s7fjSR7vcQETUkRm9O+MXyo9OYhfe4xt9STQ2pcZRLayCV90b4D3jR0DYAfyxJ+eywg2IL7NTMXna7S/RpQ63JhWEM8U41ZyQGjwsVS0QBrEKLu8xwZsbi4wLcCT+OGidPIOCe1PiSc9Qt+go+vYqB7cG+B9d8cAD+WJPz0Am2gxXgU9IneOqDpAAXOsOltVuMzpdakJXrdPCzXiNVUpCeOos5cxnpQT39G+XVLhs1osQVvJKPZyNq8HDwd4d7pNDuWJPxVX7MSzqUDU6gfadKiNlUFTzLeFHHDlzO4kpa7aiKhBPGKwOqxsBAmYkOIpipyXcQSPlRTf+Tii0U3EJGaZsDER2qoB3h2hu0qe+NNwUooYU8y5mILbJe6OuX+2FTKy7bieTDAemaQyQ0CPthljSWO+xmFDIYiESjM5xKd6Ik5lvLq5GrQ3aCMLvmCA9wowLuWJb9xF59hVVP6O0CrBi3ZjZSNOvRy+I6klNVRJYRBaEzdN+imiUXQ8iVF8fsp+W4JXw7WISW7fDh7lptWkCwZ4d7QTXyBPfJMYK7SijjFppGnlIVJBJBYj7eUwtiP1IBXGI1XCsjNpbjENVpSAJ2hq2LTywEly3hUYazt31J8w2+aiLx3g3fohXixPfOMYm6zCGs9LVo9MoW3MCJE7R5u/WsOIjrqBoHUO0bJE9vxBpbhsd3+Nb4/vtPCZ4oZYCitNeYuC/8UDvDvy0qvkiW/cgqNqRyzqSZa/s0mqNGjtKOoTm14zZpUauiQgVfqtQiZjq7Q27JNaSK5ExRcrGCXO1FJYh6jR6CFqK7bZdQZ4t8g0rSlPfP1RdBtqaa9diqtzJkQ9duSryi2brQXbxDwbRUpFMBHjRj8+Nt7GDKgvph9okW7LX47gu0SpGnnFQ1S1lYldOsC7hYteR574ZuKs7Ei1lBsfdz7IZoxzzCVmmVqaSySzQbBVAWDek+N4jh9E/4VqZrJjPwiv9BC1XcvOWgO8275CVyBPvAtTVlDJfZkaZGU7NpqBogAj/xEHkeAuJihWYCxGN6e8+9JtSegFXF1TrhhLGP1fak3pebgPz192/8gB4d/6WT7+GdYnpH7hH/DJzzFiYPn/vjW0SgNpTNuPIZoAEZv8tlGw4+RLxy+ZjnKa5NdFoC7UaW0aduoYse6+bXg1DLg6UfRYwmhGEjqPvF75U558SANrElK/+MdpXvmqBpaXOa/MTZaa1DOcSiLaw9j0NNNst3c+63c7EKTpkvKHzu6bPbP0RkuHAVcbRY8ijP46MIbQeeT1mhA+5PV/inyDdQipf8LTvMXbwvoDy7IruDNVZKTfV4CTSRUYdybUCnGU7KUTDxLgCknqUm5aAW6/1p6eMsOYsphLzsHrE0Y/P5bQedx1F/4yPHnMB3/IOoTU9+BL8PhtjuFKBpZXnYNJxTuv+2XqolKR2UQgHhS5novuxVySJhBNRF3SoKK1XZbbXjVwWNyOjlqWJjrWJIy+P5bQedyldNScP+HZ61xKSK3jyrz+NiHG1hcOLL/+P+PDF2gOkekKGiNWKgJ+8Z/x8Iv4DdQHzcpZyF4v19I27w9/yPGDFQvmEpKtqv/TLiWMfn4sofMm9eAH8Ao0zzh7h4sJqYtxZd5/D7hkYPneDzl5idlzNHcIB0jVlQ+8ULzw/nc5/ojzl2juE0apD7LRnJxe04dMz2iOCFNtGFpTuXA5AhcTRo8mdN4kz30nVjEC4YTZQy4gpC7GlTlrePKhGsKKgeXpCYeO0MAd/GH7yKQUlXPLOasOH3FnSphjHuDvEu4gB8g66oNbtr6eMbFIA4fIBJkgayoXriw2XEDQPJrQeROAlY6aeYOcMf+IVYTU3XFlZufMHinGywaW3YLpObVBAsbjF4QJMsVUSayjk4voPsHJOQfPWDhCgDnmDl6XIRerD24HsGtw86RMHOLvVSHrKBdeVE26gKB5NKHzaIwLOmrqBWJYZDLhASG16c0Tn+CdRhWDgWXnqRZUTnPIHuMJTfLVpkoYy5CzylHVTGZMTwkGAo2HBlkQplrJX6U+uF1wZz2uwS1SQ12IqWaPuO4baZaEFBdukksJmkcTOm+YJSvoqPFzxFA/YUhIvWxcmSdPWTWwbAKVp6rxTtPFUZfKIwpzm4IoMfaYQLWgmlG5FME2gdBgm+J7J+rtS/XBbaVLsR7bpPQnpMFlo2doWaVceHk9+MkyguZNCJ1He+kuHTWyQAzNM5YSUg/GlTk9ZunAsg1qELVOhUSAK0LABIJHLKbqaEbHZLL1VA3VgqoiOKXYiS+HRyaEKgsfIqX64HYWbLRXy/qWoylIV9gudL1OWBNgBgTNmxA6b4txDT4gi3Ri7xFSLxtXpmmYnzAcWDZgY8d503LFogz5sbonDgkKcxGsWsE1OI+rcQtlgBBCSOKD1mtqYpIU8cTvBmAT0yZe+zUzeY92fYjTtGipXLhuR0ePoHk0ofNWBX+lo8Z7pAZDk8mEw5L7dVyZZoE/pTewbI6SNbiAL5xeygW4xPRuLCGbhcO4RIeTMFYHEJkYyEO9HmJfXMDEj/LaH781wHHZEtqSQ/69UnGpzH7LKIAZEDSPJnTesJTUa+rwTepI9dLJEawYV+ZkRn9g+QirD8vF8Mq0jFQ29js6kCS3E1+jZIhgPNanHdHFqFvPJLHqFwQqbIA4jhDxcNsOCCQLDomaL/dr5lyJaJU6FxPFjO3JOh3kVMcROo8u+C+jo05GjMF3P3/FuDLn5x2M04xXULPwaS6hBYki+MrMdZJSgPHlcB7nCR5bJ9Kr5ACUn9jk5kivdd8tk95SOGrtqu9lr2IhK65ZtEl7ZKrp7DrqwZfRUSN1el7+7NJxZbywOC8neNKTch5vsTEMNsoCCqHBCqIPRjIPkm0BjvFODGtto99rCl+d3wmHkW0FPdpZtC7MMcVtGFQjJLX5bdQ2+x9ypdc313uj8xlsrfuLgWXz1cRhZvJYX0iNVBRcVcmCXZs6aEf3RQF2WI/TcCbKmGU3IOoDJGDdDub0+hYckt6PlGu2BcxmhbTdj/klhccLGJMcqRjMJP1jW2ETqLSWJ/29MAoORluJ+6LPffBZbi5gqi5h6catQpmOT7/OFf5UorRpLzCqcMltBLhwd1are3kztrSzXO0LUbXRQcdLh/RdSZ+swRm819REDrtqzC4es6Gw4JCKlSnjYVpo0xeq33PrADbFLL3RuCmObVmPN+24kfa+AojDuM4umKe2QwCf6EN906HwjujaitDs5o0s1y+k3lgbT2W2i7FJdnwbLXhJUBq/9liTctSmFC/0OqUinb0QddTWamtjbHRFuWJJ6NpqZ8vO3fZJ37Db+2GkaPYLGHs7XTTdiFQJ68SkVJFVmY6McR5UycflNCsccHFaV9FNbR4NttLxw4pQ7wJd066Z0ohVbzihaxHVExd/ay04oxUKWt+AsdiQ9OUyZ2krzN19IZIwafSTFgIBnMV73ADj7V/K8u1MaY2sJp2HWm0f41tqwajEvdHWOJs510MaAqN4aoSiPCXtN2KSi46dUxHdaMquar82O1x5jqhDGvqmoE9LfxcY3zqA7/x3HA67r9ZG4O6Cuxu12/+TP+eLP+I+HErqDDCDVmBDO4larujNe7x8om2rMug0MX0rL1+IWwdwfR+p1TNTyNmVJ85ljWzbWuGv8/C7HD/izjkHNZNYlhZcUOKVzKFUxsxxN/kax+8zPWPSFKw80rJr9Tizyj3o1gEsdwgWGoxPezDdZ1TSENE1dLdNvuKL+I84nxKesZgxXVA1VA1OcL49dFlpFV5yJMhzyCmNQ+a4BqusPJ2bB+xo8V9u3x48VVIEPS/mc3DvAbXyoYr6VgDfh5do5hhHOCXMqBZUPhWYbWZECwVJljLgMUWOCB4MUuMaxGNUQDVI50TQ+S3kFgIcu2qKkNSHVoM0SHsgoZxP2d5HH8B9woOk4x5bPkKtAHucZsdykjxuIpbUrSILgrT8G7G5oCW+K0990o7E3T6AdW4TilH5kDjds+H64kS0mz24grtwlzDHBJqI8YJQExotPvoC4JBq0lEjjQkyBZ8oH2LnRsQ4Hu1QsgDTJbO8fQDnllitkxuVskoiKbRF9VwzMDvxHAdwB7mD9yCplhHFEyUWHx3WtwCbSMMTCUCcEmSGlg4gTXkHpZXWQ7kpznK3EmCHiXInqndkQjunG5kxTKEeGye7jWz9cyMR2mGiFQ15ENRBTbCp+Gh86vAyASdgmJq2MC6hoADQ3GosP0QHbnMHjyBQvQqfhy/BUbeHd5WY/G/9LK/8Ka8Jd7UFeNWEZvzPb458Dn8DGLOe3/wGL/4xP+HXlRt+M1PE2iLhR8t+lfgxsuh7AfO2AOf+owWhSZRYQbd622hbpKWKuU+XuvNzP0OseRDa+mObgDHJUSc/pKx31QdKffQ5OIJpt8GWjlgTwMc/w5MPCR/yl1XC2a2Yut54SvOtMev55Of45BOat9aWG27p2ZVORRvnEk1hqWMVUmqa7S2YtvlIpspuF1pt0syuZS2NV14mUidCSfzQzg+KqvIYCMljIx2YK2AO34fX4GWdu5xcIAb8MzTw+j/lyWM+Dw/gjs4GD6ehNgA48kX/AI7XXM/XAN4WHr+9ntywqoCakCqmKP0rmQrJJEErG2Upg1JObr01lKQy4jskWalKYfJ/EDLMpjNSHFEUAde2fltaDgmrNaWQ9+AAb8I5vKjz3L1n1LriB/BXkG/wwR9y/oRX4LlioHA4LzP2inzRx/DWmutRweFjeP3tNeSGlaE1Fde0OS11yOpmbIp2u/jF1n2RRZviJM0yBT3IZl2HWImKjQOxIyeU325b/qWyU9Moj1o07tS0G7qJDoGHg5m8yeCxMoEH8GU45tnrNM84D2l297DQ9t1YP7jki/7RmutRweEA77/HWXOh3HCxkRgldDQkAjNTMl2Iloc1qN5JfJeeTlyTRzxURTdn1Ixv2uKjs12AbdEWlBtmVdk2k7FFwj07PCZ9XAwW3dG+8xKzNFr4EnwBZpy9Qzhh3jDXebBpYcpuo4fQ44u+fD1dweEnHzI7v0xuuOALRUV8rXpFyfSTQYkhd7IHm07jpyhlkCmI0ALYqPTpUxXS+z4jgDj1Pflvmz5ecuItpIBxyTHpSTGWd9g1ApfD/bvwUhL4nT1EzqgX7cxfCcNmb3mPL/qi9SwTHJ49oj5ZLjccbTG3pRmlYi6JCG0mQrAt1+i2UXTZ2dv9IlQpN5naMYtviaXlTrFpoMsl3bOAFEa8sqPj2WCMrx3Yjx99qFwO59Aw/wgx+HlqNz8oZvA3exRDvuhL1jMQHPaOJ0+XyA3fp1OfM3qObEVdhxjvynxNMXQV4+GJyvOEFqeQBaIbbO7i63rpxCltdZShPFxkjM2FPVkn3TG+Rp9pO3l2RzFegGfxGDHIAh8SteR0C4HopXzRF61nheDw6TFN05Ebvq8M3VKKpGjjO6r7nhudTEGMtYM92HTDaR1FDMXJ1eThsbKfywyoWwrzRSXkc51flG3vIid62h29bIcFbTGhfV+faaB+ohj7dPN0C2e2lC96+XouFByen9AsunLDJZ9z7NExiUc0OuoYW6UZkIyx2YUR2z6/TiRjyKMx5GbbjLHvHuf7YmtKghf34LJfx63Yg8vrvN2zC7lY0x0tvKezo4HmGYDU+Gab6dFL+KI761lDcNifcjLrrr9LWZJctG1FfU1uwhoQE22ObjdfkSzY63CbU5hzs21WeTddH2BaL11Gi7lVdlxP1nkxqhnKhVY6knS3EPgVGg1JpN5cP/hivujOelhXcPj8HC/LyI6MkteVjlolBdMmF3a3DbsuAYhL44dxzthWSN065xxUd55Lmf0wRbOYOqH09/o9WbO2VtFdaMb4qBgtFJoT1SqoN8wPXMoXLb3p1PUEhxfnnLzGzBI0Ku7FxrKsNJj/8bn/H8fPIVOd3rfrklUB/DOeO+nkghgSPzrlPxluCMtOnDL4Yml6dK1r3vsgMxgtPOrMFUZbEUbTdIzii5beq72G4PD0DKnwjmBULUVFmy8t+k7fZ3pKc0Q4UC6jpVRqS9Umv8bxw35flZVOU1X7qkjnhZlsMbk24qQ6Hz7QcuL6sDC0iHHki96Uh2UdvmgZnjIvExy2TeJdMDZNSbdZyAHe/Yd1xsQhHiKzjh7GxQ4yqMPaywPkjMamvqrYpmO7Knad+ZQC5msCuAPWUoxrxVhrGv7a+KLXFhyONdTMrZ7ke23qiO40ZJUyzgYyX5XyL0mV7NiUzEs9mjtbMN0dERqwyAJpigad0B3/zRV7s4PIfXSu6YV/MK7+OrYe/JvfGMn/PHJe2fyUdtnFrKRNpXV0Y2559aWPt/G4BlvjTMtXlVIWCnNyA3YQBDmYIodFz41PvXPSa6rq9lWZawZ4dP115HXV/M/tnFkkrBOdzg6aP4pID+MZnTJ1SuuB6iZlyiox4HT2y3YBtkUKWooacBQUDTpjwaDt5poBHl1/HXltwP887lKKXxNUEyPqpGTyA699UqY/lt9yGdlUKra0fFWS+36iylVWrAyd7Uw0CZM0z7xKTOduznLIjG2Hx8cDPLb+OvK6Bv7n1DYci4CxUuRxrjBc0bb4vD3rN5Zz36ntLb83eVJIB8LiIzCmn6SMPjlX+yNlTjvIGjs+QzHPf60Aj62/jrzG8j9vYMFtm1VoRWCJdmw7z9N0t+c8cxZpPeK4aTRicS25QhrVtUp7U578chk4q04Wx4YoQSjFryUlpcQ1AbxZ/XVMknIU//OGl7Q6z9Zpxi0+3yFhSkjUDpnCIUhLWVX23KQ+L9vKvFKI0ZWFQgkDLvBoylrHNVmaw10zwCPrr5tlodfnf94EWnQ0lFRWy8pW9LbkLsyUVDc2NSTHGDtnD1uMtchjbCeb1mpxFP0YbcClhzdLu6lfO8Bj6q+bdT2sz/+8SZCV7VIxtt0DUn9L7r4cLYWDSXnseEpOGFuty0qbOVlS7NNzs5FOGJUqQpl2Q64/yBpZf90sxbE+//PGdZ02HSipCbmD6NItmQ4Lk5XUrGpDMkhbMm2ZVheNYV+VbUWTcv99+2NyX1VoafSuC+AN6q9bFIMv5X/eagNWXZxEa9JjlMwNWb00akGUkSoepp1/yRuuqHGbUn3UdBSTxBU6SEVklzWRUkPndVvw2PrrpjvxOvzPmwHc0hpmq82npi7GRro8dXp0KXnUQmhZbRL7NEVp1uuZmO45vuzKsHrktS3GLWXODVjw+vXXLYx4Hf7njRPd0i3aoAGX6W29GnaV5YdyDj9TFkakje7GHYzDoObfddHtOSpoi2SmzJHrB3hM/XUDDEbxP2/oosszcRlehWXUvzHv4TpBVktHqwenFo8uLVmy4DKLa5d3RtLrmrM3aMFr1183E4sewf+85VWeg1c5ag276NZrM9IJVNcmLEvDNaV62aq+14IAOGFsBt973Ra8Xv11YzXwNfmft7Jg2oS+XOyoC8/cwzi66Dhmgk38kUmP1CUiYWOX1bpD2zWXt2FCp7uq8703APAa9dfNdscR/M/bZLIyouVxqJfeWvG9Je+JVckHQ9+CI9NWxz+blX/KYYvO5n2tAP/vrlZ7+8/h9y+9qeB/Hnt967e5mevX10rALDWK//FaAT5MXdBXdP0C/BAes792c40H+AiAp1e1oH8HgH94g/Lttx1gp63op1eyoM/Bvw5/G/7xFbqJPcCXnmBiwDPb/YKO4FX4OjyCb289db2/Noqicw4i7N6TVtoz8tNwDH+8x/i6Ae7lmaQVENzJFb3Di/BFeAwz+Is9SjeQySpPqbLFlNmyz47z5a/AF+AYFvDmHqibSXTEzoT4Gc3OALaqAP4KPFUJ6n+1x+rGAM6Zd78bgJ0a8QN4GU614vxwD9e1Amy6CcskNrczLx1JIp6HE5UZD/DBHrFr2oNlgG4Odv226BodoryjGJ9q2T/AR3vQrsOCS0ctXZi3ruLlhpFDJYl4HmYtjQCP9rhdn4suySLKDt6wLcC52h8xPlcjju1fn+yhuw4LZsAGUuo2b4Fx2UwQu77uqRHXGtg92aN3tQCbFexc0uk93vhTXbct6y7MulLycoUljx8ngDMBg1tvJjAazpEmOtxlzclvj1vQf1Tx7QlPDpGpqgtdSKz/d9/hdy1vTfFHSmC9dGDZbLiezz7Ac801HirGZsWjydfZyPvHXL/Y8Mjzg8BxTZiuwKz4Eb8sBE9zznszmjvFwHKPIWUnwhqfVRcd4Ck0K6ate48m1oOfrX3/yOtvAsJ8zsPAM89sjnddmuLuDPjX9Bu/L7x7xpMzFk6nWtyQfPg278Gn4Aekz2ZgOmU9eJ37R14vwE/BL8G3aibCiWMWWDQ0ZtkPMnlcGeAu/Ag+8ZyecU5BPuy2ILD+sQqyZhAKmn7XZd+jIMTN9eBL7x95xVLSX4On8EcNlXDqmBlqS13jG4LpmGbkF/0CnOi3H8ETOIXzmnmtb0a16Tzxj1sUvQCBiXZGDtmB3KAefPH94xcUa/6vwRn80GOFyjEXFpba4A1e8KQfFF+259tx5XS4egYn8fQsLGrqGrHbztr+uByTahWuL1NUGbDpsnrwBfePPwHHIf9X4RnM4Z2ABWdxUBlqQ2PwhuDxoS0vvqB1JzS0P4h2nA/QgTrsJFn+Y3AOjs9JFC07CGWX1oNX3T/yHOzgDjwPn1PM3g9Jk9lZrMEpxnlPmBbjyo2+KFXRU52TJM/2ALcY57RUzjObbjqxVw++4P6RAOf58pcVsw9Daje3htriYrpDOonre3CudSe6bfkTEgHBHuDiyu5MCsc7BHhYDx7ePxLjqigXZsw+ijMHFhuwBmtoTPtOxOrTvYJDnC75dnUbhfwu/ZW9AgYd+peL68HD+0emKquiXHhWjJg/UrkJYzuiaL3E9aI/ytrCvAd4GcYZMCkSQxfUg3v3j8c4e90j5ZTPdvmJJGHnOCI2nHS8081X013pHuBlV1gB2MX1YNmWLHqqGN/TWmG0y6clJWthxNUl48q38Bi8vtMKyzzpFdSDhxZ5WBA5ZLt8Jv3895DduBlgbPYAj8C4B8hO68FDkoh5lydC4FiWvBOVqjYdqjiLv92t8yPDjrDaiHdUD15qkSURSGmXJwOMSxWAXYwr3zaAufJ66l+94vv3AO+vPcD7aw/w/toDvL/2AO+vPcD7aw/wHuD9tQd4f+0B3l97gPfXHuD9tQd4f+0B3l97gG8LwP8G/AL8O/A5OCq0Ys2KIdv/qOIXG/4mvFAMF16gZD+2Xvu/B8as5+8bfllWyg0zaNO5bfXj6vfhhwD86/Aq3NfRS9t9WPnhfnvCIw/CT8GLcFTMnpntdF/z9V+PWc/vWoIH+FL3Znv57PitcdGP4R/C34avw5fgRVUInCwbsn1yyA8C8zm/BH8NXoXnVE6wVPjdeCI38kX/3+Ct9dbz1pTmHFRu+Hm4O9Ch3clr99negxfwj+ER/DR8EV6B5+DuQOnTgUw5rnkY+FbNU3gNXh0o/JYTuWOvyBf9FvzX663HH/HejO8LwAl8Hl5YLTd8q7sqA3wbjuExfAFegQdwfyDoSkWY8swzEf6o4Qyewefg+cHNbqMQruSL/u/WWc+E5g7vnnEXgDmcDeSGb/F4cBcCgT+GGRzDU3hZYburAt9TEtHgbM6JoxJ+6NMzzTcf6c2bycv2+KK/f+l6LBzw5IwfqZJhA3M472pWT/ajKxnjv4AFnMEpnBTPND6s2J7qHbPAqcMK74T2mZ4VGB9uJA465It+/eL1WKhYOD7xHOkr1ajK7d0C4+ke4Hy9qXZwpgLr+Znm/uNFw8xQOSy8H9IzjUrd9+BIfenYaylf9FsXr8fBAadnPIEDna8IBcwlxnuA0/Wv6GAWPd7dDIKjMdSWueAsBj4M7TOd06qBbwDwKr7oleuxMOEcTuEZTHWvDYUO7aHqAe0Bbq+HEFRzOz7WVoTDQkVds7A4sIIxfCQdCefFRoIOF/NFL1mPab/nvOakSL/Q1aFtNpUb/nFOVX6gzyg/1nISyDfUhsokIzaBR9Kxm80s5mK+6P56il1jXic7nhQxsxSm3OwBHl4fFdLqi64nDQZvqE2at7cWAp/IVvrN6/BFL1mPhYrGMBfOi4PyjuSGf6wBBh7p/FZTghCNWGgMzlBbrNJoPJX2mW5mwZfyRffXo7OFi5pZcS4qZUrlViptrXtw+GQoyhDPS+ANjcGBNRiLCQDPZPMHuiZfdFpPSTcQwwKYdRNqpkjm7AFeeT0pJzALgo7g8YYGrMHS0iocy+YTm2vyRUvvpXCIpQ5pe666TJrcygnScUf/p0NDs/iAI/nqDHC8TmQT8x3NF91l76oDdQGwu61Z6E0ABv7uO1dbf/37Zlv+Zw/Pbh8f1s4Avur6657/+YYBvur6657/+YYBvur6657/+YYBvur6657/+aYBvuL6657/+VMA8FXWX/f8zzcN8BXXX/f8zzcNMFdbf93zP38KLPiK6697/uebtuArrr/u+Z9vGmCusP6653/+1FjwVdZf9/zPN7oHX339dc//fNMu+irrr3v+50+Bi+Zq6697/uebA/jz8Pudf9ht/fWv517J/XUzAP8C/BAeX9WCDrUpZ3/dEMBxgPcfbtTVvsYV5Yn32u03B3Ac4P3b8I+vxNBKeeL9dRMAlwO83959qGO78sT769oB7g3w/vGVYFzKE++v6wV4OMD7F7tckFkmT7y/rhHgpQO8b+4Y46XyxPvrugBeNcB7BRiX8sT767oAvmCA9woAHsoT76+rBJjLBnh3txOvkifeX1dswZcO8G6N7sXyxPvr6i340gHe3TnqVfLE++uKAb50gHcXLnrX8sR7gNdPRqwzwLu7Y/FO5Yn3AK9jXCMGeHdgxDuVJ75VAI8ljP7PAb3/RfjcZfePHBB+79dpfpH1CanN30d+mT1h9GqAxxJGM5LQeeQ1+Tb+EQJrElLb38VHQ94TRq900aMIo8cSOo+8Dp8QfsB8zpqE1NO3OI9Zrj1h9EV78PqE0WMJnUdeU6E+Jjyk/hbrEFIfeWbvId8H9oTRFwdZaxJGvziW0Hn0gqYB/wyZ0PwRlxJST+BOw9m77Amj14ii1yGM/txYQudN0qDzGe4EqfA/5GJCagsHcPaEPWH0esekSwmjRxM6b5JEcZ4ww50ilvAOFxBSx4yLW+A/YU8YvfY5+ALC6NGEzhtmyZoFZoarwBLeZxUhtY4rc3bKnjB6TKJjFUHzJoTOozF2YBpsjcyxDgzhQ1YRUse8+J4wenwmaylB82hC5w0zoRXUNXaRBmSMQUqiWSWkLsaVqc/ZE0aPTFUuJWgeTei8SfLZQeMxNaZSIzbII4aE1Nmr13P2hNHjc9E9guYNCZ032YlNwESMLcZiLQHkE4aE1BFg0yAR4z1h9AiAGRA0jyZ03tyIxWMajMPWBIsxYJCnlITU5ShiHYdZ94TR4wCmSxg9jtB5KyPGYzymAYexWEMwAPIsAdYdV6aObmNPGD0aYLoEzaMJnTc0Ygs+YDw0GAtqxBjkuP38bMRWCHn73xNGjz75P73WenCEJnhwyVe3AEe8TtKdJcYhBl97wuhNAObK66lvD/9J9NS75v17wuitAN5fe4D31x7g/bUHeH/tAd5fe4D3AO+vPcD7aw/w/toDvL/2AO+vPcD7aw/w/toDvAd4f/24ABzZ8o+KLsSLS+Pv/TqTb3P4hKlQrTGh+fbIBT0Axqznnb+L/V2mb3HkN5Mb/nEHeK7d4IcDld6lmDW/iH9E+AH1MdOw/Jlu2T1xNmY98sv4wHnD7D3uNHu54WUuOsBTbQuvBsPT/UfzNxGYzwkP8c+Yz3C+r/i6DcyRL/rZ+utRwWH5PmfvcvYEt9jLDS/bg0/B64DWKrQM8AL8FPwS9beQCe6EMKNZYJol37jBMy35otdaz0Bw2H/C2Smc7+WGB0HWDELBmOByA3r5QONo4V+DpzR/hFS4U8wMW1PXNB4TOqYz9urxRV++ntWCw/U59Ty9ebdWbrgfRS9AYKKN63ZokZVygr8GZ/gfIhZXIXPsAlNjPOLBby5c1eOLvmQ9lwkOy5x6QV1j5TYqpS05JtUgUHUp5toHGsVfn4NX4RnMCe+AxTpwmApTYxqMxwfCeJGjpXzRF61nbcHhUBPqWze9svwcHJ+S6NPscKrEjug78Dx8Lj3T8D4YxGIdxmJcwhi34fzZUr7olevZCw5vkOhoClq5zBPZAnygD/Tl9EzDh6kl3VhsHYcDEb+hCtJSvuiV69kLDm+WycrOTArHmB5/VYyP6jOVjwgGawk2zQOaTcc1L+aLXrKeveDwZqlKrw8U9Y1p66uK8dEzdYwBeUQAY7DbyYNezBfdWQ97weEtAKYQg2xJIkuveAT3dYeLGH+ShrWNwZgN0b2YL7qznr3g8JYAo5bQBziPjx7BPZ0d9RCQp4UZbnFdzBddor4XHN4KYMrB2qHFRIzzcLAHQZ5the5ovui94PCWAPefaYnxIdzRwdHCbuR4B+tbiy96Lzi8E4D7z7S0mEPd+eqO3cT53Z0Y8SV80XvB4Z0ADJi/f7X113f+7p7/+UYBvur6657/+YYBvur6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+VMA8FXWX/f8z58OgK+y/rrnf75RgLna+uue//lTA/CV1V/3/M837aKvvv6653++UQvmauuve/7nTwfAV1N/3fM/fzr24Cuuv+75nz8FFnxl9dc9//MOr/8/glixwRuUfM4AAAAASUVORK5CYII="}
4460_getSearchTexture(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII="}}const Ja={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:` 4461 precision highp float; 4462 4463 uniform mat4 modelViewMatrix; 4464 uniform mat4 projectionMatrix; 4465 4466 attribute vec3 position; 4467 attribute vec2 uv; 4468 4469 varying vec2 vUv; 4470 4471 void main() { 4472 4473 vUv = uv; 4474 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 4475 4476 }`,fragmentShader:` 4477 4478 precision highp float; 4479 4480 uniform sampler2D tDiffuse; 4481 4482 #include <tonemapping_pars_fragment> 4483 #include <colorspace_pars_fragment> 4484 4485 varying vec2 vUv; 4486 4487 void main() { 4488 4489 gl_FragColor = texture2D( tDiffuse, vUv ); 4490 4491 // tone mapping 4492 4493 #ifdef LINEAR_TONE_MAPPING 4494 4495 gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); 4496 4497 #elif defined( REINHARD_TONE_MAPPING ) 4498 4499 gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); 4500 4501 #elif defined( CINEON_TONE_MAPPING ) 4502 4503 gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); 4504 4505 #elif defined( ACES_FILMIC_TONE_MAPPING ) 4506 4507 gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); 4508 4509 #elif defined( AGX_TONE_MAPPING ) 4510 4511 gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); 4512 4513 #elif defined( NEUTRAL_TONE_MAPPING ) 4514 4515 gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); 4516 4517 #elif defined( CUSTOM_TONE_MAPPING ) 4518 4519 gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); 4520 4521 #endif 4522 4523 // color space 4524 4525 #ifdef SRGB_TRANSFER 4526 4527 gl_FragColor = sRGBTransferOETF( gl_FragColor ); 4528 4529 #endif 4530 4531 }`};class lT extends jr{constructor(){super(),this.isOutputPass=!0,this.uniforms=Ar.clone(Ja.uniforms),this.material=new cm({name:Ja.name,uniforms:this.uniforms,vertexShader:Ja.vertexShader,fragmentShader:Ja.fragmentShader}),this._fsQuad=new rh(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},it.getTransfer(this._outputColorSpace)===ut&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===xd?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===yd?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===vd?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===_d?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===Md?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===Sd?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===bd&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}function uT(s,e,t,n,i=!1){let r,o,a,c,l=!0,d="auto",u=1,h=1,f=1,m=1,x=0,p=0,g=0,y,_;const v=()=>matchMedia("(pointer: coarse)").matches||innerWidth<=760,M=s.extensions.has("EXT_color_buffer_float"),w=()=>!i&&M&&d==="high";function E(S){u=S,s.setPixelRatio(u),s.setSize(f,m),r&&(r.setPixelRatio(u),r.setSize(f,m));const P=document.querySelector("#quality-status");P&&(P.textContent=`${w()?"SMAA":"Native AA"} / ${u.toFixed(2)}x`)}function b(){h=i?Qw(f,m,devicePixelRatio):Math.min(devicePixelRatio,d==="high"?2.5:v()?1.5:2),d==="battery"&&(h=Math.min(h,1)),w()&&!r&&(r=new aT(s),o&&(a=new bp(o,t),a.enabled=l,r.addPass(a)),c=new bp(e,t),c.clear=!o||!l,r.addPass(c),r.addPass(new cT),r.addPass(new lT)),E(h),p=0,g=0}return b(),{setOverlay(S){_=S},setExterior(S){if(o=S,r){for(const P of r.passes)P.dispose();r.dispose(),r=null,a=c=null}b()},setExteriorVisible(S){l=S,a&&(a.enabled=S),c&&(c.clear=!o||!S)},resize(S,P){f=S,m=P,b()},setQuality(S){if(!["auto","high","battery"].includes(S))throw new Error("Unknown rendering quality");d=S,clearTimeout(y),y=null,b(),n()},draw(S,P,A=16.7){P?(clearTimeout(y),y=null):u<h&&!y&&(y=setTimeout(()=>{y=null,E(h),n()},300));const T=S-x;if(x=S,P&&d==="auto"&&T>0&&T<250&&(p=p?p*.93+T*.07:T,g++,g>=30&&(p>A*1.25&&u>.75?E(Math.max(.75,u-.15)):p<A*.72&&u<h&&E(Math.min(h,u+.1)),g=0)),w())r.render();else if(o&&l){const I=s.autoClear;s.autoClear=!1,s.clear(),s.render(o,t),s.render(e,t),s.autoClear=I}else s.render(e,t);
4531if(_?.scene.visible){const I=s.autoClear;s.autoClear=!1,s.clearDepth(),s.render(_.scene,_.camera),s.autoClear=I}},get state(){return{mode:d,pixelRatio:u,ceiling:h,antialiasing:w()?"SMAA":"native",adaptive:d==="auto",exteriorVisible:l}},dispose(){if(clearTimeout(y),r){for(const S of r.passes)S.dispose();r.dispose()}}}}const Dm=["monitor","cv","songbook","books","phone","piano","window"],Nm=["stackoverflow","github","linkedin","microsoft","medium","youtube","instagram","whatsapp","email","cv"];function dT(s,{places:e=!1,links:t=!1,paused:n=!1,piano:i=!1}={}){if(s.ctrlKey||s.metaKey||s.altKey)return null;const r=s.code;if(i&&!e&&!n&&r!=="KeyM")return null;const o=/^Digit[0-9]$/.test(r)?Number(r.at(-1)):null;let a;if((t||n)&&o!==null&&!s.shiftKey)a={kind:"link",value:Nm[o]};else if(e&&o!==null){const c=s.shiftKey?["entry","home","desk","music"][o-1]:Dm[o-1];c&&(a={kind:"view",value:c})}else{const c={KeyL:"links",KeyV:"overview",KeyM:"places",KeyE:"interact",KeyH:"hints",KeyF:"mouse-look",KeyT:"terminal",Slash:"help",Equal:"zoom-in",NumpadAdd:"zoom-in",Minus:"zoom-out",NumpadSubtract:"zoom-out"},d=e&&{KeyR:"desk-height",KeyB:"blue-light",KeyO:"orange-light",BracketLeft:"sensitivity-down",BracketRight:"sensitivity-up",KeyX:"screen-section"}[r]||c[r];d&&(a={kind:d})}return!a||n&&!["link","links","overview"].includes(a.kind)||s.repeat&&!["zoom-in","zoom-out","sensitivity-down","sensitivity-up"].includes(a.kind)?null:a}const Mr=3;function hT({canvas:s,camera:e,navigation:t,manifest:n,setView:i,activate:r,hitAt:o,actionFor:a,invalidate:c,onMenuOpen:l,onMenuChange:d,onMove:u,onInteract:h,onShortcut:f,allowShortcuts:m=()=>!0}){const x=document.querySelector("#room-menu"),p=document.querySelector("#interaction-prompt"),g=document.querySelector("#enter-room"),y=document.querySelector("#crosshair"),_=document.querySelector("#move-stick"),v=document.querySelector("#stick-knob"),M=document.querySelector("#map-player"),w=document.querySelector("#heading"),E=document.querySelector("#prompt-label"),b=new D;let S=-1/0,P=-1/0,A,T=null,I=!1;const k=()=>{document.body.dataset.touchControls=String(navigator.maxTouchPoints>0||matchMedia("(any-pointer: coarse)").matches||innerWidth<=760),g.querySelector("span").textContent=document.body.dataset.touchControls==="true"?"tap to begin":"click to look freely"};k(),window.addEventListener("resize",k);const F={monitor:"Use monitor",cv:"Request CV",music:"Sit at piano",songbook:"Open music book",books:"Read the writing",desk:"Sit at desk",phone:"Use iPhone",piano:"Play piano","desk-height":"Raise / lower the desk","light-color":"Choose tube color",cockroach:"Startle the cockroach","guitar-video":"Watch guitar video"};function L(){T=null,v.style.transform="translate(0, 0)",t.setMoveVector(0,0)}function O($,R=!0){x.hidden=!$,document.body.dataset.roomMenu=String($),document.querySelector("#open-room-menu").setAttribute("aria-expanded",String($)),$?(l?.(),t.stop(),t.unlock(),L(),x.querySelector("button").focus({preventScroll:!0})):(s.focus({preventScroll:!0}),R&&t.mode==="look"&&document.body.dataset.touchControls!=="true"&&document.body.dataset.paused!=="true"&&t.captureLook()),d?.(),c()}function H(){if(!x.hidden||document.body.dataset.paused==="true")return;I=!0,g.hidden=!0;const $=s.getBoundingClientRect(),R=o($.left+$.width/2,$.top+$.height/2,Mr);R?.distance<=Mr&&a(R)?r(R):h?.()}function W(){I=!0,g.hidden=!0,s.focus({preventScroll:!0}),matchMedia("(pointer: coarse)").matches||t.toggleLock()}document.querySelector("#open-room-menu").addEventListener("click",()=>O(x.hidden)),document.querySelector("#close-room-menu").addEventListener("click",()=>O(!1)),document.querySelector("#quick-overview").addEventListener("click",()=>i(document.body.dataset.view==="home"?"entry":"home")),document.querySelector("#guide-toggle").addEventListener("change",$=>{document.body.dataset.guides=String($.target.checked),c()}),document.querySelector("#look-sensitivity").addEventListener("input",$=>{const R=Number($.target.value);t.setLookSensitivity(R),document.querySelector("#look-sensitivity-value").textContent=`${Math.round(R*100)}%`}),g.addEventListener("click",W),s.addEventListener("pointerdown",$=>{$.pointerType==="touch"&&(I=!0,g.hidden=!0)}),document.addEventListener("keydown",$=>{if(!m()||$.defaultPrevented||$.target.closest('input, select, textarea, [contenteditable="true"], dialog'))return;const R=dT($,{places:!x.hidden,links:document.querySelector("#link-menu").open,paused:document.body.dataset.paused==="true",piano:document.body.dataset.view==="piano"});if(R)if($.preventDefault(),R.kind==="interact")H();else if(R.kind==="places")O(x.hidden);else if(R.kind==="overview")i(document.body.dataset.view==="home"?"entry":"home");else if(R.kind==="view")i(R.value),s.focus({preventScroll:!0});else if(R.kind==="hints"){const z=document.querySelector("#guide-toggle");z.checked=!z.checked,document.body.dataset.guides=String(z.checked),c()}else if(R.kind==="zoom-in"||R.kind==="zoom-out")t.zoom(R.kind==="zoom-in"?1.25:1/1.25);else if(R.kind.startsWith("sensitivity-")){const z=document.querySelector("#look-sensitivity");z.value=Ct.clamp(Number(z.value)+(R.kind.endsWith("up")?.05:-.05),.5,2),z.dispatchEvent(new Event("input",{bubbles:!0}))}else f?.(R)});function q($){const R=_.getBoundingClientRect();let z=($.clientX-R.left-R.width/2)/38,Y=($.clientY-R.top-R.height/2)/38;const ie=Math.hypot(z,Y);ie>1&&(z/=ie,Y/=ie),v.style.transform=`translate(${z*30}px, ${Y*30}px)`,t.setMoveVector(z,Y)}_.addEventListener("pointerdown",$=>{$.preventDefault(),document.body.dataset.view!=="piano"&&(u(),I=!0,g.hidden=!0,T=$.pointerId,_.setPointerCapture($.pointerId),q($))}),_.addEventListener("pointermove",$=>{$.pointerId===T&&q($)});for(const $ of["pointerup","pointercancel","lostpointercapture"])_.addEventListener($,L);window.addEventListener("blur",L),document.addEventListener("visibilitychange",()=>{document.hidden&&L()});const Z=n.roomBounds,V=($,R)=>
4531[8+($-Z.min[0])/(Z.max[0]-Z.min[0])*94,8+(R-Z.min[2])/(Z.max[2]-Z.min[2])*73],K=document.querySelector("#map-furniture"),ce=new Set(["Main sit-stand desk","Craft desktop","Storage cabinets","Digital piano"]);for(const $ of n.assets.filter(R=>ce.has(R.name))){const R=$.id===n.desk?.assetId?n.desk.footprint:$.bounds,z=V(R.min[0],R.min[2]),Y=V(R.max[0],R.max[2]),ie=document.createElementNS("http://www.w3.org/2000/svg","rect");for(const[re,ge]of Object.entries({x:z[0],y:z[1],width:Y[0]-z[0],height:Y[1]-z[1]}))ie.setAttribute(re,ge);K.append(ie)}return{get menuOpen(){return!x.hidden},setMenu:O,resetStick:L,viewChanged(){L(),document.body.dataset.view!=="entry"&&(I=!0),A=null,p.hidden=!0,g.hidden=I||t.mode!=="look"},locked($){$&&(I=!0,g.hidden=!0)},update($,R){if(R&&$-P<50)return;P=$;const z=document.body.dataset.paused==="true",Y=t.mode==="look"&&!t.transitioning&&!z,ie=String(t.mode==="look"&&x.hidden&&!z);document.body.dataset.gameplay!==ie&&(document.body.dataset.gameplay=ie);const re=String(z||document.body.dataset.view==="piano");if(_.getAttribute("aria-disabled")!==re&&_.setAttribute("aria-disabled",re),(!R||$-S>=120)&&Y&&x.hidden){S=$;const je=s.getBoundingClientRect();A=o(je.left+je.width/2,je.top+je.height/2,Mr),(!A?.asset||A.distance>Mr||!a(A))&&(A=null)}const ge=Y&&x.hidden&&A&&I;if(p.hidden=!ge||a(A)==="guitar-video",y.dataset.actionable=String(!!ge),A){const je=F[a(A)]||"Interact";E.textContent!==je&&(E.textContent=je)}e.getWorldDirection(b);const Fe=Math.atan2(b.x,-b.z)*180/Math.PI,Ie=V(e.position.x,e.position.z);M.setAttribute("transform",`translate(${Ct.clamp(Ie[0],8,102)},${Ct.clamp(Ie[1],8,81)}) rotate(${Fe})`),M.style.display=t.mode==="orbit"?"none":"";const He=`${(Math.round(Fe)%360+360)%360}°`;w.textContent!==He&&(w.textContent=He)}}}let yr,Kl,Po=performance.now(),pd=!1,vo=!document.hidden;function oh(s,e=!1){if(!pd)return;const t=JSON.stringify({session:yr,...s});e&&navigator.sendBeacon?.("/api/analytics",new Blob([t],{type:"application/json"}))||fetch("/api/analytics",{method:"POST",headers:{"Content-Type":"application/json"},body:t,credentials:"same-origin",referrerPolicy:"no-referrer",keepalive:!0,signal:AbortSignal.timeout(6e3)}).then(n=>{if(!n.ok)throw new Error(`Analytics: HTTP ${n.status}`)}).catch(n=>console.info("Anonymous analytics is unavailable:",n.message))}function Zl(s=!1){if(!vo)return;const e=performance.now();oh({kind:"heartbeat",visibleMs:Math.min(6e4,Math.max(0,e-Po))},s),Po=e}function us(s){oh({kind:"click",target:s})}function fT(){if(pd)return;try{yr=sessionStorage.getItem("workspace-session"),yr||(yr=crypto.randomUUID(),sessionStorage.setItem("workspace-session",yr))}catch(e){console.info("Persistent session deduplication is unavailable:",e.message),yr=crypto.randomUUID()}pd=!0,Po=performance.now(),oh({kind:"visit"});const s=()=>{clearInterval(Kl),Kl=setInterval(()=>{document.hidden||Zl()},3e4)};s(),document.addEventListener("visibilitychange",()=>{document.hidden?(Zl(!0),vo=!1):(vo=!0,Po=performance.now())}),window.addEventListener("pagehide",()=>{Zl(!0),vo=!1,clearInterval(Kl)}),window.addEventListener("pageshow",()=>{vo=!document.hidden,Po=performance.now(),s()}),document.addEventListener("click",e=>{const t=e.target.closest("a");if(!t)return;const n=Object.entries(sn).find(([,i])=>i.href===t.getAttribute("href"));n&&us(n[0])})}const Di=s=>new Intl.NumberFormat().format(s),Jl=s=>new Date(s).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short",timeZone:"UTC"}),pT=s=>new Date(s+"T00:00:00Z").toLocaleDateString(void 0,{month:"short",day:"numeric",timeZone:"UTC"}),mT="http://www.w3.org/2000/svg";function gr(s,e,t){const n=document.createElementNS(mT,s);for(const[i,r]of Object.entries(e))n.setAttribute(i,r);return t!==void 0&&(n.textContent=t),n}function Vn(s,e){const t=document.createElement("td");return t.textContent=s,e&&(t.className=e),t}function gT({onOpen:s,onClose:e,onSignOut:t}){const n=document.createElement("dialog");n.id="owner-dashboard",n.setAttribute("aria-labelledby","dashboard-title"),n.innerHTML=` 4532 <div class="dashboard-shell"> 4533 <aside class="dashboard-rail"> 4534 <div class="dashboard-wordmark"><span aria-hidden="true">d.</span><div>THE WORKSPACE<small>Private observatory</small></div></div> 4535 <p class="dashboard-rail-label">ANALYTICS / OWNER</p> 4536 <nav aria-label="Dashboard sections"> 4537 <button data-section="overview" aria-current="page"><span>01</span> Overview</button> 4538 <button data-section="actions"><span>02</span> Clicks & actions</button> 4539 <button data-section="sessions"><span>03</span> Sessions</button> 4540 </nav> 4541 <div class="dashboard-rail-bottom"><p><span class="dashboard-private-dot"></span>Owner access only</p> 4542 <small>No identities. No IP addresses.<br />Just how the room is explored.</small> 4543 <button id="dashboard-signout">Sign out</button> 4544 </div> 4545 </aside> 4546 <div class="dashboard-main"> 4547 <header class="dashboard-header"><div><p class="dashboard-eyebrow">A LITTLE PERSPECTIVE</p> 4548 <h2 id="dashboard-title">Inside the workspace.</h2> 4549 <p>Understand the visits, the clicks, and the time spent here.</p></div> 4550 <button id="dashboard-close" class="dashboard-close" aria-label="Close dashboard and return to the monitor">×</button> 4551 </header> 4552 <form id="dashboard-filters" class="dashboard-filters"> 4553 <label>Session start date<select id="dashboard-range"><option value="1">Today</option><option value="7">Last 7 days</option><option value="30" selected>Last 30 days</option><option value="90">Last 90 days</option><option value="all">All time</option><option value="custom">Custom range</option></select></label> 4554 <div id="dashboard-custom-range" class="dashboard-custom-range" hidden> 4555 <label>From<input id="dashboard-from" type="date" /></label><label>To<input id="dashboard-to" type="date" /></label> 4556 <button type="submit" class="dashboard-primary">Apply dates</button> 4557 </div>
4558 <span class="dashboard-timezone">UTC</span> 4559 <button type="button" id="dashboard-refresh" class="dashboard-refresh">Refresh data <span aria-hidden="true">↻</span></button> 4560 </form> 4561 <div class="dashboard-status-row"><p id="dashboard-status" role="status" aria-live="polite"></p><span id="dashboard-updated"></span></div> 4562 <section id="dashboard-error" class="dashboard-error" role="alert" hidden><h3 id="dashboard-error-title"></h3><p id="dashboard-error-message"></p><button id="dashboard-retry" class="dashboard-primary">Try again</button><button id="dashboard-login" class="dashboard-primary" hidden>Return to login</button></section> 4563 <div id="dashboard-private-content" hidden> 4564 <section class="dashboard-metrics" aria-label="Selected session totals"> 4565 <article><span>Sessions</span><strong id="metric-sessions">0</strong><small>Anonymous visits, not unique people</small></article> 4566 <article><span>Clicks & actions</span><strong id="metric-clicks">0</strong><small id="metric-engagement"></small></article> 4567 <article><span>Active time</span><strong id="metric-time">0s</strong><small id="metric-average"></small></article> 4568 </section> 4569 <section data-dashboard-panel="overview" aria-label="Overview"> 4570 <div class="dashboard-chart-card"><div class="dashboard-card-heading"><div><p class="dashboard-eyebrow">THE RHYTHM OF THE ROOM</p><h3>Activity over time</h3></div> 4571 <label class="dashboard-chart-select">Show<select id="dashboard-metric"><option value="views">Sessions</option><option value="clicks">Clicks & actions</option><option value="activeMs">Active time</option></select></label></div> 4572 <p id="dashboard-chart-summary" class="dashboard-chart-summary"></p> 4573 <div id="dashboard-chart" class="dashboard-chart"></div> 4574 <p id="dashboard-chart-empty" class="dashboard-empty" hidden>No sessions in this range. Try a wider date range.</p>
4575 <details class="dashboard-data-details"><summary>View chart as a table</summary><div class="dashboard-table-scroll"><table><caption class="sr-only">Activity by session start date, UTC</caption><thead><tr><th scope="col">Date</th><th scope="col">Sessions</th><th scope="col">Clicks</th><th scope="col">Active time</th></tr></thead><tbody id="dashboard-chart-table"></tbody></table></div></details> 4576 </div> 4577 <div class="dashboard-overview-bottom"> 4578 <section class="dashboard-chart-card"><div class="dashboard-card-heading"><div><p class="dashboard-eyebrow">WHAT DRAWS ATTENTION</p><h3>Top destinations</h3></div><button data-section="actions" class="dashboard-text-button">See all →</button></div><ol id="dashboard-top-actions" class="dashboard-ranking"></ol></section> 4579 <section class="dashboard-notes"><p class="dashboard-eyebrow">READING THESE NUMBERS</p><h3>Visits, not visitors.</h3><p>A session is an anonymous browser visit. Returning visits can count more than once.</p><p>Date filters select when sessions <strong>started</strong>. Clicks and foreground time include all recorded activity for those sessions, not just events inside the date range.</p><p>Active time is approximate. Visits shorter than the reporting interval may show zero.</p></section> 4580 </div> 4581 </section> 4582 <section data-dashboard-panel="actions" aria-label="Clicks and actions" hidden> 4583 <div class="dashboard-chart-card"> 4584 <div class="dashboard-card-heading"><div><p class="dashboard-eyebrow">FOLLOW THE INTEREST</p><h3>Clicks & actions</h3></div><span id="dashboard-action-count" class="dashboard-pill"></span></div> 4585 <div class="dashboard-table-filters"><label>Search<input id="dashboard-search" type="search" placeholder="Find a destination or action" maxlength="100" /></label><label>Category<select id="dashboard-category"><option>All</option><option>Profiles</option><option>Contact</option><option>Navigation</option><option>Music</option><option>Room actions</option><option>Apps</option><option>Other</option></select></label><label>Sort<select id="dashboard-action-sort"><option value="clicks">Most clicked</option><option value="name">Name AâZ</option></select></label></div> 4586 <div class="dashboard-table-scroll"><table><caption class="sr-only">Recorded clicks for the selected sessions</caption><thead><tr><th scope="col">Destination / action</th><th scope="col">Category</th><th scope="col">Clicks</th><th scope="col">Share of all clicks</th></tr></thead><tbody id="dashboard-action-rows"></tbody></table></div><p id="dashboard-actions-empty" class="dashboard-empty" hidden>No actions match these filters.</p> 4587 </div> 4588 </section> 4589 <section data-dashboard-panel="sessions" aria-label="Sessions" hidden> 4590 <div class="dashboard-chart-card"> 4591 <div class="dashboard-card-heading"><div><p class="dashboard-eyebrow">EACH VISIT, AT A GLANCE</p><h3>Session activity</h3></div><span class="dashboard-pill">Times in UTC</span></div> 4592 <div class="dashboard-table-filters"><label>Order by<select id="dashboard-session-sort"><option value="recent">Newest first</option><option value="active">Most active time</option><option value="clicks">Most clicks</option></select></label><label>Rows per page<select id="dashboard-page-size"><option value="10">10</option><option value="25" selected>25</option><option value="50">50</option></select></label></div> 4593 <div class="dashboard-table-scroll"><table><caption class="sr-only">Anonymous sessions in the selected start-date range</caption><thead><tr><th scope="col">Started</th><th scope="col">Last activity</th><th scope="col">Active time</th><th scope="col">Clicks</th></tr></thead><tbody id="dashboard-session-rows"></tbody></table></div> 4594 <p id="dashboard-sessions-empty" class="dashboard-empty" hidden>No sessions in this range.</p> 4595 <nav class="dashboard-pagination" aria-label="Session pages"><span id="dashboard-page-label"></span><div><button id="dashboard-prev">Previous</button><button id="dashboard-next">Next</button></div></nav> 4596 </div> 4597 </section> 4598 <footer class="dashboard-footnote">PRIVATE BY DESIGN <span id="dashboard-privacy"></span></footer> 4599 </div> 4600 </div> 4601 </div>`,document.body.append(n);const i=T=>n.querySelector(T);let r=null,o,a,c=0,l=!1,d=!1,u=!1,h=0,f=uc(30),m=1,x="overview";function p(T){i("#dashboard-status").textContent=T}function g(){r=null,i("#dashboard-private-content").hidden=!0,i("#dashboard-updated").textContent="";for(const T of["#dashboard-chart","#dashboard-chart-table","#dashboard-top-actions","#dashboard-action-rows","#dashboard-session-rows"])i(T).replaceChildren();for(const T of["#metric-sessions","#metric-clicks","#metric-time","#metric-average","#metric-engagement","#dashboard-chart-summary","#dashboard-action-count","#dashboard-page-label","#dashboard-privacy"])i(T).textContent=""}function y(T){l=T,i("#dashboard-private-content").setAttribute("aria-busy",String(T)),i("#dashboard-refresh").disabled=T,i("#dashboard-prev").disabled=T||!r||r.pagination.page<=1,i("#dashboard-next").disabled=T||!r||r.pagination.page>=r.pagination.pages}function _(T){g(),d=T.status===401,i("#dashboard-error").hidden=!1,i("#dashboard-error-title").textContent=d?"Your owner session has ended.":"The data could not be loaded.",i("#dashboard-error-message").textContent=d?"Sign in again in the monitor terminal to view private statistics.":T.message,i("#dashboard-retry").hidden=d,i("#dashboard-login").hidden=!d,p(d?"Sign-in required. Private data has been cleared.":"No statistics are being shown.")}function v(){if(!n.open)return;++c,o?.abort(),clearTimeout(a);const T=d;g(),y(!1),n.close(),document.body.dataset.ownerDashboard="false",e(),T&&t()}function M(){++c,o?.abort(),clearTimeout(a),y(!1),_(Object.assign(new Error("Owner sign-in required"),{status:401}))}function w(){const T=i("#dashboard-metric").value,I=bw(r.daily,r.range),k=Math.max(1,...I.map(R=>R[T])),F=T==="activeMs"?3:Math.min(3,k),L=Math.ceil(k/F)*F,O=R=>
4601T==="activeMs"?po(R):Di(Math.round(R)),H=I.reduce((R,z)=>R+z[T],0);i("#dashboard-chart-summary").textContent=`${O(H)} ${T==="activeMs"?"foreground time":T==="views"?"sessions":"recorded actions"} · ${I.length&&I[0].day!==I[0].end?"Grouped date intervals":"Daily totals"} · UTC`,i("#dashboard-chart-empty").hidden=r.views!==0,h=i("#dashboard-chart").clientWidth;const W=Math.max(280,Math.min(900,h||860)),q=gr("svg",{viewBox:`0 0 ${W} 265`,role:"img","aria-label":i("#dashboard-chart-summary").textContent}),Z=55,V=W-12,K=V-Z,ce=20,$=193;for(let R=0;R<=F;R++){const z=ce+$*R/F;q.append(gr("line",{x1:Z,x2:V,y1:z,y2:z,class:"dashboard-gridline"})),q.append(gr("text",{x:45,y:z+4,"text-anchor":"end",class:"dashboard-axis"},O(L*(1-R/F))))}I.forEach((R,z)=>{const Y=K/I.length,ie=R[T]/L*$,re=gr("rect",{x:Z+z*Y+Y*.14,y:ce+$-ie,width:Math.max(1,Y*.72),height:ie,rx:2,class:"dashboard-chart-bar"});re.append(gr("title",{},`${R.day}${R.day!==R.end?" â "+R.end:""}: ${O(R[T])}`)),q.append(re);const ge=W<480?3:6;(z===0||z===I.length-1||I.length>ge&&z%Math.ceil(I.length/(ge-1))===0)&&q.append(gr("text",{x:Z+z*Y+Y/2,y:239,"text-anchor":z===0?"start":z===I.length-1?"end":"middle",class:"dashboard-axis"},pT(R.day)))}),i("#dashboard-chart").replaceChildren(q),i("#dashboard-chart-table").replaceChildren(...I.map(R=>{const z=document.createElement("tr");return z.append(Vn(R.day===R.end?R.day:`${R.day} â ${R.end}`),Vn(Di(R.views)),Vn(Di(R.clicks)),Vn(po(R.activeMs))),z}))}function E(){if(!r)return;const T=_w(r.popular,i("#dashboard-category").value,i("#dashboard-search").value,i("#dashboard-action-sort").value);i("#dashboard-action-count").textContent=`${T.length} ${T.length===1?"action":"actions"}`,i("#dashboard-actions-empty").hidden=T.length>0,i("#dashboard-action-rows").replaceChildren(...T.map(I=>{const k=document.createElement("tr"),F=Vn(I.label,"dashboard-action-name"),L=document.createElement("small");L.textContent=I.target,F.append(L);const O=r.clicks?I.clicks/r.clicks:0,H=Vn(`${Math.round(O*100)}%`,"dashboard-share"),W=document.createElement("span"),q=document.createElement("span");return q.style.width=`${O*100}%`,W.append(q),H.append(W),k.append(F,Vn(I.category),Vn(Di(I.clicks),"dashboard-numeric"),H),k}))}function b(){i("#dashboard-error").hidden=!0,i("#dashboard-private-content").hidden=!1,i("#metric-sessions").textContent=Di(r.views),i("#metric-clicks").textContent=Di(r.clicks),i("#metric-time").textContent=po(r.activeMs),i("#metric-average").textContent=`${po(r.averageActiveMs)} average per session`,i("#metric-engagement").textContent=`${Math.round(r.engagementRate*100)}% of sessions recorded a click`,i("#dashboard-updated").textContent=`Updated ${Jl(r.generatedAt)} UTC`,i("#dashboard-privacy").textContent=r.privacy;const T=i("#dashboard-top-actions");if(T.replaceChildren(...r.popular.slice(0,5).map((F,L)=>{const O=document.createElement("li"),H=document.createElement("span"),W=document.createElement("span"),q=document.createElement("strong");return H.textContent=String(L+1).padStart(2,"0"),W.textContent=Lm(F.target).label,q.textContent=Di(F.clicks),O.append(H,W,q),O})),!r.popular.length){const F=document.createElement("li");F.textContent="No clicks recorded for these sessions yet.",T.append(F)}i("#dashboard-session-rows").replaceChildren(...r.recentVisits.map(F=>{const L=document.createElement("tr");return L.append(Vn(Jl(F.startedAt)),Vn(Jl(F.lastSeenAt)),Vn(po(F.activeMs)),Vn(Di(F.clicks))),L})),i("#dashboard-sessions-empty").hidden=r.pagination.total>0;const I=r.pagination.total?(r.pagination.page-1)*r.pagination.pageSize+1:0,k=I?I+r.recentVisits.length-1:0;i("#dashboard-page-label").textContent=`${I}â${k} of ${Di(r.pagination.total)} sessions · Page ${r.pagination.page} of ${r.pagination.pages}`,w(),E(),p(r.range.from?`Sessions started ${r.range.from} through ${r.range.to}.`:"All recorded sessions.")}function S(T){if(!T||!Number.isFinite(T.expiresAt)||!Number.isFinite(T.generatedAt)||!Number.isFinite(T.views)||!Number.isFinite(T.clicks)||!Number.isFinite(T.activeMs)||!Array.isArray(T.daily)||!Array.isArray(T.popular)||!Array.isArray(T.recentVisits)||!T.pagination||!T.range)throw new Error("The analytics response is incomplete. Refresh to try again.");if(T.expiresAt<=Date.now()){M();return}
4601r=T,m=r.pagination.page,d=!1,clearTimeout(a),a=setTimeout(M,Math.min(36e5,r.expiresAt-Date.now())),b()}async function P(){if(u)return;o?.abort(),o=new AbortController;const T=o.signal,I=++c;g(),i("#dashboard-error").hidden=!0,y(!0),p("Loading private analyticsâ¦");const k=new URLSearchParams({page:String(m),pageSize:i("#dashboard-page-size").value,sort:i("#dashboard-session-sort").value});f.from&&(k.set("from",f.from),k.set("to",f.to));try{const F=await wc("/api/stats?"+k,void 0,T);I===c&&n.open&&S(F)}catch(F){if(T.aborted||I!==c||!n.open)return;_(F)}finally{I===c&&y(!1)}}function A(T){x=T,i(".dashboard-main").scrollTop=0,n.querySelectorAll("[data-dashboard-panel]").forEach(I=>{I.hidden=I.dataset.dashboardPanel!==x}),n.querySelectorAll(".dashboard-rail [data-section]").forEach(I=>{I.dataset.section===x?I.setAttribute("aria-current","page"):I.removeAttribute("aria-current")})}n.querySelectorAll("[data-section]").forEach(T=>T.addEventListener("click",()=>A(T.dataset.section))),i("#dashboard-close").addEventListener("click",v),n.addEventListener("cancel",T=>{T.preventDefault(),v()}),n.addEventListener("keydown",T=>{if(T.stopPropagation(),T.key==="Escape"&&(T.preventDefault(),v()),T.key==="Tab"){const I=[...n.querySelectorAll("button, a[href], input, select, summary, [tabindex]")].filter(F=>!F.disabled&&F.tabIndex>=0&&F.getClientRects().length);if(!I.length)return;T.preventDefault();const k=I.indexOf(document.activeElement);I[(k+(T.shiftKey?-1:1)+I.length)%I.length].focus()}}),i("#dashboard-range").addEventListener("change",()=>{const T=i("#dashboard-range").value==="custom";if(i("#dashboard-custom-range").hidden=!T,T){const I=f.from?f:uc(30);i("#dashboard-from").value=I.from,i("#dashboard-to").value=I.to,i("#dashboard-from").required=i("#dashboard-to").required=!0,i("#dashboard-from").focus();return}i("#dashboard-from").required=i("#dashboard-to").required=!1,f=uc(i("#dashboard-range").value),m=1,P()}),i("#dashboard-filters").addEventListener("submit",T=>{T.preventDefault();const I=i("#dashboard-from"),k=i("#dashboard-to");k.setCustomValidity(I.value>k.value?"End date must be on or after the start date.":""),i("#dashboard-filters").reportValidity()&&(f={from:I.value,to:k.value},m=1,P())});for(const T of["#dashboard-from","#dashboard-to"])i(T).addEventListener("input",()=>i("#dashboard-to").setCustomValidity(""));i("#dashboard-refresh").addEventListener("click",P),i("#dashboard-retry").addEventListener("click",P),i("#dashboard-login").addEventListener("click",v),i("#dashboard-metric").addEventListener("change",()=>{r&&w()});for(const T of["#dashboard-category","#dashboard-action-sort"])i(T).addEventListener("change",E);i("#dashboard-search").addEventListener("input",E);for(const T of["#dashboard-session-sort","#dashboard-page-size"])i(T).addEventListener("change",()=>{m=1,P()});return i("#dashboard-prev").addEventListener("click",()=>{!l&&m>1&&(m--,P())}),i("#dashboard-next").addEventListener("click",()=>{!l&&r&&m<r.pagination.pages&&(m++,P())}),i("#dashboard-signout").addEventListener("click",async()=>{u=!0,i("#dashboard-signout").disabled=!0,++c,o?.abort(),g(),y(!1),p("Signing outâ¦");try{await wc("/api/admin/logout",{}),d=!0,n.open?v():t()}catch(T){_(T),i("#dashboard-error-title").textContent="Sign-out did not complete."}finally{u=!1,i("#dashboard-signout").disabled=!1}}),new ResizeObserver(()=>{const T=i("#dashboard-chart").clientWidth;n.open&&r&&T>0&&Math.abs(T-h)>1&&w()}).observe(i("#dashboard-chart")),document.addEventListener("visibilitychange",()=>{n.open&&r&&r.expiresAt<=Date.now()&&M()}),{get open(){return n.open},show(T){if(u)throw new Error("Sign-out is still in progress. Wait a moment and sign in again.");if(n.open){i("#dashboard-close").focus();return}f={from:T.range.from||"",to:T.range.to||""},m=1,i("#dashboard-range").value="30",i("#dashboard-custom-range").hidden=!0,i("#dashboard-from").required=i("#dashboard-to").required=!1,i("#dashboard-to").setCustomValidity(""),i("#dashboard-page-size").value="25",i("#dashboard-session-sort").value="recent",i("#dashboard-metric").value="views",i("#dashboard-search").value="",i("#dashboard-category").value="All",i("#dashboard-action-sort").value="clicks",A("overview"),s(),document.body.dataset.ownerDashboard="true",n.showModal();try{S(T)}catch(I){_(I)}y(!1),i("#dashboard-close").focus({preventScroll:!0})},close:v}}function xT(){const s=document.querySelector("#intro"),e=document.querySelector("#intro-name"),t=document.querySelector("#intro-subtitle"),n=document.querySelector("#identity-name");let i,r=!1;function o(){r||(r=!0,i?.cancel(),s.hidden=!0,document.body.dataset.intro="done")}return window.addEventListener("resize",()=>{document.body.dataset.intro==="revealing"&&o()}),{finish:o,async reveal(){if(await document.fonts.ready,await new Promise(requestAnimationFrame),r)return;if(matchMedia("(prefers-reduced-motion: reduce)").matches){o();return}document.body.dataset.intro="revealing";const a=e.getBoundingClientRect(),c=n.getBoundingClientRect(),l=c.width/a.width;t.animate([{opacity:1},{opacity:0}
4601],{duration:420,delay:180,fill:"forwards"}),i=e.animate([{transform:"translate(0, 0) scale(1)",opacity:1},{transform:`translate(${c.left-a.left}px, ${c.top-a.top}px) scale(${l})`,opacity:1}],{duration:1450,delay:230,easing:"cubic-bezier(.22,.8,.15,1)",fill:"forwards"}),i.finished.then(o,d=>{d.name!=="AbortError"&&console.error("Intro animation failed:",d),o()})}}}const yT=[{midi:21,file:"A0"},...Array.from({length:7},(s,e)=>[{midi:24+e*12,file:`C${e+1}`},{midi:27+e*12,file:`Ds${e+1}`},{midi:30+e*12,file:`Fs${e+1}`},{midi:33+e*12,file:`A${e+1}`}]).flat(),{midi:108,file:"C8"}],vT=["KeyA","KeyW","KeyS","KeyE","KeyD","KeyF","KeyT","KeyG","KeyY","KeyH","KeyU","KeyJ","KeyK","KeyO","KeyL","KeyP","Semicolon","Quote"],Mp=s=>["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"][s%12]+(Math.floor(s/12)-1),Ql=s=>yT.reduce((e,t)=>Math.abs(t.midi-s)<Math.abs(e.midi-s)?t:e);function _T({model:s,canvas:e,hitAt:t,invalidate:n,enabled:i,onOctave:r}){const o=new Map,a=new Map,c=new Map,l=new Map,d=new Map,u=new Map,h=document.querySelector("#piano-status");let f,m,x,p=!1,g=4,y=!1;if(s.traverse(L=>{if(!L.isMesh||!Number.isInteger(L.userData.midi))return;if(L.userData.midi<21||L.userData.midi>108||o.has(L.userData.midi)||Array.isArray(L.material))throw new Error("A piano key has duplicate MIDI metadata or incompatible geometry.");const O=L.material.clone();L.material=O,o.set(L.userData.midi,{mesh:L,position:L.position.clone(),color:O.color.clone(),map:O.map})}),o.size!==88)throw new Error("The playable piano must contain 88 separately identified keys.");function _(){if(!f){const L=window.AudioContext||window.webkitAudioContext;if(!L)throw new Error("Web Audio is unavailable in this browser.");f=new L;const O=f.createDynamicsCompressor();O.threshold.value=-15,O.knee.value=18,O.ratio.value=8,m=f.createGain(),m.gain.value=.45,x=f.createAnalyser(),x.fftSize=256,m.connect(O).connect(x).connect(f.destination)}return f}async function v(L){if(!l.has(L.midi)){const O=fetch(`/audio/piano/${L.file}.mp3`).then(H=>{if(!H.ok)throw new Error(`Piano sample: HTTP ${H.status}`);return H.arrayBuffer()}).then(H=>_().decodeAudioData(H)).catch(H=>{throw l.delete(L.midi),H});l.set(L.midi,O)}return l.get(L.midi)}function M(L,O){const H=Math.max(0,(d.get(L)||0)+(O?1:-1));d.set(L,H);const W=o.get(L);W.mesh.position.copy(W.position),W.mesh.material.color.copy(W.color);const q=H?null:W.map;W.mesh.material.map!==q&&(W.mesh.material.map=q,W.mesh.material.needsUpdate=!0),H&&(W.mesh.position.y-=.0025,W.mesh.material.color.setRGB(.55,1,.95),h.textContent=Mp(L)),W.mesh.updateMatrix(),W.mesh.updateMatrixWorld(),n()}function w(L,O=!1){const H=a.get(L);if(!H)return;if(H.held&&(H.held=!1,M(H.midi,!1)),!H.source){a.delete(L);return}if(H.releasing)return;H.releasing=!0;const W=f.currentTime;H.gain.gain.cancelScheduledValues(W),H.gain.gain.setTargetAtTime(0,W,O?.015:.085),H.source.stop(W+(O?.06:.4))}async function E(L,O,H=.8){if(!i()||!o.has(L))return;b(O);const W=Symbol(O);c.set(O,W);const q=matchMedia("(pointer: coarse)").matches?16:32;if(a.size>=q){const V=a.keys().next().value;w(V,!0),a.delete(V)}const Z={midi:L,held:!0};a.set(W,Z),M(L,!0);try{const V=_(),K=Ql(L),[ce]=await Promise.all([v(K),V.resume()]);if(a.get(W)!==Z)return;if(!Z.held&&!p||!i()){w(W,!0);return}Z.source=V.createBufferSource(),Z.gain=V.createGain(),Z.source.buffer=ce,Z.source.playbackRate.value=2**((L-K.midi)/12),Z.gain.gain.setValueAtTime(0,V.currentTime),Z.gain.gain.linearRampToValueAtTime(Math.max(.1,Math.min(1,H)),V.currentTime+.006),Z.source.connect(Z.gain).connect(m),Z.source.onended=()=>{Z.held&&M(L,!1),Z.source.disconnect(),Z.gain.disconnect(),a.get(W)===Z&&a.delete(W)},Z.source.start(),y=!0}catch(V){console.error("Piano playback failed:",V),h.textContent="Audio unavailable. Tap a key to retry.",w(W,!0)}}function b(L){const O=c.get(L);c.delete(L);const H=a.get(O);H&&(H.held&&(H.held=!1,M(H.midi,!1)),p||w(O))}function S(L){if(p=L,document.querySelector("#piano-sustain").setAttribute("aria-pressed",String(L)),!L)for(const[O,H]of a)H.held||w(O)}function P(){S(!1);for(const L of a.keys())w(L,!0);c.clear();for(const L of u.keys())e.hasPointerCapture(L)&&e.releasePointerCapture(L);u.clear()}const A=()=>g===0?21:12*(g+1);function T(L){const O=t(L.clientX,L.clientY);return Number.isInteger(O?.object?.userData.midi)?O.object.userData.midi:null}function I(L){P(),g=Math.min(7,Math.max(0,g+L)),document.querySelector("#piano-octave").textContent=Mp(A()),document.querySelector("#piano-octave-down").disabled=g===0,document.querySelector("#piano-octave-up").disabled=g===7,r?.(),k(),e.focus({preventScroll:!0})}async function k(){const L=g;h.textContent="Loading piano...";try{const O=new Set([...o.keys()].filter(H=>H>=A()&&H<=A()+17).map(Ql));await Promise.all([...O].map(v)),g===L&&(h.textContent="Play a key")}catch(O){console.error("Piano samples could not preload:",O),g===L&&(h.textContent="Tap a key to load its sound")}}document.querySelector("#piano-octave-down").addEventListener("click",()=>I(-1)),document.querySelector("#piano-octave-up").addEventListener("click",()=>I(1));const F=document.querySelector("#piano-sustain");F.addEventListener("pointerdown",L=>{L.preventDefault(),F.setPointerCapture(L.pointerId),S(!0)});for(const L of["pointerup","pointercancel","lostpointercapture"])F.addEventListener(L,()=>S(!1));return F.addEventListener("click",L=>{L.detail===0&&S(!p)}),window.addEventListener("keyup",L=>{L.code==="Space"&&i()&&S(!1),b("key-"+L.code)}),window.addEventListener("blur",P),document.addEventListener("visibilitychange",()=>{document.hidden&&P()}),{prepare:k,async prepareNotes(L){if(L.some(H=>!Number.isInteger(H)||!o.has(H)))throw new RangeError("Note outside the piano range");const O=_();await Promise.all([O.resume(),...[...new Set(L.map(Ql))].map(v)])},press:E,release:b,stop:P,pointerDown(L){if(!i()||L.button!==0)return;L.preventDefault(),e.focus({preventScroll:!0}),e.setPointerCapture(L.pointerId);const O=T(L);u.set(L.pointerId,O),O!==null&&E(O,"pointer-"+L.pointerId,L.pressure>.05?.4+L.pressure*.6:.8)},pointerMove(L){if(!u.has(L.pointerId))return;const O=T(L);if(O===u.get(L.pointerId))return;const H="pointer-"+L.pointerId;b(H),u.set(L.pointerId,O),O!==null&&E(O,H)},pointerUp(L){u.delete(L.pointerId),b("pointer-"+L.pointerId)},keyDown(L){if(!i()||L.ctrlKey||L.metaKey||L.altKey)return;if(L.code==="Space"){L.preventDefault(),S(!0);return}if(L.code==="KeyZ"){L.preventDefault(),L.repeat||I(-1);return}if(L.code==="KeyX"){L.preventDefault(),L.repeat||I(1);return}const O=vT.indexOf(L.code);O>=0&&(L.preventDefault(),L.repeat||E(A()+O,"key-"+L.code))},get state(){const L=x?new Float32Array(x.fftSize):null;return L&&x.getFloatTimeDomainData(L),{keys:o.size,voices:a.size,held:[...d].filter(([,O])=>O>0).map(([O])=>O),sustain:p,octave:g,baseMidi:A(),context:f?.state||"uninitialized",audioReady:y,signal:L?Math.sqrt(L.reduce((O,H)=>O+H*H,0)/L.length):0}}}}const Sp=s=>new D(0,1,0).applyMatrix4(s).sub(new D().applyMatrix4(s));function bT(s,e,t){const n=e.map(l=>{let d;const u=[];
4601if(s.traverse(m=>{m.userData.assetId===l.assetId&&m.userData.assetName&&(d=m)}),!d)throw new Error(`Missing tube light: ${l.id}`);if(d.traverse(m=>{if(!(!m.isMesh||t(m)!=="emitter")){if(Array.isArray(m.material))throw new Error("Tube emitters require one material");m.material=m.material.clone(),u.push(m.material)}}),!u.length)throw new Error(`Missing tube diffuser: ${l.id}`);const h=new ct().setFromObject(d),f=h.getCenter(new D);return{...l,emitters:u,center:f,color:new ze(l.color),start:new D(h.min.x+.012,f.y,f.z),end:new D(h.max.x-.012,f.y,f.z)}});if(n.length!==2)throw new Error("Two tube lights are required");const i={roomTubeStart:{value:n.map(l=>l.start)},roomTubeEnd:{value:n.map(l=>l.end)},roomTubeColor:{value:n.map(l=>l.color)}},r=new Map;let o=0;function a(l){if(r.has(l))return r.get(l);const d=l.clone();return d.customProgramCacheKey=()=>"room-tube-spill-v1",d.onBeforeCompile=u=>{Object.assign(u.uniforms,i),u.vertexShader=u.vertexShader.replace("#include <common>",`#include <common> 4602varying vec3 roomSurfacePosition; 4603varying vec3 roomSurfaceNormal;`).replace("#include <project_vertex>",`#include <project_vertex> 4604roomSurfacePosition = (modelMatrix * vec4(transformed, 1.0)).xyz; 4605roomSurfaceNormal = inverseTransformDirection(normalMatrix * normal, viewMatrix);`),u.fragmentShader=u.fragmentShader.replace("#include <common>",`#include <common> 4606varying vec3 roomSurfacePosition; 4607varying vec3 roomSurfaceNormal; 4608uniform vec3 roomTubeStart[2]; 4609uniform vec3 roomTubeEnd[2]; 4610uniform vec3 roomTubeColor[2];`).replace("#include <opaque_fragment>",` 4611if (roomSurfacePosition.y >= 0.752) { 4612 vec3 roomNormal = normalize(roomSurfaceNormal) * (gl_FrontFacing ? 1.0 : -1.0); 4613 vec3 roomView = normalize(cameraPosition - roomSurfacePosition); 4614 for (int i = 0; i < 2; i++) { 4615 vec3 segment = roomTubeEnd[i] - roomTubeStart[i]; 4616 float t = clamp(dot(roomSurfacePosition - roomTubeStart[i], segment) / max(dot(segment, segment), 0.0001), 0.0, 1.0); 4617 vec3 delta = mix(roomTubeStart[i], roomTubeEnd[i], t) - roomSurfacePosition; 4618 float distanceToTube = length(delta); 4619 if (distanceToTube < 0.72) { 4620 vec3 directionToTube = delta / max(distanceToTube, 0.0001); 4621 float falloff = pow(1.0 - distanceToTube / 0.72, 2.0); 4622 float facing = max(dot(roomNormal, directionToTube), 0.0); 4623 float sheen = pow(max(dot(roomNormal, normalize(directionToTube + roomView)), 0.0), 24.0); 4624 vec3 reflectance = mix(vec3(0.18), diffuseColor.rgb, 0.70); 4625 outgoingLight += roomTubeColor[i] * falloff * (reflectance * (0.10 + 0.9 * facing) + 0.48 * sheen); 4626 } 4627 } 4628} 4629#include <opaque_fragment>`)},r.set(l,d),d}s.traverse(l=>{if(!l.isMesh||["emitter","screen","cv","songbook","phone","book-spine","artwork","exterior"].includes(t(l)))return;const d=new ct().setFromObject(l);if(!n.some(h=>d.distanceToPoint(h.center)<.95))return;const u=h=>h.isMeshBasicMaterial||h.isMeshStandardMaterial;Array.isArray(l.material)?l.material=l.material.map(h=>u(h)?a(h):h):u(l.material)&&(l.material=a(l.material)),o++});function c(l,d){const u=n.find(h=>h.id===l);if(!u||!/^#[0-9a-f]{6}$/i.test(d))throw new Error("Invalid tube-light color");u.color.set(d);for(const h of u.emitters)h.color.copy(u.color)}for(const l of e)c(l.id,l.color);return{setColor:c,affected:o}}function MT(s,e,t=()=>{}){const n=new Map;s.traverse(m=>{m.userData.assetName&&n.set(m.userData.assetId,m)});const i=n.get(e.liftAssetId),r=n.get(e.middleAssetId),o=n.get(e.cableAssetId);if(!i||!r||!o||!Number.isFinite(e.travel)||e.travel<=0||e.travel>.65)throw new Error("The standing desk assembly is incomplete");s.updateMatrixWorld(!0);const a=[i,r].map(m=>({object:m,base:m.position.clone(),up:Sp(m.parent.matrixWorld.clone().invert())})),c=[];o.traverse(m=>{if(!m.isMesh)return;const x=m.geometry.attributes.position,p=x.array.slice(),g=[],y=new D;for(let _=0;_<x.count;_++)y.fromBufferAttribute(x,_).applyMatrix4(m.matrixWorld),g.push(Ct.clamp((y.y-.15)/.45,0,1));c.push({mesh:m,positions:x,base:p,weights:g,up:Sp(m.matrixWorld.clone().invert())})});let l=0,d=!1,u,h=null;function f(m){const x=m-l;l=m,a.forEach(({object:p,base:g,up:y},_)=>{p.position.copy(g).addScaledVector(y,m/(_+1)),p.updateMatrix(),p.updateMatrixWorld(!0)});for(const{mesh:p,positions:g,base:y,weights:_,up:v}of c){for(let M=0;M<g.count;M++)g.setXYZ(M,y[M*3]+v.x*m*_[M],y[M*3+1]+v.y*m*_[M],y[M*3+2]+v.z*m*_[M]);g.needsUpdate=!0,p.geometry.computeBoundingBox(),p.geometry.computeBoundingSphere(),p.geometry.boundsTree?.refit()}t(x)}return{toggle(m,x=!1){d=!d,u={start:m,from:l,to:d?e.travel:0,duration:x?0:Math.max(180,2200*Math.abs((d?e.travel:0)-l)/e.travel)},x&&(f(u.to),u=null)},update(m){if(!u||h!==null)return!1;const x=Math.min(1,Math.max(0,(m-u.start)/u.duration));return f(Ct.lerp(u.from,u.to,x*x*(3-2*x))),x===1&&(u=null),!0}
4629,setPaused(m,x){m&&h===null?h=x:!m&&h!==null&&(u&&(u.start+=x-h),h=null)},get state(){return{offset:l,standing:d,moving:!!u}}}}function ST({model:s,manifest:e,invalidate:t,track:n,onDeskShift:i,surfaceKind:r}){const o=MT(s,e.desk,i),a=bT(s,e.tubeLights,r),c=document.querySelector("#desk-height-toggle"),l=document.querySelector("#desk-height-status"),d=document.querySelector("#tube-colors"),u=new Map;function h(x,p){if(!u.has(x)||!/^#[0-9a-f]{6}$/i.test(p))throw new Error("Invalid tube-light color");const g=u.get(x);a.setColor(x,p),g.input.value=p,g.value.textContent=p.toUpperCase(),g.color=p,t()}for(const x of e.tubeLights){const p=document.createElement("label"),g=document.createElement("span"),y=document.createElement("input"),_=document.createElement("span");p.className="tube-color",p.dataset.light=x.id,g.textContent=x.label,y.type="color",y.id=`tube-color-${x.id}`,y.setAttribute("aria-label",`${x.label} color`);const v=document.createElement("kbd");v.textContent=x.id==="blue"?"B":"O",g.append(" ",v),_.className="tube-color-value",p.append(g,y,_),d.append(p),u.set(x.id,{...x,input:y,value:_}),h(x.id,x.color),y.addEventListener("input",()=>h(x.id,y.value)),y.addEventListener("change",()=>n(`tube_${x.id}_color`))}function f(){const x=o.state;c.setAttribute("aria-pressed",String(x.standing)),c.textContent=x.standing?"Lower to sitting":"Raise to standing",l.textContent=x.moving?x.standing?"Raising the desk...":"Lowering the desk...":`${x.standing?"Standing":"Sitting"} / ${Math.round((e.desk.sittingHeight+x.offset)*100)} cm`,document.body.dataset.deskState=x.moving?x.standing?"raising":"lowering":x.standing?"standing":"sitting"}function m(){o.toggle(performance.now(),matchMedia("(prefers-reduced-motion: reduce)").matches),n(o.state.standing?"desk_stand":"desk_sit"),f(),t()}return c.addEventListener("click",m),document.querySelector("#room-controls").hidden=!1,f(),{toggleDesk:m,setColor:h,cycleLight(x){const p=["#2163ff","#ff8b38","#a957ff","#37d9b2","#ff5276","#fff1cf"],g=u.get(x);if(!g)throw new Error("Unknown tube light");h(x,p[(p.indexOf(g.color)+1)%p.length]),n(`tube_${x}_color`)},setPaused(x){o.setPaused(x,performance.now())},focusLight(x){const p=[...u.values()].find(g=>g.assetId===x);if(!p)throw new Error("The selected tube light is missing");p.input.focus({preventScroll:!0}),p.input.scrollIntoView({block:"nearest"})},update(x){const p=o.update(x);return p&&!o.state.moving&&f(),p},get state(){return{...o.state,reflectedSurfaces:a.affected,lights:Object.fromEntries([...u].map(([x,p])=>[x,p.color]))}}}}const wp={Cmaj7:[48,55,59,64],Dm7:[50,57,60,65],G7:[43,53,59,62],Em7:[52,59,62,67],A7:[45,55,61,64],Fmaj7:[41,52,57,60],Fm6:[41,50,56,60],F7:[41,51,57,60],Bb7:[46,56,62,65],D7:[50,60,66,69],Gm7:[43,53,58,62],C7:[48,58,64,67],Dm9:[50,60,64,65],G13:[43,53,59,64],Bbmaj7:[46,57,62,65]},ot=(s,e)=>({chord:s,notes:e.map(t=>Array.isArray(t)?t:[t,1])}),hi=[{title:"Windowlight",key:"C major",style:"Medium swing",bpm:112,swing:!0,bars:[ot("Cmaj7",[64,67,71,69]),ot("Cmaj7",[67,64,62,60]),ot("Dm7",[[62,.5],[65,.5],[69,1],[72,1],[69,1]]),ot("G7",[71,69,65,62]),ot("Em7",[67,71,74,71]),ot("A7",[73,72,69,67]),ot("Dm7",[65,69,72,74]),ot("G7",[[71,.5],[69,.5],[67,1],[65,1],[62,1]]),ot("Fmaj7",[64,69,72,76]),ot("Fm6",[75,72,68,62]),ot("Cmaj7",[64,67,[60,2]]),ot("G7",[62,65,69,71])]},{title:"Midnight Walnut",key:"F blues",style:"Slow shuffle",bpm:96,swing:!0,bars:[ot("F7",[65,68,70,72]),ot("Bb7",[[74,.5],[72,.5],[70,1],[68,1],[65,1]]),ot("F7",[63,65,68,69]),ot("F7",[72,69,[65,2]]),ot("Bb7",[70,74,77,75]),ot("Bb7",[74,72,70,68]),ot("F7",[[65,.5],[68,.5],[69,1],[72,1],[75,1]]),ot("D7",[74,72,69,66]),ot("Gm7",[67,70,74,77]),ot("C7",[76,74,70,67]),ot("F7",[69,68,[65,2]]),ot("C7",[64,67,70,72])]},{title:"Open Window",key:"D minor",style:"Easy bossa",bpm:124,swing:!1,bars:[ot("Dm9",[69,65,64,62]),ot("G13",[[64,.5],[67,.5],[69,1],[71,1],[69,1]]),ot("Cmaj7",[67,71,[76,2]]),ot("A7",[73,72,69,64]),ot("Dm9",[65,69,72,76]),ot("G13",[74,71,69,67]),ot("Cmaj7",[[64,.5],[67,.5],[71,1],[72,1],[71,1]]),ot("A7",[69,67,64,61]),ot("Bbmaj7",[62,65,69,70]),ot("A7",[73,76,72,69]),ot("Dm9",[65,64,[62,2]]),ot("A7",[61,64,67,69])]}];function wT(s,e,t){if(!Number.isFinite(e)||e<50||e>200)throw new RangeError("Choose a tempo from 50 to 200 BPM");if(t!==void 0&&(!Number.isInteger(t)||t<0||t>=s.bars.length))throw new RangeError("Invalid songbook bar");const n=[],i=60/e,r=t===void 0?s.bars.map((a,c)=>c):[t],o=a=>{if(!s.swing)return a;const c=a%1;return Math.floor(a)+(c<=.5?c*4/3:2/3+(c-.5)*2/3)};return r.forEach((a,c)=>{const l=s.bars[a];n.push({at:c*4*i,duration:3.7*i,notes:wp[l.chord],velocity:.35,bar:a});let d=0;for(const[u,h]of l.notes)n.push({at:(c*4+o(d))*i,duration:(o(d+h)-o(d))*i*.9,notes:[u],velocity:.78,bar:a}),d+=h;if(d!==4||!wp[l.chord])throw new Error("The lead sheet has an invali
4629d measure")}),{events:n,duration:r.length*4*i}}function TT({model:s,piano:e,invalidate:t,track:n,enabled:i,surfaceKind:r,compact:o=!1}){const a=document.createElement("canvas"),c=2400,l=1680,d=o?.5:1;a.width=c*d,a.height=l*d;const u=a.getContext("2d");if(!u)throw new Error("The jazz book canvas is unavailable");u.scale(d,d);const h=new im(a);h.colorSpace=At,h.flipY=!1,h.anisotropy=o?2:8,o&&(h.generateMipmaps=!1,h.minFilter=It);let f=0;if(s.traverse(q=>{!q.isMesh||r(q)!=="songbook"||(q.material=new nn({map:h,side:Tt,toneMapped:!1}),f++)}),!f)throw new Error("The jazz book reading surface is missing");const m=document.querySelector("#songbook-tune"),x=document.querySelector("#songbook-status"),p=document.querySelector("#songbook-play"),g=document.querySelector("#songbook-tempo"),y=document.querySelector("#songbook-tempo-label"),_=document.querySelector("#songbook-chords"),v=[],M=new Set,w=new Set;let E=0,b=-1,S=!1,P=!1,A=0;hi.forEach((q,Z)=>m.add(new Option(q.title,String(Z))));function T(q,Z,V,K,ce=!1){u.font=`${ce?"italic ":""}${K}px ${ce?"Georgia, serif":'"Avenir Next", sans-serif'}`,u.fillStyle="#302e29",u.fillText(q,Z,V)}function I(q,Z){u.save(),u.translate(q,Z),u.strokeStyle="#36332b",u.lineWidth=6,u.beginPath(),u.moveTo(23,100),u.bezierCurveTo(7,130,-9,104,13,96),u.bezierCurveTo(33,87,27,38,18,7),u.bezierCurveTo(4,-33,37,-34,29,-5),u.bezierCurveTo(24,16,-13,34,-6,64),u.bezierCurveTo(0,93,48,87,40,59),u.bezierCurveTo(34,38,5,48,13,66),u.stroke(),u.restore()}function k(q,Z,V,K){const ce=q%12,$=(Math.floor(q/12)-5)*7+[0,1,1,2,2,3,4,4,5,5,6,6][ce],R=K+88-($-2)*11;u.strokeStyle="#423d32",u.lineWidth=2.5;for(let re=K+110;re<=R;re+=22)u.beginPath(),u.moveTo(V-23,re),u.lineTo(V+23,re),u.stroke();for(let re=K-22;re>=R;re-=22)u.beginPath(),u.moveTo(V-23,re),u.lineTo(V+23,re),u.stroke();[1,3,6,8,10].includes(ce)&&T("â",V-43,R+12,45),u.beginPath(),u.ellipse(V,R,15,10,-.28,0,Math.PI*2),u.fillStyle=Z>=2?"#faf7eb":"#302e29",u.fill(),u.stroke();const z=R>K+44,Y=V+(z?13:-13),ie=R+(z?-75:75);u.beginPath(),u.moveTo(Y,R),u.lineTo(Y,ie),u.stroke(),Z<1&&(u.beginPath(),u.moveTo(Y,ie),u.bezierCurveTo(Y+28,ie+(z?18:-18),Y+32,ie+(z?32:-32),Y+19,ie+(z?44:-44)),u.stroke())}function F(){const q=hi[E];u.fillStyle="#faf7eb",u.fillRect(0,0,2400,1680);const Z=u.createLinearGradient(1150,0,1250,0);Z.addColorStop(0,"#faf7eb"),Z.addColorStop(.5,"#c8c0aa"),Z.addColorStop(1,"#faf7eb"),u.fillStyle=Z,u.fillRect(1150,0,100,1680),T("THE ROOM BOOK",95,125,43),T(`${String(E+1).padStart(2,"0")} / ORIGINAL JAZZ`,1315,125,35),T(q.title,95,255,88,!0),T("Play the changes.",1315,245,76,!0),T(`${q.key} / ${q.style} / ${g.value} BPM`,95,330,34),T("Touch a bar to hear its melody and chords.",1315,320,31),T("4/4",94,404,33),v.length=0,q.bars.forEach((V,K)=>{const ce=Math.floor(K/6),$=K%6,R=$%2,z=Math.floor($/2),Y=ce*1200+90+R*535,ie=540+z*365;K===b&&(u.fillStyle="#d8b86444",u.fillRect(Y-10,ie-114,520,280)),T(V.chord,Y+55,ie-57,57,!0),T(String(K+1),Y+2,ie-66,24),u.strokeStyle="#817963",u.lineWidth=2;for(let ge=0;ge<5;ge++)u.beginPath(),u.moveTo(Y,ie+ge*22),u.lineTo(Y+510,ie+ge*22),u.stroke();u.beginPath(),u.moveTo(Y+510,ie),u.lineTo(Y+510,ie+88),u.stroke(),R===0&&I(Y+12,ie-9);let re=0;for(const[ge,Fe]of V.notes)k(ge,Fe,Y+96+re*96,ie),re+=Fe;v.push({x:Y-10,y:ie-120,width:530,height:300,bar:K})}),T("A Real Book-inspired format. All melodies are original.",95,1595,28),T("Not an official Real Book edition. Make some music.",1315,1595,27),h.needsUpdate=!0;for(const V of _.children)V.setAttribute("aria-pressed",String(Number(V.dataset.bar)===b));t()}function L(){A++;for(const q of M)clearTimeout(q);M.clear();for(const q of w)e.release(q);w.clear(),S=P=!1,b=-1,p.textContent="Play tune",p.setAttribute("aria-pressed","false"),x.textContent="Play a bar, or listen to the whole tune.",F()}function O(q,Z){const V=setTimeout(()=>{M.delete(V),q()},Z);M.add(V)}async function H(q){if(!i())return;if((S||P)&&q===void 0){L();return}L();const Z=A,V=wT(hi[E],Number(g.value),q);P=!0,p.textContent="Stop",x.textContent="Warming up the piano...";try{await e.prepareNotes(V.events.flatMap(K=>K.notes))}catch(K){console.error("Jazz-book audio failed:",K),Z===A&&(L(),x.textContent="Piano audio could not load. Please try again.");return}Z!==A||!i()||(P=!1,S=!0,p.setAttribute("aria-pressed","true"),n("songbook_play"),V.events.forEac
4629h((K,ce)=>O(()=>{if(!(Z!==A||!i())){b!==K.bar&&(b=K.bar,x.textContent=`Bar ${K.bar+1} / ${hi[E].bars[K.bar].chord}`,F());for(const $ of K.notes){const R=`book-${Z}-${ce}-${$}`;w.add(R),e.press($,R,K.velocity),O(()=>{e.release(R),w.delete(R)},K.duration*1e3)}}},K.at*1e3)),O(L,V.duration*1e3+100))}function W(q){L(),E=(q+hi.length)%hi.length,m.value=String(E),g.value=String(hi[E].bpm),y.textContent=`${g.value} BPM`,_.replaceChildren(...hi[E].bars.map((Z,V)=>{const K=document.createElement("button");return K.dataset.bar=String(V),K.textContent=Z.chord,K.setAttribute("aria-label",`Play bar ${V+1}: ${Z.chord}`),K.addEventListener("click",()=>H(V)),K})),document.querySelector("#songbook-page").textContent=`${E+1} / ${hi.length}`,F()}return m.addEventListener("change",()=>{W(Number(m.value)),n("songbook_page")}),document.querySelector("#songbook-prev").addEventListener("click",()=>{W(E-1),n("songbook_page")}),document.querySelector("#songbook-next").addEventListener("click",()=>{W(E+1),n("songbook_page")}),p.addEventListener("click",()=>H()),g.addEventListener("input",()=>{L(),y.textContent=`${g.value} BPM`,F()}),document.addEventListener("keydown",q=>{!i()||q.repeat||q.ctrlKey||q.metaKey||q.altKey||q.target.closest("input, select, textarea, a, button")||["ArrowLeft","ArrowRight","PageUp","PageDown"].includes(q.code)&&(q.preventDefault(),W(E+(["ArrowLeft","PageUp"].includes(q.code)?-1:1)),n("songbook_page"))}),window.addEventListener("blur",L),document.addEventListener("visibilitychange",()=>{document.hidden&&L()}),W(0),{stop:L,play:H,hit(q){const Z=v.find(V=>q.x*c>=V.x&&q.x*c<=V.x+V.width&&q.y*l>=V.y&&q.y*l<=V.y+V.height);return Z&&H(Z.bar),!!Z},get state(){return{page:E,title:hi[E].title,activeBar:b,playing:S,loading:P,tempo:Number(g.value)}}}}const ET=[[[2.17,-.326],[2.17,.4],[2.17,1.42],[1.1,1.42]],[[1.4,1.52],[2.42,2.12]]];function AT({model:s,invalidate:e,notice:t,track:n,reducedMotion:i}){let r;if(s.traverse(P=>{P.userData.assetId==="asset-cockroach-behind-guitar-case"&&P.userData.assetName&&(r=P)}),!r)throw new Error("The interactive cockroach is missing");s.updateMatrixWorld(!0);const o=new ct().setFromObject(r).getCenter(new D),a=o.clone(),c=new D,l=r.parent,d=new Kt;d.name="Cockroach movement",l.add(d),d.position.copy(l.worldToLocal(o.clone())),d.updateMatrixWorld(!0),d.attach(r),r.updateMatrix();const u=new Qe(new Cn(.055,12,8),new nn({transparent:!0,opacity:0,depthWrite:!1,colorWrite:!1}));u.name="Cockroach touch target",u.userData.assetId="asset-cockroach-behind-guitar-case",d.add(u);const h=28,f=new Float32Array(h*3),m=new Float32Array(h*3),x=new vt;x.setAttribute("position",new Rt(f,3));const p=new Dc(x,new Vd({color:"#b79a72",size:.016,transparent:!0,opacity:0,depthWrite:!1}));p.name="Cockroach dust pop",p.visible=!1,s.add(p);let g=0,y="idle",_=[],v=0,M=null,w=0,E=!1;function b(){d.position.copy(l.worldToLocal(a.clone())),d.updateMatrix(),d.updateMatrixWorld(!0)}function S(){if(d.visible=!1,i()){y="gone";return}y="burst",w=0;const P=s.worldToLocal(a.clone());for(let A=0;A<h;A++){f.set([P.x,P.y,P.z],A*3);const T=A*2.3999632297,I=.12+A%5*.045;m.set([Math.cos(T)*I,.17+A%7*.025,Math.sin(T)*I],A*3)}x.attributes.position.needsUpdate=!0,x.computeBoundingSphere(),p.material.opacity=1,p.visible=!0}return{pickMesh:u,trigger(){return y==="running"?(t("Let it stop, then try touching it again."),!1):y!=="idle"?!1:(g++,M=null,g===3?(S(),n("roach_pop"),t("Poof. The room is yours again.")):(_=ET[g-1].map(([P,A])=>new D(P,o.y,A)),v=0,y="running",i()&&(a.copy(_.at(-1)),b(),y="idle"),n("roach_startle"),t("It scuttled away. Find it and try again.")),e(),!0)},update(P){if(E||!["running","burst"].includes(y))return M=null,!1;const A=M===null?0:Math.min(.05,Math.max(0,(P-M)/1e3));if(M=P,y==="running"){let T=A*1.35;for(;T>0&&v<_.length;){c.copy(_[v]).sub(a);const I=c.length();I>1e-5&&(d.rotation.y=Math.atan2(c.x,c.z)),I<=T?(a.copy(_[v++]),T-=I):(a.addScaledVector(c,T/I),T=0)}b(),v===_.length&&(y="idle")}else{w+=A;for(let T=0;T<h;T++){const I=T*3;m[I+1]-=1.5*A,f[I]+=m[I]*A,f[I+1]=Math.max(.009,f[I+1]+m[I+1]*A),f[I+2]+=m[I+2]*A}x.attributes.position.needsUpdate=!0,x.computeBoundingSphere(),p.material.opacity=Math.max(0,1-w/.75
4629),w>=.75&&(y="gone",p.visible=!1)}return!0},setPaused(P){E=P,M=null},get position(){return a.clone()},get state(){return{hits:g,phase:y,position:a.toArray()}}}}const Vc={"Electric guitar and hangers":{label:"Frankenstrat",href:"https://www.youtube.com/watch?v=9sCRKCLHJf8",thumbnail:"/images/guitars/frankenstrat-youtube.jpg"},"Ibanez JEM 7V":{label:"Steve Vai JEM",href:"https://www.youtube.com/watch?v=POYwemFbkk0",thumbnail:"/images/guitars/jem-youtube.jpg"}},ah=s=>!["home","piano","songbook"].includes(s);function ch(s){const e=Vc[s?.asset?.name];if(!e||!s.point)return null;if(s.asset.name==="Electric guitar and hangers"){const t=s.asset.bounds.max;if(s.point.y<t[1]-.93||s.point.x<t[0]-.35)return null}return e}function CT(s,e,t,n,i,r=[]){const o=s.clone().project(e);if(o.z<-1||o.z>1||Math.abs(o.x)>1||Math.abs(o.y)>1)return null;const a=t.left+(o.x+1)*t.width/2,c=t.top+(1-o.y)*t.height/2,l=t.left+12,d=t.left+t.width-n-12,u=t.top+12,h=t.top+t.height-i-12;if(d<l||h<u)return null;const f=[[a+24,c-i/2],[a-n-24,c-i/2],...r.flatMap(m=>[[m.right+16,c-i/2],[m.left-n-16,c-i/2],[a-n/2,m.top-i-16],[a-n/2,m.bottom+16]]),...[l,d].flatMap(m=>[u,c-i/2,h].map(x=>[m,x]))].map(([m,x])=>({left:Ct.clamp(m,l,d),top:Ct.clamp(x,u,h)})).filter(m=>r.every(x=>m.left+n+12<=x.left||m.left>=x.right+12||m.top+i+12<=x.top||m.top>=x.bottom+12));return f.sort((m,x)=>Math.hypot(m.left+n/2-a,m.top+i/2-c)-Math.hypot(x.left+n/2-a,x.top+i/2-c)),f.find(m=>Math.hypot(Ct.clamp(a,m.left,m.left+n)-a,Ct.clamp(c,m.top,m.top+i)-c)<300)||null}function RT({roots:s,camera:e,mount:t,invalidate:n,onOpen:i}){const r=[...s.values()].filter(A=>Vc[A.userData.assetName]||["Digital piano","Music sheet book"].includes(A.userData.assetName)),o=new ct;function a(A){return r.flatMap(T=>{if(!T.visible)return[];o.setFromObject(T);const I=[];for(const F of[o.min.x,o.max.x])for(const L of[o.min.y,o.max.y])for(const O of[o.min.z,o.max.z]){const H=new D(F,L,O).project(e);H.z<-1||H.z>1||I.push({x:A.left+(H.x+1)*A.width/2,y:A.top+(1-H.y)*A.height/2})}if(!I.length)return[];const k={left:Math.min(...I.map(F=>F.x)),right:Math.max(...I.map(F=>F.x)),top:Math.min(...I.map(F=>F.y)),bottom:Math.max(...I.map(F=>F.y))};return k.right<A.left||k.left>A.left+A.width||k.bottom<A.top||k.top>A.top+A.height?[]:[k]})}const c=document.createElement("a");c.id="guitar-video-preview",c.target="_blank",c.rel="noopener noreferrer",c.hidden=!0;const l=document.createElement("img");l.alt="",l.width=480,l.height=360;const d=document.createElement("strong"),u=document.createElement("span"),h=document.createElement("kbd");h.textContent="E",u.append(h," Watch on YouTube");const f=document.createElement("span");f.className="guitar-preview-play",f.setAttribute("aria-hidden","true");const m=document.createElement("span");m.className="guitar-preview-copy",m.append(d,u),c.append(l,f,m),document.querySelector("#workspace").append(c);const x=new D,p=new D;let g=null,y=null,_=0,v=0,M=!1;const w=()=>{clearTimeout(_),clearTimeout(v),_=v=0,c.classList.remove("is-fading")};function E(){w(),g=null,y=null,M=!1,c.hidden=!0}function b(){M=!1,!(!g||_||c.matches(":hover, :focus-visible"))&&(_=setTimeout(()=>{c.classList.add("is-fading"),v=setTimeout(E,220)},500))}function S(){if(!g)return;for(let F=g;F;F=F.parent)if(!F.visible){c.hidden=!0;return}g.updateWorldMatrix(!0,!1),p.copy(x).applyMatrix4(g.matrixWorld);const A=t.getBoundingClientRect(),T=a(A);let I=null,k;for(const F of[240,200,160])if(k=Math.min(F,A.width-24),I=CT(p,e,A,k,k*9/16+56,T),I)break;c.hidden=!I,I&&(c.style.width=`${k}px`,c.style.left=`${I.left}px`,c.style.top=`${I.top}px`)}function P(A){const T=ch(A),I=s.get(A?.asset?.id);return!T||!I?(b(),!1):(w(),M=!0,g!==I&&(g=I,y=T,g.updateWorldMatrix(!0,!1),o.setFromObject(g),o.getCenter(x),x.y=o.max.y-.61,A.asset.name==="Electric guitar and hangers"&&(x.x=o.max.x-.16),g.worldToLocal(x),c.href=T.href,c.dataset.assetId=A.asset.id,l.hidden=!1,l.src=T.thumbnail,d.textContent=T.label,c.setAttribute("aria-label",`${T.label}: play video on YouTube (opens in a new tab)`)),S(),n(),!0)}return l.addEventListener("error",()=>{l.hidden=!0}),c.addEventListener("pointerenter",()=>{M=!0,w()}),c.addEventListener("pointerleave",b),c.addEventListener("focus",w),c.addEventListener("blur",b),c.addEventListener("click",()=>i(y)),document.addEventListener("keydown",A=>{A.code!=="KeyE"||A.repeat||A.ctrlKey||A.metaKey||A.altKey||c.hidden||!M&&!c.matches(":hover, :focus-visible")||A.target.closest('input, select, textarea, [contenteditable="true"]')||(A.preventDefault(),A.stopImmediatePropagation(),w(),c.click())},!0),{show:P,hide:E,leave:b,update:S,get assetId(){return g?.userData.assetId}}}const PT=-26.695,LT=[[[-28.45,15.38],[-27.5,10],[-25,6],[-24,1],[-18,-1],[-12,-2.47]],[[-30,2],[-27,4],[-24,8],[-23,10.8],[-20,11.5],[-16,8],[-13,5],[-9,1]],[[-12,-2],[-16,1],[-19,4],[-24,3],[-28,6],[-27.8,10],[-30,13],[-29,17]],[[-29,21],[-26,17],[-27,12],[-23.5,10.5],[-22.5,6],[-20,2],[-15,-3]]],_o=(s,e)=>Math.hypot(...s.map((t,n)=>t-e[n])),mo=(s,e,t)=>s.map((n,i)=>n+(e[i]-n)*t);function IT(s){const e=[s[0]];for(let t=1;t<s.length-1;t++){const n=s[t-1],i=s[t],r=s[t+1],o=Math.min(1.5,_o(n,i)*.3,_o(i,r)*.3),a=mo(i,n,o/_o(i,n)),c=mo(i,r,o/_o(i,r));for(let l=0;l<=8;l++){const d=l/8;e.push(mo(mo(a,i,d),mo(i,c,d),d))}}return e.push(s.at(-1)),e}const Tc=LT.map(s=>IT(s.map(([e,t])=>[e,PT,t]))),Um=s=>
4629s.slice(1).reduce((e,t,n)=>e+_o(t,s[n]),0);function $l(s,e,t,n){const i=(r,o)=>[s[0]+e[0]*r+1.42*o,t,s[1]+e[1]*r+.693*o];return{width:n,floor:t,route:[i(.5,.22),i(.35,.7),i(.62,.7),i(.5,.22)],retreat:i(.5,.16),outward:[1.42,0,.693]}}const Sr=[$l([-32.3303,-8.1577],[-1.6921,3.469],-14.695,3.7),$l([-28.7367,-15.5261],[-2.3493,4.8174],-8.695,5.2),$l([-32.3303,-8.1577],[-1.6921,3.469],-5.695,3.7)];function Om(s){if(s.balcony!==void 0)return Sr[s.balcony].route;const e=Tc[s.route];return s.reverse?e.toReversed():e}const Us=2,vr=.02,dc=10,Fm=[[-28.455177,-26.695,15.377309],[-24.009764,-26.695,1.157874],[-12.051639,-26.695,-2.474534]],Rr={neighbor:{name:"Neighbor",hp:1,points:100,speed:1,color:"#497b87"},sturdy:{name:"Big neighbor",hp:2,points:220,speed:.8,color:"#ac7848"},jogger:{name:"Jogger",hp:1,points:180,speed:1.5,color:"#d56c51"},chair:{name:"Chair racer",hp:1,points:350,speed:1.25,color:"#9475ad"},balcony:{name:"Balcony bonus",hp:1,points:300,speed:.12,color:"#d5a965"}},DT=Um(Fm),Tp=50*600;function NT(s,e,t=Us){const n=["neighbor","neighbor","sturdy","jogger","neighbor","chair","sturdy","jogger"],i=Array.from({length:Math.min(3+s,10)},(r,o)=>{const a=n[(o+(s-1)*3+e%3)%n.length],c=Rr[a],l=t===1?{}:{route:(o+s-1+e%4)%Tc.length,reverse:(o+s)%3===0};return{index:o,kind:a,hp:c.hp,maxHp:c.hp,points:c.points,...l,speed:(1.05+s*.14)*c.speed,lane:[-1.15,1.15,0][(o+e%3)%3],spawn:Math.round(o*Math.max(1.7,3.1-s*.1)/vr),progress:0,stunUntil:0,status:"waiting"}});return t>1&&s>=2&&i.push({index:i.length,kind:"balcony",hp:1,maxHp:1,points:Rr.balcony.points,speed:Rr.balcony.speed,balcony:(s+e%3)%Sr.length,bonus:!0,spawn:300,progress:0,stunUntil:0,status:"waiting"}),i}function UT(){let s=0,e=0,t="idle",n=0,i=0,r=0,o=0,a=0,c=0,l=0,d=0,u=3,h=0,f=-100,m="",x=Us,p=[],g=[],y=[],_=null,v=0;function M(){n++,r=0,v=0,p=NT(n,s,x).map(b=>({...b,length:x===1?DT:Um(Om(b))})),h=10+n*2,t="wave"}function w(b){t="over",m=b}function E(){if(["wave","break"].includes(t)){if(i++,i>=Tp){w("Time is up");return}if(t==="break"){--o<=0&&M();return}r++;for(const b of p)if(b.status==="waiting"&&r>=b.spawn&&(b.status="active"),!(b.status!=="active"||r<b.stunUntil)&&(b.progress+=b.speed*vr,b.progress>=b.length)){if(b.status="escaped",b.bonus)continue;if(u--,v++,l=0,u<=0){w("Three got away");return}}if(p.every(b=>b.bonus||["tagged","escaped"].includes(b.status))){const b=n*100+(v===0?h*10:0);c+=b,_={points:b,text:v===0?"Perfect wave":"Wave clear",tick:i},n===dc?w("All ten waves cleared!"):(t="break",o=225)}}}return{start(b=0,S=Us){if(!Number.isSafeInteger(b)||b<0||b>4294967295)throw new Error("Invalid challenge seed");if(![1,Us].includes(S))throw new Error("Unsupported challenge version");x=S,s=b,e++,t="idle",n=i=r=a=c=l=d=0,u=3,f=-100,m="",g=[],y=[],_=null,M()},reset(){t="idle",p=[]},update(b){if(!Number.isFinite(b)||b<0)throw new Error("Invalid challenge time");for(a+=Math.min(b,.25);a+1e-9>=vr;)a-=vr,E()},advanceTo(b){if(!Number.isSafeInteger(b)||b<i||b>Tp)throw new Error("Invalid replay tick");for(;i<b;){if(t==="over"||t==="idle")throw new Error("Replay continues after the run ended");E()}},fire(b){if(!Number.isFinite(b)||b<0||b>1)throw new Error("Invalid throw power");if(t!=="wave"||h<=0||i-f<18||g.length>=300)return null;h--,f=i;const S={id:g.length,wave:n,tick:i,power:Math.round(b*100)/100,result:null};return g.push(S),y.push({type:"shot",tick:i,power:S.power}),{...S}},hit(b,S,P={}){const A=p[b],T=g[S];if(t!=="wave"||!A||A.status!=="active"||!T||T.result||T.wave!==n||i-T.tick>300)return null;T.result="hit",A.hp--;const I=A.hp===0;I?A.status="tagged":A.stunUntil=r+28,l++,d=Math.max(d,l);const k=Math.min(4,1+Math.floor(l/3)),F=((I?A.points:50)+(P.long?50:0)+(P.precision?25:0))*k;return c+=F,_={points:F,text:I?P.precision?"Bullseye!":Rr[A.kind].name:"One more egg!",tick:i},y.push({type:"hit",tick:i,target:b,shot:S,long:!!P.long,precision:!!P.precision}),{defeated:I,points:F,multiplier:k}},miss(b){const S=g[b];return!S||S.result||t==="over"||t==="idle"?!1:(S.result="miss",S.wave===n&&(l=0),y.push({type:"miss",tick:i,shot:b}),!0)},finish(){["wave","break"].includes(t)&&(y.push({type:"quit",tick:i}),w("Run ended"))},get state(){return{version:x,seed:s,run:e,status:t,wave:n,tick:i,seconds:i*vr,waveTick:r,countdown:Math.ceil(o*vr),score:c,combo:l,bestCombo:d,multiplier:Math.min(4,1+Math.floor(l/3)),lives:u,ammo:h,targets:p.map(b=>({...b})),shots:g.length,hits:g.filter(b=>b.result==="hit").length,remaining:p.filter(b=>!b.bonus&&!["tagged","escaped"].includes(b.status)).length,lastPoints:_,reason:m,wind:n<3?[0,0,0]:[0,0,Math.sin(s%100+n*2.4)*Math.min(1.4,(n-2)*.22)]}},get active(){return t==="wave"||t==="break"},get replay(){return{version:x,tick:i,events:y.map(b=>({...b}))}}}}function Qa(s,e,t=1,n=0){if(!Number.isFinite(t)||t<=0)throw new Error("Walking speed must be positive");const i=s.slice(1).map((y,_)=>y.distanceTo(s[_]));if(i.some(y=>y===0))throw new Error("Pedestrian path segments must have length");const r=i.reduce((y,_)=>y+_,0);if(r<=0)throw new Error("A pedestrian path needs distinct points");const o=r/t,a=1.4,c=2*(o+a),l=((e+n)%c+c)%c,d=l>=o+a;let h=d?Math.max(0,r-(l-o-a)*t):Math.min(r,l*t),f=0;for(;f<i.length-1&&h>i[f];)h-=i[f++];const m=s[f].clone().lerp(s[f+1],h/i[f]),x=s[f+1].clone().sub(s[f]).normalize(),p=l<o||l>=o+a&&l<2*o+a;let g=Math.atan2(x.x,x.z)+(d?Math.PI:0);if(!p){const y=d?(l-2*o-a)/a:(l-o)/a;g+=Math.PI*y*y*(3-2*y)}return{position:m,yaw:g,walking:p}}function Ep(s,e){const t=[];function n(y,_,v,M){const w=new Od;return w.position.set(_,v,M),y&&y.add(w),t.push(w),w}const i=n(null,0,.88,0),r=n(i,0,.18,0),o=n(r,0,.47,0),a=[-1,1].map(y=>n(i,y*.085,-.03,0)),c=a.map(y=>n(y,0,-.38,0)),l=c.map(y=>n(y,0,-.38,.045)),d=[-1,1].map(y=>n(r,y*.19,.29,0)),u=d.map(y=>n(y,0,-.28,0));i.updateMatrixWorld(!0);const h=[];function f(y,_,v,M){const w=y.index?y.toNonIndexed():y;w!==y&&y.dispose(),w.translate(...v),w.applyMatrix4(_.matrixWorld);
4629const E=w.attributes.position.count,b=new Uint16Array(E*4),S=new Float32Array(E*4),P=new Float32Array(E*3),A=new ze(M);for(let T=0;T<E;T++)b[T*4]=t.indexOf(_),S[T*4]=1,P.set([A.r,A.g,A.b],T*3);w.setAttribute("skinIndex",new Ud(b,4)),w.setAttribute("skinWeight",new rt(S,4)),w.setAttribute("color",new rt(P,3)),h.push(w)}f(new Ps(.145,.25,3,6),r,[0,0,0],e),f(new ei(.27,.18,.19),i,[0,0,0],"#393a3b"),f(new Cn(.12,8,5),o,[0,0,0],"#b98d6b"),f(new Cn(.123,8,5,0,Math.PI*2,0,1.25),o,[0,.015,-.01],"#40352f");for(const y of[-1,1])f(new ei(.022,.014,.014),o,[y*.042,.012,.107],"#302925");for(let y=0;y<2;y++)f(new Ps(.055,.25,2,6),a[y],[0,-.19,0],"#393a3b"),f(new Ps(.048,.25,2,6),c[y],[0,-.19,0],"#393a3b"),f(new ei(.115,.08,.22),l[y],[0,-.045,.035],"#252627"),f(new Ps(.044,.19,2,6),d[y],[0,-.14,0],e),f(new Ps(.038,.2,2,6),u[y],[0,-.14,0],"#b98d6b");const m=_m(h);for(const y of h)y.dispose();const x=new em(m,s);x.add(i),x.bind(new Ic(t)),x.boundingSphere=new fn(new D(0,.85,0),1.2);const p=new Kt;for(const y of[-1,1]){const _=new Qe(new ei(.057,.016,.016),s);_.position.set(y*.04,.042,.112),_.rotation.z=y*.4,p.add(_)}const g=new Qe(new qd(.034,.009,4,8,Math.PI),s);return g.position.set(0,-.06,.108),p.add(g),o.add(p),p.visible=!1,{mesh:x,pelvis:i,spine:r,head:o,anger:p,hips:a,knees:c,ankles:l,shoulders:d,elbows:u}}const Ap=2.1,OT=4.2,FT=12,Cp=["HEY! Watch it!","Seriously?!","Not my shirt!","Who threw that?!"];function kT(s,e,t){let n=0,i=1/0;const r=new D;for(let u=0;u<s.length-1;u++){new wi(s[u],s[u+1]).closestPointToPoint(e,!0,r);const h=r.distanceToSquared(e);h<i&&(i=h,n=u)}const o=s.at(-1).distanceToSquared(t)>=s[0].distanceToSquared(t),a=u=>[e.clone(),...(u?s.slice(n+1):s.slice(0,n+1).reverse()).filter(h=>h.distanceToSquared(e)>1e-4)],c=u=>u.slice(1).reduce((h,f,m)=>h+f.distanceTo(u[m]),0),l=a(o),d=a(!o);return c(l)<5&&c(d)>c(l)?d:l}function Rp(s,e){for(let t=0;t<s.length-1;t++){const n=s[t].distanceTo(s[t+1]);if(e<=n){const i=s[t+1].clone().sub(s[t]);return{position:s[t].clone().lerp(s[t+1],e/n),yaw:Math.atan2(i.x,i.z)}}e-=n}return null}function BT(s,e){const t=new Kt,n=(r,o)=>{const a=new Qe(new ei(...r),s);a.position.set(...o),t.add(a)};n([.39,.09,.38],[0,.52,-.025]),n([.39,.43,.075],[0,.8,-.22]),n([.065,.08,.28],[-.23,.7,-.01]),n([.065,.08,.28],[.23,.7,-.01]);const i=new Qe(new Hd(.033,.033,.38,8),e);i.position.y=.29,t.add(i);for(let r=0;r<5;r++){const o=r*Math.PI*2/5,a=new Qe(new ei(.035,.035,.3),e);a.position.set(Math.sin(o)*.15,.115,Math.cos(o)*.15),a.rotation.y=o;const c=new Qe(new Cn(.055,6,4),e);c.position.set(Math.sin(o)*.3,.055,Math.cos(o)*.3),t.add(a,c)}return t}function zT(s){const e=new Kt,t=new Cn(1,8,4);t.scale(.055,.055,.18);const n=new Cn(.052,6,4);n.translate(0,.02,.16);const i=_m([t,n]);t.dispose(),n.dispose(),e.add(new Qe(i,s));const r=[];for(const o of[-1,1]){const a=new Kt;a.position.x=o*.025;const c=new vt;c.setAttribute("position",new rt([0,0,.1,o*.24,.035,.04,o*.43,0,-.07,0,0,.1,o*.43,0,-.07,o*.17,-.015,-.13,0,0,.1,o*.17,-.015,-.13,0,0,-.11],3)),c.computeVertexNormals(),a.add(new Qe(c,s)),e.add(a),r.push(a)}return{root:e,wings:r}}function VT(s,e,t=!1,n=null){if(!e?.pedestrianPaths?.length||!e?.flightPath?.length)return null;const i=V=>Array.isArray(V)&&V.length>=2&&V.every(K=>Array.isArray(K)&&K.length===3&&K.every(Number.isFinite));if(!e.pedestrianPaths.every(i)||!i(e.flightPath))throw new Error("Exterior motion paths are invalid");const r=e.pedestrianPaths.map(V=>V.map(K=>new D(...K))),o=new Wd(e.flightPath.map(V=>new D(...V)),!0,"centripetal"),a=new Kt;a.name="Animated exterior life",s.updateWorldMatrix(!0,!1),a.matrixAutoUpdate=!1,a.matrix.copy(s.matrixWorld).invert(),s.add(a);const c=new Un({color:"white",vertexColors:!0,roughness:.93,toneMapped:!1}),l=new Un({color:"#303638",roughness:.8,side:Tt,toneMapped:!1}),d=[],u=["#d7d4bd","#31575f","#9b5943","#617057","#c4b5a3","#3c475e"],h=t?12:16,f=new Wo(.32,12);f.rotateX(-Math.PI/2);const m=new nn({color:"#000000",transparent:!0,opacity:.16,depthWrite:!1}),x=new Fd(f,m,h);x.frustumCulled=!1,a.add(x);const p=new nn({color:"#641f16",toneMapped:!1}),g=new nn({color:"#ffc32b",side:Tt,toneMapped:!1}),y=new Wo(.12,9),_=new Un({color:"#4d4068",roughness:.8,toneMapped:!1}),v=new Un({color:"#252b32",roughness:.6,metalness:.4,toneMapped:!1}),M=Fm.map(V=>new D(...V)),w=V=>M.map((K,ce)=>
4629{const $=M[Math.min(ce+1,M.length-1)].clone().sub(M[Math.max(0,ce-1)]).normalize();return K.clone().add(new D(-$.z,0,$.x).multiplyScalar(V))}),E=t?8:10,b=r[Math.min(1,r.length-1)],S=b.slice(Math.floor(b.length*.35)),P=S.length>=2?S:b;for(let V=0;V<h;V++){const K=Ep(c,u[V%u.length]);K.anger.traverse(R=>{R.isMesh&&(R.material=p)});const ce=new Qe(y,g);ce.position.set(.035,.04,.147),ce.scale.set(.8,1.2,1),K.spine.add(ce),K.stain=ce,K.chair=BT(_,v),K.chair.visible=!1,K.mesh.add(K.chair),K.mesh.name=`Walking pedestrian ${V+1}`,K.mesh.scale.setScalar(.96+V%3*.035),a.add(K.mesh);const $=V<(t?4:6)?n?Tc[V%Tc.length].map(R=>new D(...R)):P:r[V%r.length];d.push({...K,path:$,speed:.8+V%4*.09,offset:V*4.9,reaction:null,phase:"walking",color:u[V%u.length],kind:null})}const A=n?Sr.map((V,K)=>{const ce=Ep(c,u[(K+2)%u.length]);return ce.anger.traverse($=>{$.isMesh&&($.material=p)}),ce.mesh.name=`Balcony resident ${K+1}`,a.add(ce.mesh),{...ce,site:V,path:V.route.map($=>new D(...$))}}):[],T=Array.from({length:t?6:9},(V,K)=>{const ce=zT(l);return ce.root.name=`Flying bird ${K+1}`,a.add(ce.root),ce}),I=new Oe,k=new D(0,0,1);let F=0,L=0,O=null,H=!1,W=!0,q=null;function Z(V=!0){const K=n?.state,ce=K&&K.status!=="idle",$=ce?`${K.run}:${K.seed}:${K.wave}`:null;$!==q&&(d.forEach((R,z)=>{R.reaction=null;const Y=K?.targets[z];R.challengeRoute=Y&&K.version>1?Om(Y).map(ie=>new D(...ie)):w(Y?.lane||0)}),q=$),d.forEach((R,z)=>{let Y=Qa(R.path,L,R.speed,R.offset);const ie=ce?K.targets[z]:null,re=ie?.kind||null,ge=re==="chair";if(R.kind!==re){R.kind=re;const Ye=new ze(re?Rr[re].color:R.color),{color:U,skinIndex:pe}=R.mesh.geometry.attributes;for(let Ve=0;Ve<U.count;Ve++)[1,9,10].includes(pe.getX(Ve))&&U.setXYZ(Ve,Ye.r,Ye.g,Ye.b);U.needsUpdate=!0;const Ce=.96+z%3*.035;R.mesh.scale.set(re==="sturdy"?Ce*1.5:Ce,re==="sturdy"?Ce*1.08:Ce,re==="sturdy"?Ce*1.4:Ce)}R.chair.visible=ge,ie&&(Y={...Rp(R.challengeRoute,ie.progress)||{position:R.challengeRoute.at(-1),yaw:0},walking:ie.status==="active"},re==="balcony"&&(Y.yaw=Math.atan2(Sr[ie.balcony].outward[0],Sr[ie.balcony].outward[2]),Y.walking=!1));const Fe=R.reaction;if(R.phase="walking",Fe){const Ye=F-Fe.start;if(Ye<(Fe.partial?.56:Ap))R.phase="complaining",Y={position:Fe.position,yaw:Fe.yaw,walking:!1};else if(Fe.partial)R.reaction=null;else{const U=Rp(Fe.path,(Ye-Ap)*(re==="balcony"?1.25:OT));if(U)R.phase="running",Y={...U,walking:!0};else if(R.phase="away",Fe.awayAt??=F,F-Fe.awayAt>=FT){R.reaction=null,R.phase="walking";const pe=R.path.slice(1).reduce((Ce,Ve,_e)=>Ce+Ve.distanceTo(R.path[_e]),0)/R.speed;R.offset=(Fe.path.at(-1).equals(R.path.at(-1))?pe:0)-L,Y=Qa(R.path,L,R.speed,R.offset)}}}const Ie=R.phase==="complaining",He=R.phase==="running";R.mesh.visible=R.phase!=="away"&&(ce?!!(ie&&!["waiting","escaped"].includes(ie.status)&&(ie.status!=="tagged"||R.reaction)):z<E),R.mesh.position.copy(Y.position),R.mesh.rotation.y=Y.yaw,R.spine.rotation.x=He?.2:Ie?-.15:re==="balcony"?.08:0,R.head.rotation.x=Ie?-.65:0,R.anger.visible=Ie,R.stain.visible=!!R.reaction;const je=F*(He?17:8.4)+z*1.7,Ke=Y.walking&&V?1:0;R.pelvis.position.y=(ge?.59:.88)+Math.abs(Math.sin(je))*.018*Ke;for(let Ye=0;Ye<2;Ye++){const U=Math.sin(je+Ye*Math.PI)*Ke;R.hips[Ye].rotation.x=ge?-1.3:U*(He?.85:.37),R.knees[Ye].rotation.x=ge?1.5:Math.max(0,-U)*(He?1.15:.52),R.ankles[Ye].rotation.x=-R.hips[Ye].rotation.x-R.knees[Ye].rotation.x,R.shoulders[Ye].rotation.x=Ie?-2.2+(V?Math.sin(je*.7+Ye)*.3:0):-U*(He?.8:.29),R.shoulders[Ye].rotation.z=Ie?(Ye?1:-1)*.3:0,R.elbows[Ye].rotation.x=Ie?-1.1:He?-1.25:re==="balcony"?-.8:-.18}R.mesh.updateMatrixWorld(!0),I.makeTranslation(Y.position.x,Y.position.y+.012,Y.position.z),R.mesh.visible||I.scale(new D(0,0,0)),x.setMatrixAt(z,I)}),x.instanceMatrix.needsUpdate=!0;for(const[R,z]of A.entries()){if(z.mesh.visible=!ce,!z.mesh.visible)continue;const Y=Qa(z.path,L,.1,9+R*7);z.mesh.position.copy(Y.position),z.mesh.rotation.y=Math.atan2(z.site.outward[0],z.site.outward[2]),z.spine.rotation.x=.08,z.head.rotation.y=V?Math.sin(L*.3+R)*.3:0;for(let ie=0;ie<2;ie++)z.shoulders[ie].rotation.x=-.3,z.elbows[ie].rotation.x=-.85;z.mesh.updateMatrixWorld(!0)}T.forEach((R,z)=>{const Y=Math.floor(z/3)*.29+z%3*.014,ie=(L/(46+z%3*3)+Y)%1,re=o.getPointAt(ie),ge=o.getTangentAt(ie).normalize();re.y+=Math.sin(L*.7+z)*.35+z%3*.4,R.root.position.copy(re),R.root.quaternion.setFromUnitVectors(k,ge),R.root.rotateZ(Math.sin(L*.4+z)*.1);const Fe=.5+.5*Math.sin(L*.85+z);
4629R.wings.forEach((Ie,He)=>{Ie.rotation.z=(He?-1:1)*(.18+Math.sin(L*8.5+z)*.62*Fe)}),R.root.updateMatrixWorld(!0)})}return Z(),{update(V,K,ce=!0){W=ce;const $=O===null?0:V-O;return K&&H&&$>=0&&$<250&&(F+=$/1e3,ce&&(L+=$/1e3),n?.update($/1e3)),O=V,H=K,K&&Z(ce),K&&(ce||n?.active||d.some(R=>R.reaction))},aim(V,K=0,ce=!0){let $=null;for(const[R,z]of d.entries()){if(!z.mesh.visible||z.phase!=="walking")continue;const Y=z.mesh.position.clone().add(new D(0,1,0)),ie=Y.clone().sub(V.origin).dot(V.direction);if(ie<0||V.distanceSqToPoint(Y)>.7**2||$&&ie>=$.distance)continue;const re=Qa(z.path,L+(ce?K:0),z.speed,z.offset);$={index:R,distance:ie,point:re.position.add(new D(0,1,0))}}return $},intersect(V,K){let ce=null;const $=n?.state;for(const[R,z]of d.entries()){if(!z.mesh.visible||z.phase!=="walking"&&!z.reaction?.partial||$&&$.status!=="idle"&&$.targets[R]?.status!=="active")continue;const Y=z.mesh.position,ie=z.kind==="sturdy"?.52:z.kind==="chair"?.5:.38,re=z.kind==="chair"?1.5:z.kind==="sturdy"?1.92:1.8,ge=new ct(new D(Y.x-ie,Y.y-.06,Y.z-ie),new D(Y.x+ie,Y.y+re,Y.z+ie)),Fe=ge.containsPoint(V.origin)?V.origin.clone():V.intersectBox(ge,new D);if(!Fe)continue;const Ie=Fe.distanceTo(V.origin);Ie<=K&&(!ce||Ie<ce.distance)&&(ce={index:R,point:Fe,distance:Ie,precision:Fe.y-Y.y>re-.35})}return ce},hit(V,K,ce=!1){const $=d[V];if(!$)throw new Error("Unknown pedestrian");if($.phase!=="walking"&&!$.reaction?.partial)return!1;const R=$.mesh.position.clone(),z=n?.state.targets[V]?.balcony;return $.reaction={start:F,position:R,yaw:Math.atan2(K.x-R.x,K.z-R.z),path:z!==void 0?[R.clone(),new D(...Sr[z].retreat)]:kT(n?.active?$.challengeRoute:$.path,R,K),partial:ce},Z(W),!0},get seconds(){return F},get state(){return{running:H,seconds:F,people:d.map(V=>V.mesh.position.toArray()),birds:T.map(V=>V.root.position.toArray()),balconies:A.map(V=>({position:V.mesh.position.toArray(),visible:V.mesh.visible})),reactions:d.map((V,K)=>({index:K,phase:V.phase,position:V.mesh.position.toArray(),complaint:Cp[K%Cp.length],reactedAt:V.reaction?.start??-1}))}},dispose(){const V=new Set;a.traverse(K=>{K.isMesh&&(V.add(K.geometry),K.skeleton?.dispose())});for(const K of V)K.dispose();c.dispose(),l.dispose(),m.dispose(),p.dispose(),g.dispose(),_.dispose(),v.dispose(),a.removeFromParent()}}}const md=9.81,HT=5,GT=.45;function WT(s){let e,t;if(s.traverse(c=>{c.isMesh&&(c.userData.surfaceKind==="glass"&&(e=c),c.userData.surfaceKind==="reading-prop"&&(t=c))}),!e||!t)throw new Error("The sliding window assembly is incomplete");s.updateWorldMatrix(!0,!0);const n=new ct().setFromObject(e),i=n.getCenter(new D),r=e.matrixWorld.clone().invert(),o=new D;e.geometry=e.geometry.clone();const a=e.geometry.attributes.position;for(let c=0;c<a.count;c++)o.fromBufferAttribute(a,c).applyMatrix4(e.matrixWorld),o.z=i.z+(o.z-n.min.z)*.5,o.applyMatrix4(r),a.setXYZ(c,o.x,o.y,o.z);return a.needsUpdate=!0,e.geometry.computeBoundingBox(),e.geometry.computeBoundingSphere(),e.geometry.boundsTree?.refit(),e.material=e.material.clone(),Object.assign(e.material,{transparent:!0,opacity:.28,depthWrite:!1,side:Tt}),e.material.color.set("#b7d5e0"),t.visible=!1,new ct(new D(i.x-.02,n.min.y+.055,n.min.z+.055),new D(i.x+.02,n.max.y-.32,i.z-.055))}function km(s,e){if(s.direction.x>=-.08)return null;const t=(e.min.x-s.origin.x)/s.direction.x;if(t<0||t>2)return null;const n=Math.max(0,(e.max.x-s.origin.x)/s.direction.x);for(const i of[n,t]){const r=s.at(i,new D);if(r.y<e.min.y||r.y>e.max.y||r.z<e.min.z||r.z>e.max.z)return null}return s.at(t+.12,new D)}function XT(s,e){return e.distanceToPoint(s.origin)<=.65&&s.direction.y<-.15&&km(s,e)!==null}function qT(s,e){return s.at(Math.max(.35,(e.min.x-.12-s.origin.x)/s.direction.x),new D)}function Pp(s,e){if(!Number.isFinite(e)||e<0||e>1)throw new Error("Throw power must be between zero and one");return s.clone().normalize().multiplyScalar(9+e*25)}function Lp(s,e,t,n=[0,0,0]){return s.clone().addScaledVector(e,t).addScaledVector(new D(n[0],n[1]-md,n[2]),t*t/2)}function jT(s,e,t,n=null){const i=new Kt;i.name="Thrown eggs and yolk splats",s.add(i);const r=new Cn(1,10,8),o=r.attributes.position;for(let L=0;L<o.count;L++){const O=o.getY(L);o.setXYZ(L,o.getX(L)*.045*(1-O*.17),O*.064,o.getZ(L)*.045*(1-O*.17))}r.computeVertexNormals();const a=new Un({color:"#fff6dc",roughness:.48,toneMapped:!1}),c=new nn({color:"#ffbd22",transparent:!0,opacity:.95,depthWrite:!1,side:Tt}),l=new nn({color:"#fff8df",transparent:!0,opacity:.85,depthWrite:!1,side:Tt}),d=new Wo(1,14),u=[],h=[],f=[],m=new Oc;m.firstHitOnly=!0;const x=new Si;let p=e.seconds,g=-1/0,y=0,_=0,v=null;const M=new Kt;M.name="Charged ballistic trajectory";const w=new Cn(1,6,4),E=new nn({color:"#fff1b5",depthWrite:!1}),b=new Fd(w,E,65);b.frustumCulled=!1;const S=new Xd(.3,.39,24),P=new Qe(S,new nn({color:"#ffd45c",side:Tt,depthWrite:!1}));M.add(b,P),M.visible=!1,i.add(M);const A=new Oe;function T(L,O=140){return m.ray.copy(L),m.near=.01,m.far=O,m.intersectObjects(t,!1)[0]||null}function I(L,O){const H=e.intersect(L,O),W=T(L,O);if(H&&(!W||H.distance<=W.distance))return{...H,person:H.index,normal:new D(0,1,0)};if(!W)return null;const q=W.face.normal.clone().transformDirection(W.object.matrixWorld);return q.dot(L.direction)>0&&q.negate(),{point:W.point,distance:W.distance,person:null,normal:q}}function k(L,O,H){const W=Pp(L.direction,H),q=n?.state.wind||[0,0,0],Z=[O.clone()];for(let V=1;V<=64;V++){const K=Lp(O,W,V*.06,q),ce=Z.at(-1),$=new Si(ce,K.clone().sub(ce).normalize()),R=I($,ce.distanceTo(K));if(Z.push(R?R.point:K),R)return{...R,points:Z}}return{point:Z.at(-1),points:Z,person:null,normal:new D(0,1,0)}}function F(L,O,H,W){const q=new Kt;q.position.copy(L).addScaledVector(O,.025),q.quaternion.setFromUnitVectors(new D(0,0,1),O);const Z=new Qe(d,l),V=new Qe(d,c);Z.scale.set(.52,.34,1),V.scale.set(.21,.19,1),V.position.z=.012,q.add(Z,V);for(let K=0;K<6;K++){const ce=new Qe(d,K%2?c:l),$=K*2.4;ce.position.set(Math.cos($)*.4,Math.sin($)*.31,.008),ce.scale.setScalar(.08+K*.009),q.add(ce)}i.add(q),h.push({mesh:q,start:e.seconds,lifetime:H===null?7:.5}),h.length>16&&h.shift().mesh.removeFromParent();for(let K=0;W&&K<8;K++){const ce=new Qe(r,K%3?c:a);ce.scale.setScalar(.3),ce.position.copy(L),i.add(ce),f.push({mesh:ce,age:0,velocity:new D(Math.cos(K*2.4)*2,2+K*.14,Math.sin(K*2.4)*2)})}v={point:L.toArray(),person:H,serial:y}}return{trace:k,preview(L,O,H){const W=k(L,O,H),q=W.points.slice(1);return b.count=q.length,q.forEach((Z,V)=>{const K=.004+Z.distanceTo(O)*.0012;
4629A.makeScale(K,K,K),A.setPosition(Z),b.setMatrixAt(V,A)}),b.instanceMatrix.needsUpdate=!0,P.position.copy(W.point).addScaledVector(W.normal,.035),P.quaternion.setFromUnitVectors(new D(0,0,1),W.normal),P.material.color.set(W.person===null?"#ffd45c":"#95ffd7"),M.visible=!0,W},clearPreview(){M.visible=!1},throw(L,O,H=.5,W=!0){if(e.seconds-g<GT||u.length>=HT)return!1;const q=n?.fire(H);if(n&&!q)return!1;const Z=q?q.power:H,V=new Qe(r,a);return V.name="Flying egg",V.position.copy(O),i.add(V),u.push({mesh:V,velocity:Pp(L.direction,Z),source:L.origin.clone(),age:0,animate:W,shot:q?.id,wind:n?.state.wind||[0,0,0]}),g=e.seconds,y++,M.visible=!1,!0},update(L){const O=e.seconds-p;if(p=e.seconds,!L)return!1;for(let H=Math.min(O,.25);H>1e-5;){const W=Math.min(H,.016666666666666666);H-=W;for(let q=u.length-1;q>=0;q--){const Z=u[q],V=Z.mesh.position,K=Lp(V,Z.velocity,W,Z.wind);x.set(V,K.clone().sub(V).normalize());const ce=V.distanceTo(K),$=I(x,ce);if($){if($.person!==null){const R=n?.hit($.person,Z.shot,{long:$.point.distanceTo(Z.source)>38,precision:$.precision});(!n||R)&&e.hit($.person,Z.source,!!R&&!R.defeated)&&_++}else n?.miss(Z.shot);F($.point,$.normal,$.person,Z.animate)}else Z.mesh.position.copy(K),Z.velocity.addScaledVector(new D(Z.wind[0],Z.wind[1]-md,Z.wind[2]),W),Z.animate&&(Z.mesh.rotation.x+=W*10,Z.mesh.rotation.z+=W*7);Z.age+=W,($||Z.age>6)&&($||n?.miss(Z.shot),Z.mesh.removeFromParent(),u.splice(q,1))}}for(let H=f.length-1;H>=0;H--){const W=f[H];W.age+=O,W.mesh.position.addScaledVector(W.velocity,O),W.velocity.y-=md*O,W.age>.55&&(W.mesh.removeFromParent(),f.splice(H,1))}for(let H=h.length-1;H>=0;H--){const W=h[H],q=e.seconds-W.start;W.mesh.scale.setScalar(Math.max(0,Math.min(1,(W.lifetime-q)/.5))),q>=W.lifetime&&(W.mesh.removeFromParent(),h.splice(H,1))}return u.length>0||h.length>0||f.length>0},get state(){return{thrown:y,hits:_,flying:u.length,splats:h.length,lastImpact:v}},get seconds(){return e.seconds},clear(){for(const L of[...u,...h,...f])L.mesh.removeFromParent();u.length=h.length=f.length=0,M.visible=!1,y=_=0,g=-1/0,v=null,p=e.seconds},dispose(){i.removeFromParent(),r.dispose(),d.dispose(),a.dispose(),c.dispose(),l.dispose(),w.dispose(),S.dispose(),E.dispose(),P.material.dispose()}}}const lh=` 4630float exteriorHash(vec3 p) { 4631 p = fract(p * .1031); 4632 p += dot(p, p.yzx + 33.33); 4633 return fract((p.x + p.y) * p.z); 4634} 4635float exteriorNoise(vec3 p) { 4636 vec3 i = floor(p), f = fract(p); 4637 f = f * f * (3.0 - 2.0 * f); 4638 return mix(mix(mix(exteriorHash(i), exteriorHash(i+vec3(1,0,0)), f.x), 4639 mix(exteriorHash(i+vec3(0,1,0)), exteriorHash(i+vec3(1,1,0)), f.x), f.y), 4640 mix(mix(exteriorHash(i+vec3(0,0,1)), exteriorHash(i+vec3(1,0,1)), f.x), 4641 mix(exteriorHash(i+vec3(0,1,1)), exteriorHash(i+vec3(1,1,1)), f.x), f.y), f.z); 4642}`;function YT(s){const e=s.name.toLowerCase(),t=e.endsWith("glass")||e.endsWith("glass-blue"),n=e.endsWith("water"),i=/leaf|foliage|canopy|scrub|grass/.test(e),r=e.includes("canopy"),o=/sand|soil|road|path|paving|tile-/.test(e),a=e.endsWith("sand"),c=e.endsWith("stone")||e.endsWith("stone-light"),l=e.endsWith("frame"),d=new Un({name:s.name,color:s.color.clone(),roughness:t?.18:n?.14:l?.37:i?.94:.86,metalness:t?.35:n?.15:l?.72:0,envMapIntensity:t||n?.85:.28,side:Tt,toneMapped:!1,alphaTest:r?.35:0,alphaToCoverage:r}),u=i?1:o?2:c?3:0;return d.onBeforeCompile=h=>{h.vertexShader=`varying vec3 vExteriorWorld; 4643varying vec3 vExteriorNormal; 4644${h.vertexShader}`,h.vertexShader=h.vertexShader.replace("#include <worldpos_vertex>",` 4645 #include <worldpos_vertex> 4646 vExteriorWorld = (modelMatrix * vec4(transformed, 1.0)).xyz; 4647 vExteriorNormal = normalize(mat3(modelMatrix) * objectNormal); 4648 `),h.fragmentShader=`varying vec3 vExteriorWorld; 4649varying vec3 vExteriorNormal; 4650${lh} 4651${h.fragmentShader}`;const f=u===1?"float grain = mix(.73, 1.11, exteriorNoise(vExteriorWorld * 1.8));":u===2?"float grain = mix(.82, 1.08, exteriorNoise(vExteriorWorld * 3.5)) * mix(.94, 1.06, exteriorNoise(vExteriorWorld * .19));":"float grain = mix(.93, 1.04, exteriorNoise(vExteriorWorld * 8.0));";h.fragmentShader=h.fragmentShader.replace("#include <color_fragment>",` 4652 #include <color_fragment> 4653 ${f} 4654 diffuseColor.rgb *= grain; 4655 ${r?` 4656 float foliageEdge = abs(dot(normalize(vNormal), normalize(vViewPosition))); 4657 float leafDensity = exteriorNoise(vExteriorWorld * 8.0); 4658 diffuseColor.a *= smoothstep(.25 + .09 * (1.0 - foliageEdge), .52, leafDensity); 4659 `:""} 4660 ${a?` 4661 float cover = exteriorNoise(vExteriorWorld * .075) * .7 + exteriorNoise(vExteriorWorld * .19) * .3; 4662 float basin = smoothstep(175.0, 265.0, length(vExteriorWorld.xz - vec2(-1.05, 1.815))); 4663 float scrub = smoothstep(.46, .63, cover) * basin; 4664 diffuseColor.rgb = mix(diffuseColor.rgb, diffuseColor.rgb * vec3(.37, .47, .27), scrub * .85); 4665 `:""} 4666 ${c?` 4667 float row = vExteriorWorld.y / .30; 4668 float course = fract(row); 4669 float horizontal = abs(vExteriorNormal.x) > abs(vExteriorNormal.z) ? vExteriorWorld.z : vExteriorWorld.x; 4670 float joint = fract(horizontal / .9 + mod(floor(row), 2.0) * .5); 4671 float mortar = smoothstep(.005, .017, min(course, 1.0 - course)) 4672 * smoothstep(.002, .008, min(joint, 1.0 - joint)); 4673 diffuseColor.rgb *= mix(1.0, mix(.84, 1.0, mortar), 1.0 - smoothstep(.55, .85, abs(vExteriorNormal.y))); 4674 `:""} 4675 `)},d.customProgramCacheKey=()=>`exterior-pbr-1-${u}${a?"-sand":""}${r?"-canopy":""}`,d}function KT(s){return new pn({name:"Procedural exterior sky and clouds",uniforms:{center:{value:s},horizon:{value:new ze("#bbd5e4")},zenith:{value:new ze("#3c84bc")},cloud:{value:new ze("#f8f6ef")},ground:{value:new ze("#afa487")},clock:{value:0}},side:Tt,depthWrite:!1,vertexShader:` 4676 varying vec3 vSkyWorld; 4677 void main() {
4678 vec4 world = modelMatrix * vec4(position, 1.0); 4679 vSkyWorld = world.xyz; 4680 gl_Position = projectionMatrix * viewMatrix * world; 4681 } 4682 `,fragmentShader:` 4683 uniform vec3 center; 4684 uniform vec3 horizon; 4685 uniform vec3 zenith; 4686 uniform vec3 cloud; 4687 uniform vec3 ground; 4688 uniform float clock; 4689 varying vec3 vSkyWorld; 4690 ${lh} 4691 void main() { 4692 vec3 direction = normalize(vSkyWorld - center); 4693 float h = max(direction.y, 0.0); 4694 vec3 color = mix(horizon, zenith, pow(clamp(h * 1.3, 0.0, 1.0), .6)); 4695 color = mix(color, ground, smoothstep(0.0, .5, -direction.y)); 4696 vec3 p = vec3(direction.xz / max(.24, h + .16) * 3.6 + vec2(clock * .002, clock * .0006), 2.4); 4697 float clouds = exteriorNoise(p) * .57 + exteriorNoise(p * 2.1) * .28 + exteriorNoise(p * 4.4) * .15; 4698 float mask = smoothstep(.64, .79, clouds) * smoothstep(.04, .18, h) * (1.0 - smoothstep(.65, .95, h)); 4699 color = mix(color, cloud * mix(.85, 1.0, exteriorNoise(p * 1.4)), mask * .92); 4700 gl_FragColor = vec4(color, 1.0); 4701 #include <colorspace_fragment> 4702 } 4703 `})}function ZT(s,e,t,n,i){const r=new yc;s.updateWorldMatrix(!0,!0),r.attach(s);const o=new Map,a=[],c=[];let l;s.traverse(y=>{if(!y.isMesh)return;if(y.userData.surfaceKind==="artwork"){const v=new ct().setFromObject(y);y.material=KT(v.getCenter(new D)),y.castShadow=y.receiveShadow=!1,y.renderOrder=-10,l=y;return}c.push(y);const _=v=>(o.has(v)||o.set(v,YT(v)),o.get(v));if(y.material=Array.isArray(y.material)?y.material.map(_):_(y.material),y.castShadow=!/dune|coastal.scrub|below_window|below window|own.building/i.test(y.name),y.receiveShadow=!0,!Array.isArray(y.material)&&y.material.name.includes("canopy")){const v=new lm({depthPacking:Lg,side:Tt});v.onBeforeCompile=M=>{M.vertexShader=`varying vec3 vLeafWorld; 4704${M.vertexShader}`,M.vertexShader=M.vertexShader.replace("#include <project_vertex>",` 4705 vLeafWorld = (modelMatrix * vec4(transformed, 1.0)).xyz; 4706 #include <project_vertex> 4707 `),M.fragmentShader=`varying vec3 vLeafWorld; 4708${lh} 4709${M.fragmentShader}`,M.fragmentShader=M.fragmentShader.replace("#include <alphatest_fragment>",` 4710 #include <alphatest_fragment> 4711 if (exteriorNoise(vLeafWorld * 8.0) < .35) discard; 4712 `)},v.customProgramCacheKey=()=>"exterior-leaf-depth-1",y.customDepthMaterial=v,a.push(v)}}),r.add(new Yd("#d8edff","#b79b72",.9));const d=new Zd("#fff3de",2.4);d.position.set(-12,115,115),d.target.position.set(-65,-27,10),d.castShadow=!0,d.shadow.mapSize.setScalar(t?1024:2048),Object.assign(d.shadow.camera,{left:-110,right:110,top:95,bottom:-95,near:1,far:400}),d.shadow.bias=-8e-5,d.shadow.normalBias=.09,d.shadow.camera.updateProjectionMatrix(),r.add(d,d.target),e.shadowMap.enabled=!0,e.shadowMap.type=So,e.shadowMap.autoUpdate=!1,e.shadowMap.needsUpdate=!0;let u,h;if(l&&e.extensions.has("EXT_color_buffer_float")){const y=new yc,_=new Qe(l.geometry,l.material);_.matrixAutoUpdate=!1,_.matrix.copy(l.matrixWorld),y.add(_);const v=new Ku(e);u=v.fromScene(y,0,.1,1e4),r.environment=u.texture,r.environmentIntensity=.28;for(const M of o.values())M.envMap=u.texture,M.needsUpdate=!0;h=v.fromScene(r,0,.2,1e4,{size:t?64:128,position:new D(-23,3,-6)});for(const M of o.values())/glass|water/.test(M.name)&&(M.envMap=h.texture,M.needsUpdate=!0);v.dispose()}const f=UT(),m=VT(s,n?.motion,t,f),x=m?jT(r,m,c,f):null,p=new Hr,g=new Oe;return e.shadowMap.needsUpdate=!0,{scene:r,root:s,eggs:x,challenge:f,visibleFrom(y){return g.multiplyMatrices(y.projectionMatrix,y.matrixWorldInverse),p.setFromProjectionMatrix(g),s.visible&&p.intersectsBox(i)},update(y,_,v=!0){const M=m?.update(y,_,v)||!1,w=x?.update(_)||!1;return l&&m&&v&&(l.material.uniforms.clock.value=m.seconds),M||w},get motionState(){return m?.state},dispose(){m?.dispose(),x?.dispose();for(const y of o.values())y.dispose();for(const y of a)y.dispose();l?.material.dispose(),d.shadow.dispose(),u?.dispose(),h?.dispose()}}}const JT=(s,e,t=10)=>s.left<e.right+t&&s.right>e.left-t&&s.top<e.bottom+t&&s.bottom>e.top-t;function QT(s,e,t=[]){const n=[...t],i=[];for(const r of s){const{x:o,y:a,width:c,height:l}=r,d=[[40,-l-40],[-c-40,-l-40],[-c/2,-l-44],[40,40],[-c-40,40]];for(const[u,h]of d){const f=Math.max(e.left+12,Math.min(o+u,e.right-c-12)),m=a+h,x={left:f,top:m,right:f+c,bottom:m+l};if(!(m<e.top+12||x.bottom>e.bottom-12||n.some(p=>
4712JT(x,p)))){i.push({...r,...x,tail:Math.max(14,Math.min(c-14,o-f)),below:h>0}),n.push(x);break}}if(i.length===2)break}return i}function $a(s,e,t){return Number.isInteger(s?.id)&&s.source===e&&s.id===t}function $T({camera:s,canvas:e,opening:t,game:n,challenge:i,hands:r,reactions:o,enabled:a,captured:c,obstructed:l,invalidate:d,notice:u,onStart:h,onDialog:f,onPause:m}){const x=U=>document.getElementById(U),p=x("egg-controls"),g=x("egg-game-hud"),y=x("egg-charge"),_=x("throw-egg"),v=x("egg-dialog"),M=x("egg-complaints"),w=new Oc,E=new xe,b=new Map,S=new Map;let P=null,A=-1/0,T=-1/0,I="idle",k=null,F=null,L=0,O=!1,H=!1,W=null;const q=()=>!matchMedia("(prefers-reduced-motion: reduce)").matches,Z=()=>document.body.dataset.touchControls==="true",V=()=>Z()?"Hold the throw button for power. Aim with another finger, then release the throw button. Survive ten waves.":"Hold mouse or G for power. Release to throw. Survive ten waves.",K=()=>a()&&!v.open&&t.distanceToPoint(s.position)<=1.65;function ce(){const U=R();return!!U?.ready&&XT(U.ray,t)}const $=()=>P?Math.round(Math.min(1,Math.max(0,(n.seconds-P.start)/1.3))*100)/100:0;function R(){if(!K())return null;s.updateMatrixWorld(),E.set(0,0),w.setFromCamera(E,s);const U=w.ray.clone();if(U.direction.x>=-.08)return null;const pe=km(U,t);return{ray:U,origin:pe,ready:!!pe&&!l(U,pe)}}function z(){P=null,W=null,n.clearPreview(),document.body.dataset.eggCharging="false",_.setAttribute("aria-pressed","false"),x("egg-charge-hint").textContent="HOLD FOR POWER",d()}function Y(U,pe=null){return P||!K()||i.state.status!=="wave"||i.state.ammo<1?!1:R()?.ready?(P={source:U,id:pe,start:n.seconds},_.setAttribute("aria-pressed","true"),document.body.dataset.eggCharging="true",d(),!0):(u("Move closer and aim through the open half, above the sill."),!1)}function ie(){if(!P)return!1;const U=$(),pe=R();return z(),!pe?.ready||i.state.status!=="wave"||(n.throw(pe.ray,pe.origin,U,q())&&(r.release(n.seconds),u(`Egg released at ${Math.round(U*100)} percent power.`),e.focus({preventScroll:!0})),d()),!0}async function re(U,pe={}){const Ce=await fetch(`/api/egg-game/${U}`,{...pe,signal:AbortSignal.timeout(1e4)}),Ve=await Ce.json();if(!Ce.ok)throw new Error(Ve.error||`Leaderboard request failed (${Ce.status})`);return Ve}function ge(U){if(!Array.isArray(U))throw new Error("Invalid leaderboard response");const pe=U.slice(0,10).map(Ce=>{const Ve=document.createElement("tr");for(const _e of[String(Ce.rank).padStart(2,"0"),Ce.name,Ce.score.toLocaleString(),String(Ce.wave)]){const B=document.createElement("td");B.textContent=_e,Ve.append(B)}return Ve});x("egg-board-rows").replaceChildren(...pe),x("egg-board-empty").hidden=U.length>0}async function Fe(){x("egg-board-status").textContent="Loading scores...";try{ge((await re("scores")).entries),x("egg-board-status").textContent="Community scores. Nicknames are public."}catch(U){x("egg-board-status").textContent=U.message}}async function Ie(){const U=++L;F=null,x("egg-accept").disabled=!0,x("egg-offline").hidden=!0,x("egg-retry-ticket").hidden=!0,x("egg-network").textContent="Connecting...";try{const pe=await re("runs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({version:Us})});if(U!==L||!v.open)return;if(typeof pe.token!="string"||!Number.isSafeInteger(pe.seed)||pe.version!==Us)throw new Error("Challenge update is deploying. Retry shortly.");F=pe,x("egg-accept").disabled=!1,x("egg-network").textContent=""}catch(pe){if(U!==L||!v.open)return;x("egg-network").textContent=`${pe.message} Retry, or play an unranked offline round.`,x("egg-offline").hidden=!1,x("egg-retry-ticket").hidden=!1}}function He(){z(),f(),x("egg-dialog-title").textContent="EGG DROP",x("egg-dialog-copy").textContent=V(),x("egg-rules").hidden=x("egg-start-controls").hidden=!1,x("egg-rules").open=v.querySelector(".egg-board").open=!1,x("egg-result").hidden=x("egg-score-form").hidden=x("egg-play-again").hidden=!0,v.open||v.showModal(),Ie(),Fe()}function je(U=!1){!U&&!F||(U&&(F=null),n.clear(),i.start(F?.seed??0,F?.version??Us),I="wave",O=!1,H=!1,v.close(),document.body.dataset.eggChallenge="true",e.focus({preventScroll:!0}),h(),u(Z()?"Challenge accepted. Hold the throw button, drag with another finger to aim, then release the throw button.":"Challenge accepted. Hold the mouse button or G for power, aim with the dotted arc, then release."),d())}function Ke(){z();const U=i.state;f(),x("egg-dialog-title").textContent=U.wave===dc&&U.reason.includes("cleared")?"ALL CLEAR":"RUN OVER",x("egg-dialog-copy").textContent=U.reason+".",x("egg-rules").hidden=x("egg-start-control
4712s").hidden=!0,x("egg-result").hidden=x("egg-play-again").hidden=!1,x("egg-final-score").textContent=U.score.toLocaleString(),x("egg-final-detail").textContent=`Wave ${U.wave} / ${dc} / ${U.hits}/${U.shots} hits / best streak ${U.bestCombo}`,x("egg-score-form").hidden=!F||!U.shots,x("egg-submit-score").disabled=!1,x("egg-network").textContent=F?"Add a nickname to submit this run. No account needed.":"Unranked offline round. This score cannot be posted.",v.querySelector(".egg-board").open=!1,v.open||v.showModal(),Fe()}x("egg-open-challenge").addEventListener("click",He),x("egg-accept").addEventListener("click",()=>je()),x("egg-offline").addEventListener("click",()=>je(!0)),x("egg-retry-ticket").addEventListener("click",Ie),x("egg-play-again").addEventListener("click",()=>{i.reset(),He()}),x("egg-close-dialog").addEventListener("click",()=>v.close()),x("egg-refresh-board").addEventListener("click",Fe),x("egg-pause").addEventListener("click",()=>{z(),m()}),x("egg-quit").addEventListener("click",()=>{z(),i.finish(),d()}),v.addEventListener("keydown",U=>{if(U.key==="Escape"){U.stopPropagation();return}if(!(U.target.closest("input, textarea, select")||U.ctrlKey||U.metaKey||U.altKey||U.repeat)){if(U.code==="KeyE")U.preventDefault(),U.stopPropagation(),i.state.status==="over"?(i.reset(),He()):F&&!x("egg-accept").disabled&&je();else if(U.code==="KeyB"){U.preventDefault();const pe=v.querySelector(".egg-board");pe.open=!pe.open}}}),v.addEventListener("close",()=>{L++,i.state.status==="over"&&(i.reset(),n.clear()),d()}),x("egg-score-form").addEventListener("submit",async U=>{if(U.preventDefault(),!F||O||H||i.state.status!=="over")return;const pe=F,Ce=i.state.run;H=!0,x("egg-submit-score").disabled=!0,x("egg-network").textContent="Posting your score...";try{const Ve=await re("scores",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:F.token,name:x("egg-nickname").value,replay:i.replay})});if(F!==pe||i.state.run!==Ce||!v.open)return;ge(Ve.entries),v.querySelector(".egg-board").open=!0,O=!0,x("egg-network").textContent=`Score posted: ${Ve.score.toLocaleString()}.`}catch(Ve){F===pe&&i.state.run===Ce&&v.open&&(x("egg-network").textContent=Ve.message)}finally{F===pe&&i.state.run===Ce&&(H=!1,x("egg-submit-score").disabled=O)}}),_.addEventListener("pointerdown",U=>{U.button===0&&(U.preventDefault(),Y("button",U.pointerId)&&_.setPointerCapture(U.pointerId))}),_.addEventListener("pointerup",U=>{$a(P,"button",U.pointerId)&&ie()});for(const U of["pointercancel","lostpointercapture"])_.addEventListener(U,pe=>{$a(P,"button",pe.pointerId)&&z()});_.addEventListener("keydown",U=>{["Space","Enter"].includes(U.code)&&(U.preventDefault(),U.repeat||Y("button-key"))}),_.addEventListener("keyup",U=>{["Space","Enter"].includes(U.code)&&P?.source==="button-key"&&(U.preventDefault(),ie())}),document.addEventListener("keydown",U=>{U.repeat||U.ctrlKey||U.metaKey||U.altKey||v.open||U.target.closest('input, textarea, select, [contenteditable="true"]')||(U.code==="KeyG"&&Y("key")&&U.preventDefault(),i.active&&a()&&U.code==="KeyP"&&(U.preventDefault(),z(),m()),i.active&&a()&&U.code==="KeyQ"&&(U.preventDefault(),z(),i.finish(),d()))}),document.addEventListener("keyup",U=>{U.code==="KeyG"&&P?.source==="key"&&ie()}),window.addEventListener("blur",z),document.addEventListener("visibilitychange",()=>{document.hidden&&z()});function Ye(U,pe){const Ce=new D(...U).add(new D(0,pe,0)),Ve=Ce.clone().project(s);if(Ve.z<-1||Ve.z>1||Math.abs(Ve.x)>.93||Math.abs(Ve.y)>.8||l(new Si(s.position.clone(),Ce.clone().sub(s.position).normalize()),Ce))return null;const _e=e.getBoundingClientRect();return{x:_e.left+(Ve.x+1)*_e.width/2,y:_e.top+(1-Ve.y)*_e.height/2}}return{cancelCharge:z,interact(){return i.state.status!=="idle"||!ce()?!1:(He(),!0)},pointerDown(U){return U.pointerType==="mouse"&&U.button===0&&c()&&Y("canvas",U.pointerId)},pointerUp(U){return $a(P,"canvas",U.pointerId)?ie():!1},pointerCancel(U){$a(P,"canvas",U.pointerId)&&z()},get simulationEnabled(){return K()},update(U){const pe=i.state;v.open&&!x("egg-rules").hidden&&x("egg-dialog-copy").textContent!==V()&&(x("egg-dialog-copy").textContent=V()),pe.status==="over"&&I!=="over"&&Ke(),I=pe.status,!K()&&P&&z(),k=R(),P&&!k?.ready&&z();const Ce=i.active&&K(),_e=(k?.ready?qT(k.ray,t):t.getCenter(new D)).project(s);if(p.hidden=pe.status!=="idle"||!ce()||_e.z<-1||_e.z>1,!p.hidden){const le=e.getBoundingClientRect();p.style.left=`${Ct.clamp(le.left+(_e.x+1)*le.width/2+Math.min(160,le.width*.23),108,innerWidth-108)}px`,p.style.top=`${Ct.clamp(le.top+(1-_e.y)*le.height/2,210,innerHeight-35)}px`}g.hidden=y.hidden=!Ce,document.body.dataset.eggChallenge=String(i.active||pe.status==="over");const B=$();if(r.update(n.seconds,B,Ce,s.aspect,!q(),pe.ammo),x("egg-power-fill").style.transform=`scaleX(${B})`,x("egg-power-value").textContent=`${Math.round(B*100)}%`,_.disabled=!Ce||pe.status!=="wave"||!k?.ready||pe.ammo<1,P&&k?.ready&&U-T>70){const le=n.preview(k.ray,k.origin,B);W=le.person,document.body.dataset.eggAim=le.person!==null?"person":"ready",T=U}else P||(n.clearPreview(),document.body.dataset.eggAim="ready");if(U-A<80)return;
4712A=U,x("egg-live-score").textContent=pe.score.toLocaleString().padStart(5,"0"),x("egg-wave").textContent=`${pe.wave}/${dc}`,x("egg-ammo").textContent=pe.ammo,x("egg-lives").textContent=pe.lives,x("egg-combo").textContent=pe.combo>=2?`${pe.multiplier}x / ${pe.combo} IN A ROW`:F?"":"OFFLINE",x("egg-wave-notice").textContent=pe.status==="break"?`WAVE CLEAR. NEXT WAVE IN ${pe.countdown}`:`${pe.remaining} TO GO${pe.wave>=3?` / BREEZE ${pe.wind[2]<0?"<":">"} ${Math.abs(pe.wind[2]).toFixed(1)}`:""}`,x("egg-wave-notice").hidden=pe.status!=="break",x("egg-charge-hint").textContent=k?.ready?pe.ammo===0?"Out of eggs!":P?"RELEASE TO THROW":"HOLD FOR POWER":"Clear the glass and sill";const C=pe.lastPoints,X=x("egg-points");X.hidden=!Ce||pe.status==="break"||!C||pe.tick-C.tick>100,C&&(x("egg-points-value").textContent=`+${C.points}`,x("egg-points-label").textContent=C.text);const se=new Set,oe=new Set,te=[];if(Ce)for(const le of o().sort((ae,ue)=>ue.reactedAt-ae.reactedAt)){const ae=pe.targets[le.index];if(le.phase==="complaining"){const ue=Ye(le.position,2.3);if(ue){let me=b.get(le.index);me||(me=document.createElement("div"),me.className="egg-complaint",M.append(me),b.set(le.index,me)),me.textContent=ae?.hp>0?"Hey! Not again!":le.complaint,me.hidden=!1,te.push({...ue,id:le.index,bubble:me,width:me.offsetWidth,height:me.offsetHeight})}}
4712else if(le.index===W&&ae?.status==="active"&&["sturdy","chair"].includes(ae.kind)){const ue=Ye(le.position,ae.kind==="chair"?1.7:2.1);if(ue){let me=S.get(le.index);me||(me=document.createElement("div"),me.className="egg-target-badge",M.append(me),S.set(le.index,me)),me.textContent=ae.kind==="sturdy"?`${ae.hp} EGGS`:`BONUS ${Rr.chair.points}`,me.hidden=!1,te.push({...ue,id:le.index,bubble:me,badge:!0,width:me.offsetWidth,height:me.offsetHeight})}}}const we=e.getBoundingClientRect(),fe=[g,X,y,x("egg-wave-notice"),x("egg-combo"),x("open-room-menu")].filter(le=>!le.hidden&&le.getBoundingClientRect().width).map(le=>le.getBoundingClientRect());fe.push({left:we.left+we.width/2-28,right:we.left+we.width/2+28,top:we.top+we.height/2-28,bottom:we.top+we.height/2+28});const ke=QT(te,we,fe);for(const le of te)le.bubble.hidden=!0;for(const le of ke)le.bubble.hidden=!1,le.bubble.style.left=`${le.left}px`,le.bubble.style.top=`${le.top}px`,le.bubble.style.setProperty("--tail-x",`${le.tail}px`),le.bubble.dataset.below=String(le.below),(le.badge?oe:se).add(le.id);for(const[le,ae]of b)se.has(le)||(ae.remove(),b.delete(le));for(const[le,ae]of S)oe.has(le)||(ae.remove(),S.delete(le))},get state(){return{visible:!p.hidden||!g.hidden,ready:!!k?.ready,charging:!!P,power:$(),...n.state,challenge:i.state,ranked:!!F}}}}function eu(s,e){const t=[],n=[];for(const[o,a,c,l]of s)for(let d=0;d<20;d++){const u=d/20*Math.PI*2;t.push(Math.cos(u)*a,o,l+Math.sin(u)*c)}for(let o=0;o<s.length-1;o++)for(let a=0;a<20;a++){const c=o*20+a,l=o*20+(a+1)%20;n.push(c,c+20,l,l,c+20,l+20)}const r=new vt;return r.setAttribute("position",new rt(t,3)),r.setIndex(n),r.computeVertexNormals(),new Qe(r,e)}function eE(){const s=new yc;s.visible=!1;const e=new ln(50,1,.01,5);s.add(new Yd("#fff7ea","#637887",1.3));const t=new Zd("#fff2db",1.15);t.position.set(-1.5,2,1),s.add(t);const n=new qn({color:"#be8a6b",roughness:.63,sheen:.12,sheenColor:"#d9a686"}),i=new Un({color:"#293f50",roughness:.96}),r=new Un({color:"#243541",roughness:.94}),o=new qn({color:"#ddbaa7",roughness:.48}),a=new Un({color:"#a6755c",roughness:.82}),c=new Un({color:"#f4e4c6",roughness:.58}),l=new Kt;l.scale.setScalar(.86),s.add(l),l.add(eu([[-.46,.064,.053,.14],[-.35,.06,.047,.1],[-.22,.047,.038,.055],[-.13,.036,.029,.02],[-.115,.035,.028,.012]],i)),l.add(eu([[-.13,.037,.03,.02],[-.118,.037,.03,.014],[-.111,.034,.027,.011]],r)),l.add(eu([[-.128,.03,.025,.014],[-.095,.028,.023,.008],[-.067,.033,.024,.004],[-.035,.041,.026,0],[-.005,.043,.023,-.003],[.022,.04,.018,-.004],[.039,.034,.013,-.007],[.045,.003,.002,-.01]],n));function d(p,g,y,_=l){const v=new Wd(p.map(S=>new D(...S))),M=new jd(v,20,g,10,!1),w=M.attributes.position;for(let S=0;S<=20;S++){const P=v.getPointAt(S/20),A=1.05-S/20*.27;for(let T=0;T<=10;T++){const I=S*11+T,k=new D().fromBufferAttribute(w,I).sub(P).multiplyScalar(A).add(P);w.setXYZ(I,k.x,k.y,k.z)}}M.computeVertexNormals();const E=new Qe(M,y);_.add(E);const b=new Qe(new Cn(g*.78,12,8),y);return b.position.copy(v.getPoint(1)),_.add(b),E}const u=[];for(const[p,g]of[-.03,-.009,.013,.033].entries()){const y=new Kt,_=p===3?.8:p===1?1.05:1;y.position.set(g,.025+(p===3?-.01:0),-.008),l.add(y),d([[0,-.005,.002],[0,.018*_,0],[0,.034*_,-.019],[0,.035*_,-.045],[0,.017*_,-.064],[0,.002,-.065]],p===3?.009:.0108,n,y),d([[-.007,.02*_,.007],[0,.023*_,.01],[.007,.02*_,.007]],55e-5,a,y);const v=new Qe(new Cn(1,10,6),o);v.scale.set(.0065,.009,.001),v.position.set(0,.003,-.072),y.add(v),u.push(y)}d([[-.032,-.053,.002],[-.05,-.029,-.005],[-.058,-.002,-.025],[-.049,.024,-.049],[-.031,.039,-.06]],.016,n);const h=new Qe(new Cn(1,12,8),o);h.scale.set(.008,.011,.0014),h.position.set(-.034,.045,-.051),h.rotation.set(.5,-.4,-.75),l.add(h);for(const p of[-.021,0,.021])d([[p*.7,-.067,.026],[p,-.026,.023],[p,.009,.017]],65e-5,n);const f=new Qe(new Cn(1,20,16),c),m=f.geometry.attributes.position;for(let p=0;p<m.count;p++){const g=m.getY(p);m.setXYZ(p,m.getX(p)*.03*(1-g*.15),g*.043,m.getZ(p)*.029*(1-g*.15))}f.geometry.computeVertexNormals(),f.position.set(-.006,.055,-.049),f.rotation.z=-.12,l.add(f);let x=-1/0;return{scene:s,camera:e,release(p){x=p},update(p,g,y,_,v,M){if(s.visible=y,!y)return!1;e.aspect=_,e.updateProjectionMatrix();const w=p-x,E=w>=0&&w<.65,b=E&&!v?Math.sin(Math.min(1,w/.36)*Math.PI):0;l.position.set(Math.min(.3,_*.19)-b*.075,-.235+g*.022+b*.06,-.57-b*.15+g*.035),l.rotation.set(.12-g*.22-b*.85,-.55+g*.12,-.22+g*.1);for(const[S,P]of u.entries())P.rotation.x=-b*.75,P.rotation.z=b*(S-1.5)*.1;return f.visible=M>0&&(!E||w>.4),E},dispose(){s.traverse(p=>{p.isMesh&&p.geometry.dispose()}),n.dispose(),i.dispose(),r.dispose(),o.dispose(),a.dispose(),c.dispose()}}}const yn=document.querySelector("#room"),Rn=document.querySelector("#link-menu"),tE=document.querySelector("#links-toggle"),ss=document.querySelector("#object-label"),nE=document.querySelector("#interaction-hint"),Lo=document.querySelector("#screen-links"),Xo=document.querySelector("#focus-info"),_i=document.querySelector("#controls-help");for(const[s,e]of[["screen-section","X"],["screen-terminal","T"]])document.getElementById(s).dataset.shortcut=e,document.getElementById(s).setAttribute("aria-keyshortcuts",e);const Vr=document.querySelector("#pause-overlay"),Bm=xT(),fi=$w({width:innerWidth,coarsePointer:matchMedia("(any-pointer: coarse)").matches,deviceMemory:navigator.deviceMemory}),ec=new yc,hc=new Oc;hc.firstHitOnly=!0;const Ip=new xe,Io=new Map,Is=new Map,bo=[],zm=[],Vm=[],Hm=[],Cs=new Set,iE={ceiling:new Set(["Ceiling light"]),front:new Set(["Craft display shelf","Bamboo plant and pot ornament","Miniature coffee shop","Candle holder and ribbon","Flower vase","Craft sign","Small shelf ornaments","Panda ornament","Round shelf artwork","Monitor - craft desk","Wall AC remote","Wall light switch"]),right:new Set(["Storage c
4712abinets","Wall equipment bag","Air conditioner","Door frame and hardware","Door leaf","Doorway view-only vestibule"]),left:new Set(["Window and shutter","Window curtains and rod","Window view","Bookshelf","Framed photograph","Retro sign","Handheld console","Teddy bear","Blue shelf cloth","Shelf figurine","Trailing plant","Conference badges"])},Gm={entry:"look",walk:"look",window:"look",home:"orbit",desk:"look",music:"look",monitor:"inspect",cv:"inspect",songbook:"inspect",books:"inspect",phone:"inspect",piano:"piano"},Do=new Set(["entry","walk","window","desk","music"]),Pr=new Set(["monitor","cv","songbook","books","phone","piano"]),Ns=s=>s==="monitor"&&document.body.dataset.touchControls==="true"?"look":Gm[s];let en,at,Se,Xe,is,pt,Mo,tu,Ec,Lr,Jt,No,un,_n,Xi,Fn,ki,mi,zi,_r,Dp=!1,Np=-1/0,Uo=null,Vi=0,wt=!1,Mt=!1,Ge="entry",Up="entry",Op=0,Dn,Ac;function wn(s){nE.textContent=s}function qo(){ss.hidden=!0,ki?.hide(),Rn.open=!1,_i.open=!1}function fc(){wt&&(Mt=!0,zi?.cancelCharge(),document.body.dataset.paused="true",Vr.hidden=!1,un?.stop(),Xi?.stop(),_n?.setPaused(!0),Fn?.setPaused(!0),qo(),Jt?.resetStick(),Cs.clear(),Dn=null,Se.setPaused(!0),document.querySelector("#resume-room").focus({preventScroll:!0}),wn("Room paused. Explore the links or return to the room."),Yt())}function Yr(s=!1){Mt=!1,document.body.dataset.paused="false",Vr.hidden=!0,Se?.setPaused(!1),_n?.setPaused(!1),Fn?.setPaused(!1),s&&wt&&(en.domElement.focus({preventScroll:!0}),Se.mode==="look"&&!Jt?.menuOpen&&document.body.dataset.touchControls!=="true"&&Se.captureLook()),wt&&dh(),Yt()}document.querySelector("#resume-room").addEventListener("click",()=>Yr(!0));Vr.addEventListener("click",s=>{s.target===Vr&&Yr(!0)});function Wm(s,e=!1){const t=sn[s],n=document.createElement("a");n.href=t.href,n.dataset.link=s,t.href.startsWith("mailto:")||(n.target="_blank",n.rel="noopener noreferrer");const i=document.createElement("img"),r=document.createElement("span");i.src=`/icons/${s}.svg`,i.alt="",i.className="platform-icon";const o=document.createElement("span"),a=document.createElement("small");return o.className="pause-link-name",o.textContent=t.label+" â",a.textContent=t.detail,r.className="pause-link-copy",r.append(o),e||r.append(a),n.append(i,r),n}document.querySelector("#pause-professional").replaceChildren(...["github","linkedin","microsoft","medium"].map(s=>Wm(s)));document.querySelector("#pause-social").replaceChildren(...["youtube","instagram","whatsapp"].map(s=>Wm(s,!0)));document.querySelector("#pause-email").href=sn.email.href;document.querySelector("#pause-cv").href=sn.cv.href;document.querySelector("#pause-legacy").href=sn.stackoverflow.href;document.querySelectorAll("#link-menu a[data-link], #pause-overlay a[data-link]").forEach(s=>{const e=Nm.indexOf(s.dataset.link);e>=0&&(s.dataset.shortcut=e,s.setAttribute("aria-keyshortcuts",String(e)))});document.querySelectorAll("#destination-nav button[data-view]").forEach(s=>{const e=Dm.indexOf(s.dataset.view)+1;s.querySelector("span").textContent=e,s.setAttribute("aria-keyshortcuts",String(e))});document.querySelectorAll("[data-copy-email]").forEach(s=>{s.addEventListener("click",async()=>{const e=sn.email.detail,t=()=>{let n=s.parentElement.querySelector(".email-copy-fallback");n||(n=document.createElement("input"),n.className="email-copy-fallback",n.value=e,n.readOnly=!0,n.setAttribute("aria-label","Email address. Select and copy."),s.after(n)),n.focus(),n.select(),s.textContent="Select and copy the address below"};if(!navigator.clipboard?.writeText){t();return}try{await navigator.clipboard.writeText(e),s.textContent="Email address copied",s.setAttribute("aria-live","polite")}catch(n){console.info("Clipboard permission unavailable:",n.message),t()}})});function Xm(){Jt?.menuOpen&&Jt.setMenu(!1,!1),un?.stop(),Xi?.stop(),Se?.stop(),Se?.unlock(),Rn.open=!0,Rn.querySelector("a").focus()}document.querySelector("#error-links").addEventListener("click",Xm);document.querySelector("#retry").addEventListener("click",()=>location.reload());document.addEventListener("pointerdown",s=>{Rn.open&&!Rn.contains(s.target)&&(Rn.open=!1)});Rn.addEventListener("toggle",()=>{Rn.open&&(Se?.stop(),Se?.unlock(),un?.stop(),Xi?.stop())});_i.addEventListener("toggle",()=>{_i.open&&(Se?.stop(),Se?.unlock())});
4712document.querySelector(".identity").addEventListener("click",s=>{s.ctrlKey||s.metaKey||s.shiftKey||s.altKey||(s.preventDefault(),Tn("entry"))});document.querySelectorAll("button[data-view]").forEach(s=>{s.addEventListener("click",e=>{Tn(s.dataset.view,!1,!!s.closest("#room-menu")),en?.domElement.focus({preventScroll:!0}),Ns(s.dataset.view)==="look"&&!Jt?.menuOpen&&e.detail>0&&e.pointerType!=="touch"&&matchMedia("(pointer: fine)").matches&&Se?.captureLook()})});document.querySelector("#zoom-in").addEventListener("click",()=>Se?.zoom(1.25));document.querySelector("#zoom-out").addEventListener("click",()=>Se?.zoom(1/1.25));document.querySelector("#mouse-look").addEventListener("click",()=>Se?.toggleLock());document.querySelector("#cv-fit").addEventListener("click",()=>Tn("cv"));document.querySelector("#cv-closer").addEventListener("click",()=>Se?.zoom(1.7));document.querySelector("#screen-section").addEventListener("click",()=>{Yo(pt.section==="main"?"legacy":"main")});document.querySelector("#screen-terminal").addEventListener("click",()=>Yo("terminal"));document.addEventListener("keydown",s=>{if(_r?.open||s.key!=="Escape"||s.repeat)return;if(s.preventDefault(),Rn.open){Rn.open=!1,en?.domElement.focus({preventScroll:!0});return}if(_i.open){_i.open=!1,en?.domElement.focus({preventScroll:!0});return}if(Jt?.menuOpen){Jt.setMenu(!1);return}if(!wt){qo(),tE.focus();return}Se.unlock();const e=Mt;Mt&&Yr(),Pr.has(Ge)?Cc():e||fc()});document.addEventListener("keydown",s=>{if(!wt||Mt||Ge==="piano"||s.ctrlKey||s.metaKey||s.altKey||s.target.closest('input, select, textarea, a, summary, [contenteditable="true"]'))return;const e=["KeyW","KeyA","KeyS","KeyD","Space","KeyC"].includes(s.code);s.code==="Space"&&s.target.closest("button")||(e?(Cc(),Se.keyDown(s),!s.repeat&&!Jt?.menuOpen&&document.body.dataset.touchControls!=="true"&&Se.captureLook()):Se.mode==="look"&&s.code.startsWith("Arrow")&&Se.keyDown(s))});function jo(s){const e=Object.entries(sn).find(([,n])=>n.href===s.href);e&&us(e[0]);const t=document.createElement("a");t.href=s.href,s.href.startsWith("mailto:")||(t.target="_blank",t.rel="noopener noreferrer"),t.click()}function uh(){const s=pt.section==="terminal"&&pt.open&&Ge==="monitor";if(No?.visible(s),document.body.dataset.screenSection=pt.section,document.body.dataset.screenWindow=pt.open?"open":"closed",s){Lo.hidden=!0;return}const e=Rm.monitor.sections.find(t=>t.id===pt.section);if(!e){Lo.hidden=!0;return}document.querySelector("#screen-actions").replaceChildren(...e.links.map(t=>{const n=document.createElement("a");return n.href=t.href,n.target="_blank",n.rel="noopener noreferrer",n.textContent=t.label,n.setAttribute("aria-label",`${t.label} profile (opens in a new tab)`),n})),document.querySelector("#screen-location").textContent=pt.section==="main"?"Active profiles":"Legacy mode",document.querySelector("#screen-section").textContent=pt.section==="main"?"Open legacy/":"Active profiles",document.body.dataset.screenSection=pt.section,document.body.dataset.screenWindow=pt.open?"open":"closed",Lo.hidden=!["monitor","desk"].includes(Ge)||!pt.open}function Yo(s){(s==="legacy"||s==="terminal")&&us("app_"+s),pt.section=s,pt.open=!0,pt.draw(),uh()}function nu(s){Bm.finish(),Yr(),console.error("Workspace could not load:",s),wt=!1,document.body.dataset.modelState="error",document.querySelector("#load-notice").hidden=!0,document.querySelector("#error-notice").hidden=!1,document.querySelector("#error-message").textContent="The 3D room is unavailable. Every profile and the CV email request still work in Links.",wn("The room is offline. The links are not."),document.querySelectorAll("button[data-view], #zoom-in, #zoom-out, #mouse-look").forEach(e=>{e.disabled=!0}),Lo.hidden=!0,Xo.hidden=!0,un?.stop(),Se?.disable(),Vi&&cancelAnimationFrame(Vi),Vi=0}function Hi(s){return new ct(new D(...s.min),new D(...s.max))}function sE(s){const e=[];for(const t of[s.min.x,s.max.x])for(const n of[s.min.y,s.max.y])for(const i of[s.min.z,s.max.z])e.push(new D(t,n,i));return e}function qm(){const s=new ct;return Xe.assets.filter(e=>
4712e.interaction==="books").forEach(e=>s.union(Hi(e.bounds))),s}function tc(s,e,t,n){const i=s.getCenter(new D);e.normalize();const r=document.querySelector("#room-menu"),o=innerWidth>900&&Pr.has(Ge)?r.hidden?Xo.hidden?0:Xo.getBoundingClientRect().width+50:r.getBoundingClientRect().width+40:0,a=at.aspect*(1-o/yn.clientWidth),c=new kn().setFromRotationMatrix(new Oe().lookAt(e,new D,at.up)).invert(),l=Math.tan(Ct.degToRad(t/2));let d=.1;for(const u of sE(s)){const h=u.sub(i).applyQuaternion(c);d=Math.max(d,h.z+Math.abs(h.x)*n/(l*a),h.z+Math.abs(h.y)*n/l)}return i.addScaledVector(new D().crossVectors(at.up,e).normalize(),o/yn.clientWidth*d*l*at.aspect),{position:i.clone().addScaledVector(e,d).toArray(),target:i.toArray(),fov:t}}function Fs(s){const e=_n?.state.offset||0;if(s==="window")return{position:[-.79,hd,1.6],target:[-23,-26.7,8],fov:65,standing:!0};if(s==="walk")return Ac||Fs("entry");if(s==="entry"){const n=Xe.viewpoints.entry,i=at.aspect>n.referenceAspect?Ct.radToDeg(2*Math.atan(Math.tan(Ct.degToRad(n.fov/2))*n.referenceAspect/at.aspect)):n.fov,r=hd+Xe.roomBounds.min[1]-n.position[1];return{...n,position:n.position.map((o,a)=>o+(a===1?r:0)),target:n.target.map((o,a)=>o+(a===1?r:0)),fov:i,zoom:fd}}if(s==="desk"||s==="music"){const n=Xe.viewpoints[s],i=s==="desk"?e:0;return{...n,position:n.position.map((r,o)=>r+(o===1?i:0)),target:n.target.map((r,o)=>r+(o===1?i:0)),standing:s==="desk"&&i>.1,fov:innerWidth<=760?78:68}}if(s==="monitor"){const n=Xe.cameraPresets.monitor;return{...n,position:n.position.map((i,r)=>i+(r===1?e:0)),target:n.target.map((i,r)=>i+(r===1?e:0)),fov:innerWidth<=760?70:53}}if(s==="piano"){const n=Hi(Xe.piano.bounds);if(innerWidth<=760){const i=un?.state.baseMidi||60,r=Xe.piano.keys.filter(o=>o.midi>=i&&o.midi<=i+17);n.min.x=Math.min(...r.map(o=>o.bounds.min[0])),n.max.x=Math.max(...r.map(o=>o.bounds.max[0]))}return tc(n,new D(0,.65,1),50,1.2)}if(s==="cv"||s==="songbook"||s==="phone"){const n=Xe.reading[s],i=Hi(n.bounds);return s!=="songbook"&&i.translate(new D(0,e,0)),tc(i,new D(...n.position).sub(new D(...n.target)),42,1.3)}if(s==="books")return tc(qm(),new D(.9,.15,.3),45,1.4);const t=Xe.cameraPresets.home;return tc(Ec,new D(...t.position).sub(new D(...t.target)),34,.98)}function Fp(){!en||!at||(Lr.resize(yn.clientWidth,Math.max(1,yn.clientHeight)),at.aspect=yn.clientWidth/Math.max(1,yn.clientHeight),at.updateProjectionMatrix(),wt&&Ge==="entry"&&Se.mode==="look"&&(at.fov=Fs("entry").fov,at.updateProjectionMatrix()),wt&&Se.mode!=="look"&&(Se.go(Fs(Ge),Ns(Ge),!0),Mt&&Se.setPaused(!0)),Yt())}function dh(){const s=document.body.dataset.touchControls==="true";if(Mt)return wn("Room paused. Explore the links or return to the room.");if(Se?.locked)return wn("WASD move. Space jump. C crouch. E interact. During Egg Drop, hold G or the mouse button for throw power. Esc pauses.");if(Ge==="cv")return wn("The full CV is private. Use the email link to request it.");if(Ge==="songbook")return wn(s?"Tap a bar or Play tune. Use the page buttons to change tunes; the movement stick stands up.":"Play a bar in the jazz book, or listen to a whole tune. Arrow keys turn pages. Esc stands up.");if(Ge==="piano")return wn(s?"Tap or slide across the keys. Use Sustain, the octave buttons and Back.":"Play the keys. A-W-S-E... plays notes; Space sustains. Esc stops playing and stands up.");if(Se?.mode==="inspect")return wn(s?"Drag to pan. Pinch to get closer. Use the movement stick to stand up.":"Drag to pan. Scroll or pinch to get closer. Move or press Esc to stand up.");if(Se?.mode==="look")return wn(s?"Left thumb moves. Drag to look. Tap an object to interact.":"Click to capture mouse. WASD move. Space jump. C crouch. E interact.");wn(s?"Drag to orbit. Pinch to zoom and move.":"Drag to orbit. Scroll to zoom. Right-drag to pan. V returns to your seat.")}function Tn(s,e=!1,t=!1){if(wt){if(!Gm[s])throw new Error(`Unknown room view: ${s}`);Mt&&Yr(),un?.stop(),Xi?.stop(),e||us("view_"+s),qo(),s!==Ge&&(Pr.has(s)||s==="home")&&(Do.has(Ge)&&(Se.finish(),Ac=Ym()),Pr.has(s)&&(Up=!t&&Do.has(Ge)?Ge:["songbook","piano"].includes(s)?"music":"desk",(t||!Do.has(Ge))&&(Ac=Fs(U
4712p)))),Ge=s,document.body.dataset.view=s,document.body.dataset.cameraMode=Ns(s),document.querySelectorAll("button[data-view]").forEach(n=>n.setAttribute("aria-pressed",String(n.dataset.view===s))),document.querySelector("#mode-label").textContent={entry:"Entrance",walk:"Standing",window:"Window",home:"Overview",desk:"Desk",music:"Piano seat",monitor:"Monitor",cv:"CV",songbook:"Music",books:"Writing",phone:"Phone",piano:"Playing piano"}[s],document.querySelector("#escape-hint").textContent=Pr.has(s)?"BACK":"PAUSE",document.querySelector("#mouse-look").hidden=Ns(s)!=="look",document.querySelectorAll("[data-panel]").forEach(n=>{n.hidden=n.dataset.panel!==s}),Xo.hidden=!["cv","songbook","books","phone"].includes(s),document.querySelector("#piano-controls").hidden=s!=="piano",pt.open=s==="monitor",pt.section="main",pt.draw(),uh(),Se.go(Fs(s),Ns(s),e),Jt?.viewChanged(),jm(),en.domElement.setAttribute("aria-label",Ns(s)==="look"?document.body.dataset.touchControls==="true"?"First-person room. Drag to look around and tap objects to interact. The bottom-left movement stick stands up and moves. The Places side drawer moves you to destinations.":"First-person room. Click to capture the mouse, then move it freely to look. WASD moves, Space jumps, hold C to crouch, E interacts. The side drawer moves you to places.":s==="cv"?"Blurred CV teaser on the desk. Use the email link to request the full CV.":s==="songbook"?document.body.dataset.touchControls==="true"?"Interactive jazz book. Tap a bar or Play tune, use the page buttons to change tunes, and use the movement stick to stand up.":"Interactive jazz book with original lead sheets. Click a bar to play it, Enter plays or stops the tune, arrow keys change pages, and Escape stands up.":s==="piano"?document.body.dataset.touchControls==="true"?"Playable 88-key piano. Tap or slide across the keys. Use the Sustain and octave buttons. Tap Back to finish.":"Playable 88-key piano. Click or touch the keys, or use A W S E D F T G Y H U J K O L P semicolon and apostrophe. Space sustains; Z and X change octave. Escape stops playing and stands up.":"3D room. Drag to orbit, scroll or pinch to zoom, right-drag to pan. Move with WASD or the joystick to leave inspection. The side drawer contains every destination."),dh(),s==="cv"&&(document.body.dataset.cvDetail="ready"),s==="piano"&&un.prepare()}}function jm(s=!1){const e=document.querySelector("#room-menu").hidden?document.querySelector("#workspace"):document.querySelector("#object-controls-slot");for(const t of[Xo,Lo])t.parentElement!==e&&e.append(t);s&&wt&&["inspect","piano"].includes(Se.mode)&&Se.go(Fs(Ge),Ns(Ge),!0)}function Ym(){const s=at.getWorldDirection(new D);return{position:at.position.toArray(),target:at.position.clone().add(s).toArray(),fov:at.fov,zoom:at.zoom}}function Cc(){!wt||Mt||(Ge!=="walk"&&(Do.has(Ge)&&(Se.finish(),Ac=Ym()),Tn("walk",!0)),Se.stand(),en.domElement.focus({preventScroll:!0}))}function Km(){const s=Ec.containsPoint(at.position);document.body.dataset.insideRoom=String(s);const e=at.position.clone().sub(Se.target),t=i=>s||(i==="ceiling"?!1:i==="front"?e.z<.1:i==="back"?e.z>-.1:i==="right"?e.x<.1:i==="left"?e.x>-.1:!0);for(const i of zm)i.visible=t(i.userData.cutawaySide);for(const i of Vm)i.object.visible=t(i.side);const n=Is.get("asset-window-view");n&&(n.visible=s);for(const i of[Xe.viewpoints.desk,Xe.viewpoints.music]){const r=Is.get(i.seatAssetId);r.visible=!(Se.mode==="look"&&at.position.distanceTo(new D(...i.position))<.32)}}function rE(s,e=yn.getBoundingClientRect()){at.updateMatrixWorld();const t=s.clone().project(at);return{x:e.left+(t.x+1)/2*e.width,y:e.top+(1-t.y)/2*e.height,z:t.z}}function oE(){const s=(n,i=.08)=>{const r=Io.get(n);if(!r)throw new Error(`Hint asset is missing: ${n}`);
4712return Hi(r.bounds).getCenter(new D).add(new D(0,i,0))},e=[["monitor","01","Profiles",Hi(Xe.screen.bounds).getCenter(new D).add(new D(0,.21,.02))],["cv","02","Request my CV",new D(...Xe.reading.cv.target).add(new D(0,.025,0))],["songbook","03","Music book",new D(...Xe.reading.songbook.target).add(new D(0,.18,.035))],["books","04","Writing",qm().getCenter(new D).add(new D(.12,.09,0))],["phone","05","WhatsApp",new D(...Xe.reading.phone.target).add(new D(0,.04,0))],["piano","06","Play piano",Hi(Xe.piano.bounds).getCenter(new D).add(new D(0,.05,.02))],["desk","10","Desk seat",s(Xe.viewpoints.desk.seatAssetId,.24)],["music","11","Piano seat",s(Xe.viewpoints.music.seatAssetId,.2)],["songbook","12","Ibanez JEM / music",s("asset-ibanez-jem-7v")],["songbook","13","Frankenstrat / music",s("asset-electric-guitar-and-hangers")]];Xe.desk&&(e.push(["desk-height","07","Raise / lower desk",s(Xe.desk.panelAssetId),()=>_n.toggleDesk()]),Xe.tubeLights.forEach((n,i)=>{e.push([`light-${n.id}`,String(i+8).padStart(2,"0"),`${n.label} color`,s(n.assetId),()=>{Jt.setMenu(!0),_n.focusLight(n.assetId)}])})),Fn&&e.push(["cockroach","14","Cockroach",Fn.position,()=>Fn.trigger()]),e.sort((n,i)=>n[1].localeCompare(i[1]));const t=document.querySelector("#world-markers");for(const[n,i,r,o,a]of e){const c=document.createElement("button");c.className="world-marker",c.dataset.destination=n,c.setAttribute("aria-label",a?r:`${r}: move closer`);const l=document.createElement("span");l.className="marker-number",l.textContent=i;const d=document.createElement("span");d.className="marker-title",d.textContent=r,c.append(l,d),c.addEventListener("click",()=>{a?a():(Tn(n),en.domElement.focus({preventScroll:!0}))}),t.append(c),Hm.push({point:o,button:c,desk:["monitor","cv","phone","desk-height"].includes(n),roach:n==="cockroach"})}}function aE(){if(document.body.dataset.guides!=="true")return;const s=yn.getBoundingClientRect();for(const{point:e,button:t,desk:n,roach:i}of Hm){const r=rE(i?Fn.position:n?e.clone().add(new D(0,_n?.state.offset||0,0)):e,s);t.hidden=i&&["burst","gone"].includes(Fn.state.phase)||Mt||document.body.dataset.guides!=="true"||Se.transitioning||!["look","orbit"].includes(Se.mode)||r.z<-1||r.z>1||r.x<20||r.x>
4712innerWidth-20||r.y<142||r.y>innerHeight-130,t.style.left=`${Ct.clamp(r.x,75,innerWidth-75)}px`,t.style.top=`${r.y}px`}}function Yt(){!Vi&&en&&!document.hidden&&document.body.dataset.modelState!=="error"&&(Vi=requestAnimationFrame(cE))}function cE(s){if(Vi=0,document.hidden)return;const e=!Mt&&_n?.update(s),t=!Mt&&Fn?.update(s);e&&!_n.state.moving&&_n.state.standing&&Ge==="desk"&&Se.stand();const n=Se?.update(s)||e||t;at.updateMatrixWorld();let i=!1;if(wt){Km();const r=mi?.visibleFrom(at)||!1;if(Lr.setExteriorVisible(r),i=mi?.update(s,!Mt&&Ge!=="home"&&r&&(!mi.challenge.active||zi?.simulationEnabled),!matchMedia("(prefers-reduced-motion: reduce)").matches)||!1,aE(),Jt?.update(s,n),zi?.update(s),Mt||Jt?.menuOpen||Rn.open||_i.open||!ah(Ge))ki?.hide();else{if((Se.locked||n&&Uo)&&s-Np>=120){Np=s;const o=yn.getBoundingClientRect(),a=Se.locked?ds(o.left+o.width/2,o.top+o.height/2,Mr):ds(Uo.x,Uo.y);ch(a)?ki?.show(a):ki?.leave()}ki?.update()}}if(i&&!n&&s-Op<1e3/30-.5){Yt();return}Lr.draw(s,n||i||Se?.moving,i&&!n?1e3/30:16.7),Op=s,(n||i)&&Yt()}function Zm(s){for(let e=s;e;e=e.parent){const t=Io.get(e.userData.assetId);if(t)return t}}function as(s){for(let e=s;e;e=e.parent)if(e.userData.surfaceKind)return e.userData.surfaceKind}function ds(s,e,t=1/0){if(!wt)return null;const n=yn.getBoundingClientRect();at.updateMatrixWorld(),Km(),Ip.set((s-n.left)/n.width*2-1,1-(e-n.top)/n.height*2),hc.setFromCamera(Ip,at),hc.far=t;const i=bo.filter(o=>{for(let a=o;a;a=a.parent)if(!a.visible)return!1;return as(o)!=="glass"}),r=hc.intersectObjects(i,!1)[0];return r?{...r,asset:Zm(r.object)}:null}function Oo(s){return Vc[s?.asset?.name]?ah(Ge)&&ch(s)?"guitar-video":null:s?.asset?.id===Xe.viewpoints.desk.seatAssetId?Ge==="desk"&&Se.seated?null:"desk":s?.asset?.id===Xe.viewpoints.music.seatAssetId?Ge==="music"&&Se.seated?null:"music":s?.asset?.id===Xe.reading.songbook.assetId?"songbook":{monitor:"monitor",cv:"cv",music:"songbook",books:"books",whatsapp:"phone",piano:"piano","desk-height":"desk-height","light-color":"light-color",cockroach:"cockroach"}[s?.asset?.interaction]}function gd(s){const e=Oo(s);if(!(!e||Mt||Se.transitioning)){if(e==="guitar-video"){ki?.show(s);return}if(e==="desk-height"){_n.toggleDesk();return}if(e==="light-color"){Jt.setMenu(!0),_n.focusLight(s.asset.id);return}if(e==="cockroach"){Fn.trigger();return}if(e==="songbook"&&Ge==="songbook"){as(s.object)==="songbook"&&s.uv&&Xi.hit(s.uv);return}if(s.asset.id===Xe.viewpoints.desk.seatAssetId||s.asset.id===Xe.viewpoints.music.seatAssetId){Tn(e);return}if(e==="monitor"){if(s.object===Mo&&s.uv&&["monitor","desk"].includes(Ge)){const t=pt.hit(s.uv);t?.type==="link"&&jo(t.link),t?.type==="section"&&(Ge!=="monitor"&&Tn("monitor"),Yo(t.section)),(t?.type==="terminal-input"||!t&&pt.section==="terminal"&&pt.open)&&No.focus(),t?.type==="close"&&(pt.open=!1,pt.draw(),uh()),!t&&!pt.open&&Tn("monitor");return}Tn("monitor")}else if(["cv","songbook","phone"].includes(e)&&Ge===e){const t=Xe.reading[e].linkRegion;as(s.object)===e&&s.uv&&s.uv.x>=t.min[0]&&s.uv.x<=t.max[0]&&s.uv.y>=t.min[1]&&s.uv.y<=t.max[1]&&jo({cv:sn.cv,songbook:sn.youtube,phone:sn.whatsapp}[e])}else e!==Ge&&Tn(e)}}function lE(s){s.addEventListener("pointerdown",t=>{if(!Mt){if(wt&&zi?.pointerDown(t)){Dn=null;return}if(wt&&Ge==="piano"){un.pointerDown(t);return}if(wt&&t.button===0&&t.pointerType==="mouse"&&Se.mode==="look"&&!Se.locked&&!Jt?.menuOpen){s.focus({preventScroll:!0});const n=["cockroach","guitar-video"].includes(Oo(ds(t.clientX,t.clientY,Mr)));Dn={x:t.clientX,y:t.clientY,id:t.pointerId,dragged:!1,capture:!n};return}if(Cs.add(t.pointerId),Cs.size>1){Dn=null;return}t.button===0&&(Dn={x:t.clientX,y:t.clientY,id:t.pointerId,dragged:!1})}}),s.addEventListener("pointermove",t=>{if(t.pointerType!=="touch"&&(Uo={x:t.clientX,y:t.clientY}),Mt){ss.hidden=!0;return}if(wt&&Ge==="piano"){un.pointerMove(t);return}if(Dn&&Math.hypot(t.clientX-Dn.x,t.clientY-Dn.y)>7&&(Dn.dragged=!0),t.pointerType==="touch"||Cs.size||!wt||Se.locked||Se.transitioning){ss.hidden=!0;return}const n=ds(t.clientX,t.clientY),i=Oo(n);ah(Ge)&&ki?.show(n),s.style.cursor=i?"pointer":Se.mode==="look"?"default":"grab",ss.hidden=!i||i==="guitar-video"||document.body.dataset.guides!=="true",i&&(ss.textContent={monitor:"Use the monitor",cv:"Request my CV",music:"Sit at the piano",songbook:Ge==="songbook"?"Play a bar from the jazz book":"Open the jazz book",books:"Explore the writing shelf",desk:"Sit at the desk",phone:"Open WhatsApp on the iPhone",piano:"Play the piano","desk-height":_n?.state.standing?"Lower the standing desk":"Raise the standing desk","light-color":"Choose this tube light's color",cockroach:"Startle the cockroach","guitar-video":`Watch ${Vc[n.asset.name].label} on YouTube`}[i],ss.style.left=`${Math.min(t.clientX+16,innerWidth-225)}
4712px`,ss.style.top=`${Math.min(t.clientY+18,innerHeight-55)}px`)}),s.addEventListener("pointerup",t=>{if(Mt||zi?.pointerUp(t))return;if(wt&&Ge==="piano"){un.pointerUp(t);return}const n=Dn;if(Cs.delete(t.pointerId),Dn=null,!n||n.id!==t.pointerId||n.dragged||t.button!==0||Cs.size||t.altKey||!wt)return;if(n.capture){Se.toggleLock();return}const i=yn.getBoundingClientRect(),r=Se.locked?i.left+i.width/2:t.clientX,o=Se.locked?i.top+i.height/2:t.clientY,a=ds(r,o);Oo(a)&&gd(a)});const e=t=>{zi?.pointerCancel(t),un?.pointerUp(t),Cs.delete(t.pointerId),Dn?.id===t.pointerId&&(Dn=null)};s.addEventListener("pointercancel",e),s.addEventListener("lostpointercapture",e),s.addEventListener("pointerleave",()=>{ss.hidden=!0,Uo=null,Se?.locked||ki?.leave()}),s.addEventListener("keydown",t=>{if(!(!wt||Mt||t.ctrlKey||t.metaKey||t.altKey)){if(Ge==="piano"){un.keyDown(t);return}if(t.key==="Enter")if(t.preventDefault(),Ge==="cv")jo(sn.cv);else if(Ge==="songbook")Xi.play();else if(Ge==="phone")jo(sn.whatsapp);else if(Se.mode==="look"){const n=yn.getBoundingClientRect();gd(ds(n.left+n.width/2,n.top+n.height/2))}else Tn("desk")}})}function uE(s){const e=a=>Array.isArray(a)&&a.length===3&&a.every(Number.isFinite),t=a=>e(a?.min)&&e(a?.max)&&a.min.every((c,l)=>c<=a.max[l]),n=a=>e(a?.position)&&e(a?.target)&&a.position.some((c,l)=>c!==a.target[l]);if(s?.schema!==1||s.privacyVersion!==2||s.axes!=="gltf_y_up"||typeof s.version!="string"||!s.version||!t(s.roomBounds)||!t(s.screen?.bounds)||s.screen.uvOrigin!=="top-left"||!["home","monitor","music"].every(a=>n(s.cameraPresets?.[a]))||!["desk","music"].every(a=>n(s.viewpoints?.[a])&&Number.isFinite(s.viewpoints[a].fov)&&s.viewpoints[a].fov>=25&&s.viewpoints[a].fov<=90)||!n(s.viewpoints?.entry)||!Number.isFinite(s.viewpoints.entry.fov)||s.viewpoints.entry.fov<=0||s.viewpoints.entry.fov>=150||!Number.isFinite(s.viewpoints.entry.referenceAspect)||s.viewpoints.entry.referenceAspect<=0||!["cv","songbook","phone"].every(a=>n(s.reading?.[a])&&t(s.reading[a].bounds)&&s.reading[a].uvOrigin==="top-left")||!Array.isArray(s.assets)||!s.assets.every(a=>typeof a?.id=="string"&&a.id&&t(a.bounds))||new Set(s.assets.map(a=>a.id)).size!==s.assets.length||!["monitor","music","cv","books","whatsapp","piano"].every(a=>s.assets.some(c=>c.interaction===a)))throw new Error("The room manifest is incomplete or incompatible.");if(!t(s.piano?.bounds)||!Array.isArray(s.piano?.keys)||s.piano.keys.length!==88||s.piano.keys.some((a,c)=>a.midi!==21+c||!t(a.bounds)||a.black!==[1,3,6,8,10].includes(a.midi%12))||!s.assets.some(a=>a.id===s.piano.assetId&&a.interaction==="piano"))throw new Error("The 88-key piano map is invalid.");const i=s.reading.songbook.linkRegion;if(![i?.min,i?.max].every(a=>Array.isArray(a)&&a.length===2&&a.every(c=>Number.isFinite(c)&&c>=0&&c<=1))||i.min.some((a,c)=>a>=i.max[c]))throw new Error("The music-book link region is invalid.");if(s.reading.cv.textureUrl!=="/images/cv-request.png")throw new Error("Only the sanitized CV teaser may be loaded.");const r=s.reading.cv.linkRegion;if(![r?.min,r?.max].every(a=>Array.isArray(a)&&a.length===2&&a.every(c=>Number.isFinite(c)&&c>=0&&c<=1))||r.min.some((a,c)=>a>=r.max[c]))throw new Error("The CV request link region is invalid.");const o=s.reading.phone.linkRegion;if(![o?.min,o?.max].every(a=>Array.isArray(a)&&a.length===2&&a.every(c=>Number.isFinite(c)&&c>=0&&c<=1))||o.min.some((a,c)=>a>=o.max[c]))throw new Error("The phone link region is invalid.");for(const a of[s.viewpoints.desk,s.viewpoints.music])if(!s.assets.some(c=>c.id===a.seatAssetId))throw new Error("A seat is missing from the room.");for(const[a,c]of[["cv","cv"],["songbook","music"],["phone","whatsapp"]])if(!s.assets.some(l=>l.id===s.reading[a].assetId&&l.interaction===c))throw new Error("A reading surface has no matching asset.");if(s.desk){const a=s.desk;if(!["assetId","liftAssetId","middleAssetId","panelAssetId","cableAssetId"].every(c=>s.assets.some(l=>l.id===a[c]))||!t(a.footprint)||!Number.isFinite(a.travel)||a.travel<=0||a.travel>.65||!Number.isFinite(a.sittingHeight)||!Number.isFinite(a.standingHeight)||Math.abs(a.standingHeight-a.sittingHeight-a.travel)>
4712.001)throw new Error("The standing desk metadata is invalid.");if(!Array.isArray(s.tubeLights)||s.tubeLights.length!==2||new Set(s.tubeLights.map(c=>c.id)).size!==2||s.tubeLights.some(c=>!/^#[0-9a-f]{6}$/i.test(c.color)||!s.assets.some(l=>l.id===c.assetId&&l.interaction==="light-color")))throw new Error("The individual tube-light controls are incomplete.")}for(const a of[s.modelUrl,s.screen.textureUrl,s.reading.cv.textureUrl,s.reading.songbook.textureUrl,s.reading.phone.textureUrl])if(typeof a!="string"||new URL(a,location.origin).origin!==location.origin)throw new Error("Room assets must be served locally.");if(new URL(s.modelUrl,location.origin).pathname!=="/models/room.glb")throw new Error("Only the independent room.glb export is supported.")}async function dE(){const s=new pS;try{en=new IM({antialias:!0,alpha:!0,logarithmicDepthBuffer:!0,powerPreference:fi?"low-power":"high-performance"}),en.outputColorSpace=At,en.toneMapping=ti,ec.add(new Yd("#ffffff","#9b9488",1.8));const e=en.domElement;e.tabIndex=0,e.addEventListener("webglcontextlost",u=>{u.preventDefault(),nu(new Error("The WebGL context was lost."))}),yn.append(e),at=new ln(34,1,.012,220),at.position.set(5,5,7),Lr=uT(en,ec,at,Yt,fi),Se=Kw(at,e,Yt,qo,(u,h=!1)=>{document.body.dataset.mouseLocked=String(u),document.querySelector("#mouse-look").setAttribute("aria-pressed",String(u)),document.querySelector("#mouse-look").textContent=u?"Release mouse":"Mouse look",Jt?.locked(u),!u&&h&&wt&&!Mt&&(Pr.has(Ge)?Cc():fc()),dh(),Yt()},wn),lE(e),Fp(),new ResizeObserver(Fp).observe(yn);const t=await fetch("/models/room-manifest.json",{cache:"no-cache",signal:AbortSignal.timeout(2e4)});if(!t.ok)throw new Error(`Room manifest: HTTP ${t.status}`);Xe=await t.json(),uE(Xe),Number.isFinite(Xe.exterior?.cameraFar)&&(at.far=Math.max(220,Math.min(1e4,Xe.exterior.cameraFar)),at.updateProjectionMatrix());for(const u of Xe.assets)Io.set(u.id,u);if(Io.get(Xe.screen.assetId)?.interaction!=="monitor")throw new Error("The screen is not associated with the monitor asset.");const n=eT(Xe,fi);document.body.dataset.resourceProfile=n.profile,document.body.dataset.resourceVersion=n.version;const i=new URL(n.url,location.origin);i.searchParams.set("v",n.version),s.setDecoderPath("/draco/"),s.setWorkerLimit(fi?1:2);const r=new NM;r.setDRACOLoader(s);const o=setTimeout(()=>nu(new Error("Loading the room timed out.")),9e4);let a;try{a=await r.loadAsync(i.href,u=>{const h=u.total||n.bytes;h&&(document.querySelector("#load-message").textContent=`Opening the room... ${Math.min(99,Math.round(u.loaded/h*100))}%`)}),s.dispose(),pt=await Tw(Xe.screen.textureUrl,Yt,fi)}finally{clearTimeout(o)}if(document.body.dataset.modelState==="error")return;is=a.scene;let c=0;if(is.traverse(u=>{u.userData.cutawaySide&&zm.push(u);const h=u.userData.assetName;if(h){Is.set(u.userData.assetId,u);for(const[x,p]of Object.entries(iE))(p.has(h)||x==="left"&&h.startsWith("Book - "))&&Vm.push({object:u,side:x})}if(!u.isMesh)return;bo.push(u),u.geometry.index?.count>1500&&(u.geometry.boundsTree||yw.call(u.geometry,{indirect:!0}),u.raycast=gw);const f=as(u),m=Array.isArray(u.material)?u.material:[u.material];if(m.forEach(x=>{if(x.toneMapped=!1,x.map&&(x.map.anisotropy=Math.min(fi?4:16,en.capabilities.getMaxAnisotropy())),fi)for(const p of Object.values(x))p?.isTexture&&(p.generateMipmaps=!0,p.minFilter=vi)}),f==="curtain"&&m.forEach(x=>{x.transparent=!0,x.opacity=Math.min(x.opacity,.82),x.depthWrite=!1,x.side=Tt}),f==="fabric"&&m.forEach(x=>{x.opacity=1,x.alphaTest=0,x.alphaToCoverage=!1,x.transparent=!0,x.depthWrite=!1,x.side=Tt,x.needsUpdate=!0}),f==="screen"){if(Mo||!u.geometry.attributes.uv)throw new Error("The main screen is duplicated or has no UV coordinates.");Mo=u,pt.texture.anisotropy=Math.min(fi?2:8,en.capabilities.getMaxAnisotropy()),u.material=new nn({map:pt.texture,toneMapped:!1,side:Tt})}if(f==="cv"){if(tu||!u.geometry.attributes.uv||Array.isArray(u.material))throw new Error("The readable CV surface is invalid.");tu=u}f==="songbook"&&c++}),!Mo||!tu||!c||Is.size!==Xe.assets.length)throw new Error("The room is missing an independent asset or reading surface.");if(Zm(Mo)?.id!==Xe.screen.assetId)throw new Error("The exported screen does not match the monitor asset.");ec.add(is),is.updateMatrixWorld(!0),ki=RT({roots:Is,camera:at,mount:yn,invalidate:Yt,onOpen:()=>{Se.unlock(),us("youtube")}});const l=Is.get("asset-window-view");if(l){const u=WT(Is.get("asset-window-and-shutter"));if(mi=ZT(l,en,fi,Xe.exterior,Hi(Io.get("asset-window-and-shutter").bounds)),Lr.setExterior(mi.scene),mi.eggs){const h=eE();Lr.setOverlay(h);const f=bo.filter(x=>as(x)!=="glass"&&as(x)!=="artwork"),m=new Oc;m.firstHitOnly=!0,zi=$T({camera:at,canvas:e,opening:u,game:mi.eggs,challenge:mi.challenge,hands:h,reactions:()=>mi.motionState.reactions,captured:()=>Se.locked,onStart:()=>
4712{document.body.dataset.touchControls!=="true"&&Se.captureLook()},onDialog:()=>{Se.stop(),Se.unlock()},onPause:fc,enabled:()=>wt&&!Mt&&!document.hidden&&Se.mode==="look"&&!Se.transitioning&&mi.root.visible&&!Jt?.menuOpen&&!Rn.open&&!_i.open&&Do.has(Ge),obstructed(x,p){m.ray.copy(x),m.far=Math.max(0,x.origin.distanceTo(p)-.03);const g=f.filter(y=>{for(let _=y;_;_=_.parent)if(!_.visible)return!1;return!0});return m.intersectObjects(g,!1).length>0},invalidate:Yt,notice:wn})}}ec.traverse(u=>{u.updateMatrix(),u.matrixAutoUpdate=!1}),Ec=Hi(Xe.roomBounds);const d=new Set(["Main sit-stand desk","Craft desktop","Craft cupboard","Storage cabinets","Drawer cabinet - left","Drawer cabinet - right","Digital piano"]);Se.setWorld(Ec,Xe.assets.filter(u=>d.has(u.name)).map(u=>Hi(u.id===Xe.desk?.assetId?Xe.desk.footprint:u.bounds))),wt=!0,un=_T({model:is,canvas:e,hitAt:ds,invalidate:Yt,enabled:()=>!Mt&&["piano","songbook"].includes(Ge),onOctave:()=>{Ge==="piano"&&innerWidth<=760&&Se.go(Fs("piano"),"piano",!0)}}),Xi=TT({model:is,piano:un,invalidate:Yt,track:us,surfaceKind:as,compact:fi,enabled:()=>Ge==="songbook"&&!Mt}),Xe.desk&&(_n=ST({model:is,manifest:Xe,invalidate:Yt,track:us,surfaceKind:as,onDeskShift:u=>{(["monitor","cv","phone"].includes(Ge)||Ge==="desk"&&Se.seated)&&Se.shift(u)}})),Xe.assets.some(u=>u.interaction==="cockroach")&&(Fn=AT({model:is,invalidate:Yt,notice:wn,track:us,reducedMotion:()=>matchMedia("(prefers-reduced-motion: reduce)").matches}),bo.push(Fn.pickMesh)),_r=gT({onOpen(){Dp=Mt,Se.unlock(),fc(),Vr.hidden=!0},onClose(){Dp?Vr.hidden=!1:(Yr(),Ge==="monitor"&&pt.section==="terminal"&&No.focus())},onSignOut:()=>No.signedOut()}),No=ww(pt,{openDashboard:u=>_r.show(u),dashboardOpen:()=>_r.open}),document.body.dataset.modelState="ready",document.body.dataset.modelVersion=Xe.version,document.body.dataset.modelMeshes=String(bo.length),document.querySelector("#load-notice").hidden=!0,document.querySelectorAll("button[data-view], #zoom-in, #zoom-out, #mouse-look").forEach(u=>{u.disabled=!1}),oE(),Jt=hT({canvas:e,camera:at,navigation:Se,manifest:Xe,setView:Tn,activate:gd,hitAt:ds,actionFor:Oo,invalidate:Yt,onMenuOpen:()=>{qo(),un.stop(),Xi.stop(),zi?.cancelCharge()},onMenuChange:()=>jm(!0),onMove:Cc,allowShortcuts:()=>!_r?.open,onInteract:()=>zi?.interact(),onShortcut(u){_r?.open||(u.kind==="links"?Rn.open?(Rn.open=!1,e.focus({preventScroll:!0})):Xm():u.kind==="link"?jo(sn[u.value]):u.kind==="mouse-look"?Se.toggleLock():u.kind==="help"?_i.open?_i.open=!1:(Jt.setMenu(!0),_i.open=!0):u.kind==="terminal"?(Tn("monitor"),Yo("terminal")):u.kind==="desk-height"?_n.toggleDesk():u.kind==="blue-light"||u.kind==="orange-light"?_n.cycleLight(u.kind.split("-")[0]):u.kind==="screen-section"&&(Ge==="monitor"?Yo(pt.section==="main"?"legacy":"main"):wn("Use the monitor first: press 1 in Places, then X to switch its profile section.")))}}),Tn("entry",!0),Bm.reveal(),fT()}catch(e){nu(e)}finally{s.dispose()}}document.addEventListener("visibilitychange",Yt);window.addEventListener("pagehide",()=>{un?.stop(),Xi?.stop(),Fn?.setPaused(!0),Se?.stop(),Se?.unlock(),Vi&&cancelAnimationFrame(Vi),Vi=0});window.addEventListener("pageshow",()=>{Fn?.setPaused(Mt),Yt()});dE();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.