@chanmeng666/archlang-3d 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +102 -0
- package/README.md +4 -3
- package/THIRD_PARTY_NOTICES +2 -2
- package/dist/browser.d.ts +4 -3
- package/dist/browser.js +612 -11
- package/dist/{camera-DVOiag0F.d.ts → camera-CGIIudHj.d.ts} +1 -1
- package/dist/{chunk-4SQ5YKKX.js → chunk-FHBR2U5Z.js} +17 -4
- package/dist/{chunk-OWZWBKMI.js → chunk-FVD3DZU2.js} +34 -7
- package/dist/{chunk-WCWLYIVD.js → chunk-GXWLZ2KC.js} +61 -9
- package/dist/chunk-QN4LQTVG.js +2192 -0
- package/dist/{chunk-EQBMPXB5.js → chunk-TI4RYEOL.js} +80 -5
- package/dist/cli.js +5 -5
- package/dist/{facts-BRIFxHL_.d.ts → facts-3wb9egIT.d.ts} +1 -1
- package/dist/index.d.ts +308 -7
- package/dist/index.js +62 -4
- package/dist/node.d.ts +5 -3
- package/dist/node.js +4 -4
- package/dist/replay.d.ts +22 -2
- package/dist/{strip-Nt7eJ-4E.d.ts → strip-Sdsm54Qw.d.ts} +118 -4
- package/dist/viewer.iife.js +504 -499
- package/package.json +3 -3
- package/dist/chunk-L2CX7KWM.js +0 -950
package/dist/viewer.iife.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";(()=>{var qn={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Yn={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},yc=0,Do=1,vc=2;var Es=1,Mc=2,Gi=3,Zn=0,Fe=1,mn=2,gn=0,Hi=1,No=2,Uo=3,Fo=4,Sc=5;var li=100,bc=101,Ec=102,wc=103,Tc=104,Ac=200,Cc=201,Rc=202,Pc=203,Oo=204,Bo=205,Ic=206,Lc=207,Dc=208,Nc=209,Uc=210,Fc=211,Oc=212,Bc=213,zc=214,gr=0,_r=1,xr=2,Ii=3,yr=4,vr=5,Mr=6,Sr=7,Kr=0,kc=1,Vc=2,on=0,zo=1,ko=2,Vo=3,Go=4,Ho=5,Wo=6,ws=7;var Xo=300,Jn=301,ci=302,jr=303,Qr=304,Ts=306,br=1e3,fn=1001,Er=1002,Ee=1003,Gc=1004;var As=1005;var Te=1006,ta=1007;var $n=1008;var Ge=1009,qo=1010,Yo=1011,Wi=1012,ea=1013,ln=1014,cn=1015,hn=1016,na=1017,ia=1018,Xi=1020,Zo=35902,Jo=35899,$o=1021,Ko=1022,tn=1023,pn=1026,Kn=1027,jo=1028,sa=1029,jn=1030,ra=1031;var aa=1033,Cs=33776,Rs=33777,Ps=33778,Is=33779,oa=35840,la=35841,ca=35842,ha=35843,ua=36196,da=37492,fa=37496,pa=37488,ma=37489,Ls=37490,ga=37491,_a=37808,xa=37809,ya=37810,va=37811,Ma=37812,Sa=37813,ba=37814,Ea=37815,wa=37816,Ta=37817,Aa=37818,Ca=37819,Ra=37820,Pa=37821,Ia=36492,La=36494,Da=36495,Na=36283,Ua=36284,Ds=36285,Fa=36286;var is=2300,wr=2301,pr=2302,To=2303,Ao=2400,Co=2401,Ro=2402;var Hc=3200;var Oa=0,Wc=1,Pn="",Ye="srgb",ss="srgb-linear",rs="linear",Qt="srgb";var mr=7680;var Xc=519,qc=512,Yc=513,Zc=514,Ba=515,Jc=516,$c=517,za=518,Kc=519,jc=35044;var Qo="300 es",rn=2e3,Li=2001;function uu(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function du(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function as(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Qc(){let i=as("canvas");return i.style.display="block",i}var Yl={},Di=null;function tl(...i){let t="THREE."+i.shift();Di?Di("log",t,...i):console.log(t,...i)}function th(i){let t=i[0];if(typeof t=="string"&&t.startsWith("TSL:")){let e=i[1];e&&e.isStackTrace?i[0]+=" "+e.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function It(...i){i=th(i);let t="THREE."+i.shift();if(Di)Di("warn",t,...i);else{let e=i[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...i)}}function Dt(...i){i=th(i);let t="THREE."+i.shift();if(Di)Di("error",t,...i);else{let e=i[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...i)}}function ri(...i){let t=i.join(" ");t in Yl||(Yl[t]=!0,It(...i))}function eh(i,t,e){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}var nh={[gr]:_r,[xr]:Mr,[yr]:Sr,[Ii]:vr,[_r]:gr,[Mr]:xr,[Sr]:yr,[vr]:Ii},an=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){let n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){let n=this._listeners;if(n===void 0)return;let s=n[t];if(s!==void 0){let r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let n=e[t.type];if(n!==void 0){t.target=this;let s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,t);t.target=null}}},Re=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Zl=1234567,Ri=Math.PI/180,Ni=180/Math.PI;function qi(){let i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Re[i&255]+Re[i>>8&255]+Re[i>>16&255]+Re[i>>24&255]+"-"+Re[t&255]+Re[t>>8&255]+"-"+Re[t>>16&15|64]+Re[t>>24&255]+"-"+Re[e&63|128]+Re[e>>8&255]+"-"+Re[e>>16&255]+Re[e>>24&255]+Re[n&255]+Re[n>>8&255]+Re[n>>16&255]+Re[n>>24&255]).toLowerCase()}function Ht(i,t,e){return Math.max(t,Math.min(e,i))}function el(i,t){return(i%t+t)%t}function fu(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function pu(i,t,e){return i!==t?(e-i)/(t-i):0}function ns(i,t,e){return(1-e)*i+e*t}function mu(i,t,e,n){return ns(i,t,1-Math.exp(-e*n))}function gu(i,t=1){return t-Math.abs(el(i,t*2)-t)}function _u(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function xu(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function yu(i,t){return i+Math.floor(Math.random()*(t-i+1))}function vu(i,t){return i+Math.random()*(t-i)}function Mu(i){return i*(.5-Math.random())}function Su(i){i!==void 0&&(Zl=i);let t=Zl+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function bu(i){return i*Ri}function Eu(i){return i*Ni}function wu(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function Tu(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Au(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Cu(i,t,e,n,s){let r=Math.cos,a=Math.sin,o=r(e/2),c=a(e/2),l=r((t+n)/2),h=a((t+n)/2),d=r((t-n)/2),u=a((t-n)/2),p=r((n-t)/2),_=a((n-t)/2);switch(s){case"XYX":i.set(o*h,c*d,c*u,o*l);break;case"YZY":i.set(c*u,o*h,c*d,o*l);break;case"ZXZ":i.set(c*d,c*u,o*h,o*l);break;case"XZX":i.set(o*h,c*_,c*p,o*l);break;case"YXY":i.set(c*p,o*h,c*_,o*l);break;case"ZYZ":i.set(c*_,c*p,o*h,o*l);break;default:It("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Ci(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:case Uint8ClampedArray:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function Ne(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}var nl={DEG2RAD:Ri,RAD2DEG:Ni,generateUUID:qi,clamp:Ht,euclideanModulo:el,mapLinear:fu,inverseLerp:pu,lerp:ns,damp:mu,pingpong:gu,smoothstep:_u,smootherstep:xu,randInt:yu,randFloat:vu,randFloatSpread:Mu,seededRandom:Su,degToRad:bu,radToDeg:Eu,isPowerOfTwo:wu,ceilPowerOfTwo:Tu,floorPowerOfTwo:Au,setQuaternionFromProperEuler:Cu,normalize:Ne,denormalize:Ci},ol=class ol{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Ht(this.x,t.x,e.x),this.y=Ht(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Ht(this.x,t,e),this.y=Ht(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ht(n,t,e))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(Ht(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*s+t.x,this.y=r*s+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};ol.prototype.isVector2=!0;var Nt=ol,Je=class{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,a,o){let c=n[s+0],l=n[s+1],h=n[s+2],d=n[s+3],u=r[a+0],p=r[a+1],_=r[a+2],v=r[a+3];if(d!==v||c!==u||l!==p||h!==_){let g=c*u+l*p+h*_+d*v;g<0&&(u=-u,p=-p,_=-_,v=-v,g=-g);let f=1-o;if(g<.9995){let T=Math.acos(g),L=Math.sin(T);f=Math.sin(f*T)/L,o=Math.sin(o*T)/L,c=c*f+u*o,l=l*f+p*o,h=h*f+_*o,d=d*f+v*o}else{c=c*f+u*o,l=l*f+p*o,h=h*f+_*o,d=d*f+v*o;let T=1/Math.sqrt(c*c+l*l+h*h+d*d);c*=T,l*=T,h*=T,d*=T}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=d}static multiplyQuaternionsFlat(t,e,n,s,r,a){let o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],d=r[a],u=r[a+1],p=r[a+2],_=r[a+3];return t[e]=o*_+h*d+c*p-l*u,t[e+1]=c*_+h*u+l*d-o*p,t[e+2]=l*_+h*p+o*u-c*d,t[e+3]=h*_-o*d-c*u-l*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let n=t._x,s=t._y,r=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(s/2),d=o(r/2),u=c(n/2),p=c(s/2),_=c(r/2);switch(a){case"XYZ":this._x=u*h*d+l*p*_,this._y=l*p*d-u*h*_,this._z=l*h*_+u*p*d,this._w=l*h*d-u*p*_;break;case"YXZ":this._x=u*h*d+l*p*_,this._y=l*p*d-u*h*_,this._z=l*h*_-u*p*d,this._w=l*h*d+u*p*_;break;case"ZXY":this._x=u*h*d-l*p*_,this._y=l*p*d+u*h*_,this._z=l*h*_+u*p*d,this._w=l*h*d-u*p*_;break;case"ZYX":this._x=u*h*d-l*p*_,this._y=l*p*d+u*h*_,this._z=l*h*_-u*p*d,this._w=l*h*d+u*p*_;break;case"YZX":this._x=u*h*d+l*p*_,this._y=l*p*d+u*h*_,this._z=l*h*_-u*p*d,this._w=l*h*d-u*p*_;break;case"XZY":this._x=u*h*d-l*p*_,this._y=l*p*d-u*h*_,this._z=l*h*_+u*p*d,this._w=l*h*d+u*p*_;break;default:It("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],s=e[4],r=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],d=e[10],u=n+o+d;if(u>0){let p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(h-c)*p,this._y=(r-l)*p,this._z=(a-s)*p}else if(n>o&&n>d){let p=2*Math.sqrt(1+n-o-d);this._w=(h-c)/p,this._x=.25*p,this._y=(s+a)/p,this._z=(r+l)/p}else if(o>d){let p=2*Math.sqrt(1+o-n-d);this._w=(r-l)/p,this._x=(s+a)/p,this._y=.25*p,this._z=(c+h)/p}else{let p=2*Math.sqrt(1+d-n-o);this._w=(a-s)/p,this._x=(r+l)/p,this._y=(c+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Ht(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let n=t._x,s=t._y,r=t._z,a=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=n*h+a*o+s*l-r*c,this._y=s*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-s*o,this._w=a*h-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(t,e){let n=t._x,s=t._y,r=t._z,a=t._w,o=this.dot(t);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let c=1-e;if(o<.9995){let l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,e=Math.sin(e*l)/h,this._x=this._x*c+n*e,this._y=this._y*c+s*e,this._z=this._z*c+r*e,this._w=this._w*c+a*e,this._onChangeCallback()}else this._x=this._x*c+n*e,this._y=this._y*c+s*e,this._z=this._z*c+r*e,this._w=this._w*c+a*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},ll=class ll{constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Jl.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Jl.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(t){let e=this.x,n=this.y,s=this.z,r=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*s-o*n),h=2*(o*e-r*s),d=2*(r*n-a*e);return this.x=e+c*l+a*d-o*h,this.y=n+c*h+o*l-r*d,this.z=s+c*d+r*h-a*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Ht(this.x,t.x,e.x),this.y=Ht(this.y,t.y,e.y),this.z=Ht(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Ht(this.x,t,e),this.y=Ht(this.y,t,e),this.z=Ht(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ht(n,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,s=t.y,r=t.z,a=e.x,o=e.y,c=e.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return no.copy(this).projectOnVector(t),this.sub(no)}reflect(t){return this.sub(no.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(Ht(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};ll.prototype.isVector3=!0;var U=ll,no=new U,Jl=new Je,cl=class cl{constructor(t,e,n,s,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,c,l)}set(t,e,n,s,r,a,o,c,l){let h=this.elements;return h[0]=t,h[1]=s,h[2]=o,h[3]=e,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],d=n[7],u=n[2],p=n[5],_=n[8],v=s[0],g=s[3],f=s[6],T=s[1],L=s[4],M=s[7],b=s[2],E=s[5],A=s[8];return r[0]=a*v+o*T+c*b,r[3]=a*g+o*L+c*E,r[6]=a*f+o*M+c*A,r[1]=l*v+h*T+d*b,r[4]=l*g+h*L+d*E,r[7]=l*f+h*M+d*A,r[2]=u*v+p*T+_*b,r[5]=u*g+p*L+_*E,r[8]=u*f+p*M+_*A,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-n*r*h+n*o*c+s*r*l-s*a*c}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],d=h*a-o*l,u=o*c-h*r,p=l*r-a*c,_=e*d+n*u+s*p;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);let v=1/_;return t[0]=d*v,t[1]=(s*l-h*n)*v,t[2]=(o*n-s*a)*v,t[3]=u*v,t[4]=(h*e-s*c)*v,t[5]=(s*r-o*e)*v,t[6]=p*v,t[7]=(n*c-l*e)*v,t[8]=(a*e-n*r)*v,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,a,o){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+t,-s*l,s*c,-s*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return ri("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(io.makeScale(t,e)),this}rotate(t){return ri("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(io.makeRotation(-t)),this}translate(t,e){return ri("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(io.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}};cl.prototype.isMatrix3=!0;var Ut=cl,io=new Ut,$l=new Ut().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Kl=new Ut().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Ru(){let i={enabled:!0,workingColorSpace:ss,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Qt&&(s.r=An(s.r),s.g=An(s.g),s.b=An(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Qt&&(s.r=Pi(s.r),s.g=Pi(s.g),s.b=Pi(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Pn?rs:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return ri("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return ri("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[ss]:{primaries:t,whitePoint:n,transfer:rs,toXYZ:$l,fromXYZ:Kl,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Ye},outputColorSpaceConfig:{drawingBufferColorSpace:Ye}},[Ye]:{primaries:t,whitePoint:n,transfer:Qt,toXYZ:$l,fromXYZ:Kl,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Ye}}}),i}var Yt=Ru();function An(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Pi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var mi,Tr=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{mi===void 0&&(mi=as("canvas")),mi.width=t.width,mi.height=t.height;let s=mi.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=mi}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=as("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=An(r[a]/255)*255;return n.putImageData(s,0,0),e}else if(t.data){let e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(An(e[n]/255)*255):e[n]=An(e[n]);return{data:e,width:t.width,height:t.height}}else return It("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},Pu=0,Ui=class{constructor(t=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Pu++}),this.uuid=qi(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){let e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(so(s[a].image)):r.push(so(s[a]))}else r=so(s);n.url=r}return e||(t.images[this.uuid]=n),n}};function so(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Tr.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(It("Texture: Unable to serialize Texture."),{})}var Iu=0,ro=new U,Be=class i extends an{constructor(t=i.DEFAULT_IMAGE,e=i.DEFAULT_MAPPING,n=fn,s=fn,r=Te,a=$n,o=tn,c=Ge,l=i.DEFAULT_ANISOTROPY,h=Pn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Iu++}),this.uuid=qi(),this.name="",this.source=new Ui(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Nt(0,0),this.repeat=new Nt(1,1),this.center=new Nt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ut,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(ro).x}get height(){return this.source.getSize(ro).y}get depth(){return this.source.getSize(ro).z}get image(){return this.source.data}set image(t){this.source.data=t}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(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let n=t[e];if(n===void 0){It(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){It(`Texture.setValues(): property '${e}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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,normalized:this.normalized,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),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Xo)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case br:t.x=t.x-Math.floor(t.x);break;case fn:t.x=t.x<0?0:1;break;case Er:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case br:t.y=t.y-Math.floor(t.y);break;case fn:t.y=t.y<0?0:1;break;case Er:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};Be.DEFAULT_IMAGE=null;Be.DEFAULT_MAPPING=Xo;Be.DEFAULT_ANISOTROPY=1;var hl=class hl{constructor(t=0,e=0,n=0,s=1){this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*s+a[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r,c=t.elements,l=c[0],h=c[4],d=c[8],u=c[1],p=c[5],_=c[9],v=c[2],g=c[6],f=c[10];if(Math.abs(h-u)<.01&&Math.abs(d-v)<.01&&Math.abs(_-g)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+v)<.1&&Math.abs(_+g)<.1&&Math.abs(l+p+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let L=(l+1)/2,M=(p+1)/2,b=(f+1)/2,E=(h+u)/4,A=(d+v)/4,x=(_+g)/4;return L>M&&L>b?L<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(L),s=E/n,r=A/n):M>b?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=E/s,r=x/s):b<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(b),n=A/r,s=x/r),this.set(n,s,r,e),this}let T=Math.sqrt((g-_)*(g-_)+(d-v)*(d-v)+(u-h)*(u-h));return Math.abs(T)<.001&&(T=1),this.x=(g-_)/T,this.y=(d-v)/T,this.z=(u-h)/T,this.w=Math.acos((l+p+f-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Ht(this.x,t.x,e.x),this.y=Ht(this.y,t.y,e.y),this.z=Ht(this.z,t.z,e.z),this.w=Ht(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Ht(this.x,t,e),this.y=Ht(this.y,t,e),this.z=Ht(this.z,t,e),this.w=Ht(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ht(n,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),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}};hl.prototype.isVector4=!0;var he=hl,Ar=class extends an{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Te,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new he(0,0,t,e),this.scissorTest=!1,this.viewport=new he(0,0,t,e),this.textures=[];let s={width:t,height:e,depth:n.depth},r=new Be(s),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(t={}){let e={minFilter:Te,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&this._depthTexture.renderTarget===this&&(this._depthTexture.renderTarget=null),t!==null&&t.renderTarget===null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=t,this.textures[s].image.height=e,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].image.depth>1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;let s=Object.assign({},t.textures[e].image);this.textures[e].source=new Ui(s)}if(this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveColorBuffer=t.resolveColorBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,this.storeMultisampledColorBuffer=t.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=t.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=t.storeMultisampledStencilBuffer,t.depthTexture!==null)if(t.depthTexture.renderTarget===t){let e=t.depthTexture.clone();e.renderTarget=null,this.depthTexture=e}else this.depthTexture=t.depthTexture;return this.samples=t.samples,this.multiview=t.multiview,this.useArrayDepthTexture=t.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}},ze=class extends Ar{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}},os=class extends Be{constructor(t=null,e=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=Ee,this.minFilter=Ee,this.wrapR=fn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(t){return super.copy(t),this.wrapR=t.wrapR,this}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}};var Cr=class extends Be{constructor(t=null,e=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=Ee,this.minFilter=Ee,this.wrapR=fn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(t){return super.copy(t),this.wrapR=t.wrapR,this}};var $r=class $r{constructor(t,e,n,s,r,a,o,c,l,h,d,u,p,_,v,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,c,l,h,d,u,p,_,v,g)}set(t,e,n,s,r,a,o,c,l,h,d,u,p,_,v,g){let f=this.elements;return f[0]=t,f[4]=e,f[8]=n,f[12]=s,f[1]=r,f[5]=a,f[9]=o,f[13]=c,f[2]=l,f[6]=h,f[10]=d,f[14]=u,f[3]=p,f[7]=_,f[11]=v,f[15]=g,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 $r().fromArray(this.elements)}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return this.determinantAffine()===0?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinantAffine()===0)return this.identity();let e=this.elements,n=t.elements,s=1/gi.setFromMatrixColumn(t,0).length(),r=1/gi.setFromMatrixColumn(t,1).length(),a=1/gi.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,s=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),d=Math.sin(r);if(t.order==="XYZ"){let u=a*h,p=a*d,_=o*h,v=o*d;e[0]=c*h,e[4]=-c*d,e[8]=l,e[1]=p+_*l,e[5]=u-v*l,e[9]=-o*c,e[2]=v-u*l,e[6]=_+p*l,e[10]=a*c}else if(t.order==="YXZ"){let u=c*h,p=c*d,_=l*h,v=l*d;e[0]=u+v*o,e[4]=_*o-p,e[8]=a*l,e[1]=a*d,e[5]=a*h,e[9]=-o,e[2]=p*o-_,e[6]=v+u*o,e[10]=a*c}else if(t.order==="ZXY"){let u=c*h,p=c*d,_=l*h,v=l*d;e[0]=u-v*o,e[4]=-a*d,e[8]=_+p*o,e[1]=p+_*o,e[5]=a*h,e[9]=v-u*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){let u=a*h,p=a*d,_=o*h,v=o*d;e[0]=c*h,e[4]=_*l-p,e[8]=u*l+v,e[1]=c*d,e[5]=v*l+u,e[9]=p*l-_,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){let u=a*c,p=a*l,_=o*c,v=o*l;e[0]=c*h,e[4]=v-u*d,e[8]=_*d+p,e[1]=d,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=p*d+_,e[10]=u-v*d}else if(t.order==="XZY"){let u=a*c,p=a*l,_=o*c,v=o*l;e[0]=c*h,e[4]=-d,e[8]=l*h,e[1]=u*d+v,e[5]=a*h,e[9]=p*d-_,e[2]=_*d-p,e[6]=o*h,e[10]=v*d+u}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Lu,t,Du)}lookAt(t,e,n){let s=this.elements;return Xe.subVectors(t,e),Xe.lengthSq()===0&&(Xe.z=1),Xe.normalize(),Un.crossVectors(n,Xe),Un.lengthSq()===0&&(Math.abs(n.z)===1?Xe.x+=1e-4:Xe.z+=1e-4,Xe.normalize(),Un.crossVectors(n,Xe)),Un.normalize(),Ws.crossVectors(Xe,Un),s[0]=Un.x,s[4]=Ws.x,s[8]=Xe.x,s[1]=Un.y,s[5]=Ws.y,s[9]=Xe.y,s[2]=Un.z,s[6]=Ws.z,s[10]=Xe.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],d=n[5],u=n[9],p=n[13],_=n[2],v=n[6],g=n[10],f=n[14],T=n[3],L=n[7],M=n[11],b=n[15],E=s[0],A=s[4],x=s[8],w=s[12],D=s[1],O=s[5],V=s[9],H=s[13],R=s[2],W=s[6],$=s[10],K=s[14],st=s[3],Y=s[7],et=s[11],it=s[15];return r[0]=a*E+o*D+c*R+l*st,r[4]=a*A+o*O+c*W+l*Y,r[8]=a*x+o*V+c*$+l*et,r[12]=a*w+o*H+c*K+l*it,r[1]=h*E+d*D+u*R+p*st,r[5]=h*A+d*O+u*W+p*Y,r[9]=h*x+d*V+u*$+p*et,r[13]=h*w+d*H+u*K+p*it,r[2]=_*E+v*D+g*R+f*st,r[6]=_*A+v*O+g*W+f*Y,r[10]=_*x+v*V+g*$+f*et,r[14]=_*w+v*H+g*K+f*it,r[3]=T*E+L*D+M*R+b*st,r[7]=T*A+L*O+M*W+b*Y,r[11]=T*x+L*V+M*$+b*et,r[15]=T*w+L*H+M*K+b*it,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[4],s=t[8],r=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],d=t[6],u=t[10],p=t[14],_=t[3],v=t[7],g=t[11],f=t[15],T=c*p-l*u,L=o*p-l*d,M=o*u-c*d,b=a*p-l*h,E=a*u-c*h,A=a*d-o*h;return e*(v*T-g*L+f*M)-n*(_*T-g*b+f*E)+s*(_*L-v*b+f*A)-r*(_*M-v*E+g*A)}determinantAffine(){let t=this.elements,e=t[0],n=t[4],s=t[8],r=t[1],a=t[5],o=t[9],c=t[2],l=t[6],h=t[10];return e*(a*h-o*l)-n*(r*h-o*c)+s*(r*l-a*c)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){let s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],d=t[9],u=t[10],p=t[11],_=t[12],v=t[13],g=t[14],f=t[15],T=e*o-n*a,L=e*c-s*a,M=e*l-r*a,b=n*c-s*o,E=n*l-r*o,A=s*l-r*c,x=h*v-d*_,w=h*g-u*_,D=h*f-p*_,O=d*g-u*v,V=d*f-p*v,H=u*f-p*g,R=T*H-L*V+M*O+b*D-E*w+A*x;if(R===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let W=1/R;return t[0]=(o*H-c*V+l*O)*W,t[1]=(s*V-n*H-r*O)*W,t[2]=(v*A-g*E+f*b)*W,t[3]=(u*E-d*A-p*b)*W,t[4]=(c*D-a*H-l*w)*W,t[5]=(e*H-s*D+r*w)*W,t[6]=(g*M-_*A-f*L)*W,t[7]=(h*A-u*M+p*L)*W,t[8]=(a*V-o*D+l*x)*W,t[9]=(n*D-e*V-r*x)*W,t[10]=(_*E-v*M+f*T)*W,t[11]=(d*M-h*E-p*T)*W,t[12]=(o*w-a*O-c*x)*W,t[13]=(e*O-n*w+s*x)*W,t[14]=(v*L-_*b-g*T)*W,t[15]=(h*b-d*L+u*T)*W,this}scale(t){let e=this.elements,n=t.x,s=t.y,r=t.z;return e[0]*=n,e[4]*=s,e[8]*=r,e[1]*=n,e[5]*=s,e[9]*=r,e[2]*=n,e[6]*=s,e[10]*=r,e[3]*=n,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),s=Math.sin(e),r=1-n,a=t.x,o=t.y,c=t.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-s*c,l*c+s*o,0,l*o+s*c,h*o+n,h*c-s*a,0,l*c-s*o,h*c+s*a,r*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,r,a){return this.set(1,n,r,0,t,1,a,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){let s=this.elements,r=e._x,a=e._y,o=e._z,c=e._w,l=r+r,h=a+a,d=o+o,u=r*l,p=r*h,_=r*d,v=a*h,g=a*d,f=o*d,T=c*l,L=c*h,M=c*d,b=n.x,E=n.y,A=n.z;return s[0]=(1-(v+f))*b,s[1]=(p+M)*b,s[2]=(_-L)*b,s[3]=0,s[4]=(p-M)*E,s[5]=(1-(u+f))*E,s[6]=(g+T)*E,s[7]=0,s[8]=(_+L)*A,s[9]=(g-T)*A,s[10]=(1-(u+v))*A,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){let s=this.elements;t.x=s[12],t.y=s[13],t.z=s[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),e.identity(),this;let a=gi.set(s[0],s[1],s[2]).length(),o=gi.set(s[4],s[5],s[6]).length(),c=gi.set(s[8],s[9],s[10]).length();r<0&&(a=-a),en.copy(this);let l=1/a,h=1/o,d=1/c;return en.elements[0]*=l,en.elements[1]*=l,en.elements[2]*=l,en.elements[4]*=h,en.elements[5]*=h,en.elements[6]*=h,en.elements[8]*=d,en.elements[9]*=d,en.elements[10]*=d,e.setFromRotationMatrix(en),n.x=a,n.y=o,n.z=c,this}makePerspective(t,e,n,s,r,a,o=rn,c=!1){let l=this.elements,h=2*r/(e-t),d=2*r/(n-s),u=(e+t)/(e-t),p=(n+s)/(n-s),_,v;if(c)_=r/(a-r),v=a*r/(a-r);else if(o===rn)_=-(a+r)/(a-r),v=-2*a*r/(a-r);else if(o===Li)_=-a/(a-r),v=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=d,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=_,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,s,r,a,o=rn,c=!1){let l=this.elements,h=2/(e-t),d=2/(n-s),u=-(e+t)/(e-t),p=-(n+s)/(n-s),_,v;if(c)_=1/(a-r),v=a/(a-r);else if(o===rn)_=-2/(a-r),v=-(a+r)/(a-r);else if(o===Li)_=-1/(a-r),v=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=u,l[1]=0,l[5]=d,l[9]=0,l[13]=p,l[2]=0,l[6]=0,l[10]=_,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}};$r.prototype.isMatrix4=!0;var ce=$r,gi=new U,en=new ce,Lu=new U(0,0,0),Du=new U(1,1,1),Un=new U,Ws=new U,Xe=new U,jl=new ce,Ql=new Je,Cn=class i{constructor(t=0,e=0,n=0,s=i.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){let s=t.elements,r=s[0],a=s[4],o=s[8],c=s[1],l=s[5],h=s[9],d=s[2],u=s[6],p=s[10];switch(e){case"XYZ":this._y=Math.asin(Ht(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ht(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ht(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Ht(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Ht(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Ht(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:It("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return jl.makeRotationFromQuaternion(t),this.setFromRotationMatrix(jl,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Ql.setFromEuler(this),this.setFromQuaternion(Ql,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Cn.DEFAULT_ORDER="XYZ";var ls=class{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}},Nu=0,tc=new U,_i=new Je,vn=new ce,Xs=new U,Ki=new U,Uu=new U,Fu=new Je,ec=new U(1,0,0),nc=new U(0,1,0),ic=new U(0,0,1),sc={type:"added"},Ou={type:"removed"},xi={type:"childadded",child:null},ao={type:"childremoved",child:null},Ae=class i extends an{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Nu++}),this.uuid=qi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let t=new U,e=new Cn,n=new Je,s=new U(1,1,1);function r(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new ce},normalMatrix:{value:new Ut}}),this.matrix=new ce,this.matrixWorld=new ce,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ls,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(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return _i.setFromAxisAngle(t,e),this.quaternion.multiply(_i),this}rotateOnWorldAxis(t,e){return _i.setFromAxisAngle(t,e),this.quaternion.premultiply(_i),this}rotateX(t){return this.rotateOnAxis(ec,t)}rotateY(t){return this.rotateOnAxis(nc,t)}rotateZ(t){return this.rotateOnAxis(ic,t)}translateOnAxis(t,e){return tc.copy(t).applyQuaternion(this.quaternion),this.position.add(tc.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(ec,t)}translateY(t){return this.translateOnAxis(nc,t)}translateZ(t){return this.translateOnAxis(ic,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(vn.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Xs.copy(t):Xs.set(t,e,n);let s=this.parent;this.updateWorldMatrix(!0,!1),Ki.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?vn.lookAt(Ki,Xs,this.up):vn.lookAt(Xs,Ki,this.up),this.quaternion.setFromRotationMatrix(vn),s&&(vn.extractRotation(s.matrixWorld),_i.setFromRotationMatrix(vn),this.quaternion.premultiply(_i.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Dt("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(sc),xi.child=t,this.dispatchEvent(xi),xi.child=null):Dt("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Ou),ao.child=t,this.dispatchEvent(ao),ao.child=null),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),vn.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),vn.multiply(t.parent.matrixWorld)),t.applyMatrix4(vn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(sc),xi.child=t,this.dispatchEvent(xi),xi.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,s=this.children.length;n<s;n++){let a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);let s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ki,t,Uu),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ki,Fu,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(t){t(this);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverseVisible(t)}traverseAncestors(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let t=this.pivot;if(t!==null){let e=t.x,n=t.y,s=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*n-r[8]*s,r[13]+=n-r[1]*e-r[5]*n-r[9]*s,r[14]+=s-r[2]*e-r[6]*n-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e,n=!1){let s=this.parent;if(t===!0&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),e===!0){let r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(t){let e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let s={};s.uuid=this.uuid,s.type=this.type,s.name=this.name,s.castShadow=this.castShadow,s.receiveShadow=this.receiveShadow,s.visible=this.visible,s.frustumCulled=this.frustumCulled,s.renderOrder=this.renderOrder,s.static=this.static,s.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(t),s.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){let d=c[l];r(t.shapes,d)}else r(t.shapes,c)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(t.materials,this.material[c]));s.material=o}else s.material=r(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){let c=this.animations[o];s.animations.push(r(t.animations,c))}}if(e){let o=a(t.geometries),c=a(t.materials),l=a(t.textures),h=a(t.images),d=a(t.shapes),u=a(t.skeletons),p=a(t.animations),_=a(t.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),p.length>0&&(n.animations=p),_.length>0&&(n.nodes=_)}return n.object=s,n;function a(o){let c=[];for(let l in o){let h=o[l];delete h.metadata,c.push(h)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){let s=t.children[n];this.add(s.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}};Ae.DEFAULT_UP=new U(0,1,0);Ae.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ae.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Tn=class extends Ae{constructor(){super(),this.isGroup=!0,this.type="Group"}},Bu={type:"move"},Fi=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Tn,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 Tn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Tn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let s=null,r=null,a=null,o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(let v of t.hand.values()){let g=e.getJointPose(v,n),f=this._getHandJoint(l,v);g!==null&&(f.matrix.fromArray(g.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=g.radius),f.visible=g!==null}let h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],u=h.position.distanceTo(d.position),p=.02,_=.005;l.inputState.pinching&&u>p+_?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&u<=p-_&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(r=e.getPose(t.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,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:t,target:this})));o!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Bu)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new Tn;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},ih={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},Fn={h:0,s:0,l:0},qs={h:0,s:0,l:0};function oo(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}var Ft=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ye){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Yt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=Yt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Yt.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=Yt.workingColorSpace){if(t=el(t,1),e=Ht(e,0,1),n=Ht(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=oo(a,r,t+1/3),this.g=oo(a,r,t),this.b=oo(a,r,t-1/3)}return Yt.colorSpaceToWorking(this,s),this}setStyle(t,e=Ye){function n(r){r!==void 0&&parseFloat(r)<1&&It("Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r,a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))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,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))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,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:It("Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){let r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,16),e);It("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Ye){let n=ih[t.toLowerCase()];return n!==void 0?this.setHex(n,e):It("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=An(t.r),this.g=An(t.g),this.b=An(t.b),this}copyLinearToSRGB(t){return this.r=Pi(t.r),this.g=Pi(t.g),this.b=Pi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ye){return Yt.workingToColorSpace(Pe.copy(this),t),Math.round(Ht(Pe.r*255,0,255))*65536+Math.round(Ht(Pe.g*255,0,255))*256+Math.round(Ht(Pe.b*255,0,255))}getHexString(t=Ye){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Yt.workingColorSpace){Yt.workingToColorSpace(Pe.copy(this),e);let n=Pe.r,s=Pe.g,r=Pe.b,a=Math.max(n,s,r),o=Math.min(n,s,r),c,l,h=(o+a)/2;if(o===a)c=0,l=0;else{let d=a-o;switch(l=h<=.5?d/(a+o):d/(2-a-o),a){case n:c=(s-r)/d+(s<r?6:0);break;case s:c=(r-n)/d+2;break;case r:c=(n-s)/d+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=Yt.workingColorSpace){return Yt.workingToColorSpace(Pe.copy(this),e),t.r=Pe.r,t.g=Pe.g,t.b=Pe.b,t}getStyle(t=Ye){Yt.workingToColorSpace(Pe.copy(this),t);let e=Pe.r,n=Pe.g,s=Pe.b;return t!==Ye?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(t,e,n){return this.getHSL(Fn),this.setHSL(Fn.h+t,Fn.s+e,Fn.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Fn),t.getHSL(qs);let n=ns(Fn.h,qs.h,e),s=ns(Fn.s,qs.s,e),r=ns(Fn.l,qs.l,e);return this.setHSL(n,s,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,n=this.g,s=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*s,this.g=r[1]*e+r[4]*n+r[7]*s,this.b=r[2]*e+r[5]*n+r[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Pe=new Ft;Ft.NAMES=ih;var cs=class extends Ae{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 Cn,this.environmentIntensity=1,this.environmentRotation=new Cn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),e.object.backgroundBlurriness=this.backgroundBlurriness,e.object.backgroundIntensity=this.backgroundIntensity,e.object.backgroundRotation=this.backgroundRotation.toArray(),e.object.environmentIntensity=this.environmentIntensity,e.object.environmentRotation=this.environmentRotation.toArray(),e}},nn=new U,Mn=new U,lo=new U,Sn=new U,yi=new U,vi=new U,rc=new U,co=new U,ho=new U,uo=new U,fo=new he,po=new he,mo=new he,wn=class i{constructor(t=new U,e=new U,n=new U){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,s){s.subVectors(n,e),nn.subVectors(t,e),s.cross(nn);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){nn.subVectors(s,e),Mn.subVectors(n,e),lo.subVectors(t,e);let a=nn.dot(nn),o=nn.dot(Mn),c=nn.dot(lo),l=Mn.dot(Mn),h=Mn.dot(lo),d=a*l-o*o;if(d===0)return r.set(0,0,0),null;let u=1/d,p=(l*c-o*h)*u,_=(a*h-o*c)*u;return r.set(1-p-_,_,p)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,Sn)===null?!1:Sn.x>=0&&Sn.y>=0&&Sn.x+Sn.y<=1}static getInterpolation(t,e,n,s,r,a,o,c){return this.getBarycoord(t,e,n,s,Sn)===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,Sn.x),c.addScaledVector(a,Sn.y),c.addScaledVector(o,Sn.z),c)}static getInterpolatedAttribute(t,e,n,s,r,a){return fo.setScalar(0),po.setScalar(0),mo.setScalar(0),fo.fromBufferAttribute(t,e),po.fromBufferAttribute(t,n),mo.fromBufferAttribute(t,s),a.setScalar(0),a.addScaledVector(fo,r.x),a.addScaledVector(po,r.y),a.addScaledVector(mo,r.z),a}static isFrontFacing(t,e,n,s){return nn.subVectors(n,e),Mn.subVectors(t,e),nn.cross(Mn).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return nn.subVectors(this.c,this.b),Mn.subVectors(this.a,this.b),nn.cross(Mn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return i.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return i.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return i.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return i.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return i.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,s=this.b,r=this.c,a,o;yi.subVectors(s,n),vi.subVectors(r,n),co.subVectors(t,n);let c=yi.dot(co),l=vi.dot(co);if(c<=0&&l<=0)return e.copy(n);ho.subVectors(t,s);let h=yi.dot(ho),d=vi.dot(ho);if(h>=0&&d<=h)return e.copy(s);let u=c*d-h*l;if(u<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(yi,a);uo.subVectors(t,r);let p=yi.dot(uo),_=vi.dot(uo);if(_>=0&&p<=_)return e.copy(r);let v=p*l-c*_;if(v<=0&&l>=0&&_<=0)return o=l/(l-_),e.copy(n).addScaledVector(vi,o);let g=h*_-p*d;if(g<=0&&d-h>=0&&p-_>=0)return rc.subVectors(r,s),o=(d-h)/(d-h+(p-_)),e.copy(s).addScaledVector(rc,o);let f=1/(g+v+u);return a=v*f,o=u*f,e.copy(n).addScaledVector(yi,a).addScaledVector(vi,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},kn=class{constructor(t=new U(1/0,1/0,1/0),e=new U(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(sn.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(sn.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=sn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);let n=t.geometry;if(n!==void 0){let r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,sn):sn.fromBufferAttribute(r,a),sn.applyMatrix4(t.matrixWorld),this.expandByPoint(sn);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Ys.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Ys.copy(n.boundingBox)),Ys.applyMatrix4(t.matrixWorld),this.union(Ys)}let s=t.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,sn),sn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(ji),Zs.subVectors(this.max,ji),Mi.subVectors(t.a,ji),Si.subVectors(t.b,ji),bi.subVectors(t.c,ji),On.subVectors(Si,Mi),Bn.subVectors(bi,Si),ei.subVectors(Mi,bi);let e=[0,-On.z,On.y,0,-Bn.z,Bn.y,0,-ei.z,ei.y,On.z,0,-On.x,Bn.z,0,-Bn.x,ei.z,0,-ei.x,-On.y,On.x,0,-Bn.y,Bn.x,0,-ei.y,ei.x,0];return!go(e,Mi,Si,bi,Zs)||(e=[1,0,0,0,1,0,0,0,1],!go(e,Mi,Si,bi,Zs))?!1:(Js.crossVectors(On,Bn),e=[Js.x,Js.y,Js.z],go(e,Mi,Si,bi,Zs))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,sn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(sn).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(bn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),bn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),bn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),bn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),bn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),bn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),bn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),bn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(bn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}},bn=[new U,new U,new U,new U,new U,new U,new U,new U],sn=new U,Ys=new kn,Mi=new U,Si=new U,bi=new U,On=new U,Bn=new U,ei=new U,ji=new U,Zs=new U,Js=new U,ni=new U;function go(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){ni.fromArray(i,r);let o=s.x*Math.abs(ni.x)+s.y*Math.abs(ni.y)+s.z*Math.abs(ni.z),c=t.dot(ni),l=e.dot(ni),h=n.dot(ni);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}var xe=new U,$s=new Nt,zu=0,Oe=class extends an{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:zu++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=jc,this.updateRanges=[],this.gpuType=cn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[t+s]=e.array[n+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)$s.fromBufferAttribute(this,e),$s.applyMatrix3(t),this.setXY(e,$s.x,$s.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)xe.fromBufferAttribute(this,e),xe.applyMatrix3(t),this.setXYZ(e,xe.x,xe.y,xe.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)xe.fromBufferAttribute(this,e),xe.applyMatrix4(t),this.setXYZ(e,xe.x,xe.y,xe.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)xe.fromBufferAttribute(this,e),xe.applyNormalMatrix(t),this.setXYZ(e,xe.x,xe.y,xe.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)xe.fromBufferAttribute(this,e),xe.transformDirection(t),this.setXYZ(e,xe.x,xe.y,xe.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Ci(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Ne(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ci(e,this.array)),e}setX(t,e){return this.normalized&&(e=Ne(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ci(e,this.array)),e}setY(t,e){return this.normalized&&(e=Ne(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Ci(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Ne(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Ci(e,this.array)),e}setW(t,e){return this.normalized&&(e=Ne(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Ne(e,this.array),n=Ne(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,s){return t*=this.itemSize,this.normalized&&(e=Ne(e,this.array),n=Ne(n,this.array),s=Ne(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t*=this.itemSize,this.normalized&&(e=Ne(e,this.array),n=Ne(n,this.array),s=Ne(s,this.array),r=Ne(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return t.name=this.name,t.usage=this.usage,t.gpuType=this.gpuType,t}dispose(){this.dispatchEvent({type:"dispose"})}};var hs=class extends Oe{constructor(t,e,n){super(new Uint16Array(t),e,n)}};var us=class extends Oe{constructor(t,e,n){super(new Uint32Array(t),e,n)}};var Ue=class extends Oe{constructor(t,e,n){super(new Float32Array(t),e,n)}},ku=new kn,Qi=new U,_o=new U,ai=class{constructor(t=new U,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let n=this.center;e!==void 0?n.copy(e):ku.setFromPoints(t).getCenter(n);let s=0;for(let r=0,a=t.length;r<a;r++)s=Math.max(s,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){let n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Qi.subVectors(t,this.center);let e=Qi.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Qi,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(_o.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Qi.copy(t.center).add(_o)),this.expandByPoint(Qi.copy(t.center).sub(_o))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}},Vu=0,Qe=new ce,xo=new Ae,Ei=new U,qe=new kn,ts=new kn,be=new U,ke=class i extends an{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Vu++}),this.uuid=qi(),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={},this._transformed=!1}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(uu(t)?us:hs)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Ut().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return Qe.makeRotationFromQuaternion(t),this.applyMatrix4(Qe),this}rotateX(t){return Qe.makeRotationX(t),this.applyMatrix4(Qe),this}rotateY(t){return Qe.makeRotationY(t),this.applyMatrix4(Qe),this}rotateZ(t){return Qe.makeRotationZ(t),this.applyMatrix4(Qe),this}translate(t,e,n){return Qe.makeTranslation(t,e,n),this.applyMatrix4(Qe),this}scale(t,e,n){return Qe.makeScale(t,e,n),this.applyMatrix4(Qe),this}lookAt(t){return xo.lookAt(t),xo.updateMatrix(),this.applyMatrix4(xo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ei).negate(),this.translate(Ei.x,Ei.y,Ei.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let s=0,r=t.length;s<r;s++){let a=t[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ue(n,3))}else{let n=Math.min(t.length,e.count);for(let s=0;s<n;s++){let r=t[s];e.setXYZ(s,r.x,r.y,r.z||0)}t.length>e.count&&It("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new kn);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Dt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n<s;n++){let r=e[n];qe.setFromBufferAttribute(r),this.morphTargetsRelative?(be.addVectors(this.boundingBox.min,qe.min),this.boundingBox.expandByPoint(be),be.addVectors(this.boundingBox.max,qe.max),this.boundingBox.expandByPoint(be)):(this.boundingBox.expandByPoint(qe.min),this.boundingBox.expandByPoint(qe.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Dt('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 ai);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Dt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,1/0);return}if(t){let n=this.boundingSphere.center;if(qe.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){let o=e[r];ts.setFromBufferAttribute(o),this.morphTargetsRelative?(be.addVectors(qe.min,ts.min),qe.expandByPoint(be),be.addVectors(qe.max,ts.max),qe.expandByPoint(be)):(qe.expandByPoint(ts.min),qe.expandByPoint(ts.max))}qe.getCenter(n);let s=0;for(let r=0,a=t.count;r<a;r++)be.fromBufferAttribute(t,r),s=Math.max(s,n.distanceToSquared(be));if(e)for(let r=0,a=e.length;r<a;r++){let o=e[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)be.fromBufferAttribute(o,l),c&&(Ei.fromBufferAttribute(t,l),be.add(Ei)),s=Math.max(s,n.distanceToSquared(be))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Dt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){Dt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=e.position,s=e.normal,r=e.uv,a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new Oe(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));let o=[],c=[];for(let x=0;x<n.count;x++)o[x]=new U,c[x]=new U;let l=new U,h=new U,d=new U,u=new Nt,p=new Nt,_=new Nt,v=new U,g=new U;function f(x,w,D){l.fromBufferAttribute(n,x),h.fromBufferAttribute(n,w),d.fromBufferAttribute(n,D),u.fromBufferAttribute(r,x),p.fromBufferAttribute(r,w),_.fromBufferAttribute(r,D),h.sub(l),d.sub(l),p.sub(u),_.sub(u);let O=1/(p.x*_.y-_.x*p.y);isFinite(O)&&(v.copy(h).multiplyScalar(_.y).addScaledVector(d,-p.y).multiplyScalar(O),g.copy(d).multiplyScalar(p.x).addScaledVector(h,-_.x).multiplyScalar(O),o[x].add(v),o[w].add(v),o[D].add(v),c[x].add(g),c[w].add(g),c[D].add(g))}let T=this.groups;T.length===0&&(T=[{start:0,count:t.count}]);for(let x=0,w=T.length;x<w;++x){let D=T[x],O=D.start,V=D.count;for(let H=O,R=O+V;H<R;H+=3)f(t.getX(H+0),t.getX(H+1),t.getX(H+2))}let L=new U,M=new U,b=new U,E=new U;function A(x){b.fromBufferAttribute(s,x),E.copy(b);let w=o[x];L.copy(w),L.sub(b.multiplyScalar(b.dot(w))).normalize(),M.crossVectors(E,w);let O=M.dot(c[x])<0?-1:1;a.setXYZW(x,L.x,L.y,L.z,O)}for(let x=0,w=T.length;x<w;++x){let D=T[x],O=D.start,V=D.count;for(let H=O,R=O+V;H<R;H+=3)A(t.getX(H+0)),A(t.getX(H+1)),A(t.getX(H+2))}this._transformed=!0}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==e.count)n=new Oe(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let u=0,p=n.count;u<p;u++)n.setXYZ(u,0,0,0);let s=new U,r=new U,a=new U,o=new U,c=new U,l=new U,h=new U,d=new U;if(t)for(let u=0,p=t.count;u<p;u+=3){let _=t.getX(u+0),v=t.getX(u+1),g=t.getX(u+2);s.fromBufferAttribute(e,_),r.fromBufferAttribute(e,v),a.fromBufferAttribute(e,g),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),o.fromBufferAttribute(n,_),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,g),o.add(h),c.add(h),l.add(h),n.setXYZ(_,o.x,o.y,o.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(g,l.x,l.y,l.z)}else for(let u=0,p=e.count;u<p;u+=3)s.fromBufferAttribute(e,u+0),r.fromBufferAttribute(e,u+1),a.fromBufferAttribute(e,u+2),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),n.setXYZ(u+0,h.x,h.y,h.z),n.setXYZ(u+1,h.x,h.y,h.z),n.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)be.fromBufferAttribute(t,e),be.normalize(),t.setXYZ(e,be.x,be.y,be.z)}toNonIndexed(){function t(o,c){let l=o.array,h=o.itemSize,d=o.normalized,u=new l.constructor(c.length*h),p=0,_=0;for(let v=0,g=c.length;v<g;v++){o.isInterleavedBufferAttribute?p=c[v]*o.data.stride+o.offset:p=c[v]*h;for(let f=0;f<h;f++)u[_++]=l[p++]}return new Oe(u,h,d)}if(this.index===null)return It("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new i,n=this.index.array,s=this.attributes;for(let o in s){let c=s[o],l=t(c,n);e.setAttribute(o,l)}let r=this.morphAttributes;for(let o in r){let c=[],l=r[o];for(let h=0,d=l.length;h<d;h++){let u=l[h],p=t(u,n);c.push(p)}e.morphAttributes[o]=c}e.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let o=0,c=a.length;o<c;o++){let l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){let t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,t.name=this.name,Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let c in n){let l=n[c];t.data.attributes[c]=l.toJSON(t.data)}let s={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let d=0,u=l.length;d<u;d++){let p=l[d];h.push(p.toJSON(t.data))}h.length>0&&(s[c]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone());let s=t.attributes;for(let l in s){let h=s[l];this.setAttribute(l,h.clone(e))}let r=t.morphAttributes;for(let l in r){let h=[],d=r[l];for(let u=0,p=d.length;u<p;u++)h.push(d[u].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;let a=t.groups;for(let l=0,h=a.length;l<h;l++){let d=a[l];this.addGroup(d.start,d.count,d.materialIndex)}let o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());let c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this._transformed=t._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}};var yo=new U,Gu=new U,Hu=new Ut,Ze=class{constructor(t=new U(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,s){return this.normal.set(t,e,n),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let s=yo.subVectors(n,e).cross(Gu.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,n=!0){let s=t.delta(yo),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let a=-(t.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:e.copy(t.start).addScaledVector(s,a)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||Hu.getNormalMatrix(t),s=this.coplanarPoint(yo).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(t){return this.normal.fromArray(t.normal),this.constant=t.constant,this}},Wu=0,Rn=class extends an{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Wu++}),this.uuid=qi(),this.name="",this.type="Material",this.blending=Hi,this.side=Zn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Oo,this.blendDst=Bo,this.blendEquation=li,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ft(0,0,0),this.blendAlpha=0,this.depthFunc=Ii,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Xc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=mr,this.stencilZFail=mr,this.stencilZPass=mr,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(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){It(`Material: parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){It(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,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&&(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(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),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(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).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(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).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(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(r=>r.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),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.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let a=[];for(let o in r){let c=r[o];delete c.metadata,a.push(c)}return a}if(e){let r=s(t.textures),a=s(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(t,e){if(t.uuid!==void 0&&(this.uuid=t.uuid),t.name!==void 0&&(this.name=t.name),t.color!==void 0&&this.color!==void 0&&this.color.setHex(t.color),t.roughness!==void 0&&(this.roughness=t.roughness),t.metalness!==void 0&&(this.metalness=t.metalness),t.sheen!==void 0&&(this.sheen=t.sheen),t.sheenColor!==void 0&&(this.sheenColor=new Ft().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(this.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(t.emissive),t.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(t.specular),t.specularIntensity!==void 0&&(this.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(this.shininess=t.shininess),t.clearcoat!==void 0&&(this.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(this.dispersion=t.dispersion),t.retroreflectivity!==void 0&&(this.retroreflectivity=t.retroreflectivity),t.iridescence!==void 0&&(this.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(this.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(this.transmission=t.transmission),t.thickness!==void 0&&(this.thickness=t.thickness),t.attenuationDistance!==void 0&&(this.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(this.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(this.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(this.fog=t.fog),t.flatShading!==void 0&&(this.flatShading=t.flatShading),t.blending!==void 0&&(this.blending=t.blending),t.combine!==void 0&&(this.combine=t.combine),t.side!==void 0&&(this.side=t.side),t.shadowSide!==void 0&&(this.shadowSide=t.shadowSide),t.opacity!==void 0&&(this.opacity=t.opacity),t.transparent!==void 0&&(this.transparent=t.transparent),t.alphaTest!==void 0&&(this.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(this.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(this.depthFunc=t.depthFunc),t.depthTest!==void 0&&(this.depthTest=t.depthTest),t.depthWrite!==void 0&&(this.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(this.colorWrite=t.colorWrite),t.clippingPlanes!==void 0&&(this.clippingPlanes=t.clippingPlanes.map(n=>new Ze().fromJSON(n))),t.clipIntersection!==void 0&&(this.clipIntersection=t.clipIntersection),t.clipShadows!==void 0&&(this.clipShadows=t.clipShadows),t.depthPacking!==void 0&&(this.depthPacking=t.depthPacking),t.blendSrc!==void 0&&(this.blendSrc=t.blendSrc),t.blendDst!==void 0&&(this.blendDst=t.blendDst),t.blendEquation!==void 0&&(this.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(this.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(this.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(this.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(this.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(this.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(this.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(this.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(this.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(this.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(this.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(this.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(this.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(this.rotation=t.rotation),t.linewidth!==void 0&&(this.linewidth=t.linewidth),t.linecap!==void 0&&(this.linecap=t.linecap),t.linejoin!==void 0&&(this.linejoin=t.linejoin),t.dashSize!==void 0&&(this.dashSize=t.dashSize),t.gapSize!==void 0&&(this.gapSize=t.gapSize),t.scale!==void 0&&(this.scale=t.scale),t.polygonOffset!==void 0&&(this.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(this.dithering=t.dithering),t.alphaToCoverage!==void 0&&(this.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(this.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(this.allowOverride=t.allowOverride),t.visible!==void 0&&(this.visible=t.visible),t.toneMapped!==void 0&&(this.toneMapped=t.toneMapped),t.userData!==void 0&&(this.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),t.size!==void 0&&(this.size=t.size),t.sizeAttenuation!==void 0&&(this.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(this.map=e[t.map]||null),t.matcap!==void 0&&(this.matcap=e[t.matcap]||null),t.alphaMap!==void 0&&(this.alphaMap=e[t.alphaMap]||null),t.bumpMap!==void 0&&(this.bumpMap=e[t.bumpMap]||null),t.bumpScale!==void 0&&(this.bumpScale=t.bumpScale),t.normalMap!==void 0&&(this.normalMap=e[t.normalMap]||null),t.normalMapType!==void 0&&(this.normalMapType=t.normalMapType),t.normalScale!==void 0){let n=t.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Nt().fromArray(n)}return t.displacementMap!==void 0&&(this.displacementMap=e[t.displacementMap]||null),t.displacementScale!==void 0&&(this.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(this.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(this.roughnessMap=e[t.roughnessMap]||null),t.metalnessMap!==void 0&&(this.metalnessMap=e[t.metalnessMap]||null),t.emissiveMap!==void 0&&(this.emissiveMap=e[t.emissiveMap]||null),t.emissiveIntensity!==void 0&&(this.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(this.specularMap=e[t.specularMap]||null),t.specularIntensityMap!==void 0&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),t.specularColorMap!==void 0&&(this.specularColorMap=e[t.specularColorMap]||null),t.envMap!==void 0&&(this.envMap=e[t.envMap]||null),t.envMapRotation!==void 0&&this.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(this.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(this.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(this.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(this.lightMap=e[t.lightMap]||null),t.lightMapIntensity!==void 0&&(this.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(this.aoMap=e[t.aoMap]||null),t.aoMapIntensity!==void 0&&(this.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(this.gradientMap=e[t.gradientMap]||null),t.clearcoatMap!==void 0&&(this.clearcoatMap=e[t.clearcoatMap]||null),t.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),t.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),t.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Nt().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(this.iridescenceMap=e[t.iridescenceMap]||null),t.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),t.transmissionMap!==void 0&&(this.transmissionMap=e[t.transmissionMap]||null),t.thicknessMap!==void 0&&(this.thicknessMap=e[t.thicknessMap]||null),t.anisotropyMap!==void 0&&(this.anisotropyMap=e[t.anisotropyMap]||null),t.sheenColorMap!==void 0&&(this.sheenColorMap=e[t.sheenColorMap]||null),t.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}};var En=new U,vo=new U,Ks=new U,js=new U,oi=class{constructor(t=new U,e=new U(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,En)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=En.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(En.copy(this.origin).addScaledVector(this.direction,e),En.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){vo.copy(t).add(e).multiplyScalar(.5),Ks.copy(e).sub(t).normalize(),js.copy(this.origin).sub(vo);let r=t.distanceTo(e)*.5,a=-this.direction.dot(Ks),o=js.dot(this.direction),c=-js.dot(Ks),l=js.lengthSq(),h=Math.abs(1-a*a),d,u,p,_;if(h>0)if(d=a*c-o,u=a*o-c,_=r*h,d>=0)if(u>=-_)if(u<=_){let v=1/h;d*=v,u*=v,p=d*(d+a*u+2*o)+u*(a*d+u+2*c)+l}else u=r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*c)+l;else u=-r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*c)+l;else u<=-_?(d=Math.max(0,-(-a*r+o)),u=d>0?-r:Math.min(Math.max(-r,-c),r),p=-d*d+u*(u+2*c)+l):u<=_?(d=0,u=Math.min(Math.max(-r,-c),r),p=u*(u+2*c)+l):(d=Math.max(0,-(a*r+o)),u=d>0?r:Math.min(Math.max(-r,-c),r),p=-d*d+u*(u+2*c)+l);else u=a>0?-r:r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(vo).addScaledVector(Ks,u),p}intersectSphere(t,e){if(t.radius<0)return null;En.subVectors(t.center,this.origin);let n=En.dot(this.direction),s=En.dot(En)-n*n,r=t.radius*t.radius;if(s>r)return null;let a=Math.sqrt(r-s),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,a,o,c,l=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return l>=0?(n=(t.min.x-u.x)*l,s=(t.max.x-u.x)*l):(n=(t.max.x-u.x)*l,s=(t.min.x-u.x)*l),h>=0?(r=(t.min.y-u.y)*h,a=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,a=(t.min.y-u.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),d>=0?(o=(t.min.z-u.z)*d,c=(t.max.z-u.z)*d):(o=(t.max.z-u.z)*d,c=(t.min.z-u.z)*d),n>c||o>s)||((o>n||n!==n)&&(n=o),(c<s||s!==s)&&(s=c),s<0)?null:this.at(n>=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,En)!==null}intersectTriangle(t,e,n,s,r){let a=this.origin,o=this.direction,c=o.x,l=o.y,h=o.z,d=t.x-a.x,u=t.y-a.y,p=t.z-a.z,_=e.x-a.x,v=e.y-a.y,g=e.z-a.z,f=n.x-a.x,T=n.y-a.y,L=n.z-a.z,M=Math.abs(c),b=Math.abs(l),E=Math.abs(h),A,x,w,D,O,V,H,R,W,$,K,st;if(M>=b&&M>=E?(w=c,V=d,W=_,st=f,c>=0?(A=l,x=h,D=u,O=p,H=v,R=g,$=T,K=L):(A=h,x=l,D=p,O=u,H=g,R=v,$=L,K=T)):b>=E?(w=l,V=u,W=v,st=T,l>=0?(A=h,x=c,D=p,O=d,H=g,R=_,$=L,K=f):(A=c,x=h,D=d,O=p,H=_,R=g,$=f,K=L)):(w=h,V=p,W=g,st=L,h>=0?(A=c,x=l,D=d,O=u,H=_,R=v,$=f,K=T):(A=l,x=c,D=u,O=d,H=v,R=_,$=T,K=f)),w===0)return null;let Y=A/w,et=x/w,it=1/w,Ct=D-Y*V,Et=O-et*V,ee=H-Y*W,Lt=R-et*W,Wt=$-Y*st,j=K-et*st,Q=Wt*Lt-j*ee,_t=Ct*j-Et*Wt,St=ee*Et-Lt*Ct;if(s){if(Q<0||_t<0||St<0)return null}else if((Q<0||_t<0||St<0)&&(Q>0||_t>0||St>0))return null;let pt=Q+_t+St;if(pt===0)return null;let Ot=it*(Q*V+_t*W+St*st);return(pt>0?Ot<0:Ot>0)?null:this.at(Ot/pt,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ds=class extends Rn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ft(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 Cn,this.combine=Kr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},ac=new ce,ii=new oi,Qs=new ai,oc=new U,tr=new U,er=new U,nr=new U,Mo=new U,ir=new U,lc=new U,sr=new U,Ve=class extends Ae{constructor(t=new ke,e=new ds){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(s,t);let o=this.morphTargetInfluences;if(r&&o){ir.set(0,0,0);for(let c=0,l=r.length;c<l;c++){let h=o[c],d=r[c];h!==0&&(Mo.fromBufferAttribute(d,t),a?ir.addScaledVector(Mo,h):ir.addScaledVector(Mo.sub(e),h))}e.add(ir)}return e}intersectsFrustum(t){return t.intersectsObject(this)}raycast(t,e){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Qs.copy(n.boundingSphere),Qs.applyMatrix4(r),ii.copy(t.ray).recast(t.near),!(Qs.containsPoint(ii.origin)===!1&&(ii.intersectSphere(Qs,oc)===null||ii.origin.distanceToSquared(oc)>(t.far-t.near)**2))&&(ac.copy(r).invert(),ii.copy(t.ray).applyMatrix4(ac),!(n.boundingBox!==null&&ii.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,ii)))}_computeIntersections(t,e,n){let s,r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let _=0,v=u.length;_<v;_++){let g=u[_],f=a[g.materialIndex],T=Math.max(g.start,p.start),L=Math.min(o.count,Math.min(g.start+g.count,p.start+p.count));for(let M=T,b=L;M<b;M+=3){let E=o.getX(M),A=o.getX(M+1),x=o.getX(M+2);s=rr(this,f,t,n,l,h,d,E,A,x),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=g.materialIndex,e.push(s))}}else{let _=Math.max(0,p.start),v=Math.min(o.count,p.start+p.count);for(let g=_,f=v;g<f;g+=3){let T=o.getX(g),L=o.getX(g+1),M=o.getX(g+2);s=rr(this,a,t,n,l,h,d,T,L,M),s&&(s.faceIndex=Math.floor(g/3),e.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let _=0,v=u.length;_<v;_++){let g=u[_],f=a[g.materialIndex],T=Math.max(g.start,p.start),L=Math.min(c.count,Math.min(g.start+g.count,p.start+p.count));for(let M=T,b=L;M<b;M+=3){let E=M,A=M+1,x=M+2;s=rr(this,f,t,n,l,h,d,E,A,x),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=g.materialIndex,e.push(s))}}else{let _=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let g=_,f=v;g<f;g+=3){let T=g,L=g+1,M=g+2;s=rr(this,a,t,n,l,h,d,T,L,M),s&&(s.faceIndex=Math.floor(g/3),e.push(s))}}}};function Xu(i,t,e,n,s,r,a,o){let c;if(t.side===Fe?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,t.side===Zn,o),c===null)return null;sr.copy(o),sr.applyMatrix4(i.matrixWorld);let l=e.ray.origin.distanceTo(sr);return l<e.near||l>e.far?null:{distance:l,point:sr.clone(),object:i}}function rr(i,t,e,n,s,r,a,o,c,l){i.getVertexPosition(o,tr),i.getVertexPosition(c,er),i.getVertexPosition(l,nr);let h=Xu(i,t,e,n,tr,er,nr,lc);if(h){let d=new U;wn.getBarycoord(lc,tr,er,nr,d),s&&(h.uv=wn.getInterpolatedAttribute(s,o,c,l,d,new Nt)),r&&(h.uv1=wn.getInterpolatedAttribute(r,o,c,l,d,new Nt)),a&&(h.normal=wn.getInterpolatedAttribute(a,o,c,l,d,new U),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a:o,b:c,c:l,normal:new U,materialIndex:0};wn.getNormal(tr,er,nr,u.normal),h.face=u,h.barycoord=d}return h}var Rr=class extends Be{constructor(t=null,e=1,n=1,s,r,a,o,c,l=Ee,h=Ee,d,u){super(null,a,o,c,l,h,s,r,d,u),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var si=new ai,qu=new Nt(.5,.5),ar=new U,Oi=class{constructor(t=new Ze,e=new Ze,n=new Ze,s=new Ze,r=new Ze,a=new Ze){this.planes=[t,e,n,s,r,a]}set(t,e,n,s,r,a){let o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(t){let e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=rn,n=!1){let s=this.planes,r=t.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],d=r[5],u=r[6],p=r[7],_=r[8],v=r[9],g=r[10],f=r[11],T=r[12],L=r[13],M=r[14],b=r[15];if(s[0].setComponents(l-a,p-h,f-_,b-T).normalize(),s[1].setComponents(l+a,p+h,f+_,b+T).normalize(),s[2].setComponents(l+o,p+d,f+v,b+L).normalize(),s[3].setComponents(l-o,p-d,f-v,b-L).normalize(),n)s[4].setComponents(c,u,g,M).normalize(),s[5].setComponents(l-c,p-u,f-g,b-M).normalize();else if(s[4].setComponents(l-c,p-u,f-g,b-M).normalize(),e===rn)s[5].setComponents(l+c,p+u,f+g,b+M).normalize();else if(e===Li)s[5].setComponents(c,u,g,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),si.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),si.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(si)}intersectsSprite(t){si.center.set(0,0,0);let e=qu.distanceTo(t.center);return si.radius=.7071067811865476+e,si.applyMatrix4(t.matrixWorld),this.intersectsSphere(si)}intersectsSphere(t){let e=this.planes,n=t.center,s=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(t){let e=this.planes;for(let n=0;n<6;n++){let s=e[n];if(ar.x=s.normal.x>0?t.max.x:t.min.x,ar.y=s.normal.y>0?t.max.y:t.min.y,ar.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(ar)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var Bi=class extends Rn{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ft(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},Pr=new U,Ir=new U,cc=new ce,es=new oi,or=new ai,So=new U,hc=new U,Lr=class extends Ae{constructor(t=new ke,e=new Bi){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let s=1,r=e.count;s<r;s++)Pr.fromBufferAttribute(e,s-1),Ir.fromBufferAttribute(e,s),n[s]=n[s-1],n[s]+=Pr.distanceTo(Ir);t.setAttribute("lineDistance",new Ue(n,1))}else It("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(t){return t.intersectsObject(this)}raycast(t,e){let n=this.geometry,s=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),or.copy(n.boundingSphere),or.applyMatrix4(s),or.radius+=r,t.ray.intersectsSphere(or)===!1)return;cc.copy(s).invert(),es.copy(t.ray).applyMatrix4(cc);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,u=n.attributes.position;if(h!==null){let p=Math.max(0,a.start),_=Math.min(h.count,a.start+a.count);for(let v=p,g=_-1;v<g;v+=l){let f=h.getX(v),T=h.getX(v+1),L=lr(this,t,es,c,f,T,v);L&&e.push(L)}if(this.isLineLoop){let v=h.getX(_-1),g=h.getX(p),f=lr(this,t,es,c,v,g,_-1);f&&e.push(f)}}else{let p=Math.max(0,a.start),_=Math.min(u.count,a.start+a.count);for(let v=p,g=_-1;v<g;v+=l){let f=lr(this,t,es,c,v,v+1,v);f&&e.push(f)}if(this.isLineLoop){let v=lr(this,t,es,c,_-1,p,_-1);v&&e.push(v)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}};function lr(i,t,e,n,s,r,a){let o=i.geometry.attributes.position;if(Pr.fromBufferAttribute(o,s),Ir.fromBufferAttribute(o,r),e.distanceSqToSegment(Pr,Ir,So,hc)>n)return;So.applyMatrix4(i.matrixWorld);let l=t.ray.origin.distanceTo(So);if(!(l<t.near||l>t.far))return{distance:l,point:hc.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}var uc=new U,dc=new U,fs=class extends Lr{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let s=0,r=e.count;s<r;s+=2)uc.fromBufferAttribute(e,s),dc.fromBufferAttribute(e,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+uc.distanceTo(dc);t.setAttribute("lineDistance",new Ue(n,1))}else It("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var ps=class extends Be{constructor(t=[],e=Jn,n,s,r,a,o,c,l,h){super(t,e,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}};var Vn=class extends Be{constructor(t,e,n=ln,s,r,a,o=Ee,c=Ee,l,h=pn,d=1){if(h!==pn&&h!==Kn)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let u={width:t,height:e,depth:d};super(u,s,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Ui(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return e.compareFunction=this.compareFunction,e}},Dr=class extends Vn{constructor(t,e=ln,n=Jn,s,r,a=Ee,o=Ee,c,l=pn){let h={width:t,height:t,depth:1},d=[h,h,h,h,h,h];super(t,t,e,n,s,r,a,o,c,l),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}},ms=class extends Be{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}},zi=class i extends ke{constructor(t=1,e=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};let o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);let c=[],l=[],h=[],d=[],u=0,p=0;_("z","y","x",-1,-1,n,e,t,a,r,0),_("z","y","x",1,-1,n,e,-t,a,r,1),_("x","z","y",1,1,t,n,e,s,a,2),_("x","z","y",1,-1,t,n,-e,s,a,3),_("x","y","z",1,-1,t,e,n,s,r,4),_("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new Ue(l,3)),this.setAttribute("normal",new Ue(h,3)),this.setAttribute("uv",new Ue(d,2));function _(v,g,f,T,L,M,b,E,A,x,w){let D=M/A,O=b/x,V=M/2,H=b/2,R=E/2,W=A+1,$=x+1,K=0,st=0,Y=new U;for(let et=0;et<$;et++){let it=et*O-H;for(let Ct=0;Ct<W;Ct++){let Et=Ct*D-V;Y[v]=Et*T,Y[g]=it*L,Y[f]=R,l.push(Y.x,Y.y,Y.z),Y[v]=0,Y[g]=0,Y[f]=E>0?1:-1,h.push(Y.x,Y.y,Y.z),d.push(Ct/A),d.push(1-et/x),K+=1}}for(let et=0;et<x;et++)for(let it=0;it<A;it++){let Ct=u+it+W*et,Et=u+it+W*(et+1),ee=u+(it+1)+W*(et+1),Lt=u+(it+1)+W*et;c.push(Ct,Et,Lt),c.push(Et,ee,Lt),st+=6}o.addGroup(p,st,w),p+=st,u+=K}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new i(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};var cr=new U,hr=new U,bo=new U,ur=new wn,gs=class extends ke{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},t!==null){let s=Math.pow(10,4),r=Math.cos(Ri*e),a=t.getIndex(),o=t.getAttribute("position"),c=a?a.count:o.count,l=[0,0,0],h=["a","b","c"],d=new Array(3),u={},p=[];for(let _=0;_<c;_+=3){a?(l[0]=a.getX(_),l[1]=a.getX(_+1),l[2]=a.getX(_+2)):(l[0]=_,l[1]=_+1,l[2]=_+2);let{a:v,b:g,c:f}=ur;if(v.fromBufferAttribute(o,l[0]),g.fromBufferAttribute(o,l[1]),f.fromBufferAttribute(o,l[2]),ur.getNormal(bo),d[0]=`${Math.round(v.x*s)},${Math.round(v.y*s)},${Math.round(v.z*s)}`,d[1]=`${Math.round(g.x*s)},${Math.round(g.y*s)},${Math.round(g.z*s)}`,d[2]=`${Math.round(f.x*s)},${Math.round(f.y*s)},${Math.round(f.z*s)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let T=0;T<3;T++){let L=(T+1)%3,M=d[T],b=d[L],E=ur[h[T]],A=ur[h[L]],x=`${M}_${b}`,w=`${b}_${M}`;w in u&&u[w]?(bo.dot(u[w].normal)<=r&&(p.push(E.x,E.y,E.z),p.push(A.x,A.y,A.z)),u[w]=null):x in u||(u[x]={index0:l[T],index1:l[L],normal:bo.clone()})}}for(let _ in u)if(u[_]){let{index0:v,index1:g}=u[_];cr.fromBufferAttribute(o,v),hr.fromBufferAttribute(o,g),p.push(cr.x,cr.y,cr.z),p.push(hr.x,hr.y,hr.z)}this.setAttribute("position",new Ue(p,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}};var _s=class i extends ke{constructor(t=1,e=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:s};let r=t/2,a=e/2,o=Math.floor(n),c=Math.floor(s),l=o+1,h=c+1,d=t/o,u=e/c,p=[],_=[],v=[],g=[];for(let f=0;f<h;f++){let T=f*u-a;for(let L=0;L<l;L++){let M=L*d-r;_.push(M,-T,0),v.push(0,0,1),g.push(L/o),g.push(1-f/c)}}for(let f=0;f<c;f++)for(let T=0;T<o;T++){let L=T+l*f,M=T+l*(f+1),b=T+1+l*(f+1),E=T+1+l*f;p.push(L,M,E),p.push(M,b,E)}this.setIndex(p),this.setAttribute("position",new Ue(_,3)),this.setAttribute("normal",new Ue(v,3)),this.setAttribute("uv",new Ue(g,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new i(t.width,t.height,t.widthSegments,t.heightSegments)}};function hi(i){let t={};for(let e in i){t[e]={};for(let n in i[e]){let s=i[e][n];if(fc(s))s.isRenderTargetTexture?(It("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=s.clone();else if(Array.isArray(s))if(fc(s[0])){let r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();t[e][n]=r}else t[e][n]=s.slice();else t[e][n]=s}}return t}function Le(i){let t={};for(let e=0;e<i.length;e++){let n=hi(i[e]);for(let s in n)t[s]=n[s]}return t}function fc(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function Yu(i){let t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function il(i){let t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Yt.workingColorSpace}var sh={clone:hi,merge:Le},Zu=`void main() {
|
|
1
|
+
"use strict";(()=>{var ii={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},si={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Pc=0,Go=1,Ic=2;var Fs=1,Lc=2,es=3,ri=0,Vt=1,bn=2,vi=0,ts=1,Ho=2,Wo=3,Xo=4,Dc=5;var Mi=100,Nc=101,Uc=102,Fc=103,Oc=104,Bc=200,zc=201,kc=202,Vc=203,qo=204,Yo=205,Gc=206,Hc=207,Wc=208,Xc=209,qc=210,Yc=211,Zc=212,$c=213,Jc=214,Pr=0,Ir=1,Lr=2,Gi=3,Dr=4,Nr=5,Ur=6,Fr=7,ua=0,Kc=1,jc=2,Sn=0,Zo=1,$o=2,Jo=3,Ko=4,jo=5,Qo=6,Os=7;var el=300,bi=301,ns=302,da=303,fa=304,Or=1e3,vn=1001,Br=1002,Et=1003,Qc=1004;var Bs=1005;var kt=1006,pa=1007;var Gn=1008;var Xt=1009,tl=1010,nl=1011,is=1012,ma=1013,fn=1014,pn=1015,mn=1016,ga=1017,_a=1018,Si=1020,il=35902,sl=35899,rl=1021,al=1022,gn=1023,Bn=1026,Hn=1027,ol=1028,xa=1029,ai=1030,ya=1031;var va=1033,zs=33776,ks=33777,Vs=33778,Gs=33779,Ma=35840,ba=35841,Sa=35842,wa=35843,Ea=36196,Ta=37492,Aa=37496,Ra=37488,Ca=37489,Hs=37490,Pa=37491,Ia=37808,La=37809,Da=37810,Na=37811,Ua=37812,Fa=37813,Oa=37814,Ba=37815,za=37816,ka=37817,Va=37818,Ga=37819,Ha=37820,Wa=37821,Xa=36492,qa=36494,Ya=36495,Za=36283,$a=36284,Ws=36285,Ja=36286;var _s=2300,zr=2301,Rr=2302,Uo=2303,Fo=2400,Oo=2401,Bo=2402;var eh=3200;var Ka=0,th=1,Wn="",Jt="srgb",xs="srgb-linear",ys="linear",nt="srgb";var Cr=7680;var nh=519,ih=512,sh=513,rh=514,ll=515,ah=516,oh=517,cl=518,hl=519,lh=35044;var ul="300 es",on=2e3,Hi=2001;function Du(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Nu(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function vs(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function ch(){let i=vs("canvas");return i.style.display="block",i}var nc={},Wi=null;function dl(...i){let e="THREE."+i.shift();Wi?Wi("log",e,...i):console.log(e,...i)}function hh(i){let e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Ie(...i){i=hh(i);let e="THREE."+i.shift();if(Wi)Wi("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Ue(...i){i=hh(i);let e="THREE."+i.shift();if(Wi)Wi("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function ms(...i){let e=i.join(" ");e in nc||(nc[e]=!0,Ie(...i))}function uh(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}var dh={[Pr]:Pr,[Lr]:Ur,[Dr]:Dr,[Gi]:Nr,[Ir]:Ir,[Ur]:Lr,[Fr]:Fr,[Nr]:Gi},dn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let s=n[e];if(s!==void 0){let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,e);e.target=null}}},Dt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],ic=1234567,ki=Math.PI/180,Xi=180/Math.PI;function ss(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Dt[i&255]+Dt[i>>8&255]+Dt[i>>16&255]+Dt[i>>24&255]+"-"+Dt[e&255]+Dt[e>>8&255]+"-"+Dt[e>>16&15|64]+Dt[e>>24&255]+"-"+Dt[t&63|128]+Dt[t>>8&255]+"-"+Dt[t>>16&255]+Dt[t>>24&255]+Dt[n&255]+Dt[n>>8&255]+Dt[n>>16&255]+Dt[n>>24&255]).toLowerCase()}function We(i,e,t){return Math.max(e,Math.min(t,i))}function fl(i,e){return(i%e+e)%e}function Uu(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function Fu(i,e,t){return i!==e?(t-i)/(e-i):0}function gs(i,e,t){return(1-t)*i+t*e}function Ou(i,e,t,n){return gs(i,e,1-Math.exp(-t*n))}function Bu(i,e=1){return e-Math.abs(fl(i,e*2)-e)}function zu(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function ku(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function Vu(i,e){return i+Math.floor(Math.random()*(e-i+1))}function Gu(i,e){return i+Math.random()*(e-i)}function Hu(i){return i*(.5-Math.random())}function Wu(i){i!==void 0&&(ic=i);let e=ic+=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 Xu(i){return i*ki}function qu(i){return i*Xi}function Yu(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function Zu(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function pl(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function $u(i,e,t,n,s){let r=Math.cos,a=Math.sin,o=r(t/2),c=a(t/2),l=r((e+n)/2),h=a((e+n)/2),d=r((e-n)/2),u=a((e-n)/2),m=r((n-e)/2),_=a((n-e)/2);switch(s){case"XYX":i.set(o*h,c*d,c*u,o*l);break;case"YZY":i.set(c*u,o*h,c*d,o*l);break;case"ZXZ":i.set(c*d,c*u,o*h,o*l);break;case"XZX":i.set(o*h,c*_,c*m,o*l);break;case"YXY":i.set(c*m,o*h,c*_,o*l);break;case"ZYZ":i.set(c*_,c*m,o*h,o*l);break;default:Ie("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function ml(i){switch(i.constructor){case Uint32Array:return 4294967295;case Uint16Array:return 65535;case Uint8Array:case Uint8ClampedArray:return 255;case Int32Array:return 2147483647;case Int16Array:return 32767;case Int8Array:return 127;default:return}}function fh(i,e){if(e.constructor===Float32Array)return i;let t=ml(e);if(t===void 0)throw new Error("THREE.MathUtils: Invalid component type.");return Math.max(i/t,-1)}function ph(i,e){if(e.constructor===Float32Array)return i;let t=ml(e);if(t===void 0)throw new Error("THREE.MathUtils: Invalid component type.");return Math.round(i*t)}var gl={DEG2RAD:ki,RAD2DEG:Xi,generateUUID:ss,clamp:We,euclideanModulo:fl,mapLinear:Uu,inverseLerp:Fu,lerp:gs,damp:Ou,pingpong:Bu,smoothstep:zu,smootherstep:ku,randInt:Vu,randFloat:Gu,randFloatSpread:Hu,seededRandom:Wu,degToRad:Xu,radToDeg:qu,isPowerOfTwo:Yu,ceilPowerOfTwo:Zu,floorPowerOfTwo:pl,setQuaternionFromProperEuler:$u,normalize:ph,denormalize:fh},Ml=class Ml{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: 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("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[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=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(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){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(We(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let 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){let n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*s+e.x,this.y=r*s+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Ml.prototype.isVector2=!0;var Fe=Ml,jt=class{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let c=n[s+0],l=n[s+1],h=n[s+2],d=n[s+3],u=r[a+0],m=r[a+1],_=r[a+2],y=r[a+3];if(d!==y||c!==u||l!==m||h!==_){let p=c*u+l*m+h*_+d*y;p<0&&(u=-u,m=-m,_=-_,y=-y,p=-p);let f=1-o;if(p<.9995){let S=Math.acos(p),A=Math.sin(S);f=Math.sin(f*S)/A,o=Math.sin(o*S)/A,c=c*f+u*o,l=l*f+m*o,h=h*f+_*o,d=d*f+y*o}else{c=c*f+u*o,l=l*f+m*o,h=h*f+_*o,d=d*f+y*o;let S=1/Math.sqrt(c*c+l*l+h*h+d*d);c*=S,l*=S,h*=S,d*=S}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,s,r,a){let o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],d=r[a],u=r[a+1],m=r[a+2],_=r[a+3];return e[t]=o*_+h*d+c*m-l*u,e[t+1]=c*_+h*u+l*d-o*m,e[t+2]=l*_+h*m+o*u-c*d,e[t+3]=h*_-o*d-c*u-l*m,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,s){return this._x=e,this._y=t,this._z=n,this._w=s,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){let n=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(s/2),d=o(r/2),u=c(n/2),m=c(s/2),_=c(r/2);switch(a){case"XYZ":this._x=u*h*d+l*m*_,this._y=l*m*d-u*h*_,this._z=l*h*_+u*m*d,this._w=l*h*d-u*m*_;break;case"YXZ":this._x=u*h*d+l*m*_,this._y=l*m*d-u*h*_,this._z=l*h*_-u*m*d,this._w=l*h*d+u*m*_;break;case"ZXY":this._x=u*h*d-l*m*_,this._y=l*m*d+u*h*_,this._z=l*h*_+u*m*d,this._w=l*h*d-u*m*_;break;case"ZYX":this._x=u*h*d-l*m*_,this._y=l*m*d+u*h*_,this._z=l*h*_-u*m*d,this._w=l*h*d+u*m*_;break;case"YZX":this._x=u*h*d+l*m*_,this._y=l*m*d+u*h*_,this._z=l*h*_-u*m*d,this._w=l*h*d-u*m*_;break;case"XZY":this._x=u*h*d-l*m*_,this._y=l*m*d-u*h*_,this._z=l*h*_+u*m*d,this._w=l*h*d+u*m*_;break;default:Ie("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],s=t[4],r=t[8],a=t[1],o=t[5],c=t[9],l=t[2],h=t[6],d=t[10],u=n+o+d;if(u>0){let m=.5/Math.sqrt(u+1);this._w=.25/m,this._x=(h-c)*m,this._y=(r-l)*m,this._z=(a-s)*m}else if(n>o&&n>d){let m=2*Math.sqrt(1+n-o-d);this._w=(h-c)/m,this._x=.25*m,this._y=(s+a)/m,this._z=(r+l)/m}else if(o>d){let m=2*Math.sqrt(1+o-n-d);this._w=(r-l)/m,this._x=(s+a)/m,this._y=.25*m,this._z=(c+h)/m}else{let m=2*Math.sqrt(1+d-n-o);this._w=(a-s)/m,this._x=(r+l)/m,this._y=(c+h)/m,this._z=.25*m}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(We(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let s=Math.min(1,t/n);return this.slerp(e,s),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){let n=e._x,s=e._y,r=e._z,a=e._w,o=t._x,c=t._y,l=t._z,h=t._w;return this._x=n*h+a*o+s*l-r*c,this._y=s*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-s*o,this._w=a*h-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let c=1-t;if(o<.9995){let l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,t=Math.sin(t*l)/h,this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*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}},bl=class bl{constructor(e=0,t=0,n=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("THREE.Vector3: 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("THREE.Vector3: 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(sc.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(sc.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,s=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*s-o*n),h=2*(o*t-r*s),d=2*(r*n-a*t);return this.x=t+c*l+a*d-o*h,this.y=n+c*h+o*l-r*d,this.z=s+c*d+r*h-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,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=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this.z=We(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this.z=We(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(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){let n=e.x,s=e.y,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return fo.copy(this).projectOnVector(e),this.sub(fo)}reflect(e){return this.sub(fo.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(We(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}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){let s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*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){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,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(){let 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}};bl.prototype.isVector3=!0;var B=bl,fo=new B,sc=new jt,Sl=class Sl{constructor(e,t,n,s,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l)}set(e,t,n,s,r,a,o,c,l){let h=this.elements;return h[0]=e,h[1]=s,h[2]=o,h[3]=t,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let 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){let 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){let n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],d=n[7],u=n[2],m=n[5],_=n[8],y=s[0],p=s[3],f=s[6],S=s[1],A=s[4],b=s[7],T=s[2],w=s[5],g=s[8];return r[0]=a*y+o*S+c*T,r[3]=a*p+o*A+c*w,r[6]=a*f+o*b+c*g,r[1]=l*y+h*S+d*T,r[4]=l*p+h*A+d*w,r[7]=l*f+h*b+d*g,r[2]=u*y+m*S+_*T,r[5]=u*p+m*A+_*w,r[8]=u*f+m*b+_*g,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*a*h-t*o*l-n*r*h+n*o*c+s*r*l-s*a*c}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],d=h*a-o*l,u=o*c-h*r,m=l*r-a*c,_=t*d+n*u+s*m;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/_;return e[0]=d*y,e[1]=(s*l-h*n)*y,e[2]=(o*n-s*a)*y,e[3]=u*y,e[4]=(h*t-s*c)*y,e[5]=(s*r-o*t)*y,e[6]=m*y,e[7]=(n*c-l*t)*y,e[8]=(a*t-n*r)*y,this}transpose(){let e,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){let 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,s,r,a,o){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-s*l,s*c,-s*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return ms("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(po.makeScale(e,t)),this}rotate(e){return ms("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(po.makeRotation(-e)),this}translate(e,t){return ms("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(po.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){let 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){let t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])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){let 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)}};Sl.prototype.isMatrix3=!0;var Oe=Sl,po=new Oe,rc=new Oe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ac=new Oe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Ju(){let i={enabled:!0,workingColorSpace:xs,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===nt&&(s.r=On(s.r),s.g=On(s.g),s.b=On(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===nt&&(s.r=Vi(s.r),s.g=Vi(s.g),s.b=Vi(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Wn?ys:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[a].fromXYZ).multiply(this.spaces[r].toXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[xs]:{primaries:e,whitePoint:n,transfer:ys,toXYZ:rc,fromXYZ:ac,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Jt},outputColorSpaceConfig:{drawingBufferColorSpace:Jt}},[Jt]:{primaries:e,whitePoint:n,transfer:nt,toXYZ:rc,fromXYZ:ac,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Jt}}}),i}var Ze=Ju();function On(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Vi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Ai,kr=class{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{Ai===void 0&&(Ai=vs("canvas")),Ai.width=e.width,Ai.height=e.height;let s=Ai.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=Ai}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){let t=vs("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=On(r[a]/255)*255;return n.putImageData(s,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(On(t[n]/255)*255):t[n]=On(t[n]);return{data:t,width:e.width,height:e.height}}else return Ie("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Ku=0,qi=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Ku++}),this.uuid=ss(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let 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.displayWidth,t.displayHeight,0):t!==null?e.set(t.width||0,t.height||0,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(mo(s[a].image)):r.push(mo(s[a]))}else r=mo(s);n.url=r}return t||(e.images[this.uuid]=n),n}};function mo(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?kr.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Ie("Texture: Unable to serialize Texture."),{})}var ju=0,go=new B,Ht=class i extends dn{constructor(e=i.DEFAULT_IMAGE,t=i.DEFAULT_MAPPING,n=vn,s=vn,r=kt,a=Gn,o=gn,c=Xt,l=i.DEFAULT_ANISOTROPY,h=Wn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ju++}),this.uuid=ss(),this.name="",this.source=new qi(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Fe(0,0),this.repeat=new Fe(1,1),this.center=new Fe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Oe,this.generateMipmaps=!0,this.mipmapsAutoUpdate=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,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,this.isPMREMTexture=!1,this.normalized=!1}get width(){return this.source.getSize(go).x}get height(){return this.source.getSize(go).y}get depth(){return this.source.getSize(go).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}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.normalized=e.normalized,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.mipmapsAutoUpdate=e.mipmapsAutoUpdate,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.isPMREMTexture=e.isPMREMTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Ie(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Ie(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let 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,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,mipmapsAutoUpdate:this.mipmapsAutoUpdate,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!==el)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Or:e.x=e.x-Math.floor(e.x);break;case vn:e.x=e.x<0?0:1;break;case Br: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 Or:e.y=e.y-Math.floor(e.y);break;case vn:e.y=e.y<0?0:1;break;case Br: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++}};Ht.DEFAULT_IMAGE=null;Ht.DEFAULT_MAPPING=el;Ht.DEFAULT_ANISOTROPY=1;var wl=class wl{constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}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,s){return this.x=e,this.y=t,this.z=n,this.w=s,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("THREE.Vector4: 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("THREE.Vector4: 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){let t=this.x,n=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*s+a[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);let 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,s,r,c=e.elements,l=c[0],h=c[4],d=c[8],u=c[1],m=c[5],_=c[9],y=c[2],p=c[6],f=c[10];if(Math.abs(h-u)<.01&&Math.abs(d-y)<.01&&Math.abs(_-p)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+y)<.1&&Math.abs(_+p)<.1&&Math.abs(l+m+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let A=(l+1)/2,b=(m+1)/2,T=(f+1)/2,w=(h+u)/4,g=(d+y)/4,M=(_+p)/4;return A>b&&A>T?A<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(A),s=w/n,r=g/n):b>T?b<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(b),n=w/s,r=M/s):T<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(T),n=g/r,s=M/r),this.set(n,s,r,t),this}let S=Math.sqrt((p-_)*(p-_)+(d-y)*(d-y)+(u-h)*(u-h));return Math.abs(S)<.001&&(S=1),this.x=(p-_)/S,this.y=(d-y)/S,this.z=(u-h)/S,this.w=Math.acos((l+m+f-1)/2),this}setFromMatrixPosition(e){let 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=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this.z=We(this.z,e.z,t.z),this.w=We(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this.z=We(this.z,e,t),this.w=We(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(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}};wl.prototype.isVector4=!0;var dt=wl,Vr=class extends dn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:kt,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new dt(0,0,e,t),this.scissorTest=!1,this.viewport=new dt(0,0,e,t),this.textures=[];let s=n.count;for(let r=0;r<s;r++)this.textures[r]=new Ht({width:e,height:t,depth:n.depth}),this.textures[r].isRenderTargetTexture=!0,this.textures[r].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:kt,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.mipmapsAutoUpdate!==void 0&&(t.mipmapsAutoUpdate=e.mipmapsAutoUpdate),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===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===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 s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].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;let s=Object.assign({},e.textures[t].image);this.textures[t].source=new qi(s)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;else this.depthTexture=null;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}},Qt=class extends Vr{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Ms=class extends Ht{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Et,this.minFilter=Et,this.wrapR=vn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var Gr=class extends Ht{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Et,this.minFilter=Et,this.wrapR=vn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}};var ha=class ha{constructor(e,t,n,s,r,a,o,c,l,h,d,u,m,_,y,p){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,s,r,a,o,c,l,h,d,u,m,_,y,p)}set(e,t,n,s,r,a,o,c,l,h,d,u,m,_,y,p){let f=this.elements;return f[0]=e,f[4]=t,f[8]=n,f[12]=s,f[1]=r,f[5]=a,f[9]=o,f[13]=c,f[2]=l,f[6]=h,f[10]=d,f[14]=u,f[3]=m,f[7]=_,f[11]=y,f[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 ha().fromArray(this.elements)}copy(e){let 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){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let 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.determinantAffine()===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.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,s=1/Ri.setFromMatrixColumn(e,0).length(),r=1/Ri.setFromMatrixColumn(e,1).length(),a=1/Ri.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,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]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,s=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){let u=a*h,m=a*d,_=o*h,y=o*d;t[0]=c*h,t[4]=-c*d,t[8]=l,t[1]=m+_*l,t[5]=u-y*l,t[9]=-o*c,t[2]=y-u*l,t[6]=_+m*l,t[10]=a*c}else if(e.order==="YXZ"){let u=c*h,m=c*d,_=l*h,y=l*d;t[0]=u+y*o,t[4]=_*o-m,t[8]=a*l,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=m*o-_,t[6]=y+u*o,t[10]=a*c}else if(e.order==="ZXY"){let u=c*h,m=c*d,_=l*h,y=l*d;t[0]=u-y*o,t[4]=-a*d,t[8]=_+m*o,t[1]=m+_*o,t[5]=a*h,t[9]=y-u*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){let u=a*h,m=a*d,_=o*h,y=o*d;t[0]=c*h,t[4]=_*l-m,t[8]=u*l+y,t[1]=c*d,t[5]=y*l+u,t[9]=m*l-_,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){let u=a*c,m=a*l,_=o*c,y=o*l;t[0]=c*h,t[4]=y-u*d,t[8]=_*d+m,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-l*h,t[6]=m*d+_,t[10]=u-y*d}else if(e.order==="XZY"){let u=a*c,m=a*l,_=o*c,y=o*l;t[0]=c*h,t[4]=-d,t[8]=l*h,t[1]=u*d+y,t[5]=a*h,t[9]=m*d-_,t[2]=_*d-m,t[6]=o*h,t[10]=y*d+u}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(Qu,e,ed)}lookAt(e,t,n){let s=this.elements;return Zt.subVectors(e,t),Zt.lengthSq()===0&&(Zt.z=1),Zt.normalize(),Yn.crossVectors(n,Zt),Yn.lengthSq()===0&&(Math.abs(n.z)===1?Zt.x+=1e-4:Zt.z+=1e-4,Zt.normalize(),Yn.crossVectors(n,Zt)),Yn.normalize(),ir.crossVectors(Zt,Yn),s[0]=Yn.x,s[4]=ir.x,s[8]=Zt.x,s[1]=Yn.y,s[5]=ir.y,s[9]=Zt.y,s[2]=Yn.z,s[6]=ir.z,s[10]=Zt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],d=n[5],u=n[9],m=n[13],_=n[2],y=n[6],p=n[10],f=n[14],S=n[3],A=n[7],b=n[11],T=n[15],w=s[0],g=s[4],M=s[8],U=s[12],I=s[1],D=s[5],F=s[9],H=s[13],C=s[2],Y=s[6],J=s[10],z=s[14],te=s[3],W=s[7],$=s[11],ae=s[15];return r[0]=a*w+o*I+c*C+l*te,r[4]=a*g+o*D+c*Y+l*W,r[8]=a*M+o*F+c*J+l*$,r[12]=a*U+o*H+c*z+l*ae,r[1]=h*w+d*I+u*C+m*te,r[5]=h*g+d*D+u*Y+m*W,r[9]=h*M+d*F+u*J+m*$,r[13]=h*U+d*H+u*z+m*ae,r[2]=_*w+y*I+p*C+f*te,r[6]=_*g+y*D+p*Y+f*W,r[10]=_*M+y*F+p*J+f*$,r[14]=_*U+y*H+p*z+f*ae,r[3]=S*w+A*I+b*C+T*te,r[7]=S*g+A*D+b*Y+T*W,r[11]=S*M+A*F+b*J+T*$,r[15]=S*U+A*H+b*z+T*ae,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[12],a=e[1],o=e[5],c=e[9],l=e[13],h=e[2],d=e[6],u=e[10],m=e[14],_=e[3],y=e[7],p=e[11],f=e[15],S=c*m-l*u,A=o*m-l*d,b=o*u-c*d,T=a*m-l*h,w=a*u-c*h,g=a*d-o*h;return t*(y*S-p*A+f*b)-n*(_*S-p*T+f*w)+s*(_*A-y*T+f*g)-r*(_*b-y*w+p*g)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[1],a=e[5],o=e[9],c=e[2],l=e[6],h=e[10];return t*(a*h-o*l)-n*(r*h-o*c)+s*(r*l-a*c)}transpose(){let e=this.elements,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){let s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],d=e[9],u=e[10],m=e[11],_=e[12],y=e[13],p=e[14],f=e[15],S=t*o-n*a,A=t*c-s*a,b=t*l-r*a,T=n*c-s*o,w=n*l-r*o,g=s*l-r*c,M=h*y-d*_,U=h*p-u*_,I=h*f-m*_,D=d*p-u*y,F=d*f-m*y,H=u*f-m*p,C=S*H-A*F+b*D+T*I-w*U+g*M;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let Y=1/C;return e[0]=(o*H-c*F+l*D)*Y,e[1]=(s*F-n*H-r*D)*Y,e[2]=(y*g-p*w+f*T)*Y,e[3]=(u*w-d*g-m*T)*Y,e[4]=(c*I-a*H-l*U)*Y,e[5]=(t*H-s*I+r*U)*Y,e[6]=(p*b-_*g-f*A)*Y,e[7]=(h*g-u*b+m*A)*Y,e[8]=(a*F-o*I+l*M)*Y,e[9]=(n*I-t*F-r*M)*Y,e[10]=(_*w-y*b+f*S)*Y,e[11]=(d*b-h*w-m*S)*Y,e[12]=(o*U-a*D-c*M)*Y,e[13]=(t*D-n*U+s*M)*Y,e[14]=(y*A-_*T-p*S)*Y,e[15]=(h*T-d*A+u*S)*Y,this}scale(e){let t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){let 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],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}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){let 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){let 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){let 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){let n=Math.cos(t),s=Math.sin(t),r=1-n,a=e.x,o=e.y,c=e.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-s*c,l*c+s*o,0,l*o+s*c,h*o+n,h*c-s*a,0,l*c-s*o,h*c+s*a,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,s,r,a){return this.set(1,n,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){let s=this.elements,r=t._x,a=t._y,o=t._z,c=t._w,l=r+r,h=a+a,d=o+o,u=r*l,m=r*h,_=r*d,y=a*h,p=a*d,f=o*d,S=c*l,A=c*h,b=c*d,T=n.x,w=n.y,g=n.z;return s[0]=(1-(y+f))*T,s[1]=(m+b)*T,s[2]=(_-A)*T,s[3]=0,s[4]=(m-b)*w,s[5]=(1-(u+f))*w,s[6]=(p+S)*w,s[7]=0,s[8]=(_+A)*g,s[9]=(p-S)*g,s[10]=(1-(u+y))*g,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){let s=this.elements;e.x=s[12],e.y=s[13],e.z=s[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let a=Ri.set(s[0],s[1],s[2]).length(),o=Ri.set(s[4],s[5],s[6]).length(),c=Ri.set(s[8],s[9],s[10]).length();r<0&&(a=-a),cn.copy(this);let l=1/a,h=1/o,d=1/c;return cn.elements[0]*=l,cn.elements[1]*=l,cn.elements[2]*=l,cn.elements[4]*=h,cn.elements[5]*=h,cn.elements[6]*=h,cn.elements[8]*=d,cn.elements[9]*=d,cn.elements[10]*=d,t.setFromRotationMatrix(cn),n.x=a,n.y=o,n.z=c,this}makePerspective(e,t,n,s,r,a,o=on,c=!1){let l=this.elements,h=2*r/(t-e),d=2*r/(n-s),u=(t+e)/(t-e),m=(n+s)/(n-s),_,y;if(c)_=r/(a-r),y=a*r/(a-r);else if(o===on)_=-(a+r)/(a-r),y=-2*a*r/(a-r);else if(o===Hi)_=-a/(a-r),y=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=d,l[9]=m,l[13]=0,l[2]=0,l[6]=0,l[10]=_,l[14]=y,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,s,r,a,o=on,c=!1){let l=this.elements,h=2/(t-e),d=2/(n-s),u=-(t+e)/(t-e),m=-(n+s)/(n-s),_,y;if(c)_=1/(a-r),y=a/(a-r);else if(o===on)_=-2/(a-r),y=-(a+r)/(a-r);else if(o===Hi)_=-1/(a-r),y=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=u,l[1]=0,l[5]=d,l[9]=0,l[13]=m,l[2]=0,l[6]=0,l[10]=_,l[14]=y,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])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){let 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}};ha.prototype.isMatrix4=!0;var ht=ha,Ri=new B,cn=new ht,Qu=new B(0,0,0),ed=new B(1,1,1),Yn=new B,ir=new B,Zt=new B,oc=new ht,lc=new jt,zn=class i{constructor(e=0,t=0,n=0,s=i.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}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,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,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){let s=e.elements,r=s[0],a=s[4],o=s[8],c=s[1],l=s[5],h=s[9],d=s[2],u=s[6],m=s[10];switch(t){case"XYZ":this._y=Math.asin(We(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-We(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(We(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,m),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-We(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,m),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(We(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-We(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,m),this._y=0);break;default:Ie("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return oc.makeRotationFromQuaternion(e),this.setFromRotationMatrix(oc,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return lc.setFromEuler(this),this.setFromQuaternion(lc,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}};zn.DEFAULT_ORDER="XYZ";var bs=class{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}},td=0,cc=new B,Ci=new jt,Pn=new ht,sr=new B,hs=new B,nd=new B,id=new jt,hc=new B(1,0,0),uc=new B(0,1,0),dc=new B(0,0,1),fc={type:"added"},sd={type:"removed"},Pi={type:"childadded",child:null},_o={type:"childremoved",child:null},Ct=class i extends dn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:td++}),this.uuid=ss(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let e=new B,t=new zn,n=new jt,s=new B(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(a),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:s},modelViewMatrix:{value:new ht},normalMatrix:{value:new Oe}}),this.matrix=new ht,this.matrixWorld=new ht,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new bs,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),this.pivot!==null&&this.position.copy(this.pivot).applyMatrix4(this.matrix).sub(this.pivot)}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 Ci.setFromAxisAngle(e,t),this.quaternion.multiply(Ci),this}rotateOnWorldAxis(e,t){return Ci.setFromAxisAngle(e,t),this.quaternion.premultiply(Ci),this}rotateX(e){return this.rotateOnAxis(hc,e)}rotateY(e){return this.rotateOnAxis(uc,e)}rotateZ(e){return this.rotateOnAxis(dc,e)}translateOnAxis(e,t){return cc.copy(e).applyQuaternion(this.quaternion),this.position.add(cc.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(hc,e)}translateY(e){return this.translateOnAxis(uc,e)}translateZ(e){return this.translateOnAxis(dc,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Pn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?sr.copy(e):sr.set(e,t,n);let s=this.parent;this.updateWorldMatrix(!0,!1),hs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Pn.lookAt(hs,sr,this.up):Pn.lookAt(sr,hs,this.up),this.quaternion.setFromRotationMatrix(Pn),s&&(Pn.extractRotation(s.matrixWorld),Ci.setFromRotationMatrix(Pn),this.quaternion.premultiply(Ci.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Ue("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(fc),Pi.child=e,this.dispatchEvent(Pi),Pi.child=null):Ue("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}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(sd),_o.child=e,this.dispatchEvent(_o),_o.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Pn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Pn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Pn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(fc),Pi.child=e,this.dispatchEvent(Pi),Pi.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,s=this.children.length;n<s;n++){let a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let s=this.children;for(let r=0,a=s.length;r<a;r++)s[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(hs,e,nd),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hs,id,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){return!0}traverse(e){e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,s=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*s,r[13]+=n-r[1]*t-r[5]*n-r[9]*s,r[14]+=s-r[2]*t-r[6]*n-r[10]*s}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);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let s=this.parent;if(e===!0&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){let r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(e){let 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"});let s={};s.uuid=this.uuid,s.type=this.type,s.name=this.name,s.castShadow=this.castShadow,s.receiveShadow=this.receiveShadow,s.visible=this.visible,s.frustumCulled=this.frustumCulled,s.renderOrder=this.renderOrder,s.static=this.static,s.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){let d=c[l];r(e.shapes,d)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(e.materials,this.material[c]));s.material=o}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){let c=this.animations[o];s.animations.push(r(e.animations,c))}}if(t){let o=a(e.geometries),c=a(e.materials),l=a(e.textures),h=a(e.images),d=a(e.shapes),u=a(e.skeletons),m=a(e.animations),_=a(e.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),m.length>0&&(n.animations=m),_.length>0&&(n.nodes=_)}return n.object=s,n;function a(o){let c=[];for(let l in o){let h=o[l];delete h.metadata,c.push(h)}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),this.pivot=e.pivot!==null?e.pivot.clone():null,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++){let s=e.children[n];this.add(s.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}};Ct.DEFAULT_UP=new B(0,1,0);Ct.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ct.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Fn=class extends Ct{constructor(){super(),this.isGroup=!0,this.type="Group"}},rd={type:"move"},Yi=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Fn,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 Fn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new B,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new B),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Fn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new B,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new B,this._grip.eventsEnabled=!1),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){let t=this._hand;if(t)for(let 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 s=null,r=null,a=null,o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(let y of e.hand.values()){let p=t.getJointPose(y,n),f=this._getHandJoint(l,y);p!==null&&(f.matrix.fromArray(p.transform.matrix),f.matrix.decompose(f.position,f.quaternion,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=p.radius),f.visible=p!==null}let h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],u=h.position.distanceTo(d.position),m=.02,_=.005;l.inputState.pinching&&u>m+_?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&u<=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.quaternion,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,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(rd)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Fn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},mh={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},Zn={h:0,s:0,l:0},rr={h:0,s:0,l:0};function xo(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var ze=class{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){let s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Jt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ze.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Ze.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ze.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Ze.workingColorSpace){if(e=fl(e,1),t=We(t,0,1),n=We(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=xo(a,r,e+1/3),this.g=xo(a,r,e),this.b=xo(a,r,e-1/3)}return Ze.colorSpaceToWorking(this,s),this}setStyle(e,t=Jt){function n(r){r!==void 0&&parseFloat(r)<1&&Ie("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))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+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseFloat(r[1]))/100,Math.min(100,parseFloat(r[2]))/100,Math.min(100,parseFloat(r[3]))/100,t);break;case"hsl":case"hsla":if(r=/^\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ie("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Ie("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Jt){let n=mh[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ie("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=On(e.r),this.g=On(e.g),this.b=On(e.b),this}copyLinearToSRGB(e){return this.r=Vi(e.r),this.g=Vi(e.g),this.b=Vi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Jt){return Ze.workingToColorSpace(Nt.copy(this),e),Math.round(We(Nt.r*255,0,255))*65536+Math.round(We(Nt.g*255,0,255))*256+Math.round(We(Nt.b*255,0,255))}getHexString(e=Jt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ze.workingColorSpace){Ze.workingToColorSpace(Nt.copy(this),t);let n=Nt.r,s=Nt.g,r=Nt.b,a=Math.max(n,s,r),o=Math.min(n,s,r),c,l,h=(o+a)/2;if(o===a)c=0,l=0;else{let d=a-o;switch(l=h<=.5?d/(a+o):d/(2-a-o),a){case n:c=(s-r)/d+(s<r?6:0);break;case s:c=(r-n)/d+2;break;case r:c=(n-s)/d+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=Ze.workingColorSpace){return Ze.workingToColorSpace(Nt.copy(this),t),e.r=Nt.r,e.g=Nt.g,e.b=Nt.b,e}getStyle(e=Jt){Ze.workingToColorSpace(Nt.copy(this),e);let t=Nt.r,n=Nt.g,s=Nt.b;return e!==Jt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(Zn),this.setHSL(Zn.h+e,Zn.s+t,Zn.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(Zn),e.getHSL(rr);let n=gs(Zn.h,rr.h,t),s=gs(Zn.s,rr.s,t),r=gs(Zn.l,rr.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,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}},Nt=new ze;ze.NAMES=mh;var Ss=class extends Ct{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 zn,this.environmentIntensity=1,this.environmentRotation=new zn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),this.background=e.background!==null?e.background.clone():null,this.environment=e.environment!==null?e.environment.clone():null,this.fog=e.fog!==null?e.fog.clone():null,this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),this.overrideMaterial=e.overrideMaterial!==null?e.overrideMaterial.clone():null,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},hn=new B,In=new B,yo=new B,Ln=new B,Ii=new B,Li=new B,pc=new B,vo=new B,Mo=new B,bo=new B,So=new dt,wo=new dt,Eo=new dt,Un=class i{constructor(e=new B,t=new B,n=new B){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),hn.subVectors(e,t),s.cross(hn);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){hn.subVectors(s,t),In.subVectors(n,t),yo.subVectors(e,t);let a=hn.dot(hn),o=hn.dot(In),c=hn.dot(yo),l=In.dot(In),h=In.dot(yo),d=a*l-o*o;if(d===0)return r.set(0,0,0),null;let u=1/d,m=(l*c-o*h)*u,_=(a*h-o*c)*u;return r.set(1-m-_,_,m)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Ln)===null?!1:Ln.x>=0&&Ln.y>=0&&Ln.x+Ln.y<=1}static getInterpolation(e,t,n,s,r,a,o,c){return this.getBarycoord(e,t,n,s,Ln)===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,Ln.x),c.addScaledVector(a,Ln.y),c.addScaledVector(o,Ln.z),c)}static getInterpolatedAttribute(e,t,n,s,r,a){return So.setScalar(0),wo.setScalar(0),Eo.setScalar(0),So.fromBufferAttribute(e,t),wo.fromBufferAttribute(e,n),Eo.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(So,r.x),a.addScaledVector(wo,r.y),a.addScaledVector(Eo,r.z),a}static isFrontFacing(e,t,n,s){return hn.subVectors(n,t),In.subVectors(e,t),hn.cross(In).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),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 hn.subVectors(this.c,this.b),In.subVectors(this.a,this.b),hn.cross(In).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return i.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,s=this.b,r=this.c,a,o;Ii.subVectors(s,n),Li.subVectors(r,n),vo.subVectors(e,n);let c=Ii.dot(vo),l=Li.dot(vo);if(c<=0&&l<=0)return t.copy(n);Mo.subVectors(e,s);let h=Ii.dot(Mo),d=Li.dot(Mo);if(h>=0&&d<=h)return t.copy(s);let u=c*d-h*l;if(u<=0&&c>=0&&h<=0&&c-h>0)return a=c/(c-h),t.copy(n).addScaledVector(Ii,a);bo.subVectors(e,r);let m=Ii.dot(bo),_=Li.dot(bo);if(_>=0&&m<=_)return t.copy(r);let y=m*l-c*_;if(y<=0&&l>=0&&_<=0)return o=l/(l-_),t.copy(n).addScaledVector(Li,o);let p=h*_-m*d;if(p<=0&&d-h>=0&&m-_>=0)return pc.subVectors(r,s),o=(d-h)/(d-h+(m-_)),t.copy(s).addScaledVector(pc,o);let f=1/(p+y+u);return a=y*f,o=u*f,t.copy(n).addScaledVector(Ii,a).addScaledVector(Li,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},jn=class{constructor(e=new B(1/0,1/0,1/0),t=new B(-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(un.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(un.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){let n=un.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);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0&&e.isBatchedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,un):un.fromBufferAttribute(r,a),un.applyMatrix4(e.matrixWorld),this.expandByPoint(un);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),ar.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),ar.copy(n.boundingBox)),ar.applyMatrix4(e.matrixWorld),this.union(ar)}let s=e.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[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,un),un.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(us),or.subVectors(this.max,us),Di.subVectors(e.a,us),Ni.subVectors(e.b,us),Ui.subVectors(e.c,us),$n.subVectors(Ni,Di),Jn.subVectors(Ui,Ni),di.subVectors(Di,Ui);let t=[0,-$n.z,$n.y,0,-Jn.z,Jn.y,0,-di.z,di.y,$n.z,0,-$n.x,Jn.z,0,-Jn.x,di.z,0,-di.x,-$n.y,$n.x,0,-Jn.y,Jn.x,0,-di.y,di.x,0];return!To(t,Di,Ni,Ui,or)||(t=[1,0,0,0,1,0,0,0,1],!To(t,Di,Ni,Ui,or))?!1:(lr.crossVectors($n,Jn),t=[lr.x,lr.y,lr.z],To(t,Di,Ni,Ui,or))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,un).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(un).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:(Dn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Dn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Dn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Dn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Dn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Dn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Dn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Dn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Dn),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}},Dn=[new B,new B,new B,new B,new B,new B,new B,new B],un=new B,ar=new jn,Di=new B,Ni=new B,Ui=new B,$n=new B,Jn=new B,di=new B,us=new B,or=new B,lr=new B,fi=new B;function To(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){fi.fromArray(i,r);let o=s.x*Math.abs(fi.x)+s.y*Math.abs(fi.y)+s.z*Math.abs(fi.z),c=e.dot(fi),l=t.dot(fi),h=n.dot(fi);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}var xt=new B,cr=new Fe,ad=0,Gt=class extends dn{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:ad++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=lh,this.updateRanges=[],this.gpuType=pn,this.version=0,this._normalizationScale=e!==void 0?ml(e):void 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._normalizationScale=e._normalizationScale,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];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++)cr.fromBufferAttribute(this,t),cr.applyMatrix3(e),this.setXY(t,cr.x,cr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)xt.fromBufferAttribute(this,t),xt.applyMatrix3(e),this.setXYZ(t,xt.x,xt.y,xt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)xt.fromBufferAttribute(this,t),xt.applyMatrix4(e),this.setXYZ(t,xt.x,xt.y,xt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)xt.fromBufferAttribute(this,t),xt.applyNormalMatrix(e),this.setXYZ(t,xt.x,xt.y,xt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)xt.fromBufferAttribute(this,t),xt.transformDirection(e),this.setXYZ(t,xt.x,xt.y,xt.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=this._denormalize(n)),n}setComponent(e,t,n){return this.normalized&&(n=this._normalize(n)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=this._denormalize(t)),t}setX(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=this._denormalize(t)),t}setY(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=this._denormalize(t)),t}setZ(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=this._denormalize(t)),t}setW(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),s=this._normalize(s)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),s=this._normalize(s),r=this._normalize(r)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,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(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}_denormalize(e){let t=this._normalizationScale;return t!==void 0?Math.max(e/t,-1):fh(e,this.array)}_normalize(e){let t=this._normalizationScale;return t!==void 0?Math.round(e*t):ph(e,this.array)}};var ws=class extends Gt{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var Es=class extends Gt{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var zt=class extends Gt{constructor(e,t,n){super(new Float32Array(e),t,n)}},od=new jn,ds=new B,Ao=new B,gi=class{constructor(e=new B,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){let n=this.center;t!==void 0?n.copy(t):od.setFromPoints(e).getCenter(n);let s=0;for(let r=0,a=e.length;r<a;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),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){let 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){let 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;ds.subVectors(e,this.center);let t=ds.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(ds,s/n),this.radius+=s}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):(Ao.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ds.copy(e.center).add(Ao)),this.expandByPoint(ds.copy(e.center).sub(Ao))),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}},ld=0,an=new ht,Ro=new Ct,Fi=new B,$t=new jn,fs=new jn,wt=new B,Wt=class i extends dn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ld++}),this.uuid=ss(),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={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Du(e)?Es:ws)(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){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Oe().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return an.makeRotationFromQuaternion(e),this.applyMatrix4(an),this}rotateX(e){return an.makeRotationX(e),this.applyMatrix4(an),this}rotateY(e){return an.makeRotationY(e),this.applyMatrix4(an),this}rotateZ(e){return an.makeRotationZ(e),this.applyMatrix4(an),this}translate(e,t,n){return an.makeTranslation(e,t,n),this.applyMatrix4(an),this}scale(e,t,n){return an.makeScale(e,t,n),this.applyMatrix4(an),this}lookAt(e){return Ro.lookAt(e),Ro.updateMatrix(),this.applyMatrix4(Ro.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Fi).negate(),this.translate(Fi.x,Fi.y,Fi.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let s=0,r=e.length;s<r;s++){let a=e[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new zt(n,3))}else{let n=Math.min(e.length,t.count);for(let s=0;s<n;s++){let r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.count&&Ie("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 jn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){let r=t[n];$t.setFromBufferAttribute(r),this.morphTargetsRelative?(wt.addVectors(this.boundingBox.min,$t.min),this.boundingBox.expandByPoint(wt),wt.addVectors(this.boundingBox.max,$t.max),this.boundingBox.expandByPoint(wt)):(this.boundingBox.expandByPoint($t.min),this.boundingBox.expandByPoint($t.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ue('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 gi);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new B,1/0);return}if(e){let n=this.boundingSphere.center;if($t.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){let o=t[r];fs.setFromBufferAttribute(o),this.morphTargetsRelative?(wt.addVectors($t.min,fs.min),$t.expandByPoint(wt),wt.addVectors($t.max,fs.max),$t.expandByPoint(wt)):($t.expandByPoint(fs.min),$t.expandByPoint(fs.max))}$t.getCenter(n);let s=0;for(let r=0,a=e.count;r<a;r++)wt.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(wt));if(t)for(let r=0,a=t.length;r<a;r++){let o=t[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)wt.fromBufferAttribute(o,l),c&&(Fi.fromBufferAttribute(e,l),wt.add(Fi)),s=Math.max(s,n.distanceToSquared(wt))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Ue('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ue("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,s=t.normal,r=t.uv,a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new Gt(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));let o=[],c=[],l=new Uint8Array(n.count);for(let U=0;U<n.count;U++)o[U]=new B,c[U]=new B;let h=new B,d=new B,u=new B,m=new Fe,_=new Fe,y=new Fe,p=new B,f=new B;function S(U,I,D){l[U]=l[I]=l[D]=1,h.fromBufferAttribute(n,U),d.fromBufferAttribute(n,I),u.fromBufferAttribute(n,D),m.fromBufferAttribute(r,U),_.fromBufferAttribute(r,I),y.fromBufferAttribute(r,D),d.sub(h),u.sub(h),_.sub(m),y.sub(m);let F=1/(_.x*y.y-y.x*_.y);isFinite(F)&&(p.copy(d).multiplyScalar(y.y).addScaledVector(u,-_.y).multiplyScalar(F),f.copy(u).multiplyScalar(_.x).addScaledVector(d,-y.x).multiplyScalar(F),o[U].add(p),o[I].add(p),o[D].add(p),c[U].add(f),c[I].add(f),c[D].add(f))}let A=this.groups;A.length===0&&(A=[{start:0,count:e.count}]);for(let U=0,I=A.length;U<I;++U){let D=A[U],F=D.start,H=D.count;for(let C=F,Y=F+H;C<Y;C+=3)S(e.getX(C+0),e.getX(C+1),e.getX(C+2))}let b=new B,T=new B,w=new B,g=new B;function M(U){w.fromBufferAttribute(s,U),g.copy(w);let I=o[U];b.copy(I),b.sub(w.multiplyScalar(w.dot(I))).normalize(),T.crossVectors(g,I);let F=T.dot(c[U])<0?-1:1;a.setXYZW(U,b.x,b.y,b.z,F)}for(let U=0,I=n.count;U<I;++U)l[U]&&M(U);this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new Gt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let u=0,m=n.count;u<m;u++)n.setXYZ(u,0,0,0);let s=new B,r=new B,a=new B,o=new B,c=new B,l=new B,h=new B,d=new B;if(e)for(let u=0,m=e.count;u<m;u+=3){let _=e.getX(u+0),y=e.getX(u+1),p=e.getX(u+2);s.fromBufferAttribute(t,_),r.fromBufferAttribute(t,y),a.fromBufferAttribute(t,p),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),o.fromBufferAttribute(n,_),c.fromBufferAttribute(n,y),l.fromBufferAttribute(n,p),o.add(h),c.add(h),l.add(h),n.setXYZ(_,o.x,o.y,o.z),n.setXYZ(y,c.x,c.y,c.z),n.setXYZ(p,l.x,l.y,l.z)}else for(let u=0,m=t.count;u<m;u+=3)s.fromBufferAttribute(t,u+0),r.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),n.setXYZ(u+0,h.x,h.y,h.z),n.setXYZ(u+1,h.x,h.y,h.z),n.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)wt.fromBufferAttribute(e,t),wt.normalize(),e.setXYZ(t,wt.x,wt.y,wt.z)}toNonIndexed(){function e(o,c){let l=o.array,h=o.itemSize,d=o.normalized,u=new l.constructor(c.length*h),m=0,_=0;for(let y=0,p=c.length;y<p;y++){o.isInterleavedBufferAttribute?m=c[y]*o.data.stride+o.offset:m=c[y]*h;for(let f=0;f<h;f++)u[_++]=l[m++]}return new Gt(u,h,d)}if(this.index===null)return Ie("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new i,n=this.index.array,s=this.attributes;for(let o in s){let c=s[o],l=e(c,n);t.setAttribute(o,l)}let r=this.morphAttributes;for(let o in r){let c=[],l=r[o];for(let h=0,d=l.length;h<d;h++){let u=l[h],m=e(u,n);c.push(m)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let o=0,c=a.length;o<c;o++){let l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let c in n){let l=n[c];e.data.attributes[c]=l.toJSON(e.data)}let s={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let d=0,u=l.length;d<u;d++){let m=l[d];h.push(m.toJSON(e.data))}h.length>0&&(s[c]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.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;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let s=e.attributes;for(let l in s){let h=s[l];this.setAttribute(l,h.clone(t))}let r=e.morphAttributes;for(let l in r){let h=[],d=r[l];for(let u=0,m=d.length;u<m;u++)h.push(d[u].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let l=0,h=a.length;l<h;l++){let d=a[l];this.addGroup(d.start,d.count,d.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let 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._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}};var Co=new B,cd=new B,hd=new Oe,Kt=class{constructor(e=new B(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,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let s=Co.subVectors(n,t).cross(cd.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let 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,n=!0){let s=e.delta(Co),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){let 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){let n=t||hd.getNormalMatrix(e),s=this.coplanarPoint(Co).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.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)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},ud=0,kn=class extends dn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ud++}),this.uuid=ss(),this.name="",this.type="Material",this.blending=ts,this.side=ri,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=qo,this.blendDst=Yo,this.blendEquation=Mi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ze(0,0,0),this.blendAlpha=0,this.depthFunc=Gi,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=nh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Cr,this.stencilZFail=Cr,this.stencilZPass=Cr,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(let t in e){let n=e[t];if(n===void 0){Ie(`Material: parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Ie(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,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&&(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.diffuseRoughness!==void 0&&(n.diffuseRoughness=this.diffuseRoughness),this.diffuseRoughnessMap&&this.diffuseRoughnessMap.isTexture&&(n.diffuseRoughnessMap=this.diffuseRoughnessMap.toJSON(e).uuid),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.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessMinimum=this.iridescenceThicknessMinimum),this.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessMaximum=this.iridescenceThicknessMaximum),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&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(r=>r.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),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.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let a=[];for(let o in r){let c=r[o];delete c.metadata,a.push(c)}return a}if(t){let r=s(e.textures),a=s(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new ze().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.diffuseRoughness!==void 0&&(this.diffuseRoughness=e.diffuseRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessMinimum!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessMinimum),e.iridescenceThicknessMaximum!==void 0&&(this.iridescenceThicknessMaximum=e.iridescenceThicknessMaximum),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],this.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1]),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(n=>new Kt().fromJSON(n))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Fe().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Fe().fromArray(e.clearcoatNormalScale)),e.diffuseRoughnessMap!==void 0&&(this.diffuseRoughnessMap=t[e.diffuseRoughnessMap]||null),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}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;let t=e.clippingPlanes,n=null;if(t!==null){let s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.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++}};var Nn=new B,Po=new B,hr=new B,ur=new B,_i=class{constructor(e=new B,t=new B(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,Nn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let 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){let t=Nn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Nn.copy(this.origin).addScaledVector(this.direction,t),Nn.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Po.copy(e).add(t).multiplyScalar(.5),hr.copy(t).sub(e).normalize(),ur.copy(this.origin).sub(Po);let r=e.distanceTo(t)*.5,a=-this.direction.dot(hr),o=ur.dot(this.direction),c=-ur.dot(hr),l=ur.lengthSq(),h=Math.abs(1-a*a),d,u,m,_;if(h>0)if(d=a*c-o,u=a*o-c,_=r*h,d>=0)if(u>=-_)if(u<=_){let y=1/h;d*=y,u*=y,m=d*(d+a*u+2*o)+u*(a*d+u+2*c)+l}else u=r,d=Math.max(0,-(a*u+o)),m=-d*d+u*(u+2*c)+l;else u=-r,d=Math.max(0,-(a*u+o)),m=-d*d+u*(u+2*c)+l;else u<=-_?(d=Math.max(0,-(-a*r+o)),u=d>0?-r:Math.min(Math.max(-r,-c),r),m=-d*d+u*(u+2*c)+l):u<=_?(d=0,u=Math.min(Math.max(-r,-c),r),m=u*(u+2*c)+l):(d=Math.max(0,-(a*r+o)),u=d>0?r:Math.min(Math.max(-r,-c),r),m=-d*d+u*(u+2*c)+l);else u=a>0?-r:r,d=Math.max(0,-(a*u+o)),m=-d*d+u*(u+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(Po).addScaledVector(hr,u),m}intersectSphere(e,t){if(e.radius<0)return null;Nn.subVectors(e.center,this.origin);let n=Nn.dot(this.direction),s=Nn.dot(Nn)-n*n,r=e.radius*e.radius;if(s>r)return null;let a=Math.sqrt(r-s),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,a,o,c,l=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,s=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,s=(e.min.x-u.x)*l),h>=0?(r=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),d>=0?(o=(e.min.z-u.z)*d,c=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,c=(e.min.z-u.z)*d),n>c||o>s)||((o>n||n!==n)&&(n=o),(c<s||s!==s)&&(s=c),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Nn)!==null}intersectTriangle(e,t,n,s,r){let a=this.origin,o=this.direction,c=o.x,l=o.y,h=o.z,d=e.x-a.x,u=e.y-a.y,m=e.z-a.z,_=t.x-a.x,y=t.y-a.y,p=t.z-a.z,f=n.x-a.x,S=n.y-a.y,A=n.z-a.z,b=Math.abs(c),T=Math.abs(l),w=Math.abs(h),g,M,U,I,D,F,H,C,Y,J,z,te;if(b>=T&&b>=w?(U=c,F=d,Y=_,te=f,c>=0?(g=l,M=h,I=u,D=m,H=y,C=p,J=S,z=A):(g=h,M=l,I=m,D=u,H=p,C=y,J=A,z=S)):T>=w?(U=l,F=u,Y=y,te=S,l>=0?(g=h,M=c,I=m,D=d,H=p,C=_,J=A,z=f):(g=c,M=h,I=d,D=m,H=_,C=p,J=f,z=A)):(U=h,F=m,Y=p,te=A,h>=0?(g=c,M=l,I=d,D=u,H=_,C=y,J=f,z=S):(g=l,M=c,I=u,D=d,H=y,C=_,J=S,z=f)),U===0)return null;let W=g/U,$=M/U,ae=1/U,_e=I-W*F,De=D-$*F,j=H-W*Y,pe=C-$*Y,ye=J-W*te,Re=z-$*te,fe=ye*pe-Re*j,Le=_e*Re-De*ye,pt=j*De-pe*_e;if(s){if(fe<0||Le<0||pt<0)return null}else if((fe<0||Le<0||pt<0)&&(fe>0||Le>0||pt>0))return null;let be=fe+Le+pt;if(be===0)return null;let $e=ae*(fe*F+Le*Y+pt*te);return(be>0?$e<0:$e>0)?null:this.at($e/be,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)}},Hr=class extends kn{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 zn,this.combine=ua,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}},mc=new ht,pi=new _i,dr=new gi,gc=new B,fr=new B,pr=new B,mr=new B,Io=new B,gr=new B,_c=new B,_r=new B,en=class extends Ct{constructor(e=new Wt,t=new Hr){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():this.morphTargetInfluences=void 0,e.morphTargetDictionary!==void 0?this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary):this.morphTargetDictionary=void 0,this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(s,e);let o=this.morphTargetInfluences;if(r&&o){gr.set(0,0,0);for(let c=0,l=r.length;c<l;c++){let h=o[c],d=r[c];h!==0&&(Io.fromBufferAttribute(d,e),a?gr.addScaledVector(Io,h):gr.addScaledVector(Io.sub(t),h))}t.add(gr)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),dr.copy(n.boundingSphere),dr.applyMatrix4(r),pi.copy(e.ray).recast(e.near),!(dr.containsPoint(pi.origin)===!1&&(pi.intersectSphere(dr,gc)===null||pi.origin.distanceToSquared(gc)>(e.far-e.near)**2))&&(mc.copy(r).invert(),pi.copy(e.ray).applyMatrix4(mc),!(n.boundingBox!==null&&pi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,pi)))}_computeIntersections(e,t,n){let s,r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,m=r.drawRange;if(o!==null)if(Array.isArray(a))for(let _=0,y=u.length;_<y;_++){let p=u[_],f=a[p.materialIndex],S=Math.max(p.start,m.start),A=Math.min(o.count,Math.min(p.start+p.count,m.start+m.count));for(let b=S,T=A;b<T;b+=3){let w=o.getX(b),g=o.getX(b+1),M=o.getX(b+2);s=xr(this,f,e,n,l,h,d,w,g,M),s&&(s.faceIndex=Math.floor(b/3),s.face.materialIndex=p.materialIndex,t.push(s))}}else{let _=Math.max(0,m.start),y=Math.min(o.count,m.start+m.count);for(let p=_,f=y;p<f;p+=3){let S=o.getX(p),A=o.getX(p+1),b=o.getX(p+2);s=xr(this,a,e,n,l,h,d,S,A,b),s&&(s.faceIndex=Math.floor(p/3),t.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let _=0,y=u.length;_<y;_++){let p=u[_],f=a[p.materialIndex],S=Math.max(p.start,m.start),A=Math.min(c.count,Math.min(p.start+p.count,m.start+m.count));for(let b=S,T=A;b<T;b+=3){let w=b,g=b+1,M=b+2;s=xr(this,f,e,n,l,h,d,w,g,M),s&&(s.faceIndex=Math.floor(b/3),s.face.materialIndex=p.materialIndex,t.push(s))}}else{let _=Math.max(0,m.start),y=Math.min(c.count,m.start+m.count);for(let p=_,f=y;p<f;p+=3){let S=p,A=p+1,b=p+2;s=xr(this,a,e,n,l,h,d,S,A,b),s&&(s.faceIndex=Math.floor(p/3),t.push(s))}}}};function dd(i,e,t,n,s,r,a,o){let c;if(e.side===Vt?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,e.side===ri,o),c===null)return null;_r.copy(o),_r.applyMatrix4(i.matrixWorld);let l=t.ray.origin.distanceTo(_r);return l<t.near||l>t.far?null:{distance:l,point:_r.clone(),object:i}}function xr(i,e,t,n,s,r,a,o,c,l){i.getVertexPosition(o,fr),i.getVertexPosition(c,pr),i.getVertexPosition(l,mr);let h=dd(i,e,t,n,fr,pr,mr,_c);if(h){let d=new B;Un.getBarycoord(_c,fr,pr,mr,d),s&&(h.uv=Un.getInterpolatedAttribute(s,o,c,l,d,new Fe)),r&&(h.uv1=Un.getInterpolatedAttribute(r,o,c,l,d,new Fe)),a&&(h.normal=Un.getInterpolatedAttribute(a,o,c,l,d,new B),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a:o,b:c,c:l,normal:new B,materialIndex:0};Un.getNormal(fr,pr,mr,u.normal),h.face=u,h.barycoord=d}return h}var Wr=class extends Ht{constructor(e=null,t=1,n=1,s,r,a,o,c,l=Et,h=Et,d,u){super(null,a,o,c,l,h,s,r,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var mi=new gi,fd=new Fe(.5,.5),yr=new B,Qn=class{constructor(e=new Kt,t=new Kt,n=new Kt,s=new Kt,r=new Kt,a=new Kt){this.planes=[e,t,n,s,r,a]}set(e,t,n,s,r,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=on,n=!1){let s=this.planes,r=e.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],d=r[5],u=r[6],m=r[7],_=r[8],y=r[9],p=r[10],f=r[11],S=r[12],A=r[13],b=r[14],T=r[15];if(s[0].setComponents(l-a,m-h,f-_,T-S).normalize(),s[1].setComponents(l+a,m+h,f+_,T+S).normalize(),s[2].setComponents(l+o,m+d,f+y,T+A).normalize(),s[3].setComponents(l-o,m-d,f-y,T-A).normalize(),n)s[4].setComponents(c,u,p,b).normalize(),s[5].setComponents(l-c,m-u,f-p,T-b).normalize();else if(s[4].setComponents(l-c,m-u,f-p,T-b).normalize(),t===on)s[5].setComponents(l+c,m+u,f+p,T+b).normalize();else if(t===Hi)s[5].setComponents(c,u,p,b).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(),mi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),mi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(mi)}intersectsSprite(e){mi.center.set(0,0,0);let t=fd.distanceTo(e.center);return mi.radius=.7071067811865476+t,mi.applyMatrix4(e.matrixWorld),this.intersectsSphere(mi)}intersectsSphere(e){let t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let s=t[n];if(yr.x=s.normal.x>0?e.max.x:e.min.x,yr.y=s.normal.y>0?e.max.y:e.min.y,yr.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(yr)<0)return!1}return!0}containsPoint(e){let 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)}},xc=new ht,Xr=class i{constructor(){this.coordinateSystem=on,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,n=this._frustums;for(let s=0;s<t.length;s++){let r=t[s];xc.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),n[s]===void 0&&(n[s]=new Qn),n[s].setFromProjectionMatrix(xc,r.coordinateSystem,r.reversedDepth)}return this._count=t.length,this}getFrustum(e){return this._frustums[e]}intersectsObject(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsObject(e))return!0;return!1}intersectsSprite(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSprite(e))return!0;return!1}intersectsSphere(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSphere(e))return!0;return!1}intersectsBox(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsBox(e))return!0;return!1}containsPoint(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].containsPoint(e))return!0;return!1}copy(e){this.coordinateSystem=e.coordinateSystem;let t=this._frustums,n=e._frustums;for(let s=0;s<e._count;s++)t[s]===void 0&&(t[s]=new Qn),t[s].copy(n[s]);return this._count=e._count,this}clone(){return new i().copy(this)}};var xi=class extends kn{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}},qr=new B,Yr=new B,yc=new ht,ps=new _i,vr=new gi,Lo=new B,vc=new B,Zr=class extends Ct{constructor(e=new Wt,t=new xi){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),e.morphTargetInfluences!==void 0?this.morphTargetInfluences=e.morphTargetInfluences.slice():this.morphTargetInfluences=void 0,e.morphTargetDictionary!==void 0?this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary):this.morphTargetDictionary=void 0,this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let s=1,r=t.count;s<r;s++)qr.fromBufferAttribute(t,s-1),Yr.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=qr.distanceTo(Yr);e.setAttribute("lineDistance",new zt(n,1))}else Ie("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),vr.copy(n.boundingSphere),vr.applyMatrix4(s),vr.radius+=r,e.ray.intersectsSphere(vr)===!1)return;yc.copy(s).invert(),ps.copy(e.ray).applyMatrix4(yc);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,u=n.attributes.position;if(h!==null){let m=Math.max(0,a.start),_=Math.min(h.count,a.start+a.count);for(let y=m,p=_-1;y<p;y+=l){let f=h.getX(y),S=h.getX(y+1),A=Mr(this,e,ps,c,f,S,y);A&&t.push(A)}if(this.isLineLoop){let y=h.getX(_-1),p=h.getX(m),f=Mr(this,e,ps,c,y,p,_-1);f&&t.push(f)}}else{let m=Math.max(0,a.start),_=Math.min(u.count,a.start+a.count);for(let y=m,p=_-1;y<p;y+=l){let f=Mr(this,e,ps,c,y,y+1,y);f&&t.push(f)}if(this.isLineLoop){let y=Mr(this,e,ps,c,_-1,m,_-1);y&&t.push(y)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}};function Mr(i,e,t,n,s,r,a){let o=i.geometry.attributes.position;if(qr.fromBufferAttribute(o,s),Yr.fromBufferAttribute(o,r),t.distanceSqToSegment(qr,Yr,Lo,vc)>n)return;Lo.applyMatrix4(i.matrixWorld);let l=e.ray.origin.distanceTo(Lo);if(!(l<e.near||l>e.far))return{distance:l,point:vc.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}var Mc=new B,bc=new B,Zi=class extends Zr{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let s=0,r=t.count;s<r;s+=2)Mc.fromBufferAttribute(t,s),bc.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+Mc.distanceTo(bc);e.setAttribute("lineDistance",new zt(n,1))}else Ie("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Ts=class extends Ht{constructor(e=[],t=bi,n,s,r,a,o,c,l,h){super(e,t,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};var Vn=class extends Ht{constructor(e,t,n=fn,s,r,a,o=Et,c=Et,l,h=Bn,d=1){if(h!==Bn&&h!==Hn)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let u={width:e,height:t,depth:d};super(u,s,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new qi(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},As=class extends Vn{constructor(e,t=fn,n=bi,s,r,a=Et,o=Et,c,l=Bn){let h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,n,s,r,a,o,c,l),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},Rs=class extends Ht{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},$i=class i extends Wt{constructor(e=1,t=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};let o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);let c=[],l=[],h=[],d=[],u=0,m=0;_("z","y","x",-1,-1,n,t,e,a,r,0),_("z","y","x",1,-1,n,t,-e,a,r,1),_("x","z","y",1,1,e,n,t,s,a,2),_("x","z","y",1,-1,e,n,-t,s,a,3),_("x","y","z",1,-1,e,t,n,s,r,4),_("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new zt(l,3)),this.setAttribute("normal",new zt(h,3)),this.setAttribute("uv",new zt(d,2));function _(y,p,f,S,A,b,T,w,g,M,U){let I=b/g,D=T/M,F=b/2,H=T/2,C=w/2,Y=g+1,J=M+1,z=0,te=0,W=new B;for(let $=0;$<J;$++){let ae=$*D-H;for(let _e=0;_e<Y;_e++){let De=_e*I-F;W[y]=De*S,W[p]=ae*A,W[f]=C,l.push(W.x,W.y,W.z),W[y]=0,W[p]=0,W[f]=w>0?1:-1,h.push(W.x,W.y,W.z),d.push(_e/g),d.push(1-$/M),z+=1}}for(let $=0;$<M;$++)for(let ae=0;ae<g;ae++){let _e=u+ae+Y*$,De=u+ae+Y*($+1),j=u+(ae+1)+Y*($+1),pe=u+(ae+1)+Y*$;c.push(_e,De,pe),c.push(De,j,pe),te+=6}o.addGroup(m,te,U),m+=te,u+=z}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};var br=new B,Sr=new B,Do=new B,wr=new Un,Cs=class extends Wt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let s=Math.pow(10,4),r=Math.cos(ki*t),a=e.getIndex(),o=e.getAttribute("position"),c=a?a.count:o.count,l=[0,0,0],h=["a","b","c"],d=new Array(3),u=new Map,m=[];for(let _=0;_<c;_+=3){a?(l[0]=a.getX(_),l[1]=a.getX(_+1),l[2]=a.getX(_+2)):(l[0]=_,l[1]=_+1,l[2]=_+2);let{a:y,b:p,c:f}=wr;if(y.fromBufferAttribute(o,l[0]),p.fromBufferAttribute(o,l[1]),f.fromBufferAttribute(o,l[2]),wr.getNormal(Do),d[0]=`${Math.round(y.x*s)},${Math.round(y.y*s)},${Math.round(y.z*s)}`,d[1]=`${Math.round(p.x*s)},${Math.round(p.y*s)},${Math.round(p.z*s)}`,d[2]=`${Math.round(f.x*s)},${Math.round(f.y*s)},${Math.round(f.z*s)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let S=0;S<3;S++){let A=(S+1)%3,b=d[S],T=d[A],w=wr[h[S]],g=wr[h[A]],M=`${b}_${T}`,U=`${T}_${b}`,I=u.get(U);I?(Do.dot(I.normal)<=r&&(m.push(w.x,w.y,w.z),m.push(g.x,g.y,g.z)),u.set(U,null)):u.has(M)||u.set(M,{index0:l[S],index1:l[A],normal:Do.clone()})}}for(let _ of u.values())if(_){let{index0:y,index1:p}=_;br.fromBufferAttribute(o,y),Sr.fromBufferAttribute(o,p),m.push(br.x,br.y,br.z),m.push(Sr.x,Sr.y,Sr.z)}this.setAttribute("position",new zt(m,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};var Ps=class i extends Wt{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};let r=e/2,a=t/2,o=Math.floor(n),c=Math.floor(s),l=o+1,h=c+1,d=e/o,u=t/c,m=[],_=[],y=[],p=[];for(let f=0;f<h;f++){let S=f*u-a;for(let A=0;A<l;A++){let b=A*d-r;_.push(b,-S,0),y.push(0,0,1),p.push(A/o),p.push(1-f/c)}}for(let f=0;f<c;f++)for(let S=0;S<o;S++){let A=S+l*f,b=S+l*(f+1),T=S+1+l*(f+1),w=S+1+l*f;m.push(A,b,w),m.push(b,T,w)}this.setIndex(m),this.setAttribute("position",new zt(_,3)),this.setAttribute("normal",new zt(y,3)),this.setAttribute("uv",new zt(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.widthSegments,e.heightSegments)}};function wi(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let s=i[t][n];if(Sc(s))s.isRenderTargetTexture?(Ie("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone();else if(Array.isArray(s))if(Sc(s[0])){let r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();e[t][n]=r}else e[t][n]=s.slice();else e[t][n]=s}}return e}function Ut(i){let e={};for(let t=0;t<i.length;t++){let n=wi(i[t]);for(let s in n)e[s]=n[s]}return e}function Sc(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function pd(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function _l(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ze.workingColorSpace}var gh={clone:wi,merge:Ut},md=`void main() {
|
|
2
2
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
|
-
}`,
|
|
3
|
+
}`,gd=`void main() {
|
|
4
4
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
5
|
-
}`,$e=class extends Rn{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Zu,this.fragmentShader=Ju,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,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=hi(t.uniforms),this.uniformsGroups=Yu(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){let e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(let s in this.uniforms){let a=this.uniforms[s].value;a&&a.isTexture?e.uniforms[s]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[s]={type:"m4",value:a.toArray()}:e.uniforms[s]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(let n in t.uniforms){let s=t.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=e[s.value]||null;break;case"c":this.uniforms[n].value=new Ft().setHex(s.value);break;case"v2":this.uniforms[n].value=new Nt().fromArray(s.value);break;case"v3":this.uniforms[n].value=new U().fromArray(s.value);break;case"v4":this.uniforms[n].value=new he().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Ut().fromArray(s.value);break;case"m4":this.uniforms[n].value=new ce().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(t.defines!==void 0&&(this.defines=t.defines),t.vertexShader!==void 0&&(this.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(this.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(this.glslVersion=t.glslVersion),t.extensions!==void 0)for(let n in t.extensions)this.extensions[n]=t.extensions[n];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}},Nr=class extends $e{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var xs=class extends Rn{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ft(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ft(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Oa,this.normalScale=new Nt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Cn,this.combine=Kr,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}},Ur=class extends Rn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Hc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},Fr=class extends Rn{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}};function wi(i,t){return!i||i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function Eo(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}var Gn=class{constructor(t,e,n,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,s=e[n],r=e[n-1];n:{t:{let a;e:{i:if(!(t<s)){for(let o=n+2;;){if(s===void 0){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=s,s=e[++n],t<s)break t}a=e.length;break e}if(!(t>=r)){let o=e[1];t<o&&(n=2,r=o);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(s=r,r=e[--n-1],t>=r)break t}a=n,n=0;break e}break n}for(;n<a;){let o=n+a>>>1;t<e[o]?a=o:n=o+1}if(s=e[n],r=e[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,t,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=t*s;for(let a=0;a!==s;++a)e[a]=n[r+a];return e}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}},Or=class extends Gn{constructor(t,e,n,s){super(t,e,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ao,endingEnd:Ao}}intervalChanged_(t,e,n){let s=this.parameterPositions,r=t-2,a=t+1,o=s[r],c=s[a];if(o===void 0)switch(this.getSettings_().endingStart){case Co:r=t,o=2*e-n;break;case Ro:r=s.length-2,o=e+s[r]-s[r+1];break;default:r=t,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case Co:a=t,c=2*n-e;break;case Ro:a=1,c=n+s[1]-s[0];break;default:a=t-1,c=e}let l=(n-e)*.5,h=this.valueSize;this._weightPrev=l/(e-o),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this._offsetPrev,d=this._offsetNext,u=this._weightPrev,p=this._weightNext,_=(n-e)/(s-e),v=_*_,g=v*_,f=-u*g+2*u*v-u*_,T=(1+u)*g+(-1.5-2*u)*v+(-.5+u)*_+1,L=(-1-p)*g+(1.5+p)*v+.5*_,M=p*g-p*v;for(let b=0;b!==o;++b)r[b]=f*a[h+b]+T*a[l+b]+L*a[c+b]+M*a[d+b];return r}},Br=class extends Gn{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=(n-e)/(s-e),d=1-h;for(let u=0;u!==o;++u)r[u]=a[l+u]*d+a[c+u]*h;return r}},zr=class extends Gn{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t){return this.copySampleValue_(t-1)}},kr=class extends Gn{interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this.inTangents,d=this.outTangents;if(!h||!d){let _=(n-e)/(s-e),v=1-_;for(let g=0;g!==o;++g)r[g]=a[l+g]*v+a[c+g]*_;return r}let u=o*2,p=t-1;for(let _=0;_!==o;++_){let v=a[l+_],g=a[c+_],f=p*u+_*2,T=d[f],L=d[f+1],M=t*u+_*2,b=h[M],E=h[M+1],A=Ku(n,e,T,b,s);r[_]=rh(A,v,L,E,g)}return r}};function rh(i,t,e,n,s){let r=1-i;return r*r*r*t+3*r*r*i*e+3*r*i*i*n+i*i*i*s}function $u(i,t,e,n,s){let r=1-i;return 3*r*r*(e-t)+6*r*i*(n-e)+3*i*i*(s-n)}function Ku(i,t,e,n,s){let r=(i-t)/(s-t);for(let a=0;a<8;a++){let o=rh(r,t,e,n,s)-i;if(Math.abs(o)<1e-10)break;let c=$u(r,t,e,n,s);if(Math.abs(c)<1e-10)break;r=Math.max(0,Math.min(1,r-o/c))}return r}var Ke=class{constructor(t,e,n,s){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=wi(e,this.TimeBufferType),this.values=wi(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:wi(t.times,Array),values:wi(t.values,Array)};let s=t.getInterpolation();s!==t.DefaultInterpolation&&(n.interpolation=s),Eo(t.settings)&&(n.settings={inTangents:wi(t.settings.inTangents,Array),outTangents:wi(t.settings.outTangents,Array)})}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new zr(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Br(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Or(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){let e=new kr(this.times,this.values,this.getValueSize(),t);return this.settings&&(e.inTangents=this.settings.inTangents,e.outTangents=this.settings.outTangents),e}setInterpolation(t){let e;switch(t){case is:e=this.InterpolantFactoryMethodDiscrete;break;case wr:e=this.InterpolantFactoryMethodLinear;break;case pr:e=this.InterpolantFactoryMethodSmooth;break;case To:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return It("KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return is;case this.InterpolantFactoryMethodLinear:return wr;case this.InterpolantFactoryMethodSmooth:return pr;case this.InterpolantFactoryMethodBezier:return To}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,s=e.length;n!==s;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,s=e.length;n!==s;++n)e[n]*=t;Eo(this.settings)&&(pc(this.settings.inTangents,t),pc(this.settings.outTangents,t))}return this}trim(t,e){let n=this.times,s=n.length,r=0,a=s-1;for(;r!==s&&n[r]<t;)++r;for(;a!==-1&&n[a]>e;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);let o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(Dt("KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Dt("KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==r;o++){let c=n[o];if(typeof c=="number"&&isNaN(c)){Dt("KeyframeTrack: Time is not a valid number.",this,o,c),t=!1;break}if(a!==null&&a>c){Dt("KeyframeTrack: Out of order keys.",this,o,c,a),t=!1;break}a=c}if(s!==void 0&&du(s))for(let o=0,c=s.length;o!==c;++o){let l=s[o];if(isNaN(l)){Dt("KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===pr,r=t.length-1,a=1;for(let o=1;o<r;++o){let c=!1,l=t[o],h=t[o+1];if(l!==h&&(o!==1||l!==t[0]))if(s)c=!0;else{let d=o*n,u=d-n,p=d+n;for(let _=0;_!==n;++_){let v=e[d+_];if(v!==e[u+_]||v!==e[p+_]){c=!0;break}}}if(c){if(o!==a){t[a]=t[o];let d=o*n,u=a*n;for(let p=0;p!==n;++p)e[u+p]=e[d+p]}++a}}if(r>0){t[a]=t[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)e[c+l]=e[o+l];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,s=new n(this.name,t,e);return s.createInterpolant=this.createInterpolant,Eo(this.settings)&&(s.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),s}};function pc(i,t){for(let e=0,n=i.length;e!==n;e+=2)i[e]*=t}Ke.prototype.ValueTypeName="";Ke.prototype.TimeBufferType=Float32Array;Ke.prototype.ValueBufferType=Float32Array;Ke.prototype.DefaultInterpolation=wr;var Hn=class extends Ke{constructor(t,e,n){super(t,e,n)}};Hn.prototype.ValueTypeName="bool";Hn.prototype.ValueBufferType=Array;Hn.prototype.DefaultInterpolation=is;Hn.prototype.InterpolantFactoryMethodLinear=void 0;Hn.prototype.InterpolantFactoryMethodSmooth=void 0;var Vr=class extends Ke{constructor(t,e,n,s){super(t,e,n,s)}};Vr.prototype.ValueTypeName="color";var Gr=class extends Ke{constructor(t,e,n,s){super(t,e,n,s)}};Gr.prototype.ValueTypeName="number";var Hr=class extends Gn{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-e)/(s-e),l=t*o;for(let h=l+o;l!==h;l+=4)Je.slerpFlat(r,0,a,l-o,a,l,c);return r}},ys=class extends Ke{constructor(t,e,n,s){super(t,e,n,s)}InterpolantFactoryMethodLinear(t){return new Hr(this.times,this.values,this.getValueSize(),t)}};ys.prototype.ValueTypeName="quaternion";ys.prototype.InterpolantFactoryMethodSmooth=void 0;var Wn=class extends Ke{constructor(t,e,n){super(t,e,n)}};Wn.prototype.ValueTypeName="string";Wn.prototype.ValueBufferType=Array;Wn.prototype.DefaultInterpolation=is;Wn.prototype.InterpolantFactoryMethodLinear=void 0;Wn.prototype.InterpolantFactoryMethodSmooth=void 0;var Wr=class extends Ke{constructor(t,e,n,s){super(t,e,n,s)}};Wr.prototype.ValueTypeName="vector";var Xr=class{constructor(t,e,n){let s=this,r=!1,a=0,o=0,c,l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,r===!1&&s.onStart!==void 0&&s.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,s.onProgress!==void 0&&s.onProgress(h,a,o),a===o&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,d){return l.push(h,d),this},this.removeHandler=function(h){let d=l.indexOf(h);return d!==-1&&l.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=l.length;d<u;d+=2){let p=l[d],_=l[d+1];if(p.global&&(p.lastIndex=0),p.test(h))return _}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},ah=new Xr,qr=class{constructor(t){this.manager=t!==void 0?t:ah,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(t,e){let n=this;return new Promise(function(s,r){n.load(t,s,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}};qr.DEFAULT_MATERIAL_NAME="__DEFAULT";var vs=class extends Ae{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Ft(t),this.intensity=e}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}},Ms=class extends vs{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ae.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ft(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){let e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}},wo=new ce,mc=new U,gc=new U,Yr=class{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Nt(512,512),this.mapType=Ge,this.map=null,this.mapPass=null,this.matrix=new ce,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Oi,this._frameExtents=new Nt(1,1),this._viewportCount=1,this._viewports=[new he(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera;mc.setFromMatrixPosition(t.matrixWorld),e.position.copy(mc),gc.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(gc),e.updateMatrixWorld(),this._updateMatrix(e,this.matrix,this._frustum)}_updateMatrix(t,e,n,s){wo.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),n.setFromProjectionMatrix(wo,t.coordinateSystem,t.reversedDepth);let r=this._frameExtents,a=s?s.z/r.x:1,o=s?s.w/r.y:1,c=s?s.x/r.x:0,l=s?s.y/r.y:0;t.coordinateSystem===Li||t.reversedDepth?e.set(.5*a,0,0,.5*a+c,0,.5*o,0,.5*o+l,0,0,1,0,0,0,0,1):e.set(.5*a,0,0,.5*a+c,0,.5*o,0,.5*o+l,0,0,.5,.5,0,0,0,1),e.multiply(wo)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return t.intensity=this.intensity,t.bias=this.bias,t.normalBias=this.normalBias,t.radius=this.radius,t.blurSamples=this.blurSamples,t.mapSize=this.mapSize.toArray(),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},dr=new U,fr=new Je,dn=new U,Ss=class extends Ae{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ce,this.projectionMatrix=new ce,this.projectionMatrixInverse=new ce,this.coordinateSystem=rn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorld.decompose(dr,fr,dn),dn.x===1&&dn.y===1&&dn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(dr,fr,dn.set(1,1,1)).invert()}updateWorldMatrix(t,e,n=!1){super.updateWorldMatrix(t,e,n),this.matrixWorld.decompose(dr,fr,dn),dn.x===1&&dn.y===1&&dn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(dr,fr,dn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},zn=new U,_c=new Nt,xc=new Nt,Ie=class extends Ss{constructor(t=50,e=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=.5*this.getFilmHeight()/t;this.fov=Ni*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(Ri*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Ni*2*Math.atan(Math.tan(Ri*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){zn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(zn.x,zn.y).multiplyScalar(-t/zn.z),zn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(zn.x,zn.y).multiplyScalar(-t/zn.z)}getViewSize(t,e){return this.getViewBounds(t,_c,xc),e.subVectors(xc,_c)}setViewOffset(t,e,n,s,r,a){this.aspect=t/e,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(Ri*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,r=-.5*s,a=this.view;if(this.view!==null&&this.view.enabled){let c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,e-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}let o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}};var Xn=class extends Ss{constructor(t=-1,e=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,s,r,a){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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-t,a=n+t,o=s+e,c=s-e;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}},Po=class extends Yr{constructor(){super(new Xn(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},ki=class extends vs{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ae.DEFAULT_UP),this.updateMatrix(),this.target=new Ae,this.shadow=new Po}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){let e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}};var Ti=-90,Ai=1,Zr=class extends Ae{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new Ie(Ti,Ai,t,e);s.layers=this.layers,this.add(s);let r=new Ie(Ti,Ai,t,e);r.layers=this.layers,this.add(r);let a=new Ie(Ti,Ai,t,e);a.layers=this.layers,this.add(a);let o=new Ie(Ti,Ai,t,e);o.layers=this.layers,this.add(o);let c=new Ie(Ti,Ai,t,e);c.layers=this.layers,this.add(c);let l=new Ie(Ti,Ai,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[n,s,r,a,o,c]=e;for(let l of e)this.remove(l);if(t===rn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===Li)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.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: "+t);for(let l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());let[r,a,o,c,l,h]=this.children,d=t.getRenderTarget(),u=t.getActiveCubeFace(),p=t.getActiveMipmapLevel(),_=t.xr.enabled;t.xr.enabled=!1;let v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let g=!1;t.isWebGLRenderer===!0?g=t.state.buffers.depth.getReversed():g=t.reversedDepthBuffer,t.setRenderTarget(n,0,s),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,r),t.setRenderTarget(n,1,s),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,a),t.setRenderTarget(n,2,s),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(n,3,s),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),t.setRenderTarget(n,4,s),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),n.texture.generateMipmaps=v,t.setRenderTarget(n,5,s),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(d,u,p),t.xr.enabled=_,n.texture.needsPMREMUpdate=!0}},Jr=class extends Ie{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}};var sl="\\[\\]\\.:\\/",ju=new RegExp("["+sl+"]","g"),rl="[^"+sl+"]",Qu="[^"+sl.replace("\\.","")+"]",td=/((?:WC+[\/:])*)/.source.replace("WC",rl),ed=/(WCOD+)?/.source.replace("WCOD",Qu),nd=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",rl),id=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",rl),sd=new RegExp("^"+td+ed+nd+id+"$"),rd=["material","materials","bones","map"],Io=class{constructor(t,e,n){let s=n||le.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,s)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},le=class i{constructor(t,e,n){this.path=e,this.parsedPath=n||i.parseTrackName(e),this.node=i.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new i.Composite(t,e,n):new i(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(ju,"")}static parseTrackName(t){let e=sd.exec(t);if(e===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);rd.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(r){for(let a=0;a<r.length;a++){let o=r[a];if(o.name===e||o.uuid===e)return o;let c=n(o.children);if(c)return c}return null},s=n(t.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)t[e++]=n[s]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,s=e.propertyName,r=e.propertyIndex;if(t||(t=i.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){It("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=e.objectIndex;switch(n){case"materials":if(!t.material){Dt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){Dt("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){Dt("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===l){l=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){Dt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){Dt("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){Dt("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(l!==void 0){if(t[l]===void 0){Dt("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}let a=t[s];if(a===void 0){let l=e.nodeName;Dt("PropertyBinding: Trying to update property for track: "+l+"."+s+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?o=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!t.geometry){Dt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){Dt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[r]!==void 0&&(r=t.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=s;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};le.Composite=Io;le.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};le.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};le.prototype.GetterByBindingType=[le.prototype._getValue_direct,le.prototype._getValue_array,le.prototype._getValue_arrayElement,le.prototype._getValue_toArray];le.prototype.SetterByBindingTypeAndVersioning=[[le.prototype._setValue_direct,le.prototype._setValue_direct_setNeedsUpdate,le.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[le.prototype._setValue_array,le.prototype._setValue_array_setNeedsUpdate,le.prototype._setValue_array_setMatrixWorldNeedsUpdate],[le.prototype._setValue_arrayElement,le.prototype._setValue_arrayElement_setNeedsUpdate,le.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[le.prototype._setValue_fromArray,le.prototype._setValue_fromArray_setNeedsUpdate,le.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var S_=new Float32Array(1);var Vi=class{constructor(t=1,e=0,n=0){this.radius=t,this.phi=e,this.theta=n}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Ht(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Ht(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var ul=class ul{constructor(t,e,n,s){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,s){let r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=s,this}};ul.prototype.isMatrix2=!0;var Lo=ul;var bs=class extends an{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(t){this.domElement!==null&&this.disconnect(),this.domElement=t}disconnect(){}dispose(){}update(){}};function al(i,t,e,n){let s=ad(n);switch(e){case $o:return i*t;case jo:return i*t/s.components*s.byteLength;case sa:return i*t/s.components*s.byteLength;case jn:return i*t*2/s.components*s.byteLength;case ra:return i*t*2/s.components*s.byteLength;case Ko:return i*t*3/s.components*s.byteLength;case tn:return i*t*4/s.components*s.byteLength;case aa:return i*t*4/s.components*s.byteLength;case Cs:case Rs:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Ps:case Is:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case la:case ha:return Math.max(i,16)*Math.max(t,8)/4;case oa:case ca:return Math.max(i,8)*Math.max(t,8)/2;case ua:case da:case pa:case ma:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case fa:case Ls:case ga:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case _a:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case xa:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case ya:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case va:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case Ma:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case Sa:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case ba:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case Ea:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case wa:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case Ta:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case Aa:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case Ca:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case Ra:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case Pa:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case Ia:case La:case Da:return Math.ceil(i/4)*Math.ceil(t/4)*16;case Na:case Ua:return Math.ceil(i/4)*Math.ceil(t/4)*8;case Ds:case Fa:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function ad(i){switch(i){case Ge:case qo:return{byteLength:1,components:1};case Wi:case Yo:case hn:return{byteLength:2,components:1};case na:case ia:return{byteLength:2,components:4};case ln:case ea:case cn:return{byteLength:4,components:1};case Zo:case Jo:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));typeof window<"u"&&(window.__THREE__?It("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="186");function Ch(){let i=null,t=!1,e=null,n=null;function s(r,a){n=i.requestAnimationFrame(s),e(r,a)}return{start:function(){t!==!0&&e!==null&&i!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){i=r}}}function ld(i){let t=new WeakMap;function e(o,c){let l=o.array,h=o.usage,d=l.byteLength,u=i.createBuffer();i.bindBuffer(c,u),i.bufferData(c,l,h),o.onUploadCallback();let p;if(l instanceof Float32Array)p=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)p=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?p=i.HALF_FLOAT:p=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)p=i.SHORT;else if(l instanceof Uint32Array)p=i.UNSIGNED_INT;else if(l instanceof Int32Array)p=i.INT;else if(l instanceof Int8Array)p=i.BYTE;else if(l instanceof Uint8Array)p=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)p=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:u,type:p,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:d}}function n(o,c,l){let h=c.array,d=c.updateRanges;if(i.bindBuffer(l,o),d.length===0)i.bufferSubData(l,0,h);else{d.sort((p,_)=>p.start-_.start);let u=0;for(let p=1;p<d.length;p++){let _=d[u],v=d[p];v.start<=_.start+_.count+1?_.count=Math.max(_.count,v.start+v.count-_.start):(++u,d[u]=v)}d.length=u+1;for(let p=0,_=d.length;p<_;p++){let v=d[p];i.bufferSubData(l,v.start*h.BYTES_PER_ELEMENT,h,v.start,v.count)}c.clearUpdateRanges()}c.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),t.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);let c=t.get(o);c&&(i.deleteBuffer(c.buffer),t.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){let h=t.get(o);(!h||h.version<o.version)&&t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let l=t.get(o);if(l===void 0)t.set(o,e(o,c));else if(l.version<o.version){if(l.size!==o.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,o,c),l.version=o.version}}return{get:s,remove:r,update:a}}var cd=`#ifdef USE_ALPHAHASH
|
|
5
|
+
}`,Mn=class extends kn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=md,this.fragmentShader=gd,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=wi(e.uniforms),this.uniformsGroups=pd(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){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let s in this.uniforms){let a=this.uniforms[s].value;a&&a.isTexture?t.uniforms[s]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[s]={type:"m4",value:a.toArray()}:t.uniforms[s]={value:a}}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;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new ze().setHex(s.value);break;case"v2":this.uniforms[n].value=new Fe().fromArray(s.value);break;case"v3":this.uniforms[n].value=new B().fromArray(s.value);break;case"v4":this.uniforms[n].value=new dt().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Oe().fromArray(s.value);break;case"m4":this.uniforms[n].value=new ht().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},$r=class extends Mn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var Ji=class extends kn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ze(16777215),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=Ka,this.normalScale=new Fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new zn,this.combine=ua,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Jr=class extends kn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=eh,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}},Kr=class extends kn{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 Oi(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function Er(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}var ei=class{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,s=t[n],r=t[n-1];n:{e:{let a;t:{i:if(!(e<s)){for(let o=n+2;;){if(s===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=s,s=t[++n],e<s)break e}a=t.length;break t}if(!(e>=r)){let o=t[1];e<o&&(n=2,r=o);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(s=r,r=t[--n-1],e>=r)break e}a=n,n=0;break t}break n}for(;n<a;){let o=n+a>>>1;e<t[o]?a=o:n=o+1}if(s=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s;for(let a=0;a!==s;++a)t[a]=n[r+a];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}},jr=class extends ei{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Fo,endingEnd:Fo}}intervalChanged_(e,t,n){let s=this.parameterPositions,r=e-2,a=e+1,o=s[r],c=s[a];if(o===void 0)switch(this.getSettings_().endingStart){case Oo:r=e,o=2*t-n;break;case Bo:r=s.length-2,o=t+s[r]-s[r+1];break;default:r=e,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case Oo:a=e,c=2*n-t;break;case Bo:a=1,c=n+s[1]-s[0];break;default:a=e-1,c=t}let l=(n-t)*.5,h=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this._offsetPrev,d=this._offsetNext,u=this._weightPrev,m=this._weightNext,_=(n-t)/(s-t),y=_*_,p=y*_,f=-u*p+2*u*y-u*_,S=(1+u)*p+(-1.5-2*u)*y+(-.5+u)*_+1,A=(-1-m)*p+(1.5+m)*y+.5*_,b=m*p-m*y;for(let T=0;T!==o;++T)r[T]=f*a[h+T]+S*a[l+T]+A*a[c+T]+b*a[d+T];return r}},Qr=class extends ei{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=(n-t)/(s-t),d=1-h;for(let u=0;u!==o;++u)r[u]=a[l+u]*d+a[c+u]*h;return r}},ea=class extends ei{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}},ta=class extends ei{interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this.inTangents,d=this.outTangents;if(!h||!d){let _=(n-t)/(s-t),y=1-_;for(let p=0;p!==o;++p)r[p]=a[l+p]*y+a[c+p]*_;return r}let u=o*2,m=e-1;for(let _=0;_!==o;++_){let y=a[l+_],p=a[c+_],f=m*u+_*2,S=d[f],A=d[f+1],b=e*u+_*2,T=h[b],w=h[b+1],g=xd(n,t,S,T,s);r[_]=_h(g,y,A,w,p)}return r}};function _h(i,e,t,n,s){let r=1-i;return r*r*r*e+3*r*r*i*t+3*r*i*i*n+i*i*i*s}function _d(i,e,t,n,s){let r=1-i;return 3*r*r*(t-e)+6*r*i*(n-t)+3*i*i*(s-n)}function xd(i,e,t,n,s){let r=(i-e)/(s-e);for(let a=0;a<8;a++){let o=_h(r,e,t,n,s)-i;if(Math.abs(o)<1e-10)break;let c=_d(r,e,t,n,s);if(Math.abs(c)<1e-10)break;r=Math.max(0,Math.min(1,r-o/c))}return r}var tn=class{constructor(e,t,n,s){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=Oi(t,this.TimeBufferType),this.values=Oi(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Oi(e.times,Array),values:Oi(e.values,Array)};let s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s),Er(e.settings)&&(n.settings={inTangents:Oi(e.settings.inTangents,Array),outTangents:Oi(e.settings.outTangents,Array)})}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new ea(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Qr(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new jr(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new ta(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case _s:t=this.InterpolantFactoryMethodDiscrete;break;case zr:t=this.InterpolantFactoryMethodLinear;break;case Rr:t=this.InterpolantFactoryMethodSmooth;break;case Uo:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let 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 Ie("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return _s;case this.InterpolantFactoryMethodLinear:return zr;case this.InterpolantFactoryMethodSmooth:return Rr;case this.InterpolantFactoryMethodBezier:return Uo}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e;Er(this.settings)&&(wc(this.settings.inTangents,e),wc(this.settings.outTangents,e))}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e;Er(this.settings)&&(Ec(this.settings.inTangents,e),Ec(this.settings.outTangents,e))}return this}trim(e,t){let n=this.times,s=n.length,r=0,a=s-1;for(;r!==s&&n[r]<e;)++r;for(;a!==-1&&n[a]>t;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);let o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(Ue("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Ue("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){let c=n[o];if(typeof c=="number"&&isNaN(c)){Ue("KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(a!==null&&a>c){Ue("KeyframeTrack: Out of order keys.",this,o,c,a),e=!1;break}a=c}if(s!==void 0&&Nu(s))for(let o=0,c=s.length;o!==c;++o){let l=s[o];if(isNaN(l)){Ue("KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===Rr,r=e.length-1,a=1;for(let o=1;o<r;++o){let c=!1,l=e[o],h=e[o+1];if(l!==h&&(o!==1||l!==e[0]))if(s)c=!0;else{let d=o*n,u=d-n,m=d+n;for(let _=0;_!==n;++_){let y=t[d+_];if(y!==t[u+_]||y!==t[m+_]){c=!0;break}}}if(c){if(o!==a){e[a]=e[o];let d=o*n,u=a*n;for(let m=0;m!==n;++m)t[u+m]=t[d+m]}++a}}if(r>0){e[a]=e[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)t[c+l]=t[o+l];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,Er(this.settings)&&(s.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),s}};function wc(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]+=e}function Ec(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]*=e}tn.prototype.ValueTypeName="";tn.prototype.TimeBufferType=Float32Array;tn.prototype.ValueBufferType=Float32Array;tn.prototype.DefaultInterpolation=zr;var ti=class extends tn{constructor(e,t,n){super(e,t,n)}};ti.prototype.ValueTypeName="bool";ti.prototype.ValueBufferType=Array;ti.prototype.DefaultInterpolation=_s;ti.prototype.InterpolantFactoryMethodLinear=void 0;ti.prototype.InterpolantFactoryMethodSmooth=void 0;var na=class extends tn{constructor(e,t,n,s){super(e,t,n,s)}};na.prototype.ValueTypeName="color";var ia=class extends tn{constructor(e,t,n,s){super(e,t,n,s)}};ia.prototype.ValueTypeName="number";var sa=class extends ei{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-t)/(s-t),l=e*o;for(let h=l+o;l!==h;l+=4)jt.slerpFlat(r,0,a,l-o,a,l,c);return r}},Is=class extends tn{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new sa(this.times,this.values,this.getValueSize(),e)}};Is.prototype.ValueTypeName="quaternion";Is.prototype.InterpolantFactoryMethodSmooth=void 0;var ni=class extends tn{constructor(e,t,n){super(e,t,n)}};ni.prototype.ValueTypeName="string";ni.prototype.ValueBufferType=Array;ni.prototype.DefaultInterpolation=_s;ni.prototype.InterpolantFactoryMethodLinear=void 0;ni.prototype.InterpolantFactoryMethodSmooth=void 0;var ra=class extends tn{constructor(e,t,n,s){super(e,t,n,s)}};ra.prototype.ValueTypeName="vector";var aa=class{constructor(e,t,n){let s=this,r=!1,a=0,o=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,r===!1&&s.onStart!==void 0&&s.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,s.onProgress!==void 0&&s.onProgress(h,a,o),a===o&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,d){return l.push(h,d),this},this.removeHandler=function(h){let d=l.indexOf(h);return d!==-1&&l.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=l.length;d<u;d+=2){let m=l[d],_=l[d+1];if(m.global&&(m.lastIndex=0),m.test(h))return _}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},xh=new aa,oa=class{constructor(e){this.manager=e!==void 0?e:xh,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},this.priority="auto",this.cache="default",typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(s,r){n.load(e,s,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}setPriority(e){return this.priority=e,this}setCache(e){return this.cache=e,this}abort(){return this}};oa.DEFAULT_MATERIAL_NAME="__DEFAULT";var Ls=class extends Ct{static registerNode(e){this.prototype._lightNode=e}constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new ze(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},Ds=class extends Ls{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ct.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){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},No=new ht,Tc=new B,Ac=new B,la=class{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 Fe(512,512),this.mapType=Xt,this.map=null,this.mapPass=null,this.matrix=new ht,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Qn,this._frameExtents=new Fe(1,1),this._viewportCount=1,this._viewports=[new dt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;Tc.setFromMatrixPosition(e.matrixWorld),t.position.copy(Tc),Ac.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ac),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,s){No.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(No,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,a=s?s.z/r.x:1,o=s?s.w/r.y:1,c=s?s.x/r.x:0,l=s?s.y/r.y:0;e.coordinateSystem===Hi||e.reversedDepth?t.set(.5*a,0,0,.5*a+c,0,.5*o,0,.5*o+l,0,0,1,0,0,0,0,1):t.set(.5*a,0,0,.5*a+c,0,.5*o,0,.5*o+l,0,0,.5,.5,0,0,0,1),t.multiply(No)}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.mapType=e.mapType,this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.mapType=this.mapType,e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Tr=new B,Ar=new jt,yn=new B,Ns=class extends Ct{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ht,this.projectionMatrix=new ht,this.projectionMatrixInverse=new ht,this.coordinateSystem=on,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(Tr,Ar,yn),yn.x===1&&yn.y===1&&yn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Tr,Ar,yn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Tr,Ar,yn),yn.x===1&&yn.y===1&&yn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Tr,Ar,yn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},Kn=new B,Rc=new Fe,Cc=new Fe,Bt=class extends Ns{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,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){let t=.5*this.getFilmHeight()/e;this.fov=Xi*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(ki*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Xi*2*Math.atan(Math.tan(ki*.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){Kn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Kn.x,Kn.y).multiplyScalar(-e/Kn.z),Kn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Kn.x,Kn.y).multiplyScalar(-e/Kn.z)}getViewSize(e,t){return this.getViewBounds(e,Rc,Cc),t.subVectors(Cc,Rc)}setViewOffset(e,t,n,s,r,a){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=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(ki*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s,a=this.view;if(this.view!==null&&this.view.enabled){let c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,t-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}let o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let 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}};var yi=class extends Ns{constructor(e=-1,t=1,n=1,s=-1,r=.1,a=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=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,a){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=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-e,a=n+e,o=s+t,c=s-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let 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}},zo=class extends la{constructor(){super(new yi(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Ki=class extends Ls{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ct.DEFAULT_UP),this.updateMatrix(),this.target=new Ct,this.shadow=new zo}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){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}};var Bi=-90,zi=1,ji=class extends Ct{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new Bt(Bi,zi,e,t);s.layers=this.layers,this.add(s);let r=new Bt(Bi,zi,e,t);r.layers=this.layers,this.add(r);let a=new Bt(Bi,zi,e,t);a.layers=this.layers,this.add(a);let o=new Bt(Bi,zi,e,t);o.layers=this.layers,this.add(o);let c=new Bt(Bi,zi,e,t);c.layers=this.layers,this.add(c);let l=new Bt(Bi,zi,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,c]=t;for(let l of t)this.remove(l);if(e===on)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Hi)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.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(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,a,o,c,l,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;let y=n.texture.mipmapsAutoUpdate;n.texture.mipmapsAutoUpdate=!1;let p=!1;e.isWebGLRenderer===!0?p=e.state.buffers.depth.getReversed():p=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.mipmapsAutoUpdate=y,e.setRenderTarget(n,5,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,m),e.xr.enabled=_,n.texture.needsPMREMUpdate=!0}},ca=class extends Bt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e,this.perCameraFrustumCulled=!1}};var xl="\\[\\]\\.:\\/",yd=new RegExp("["+xl+"]","g"),yl="[^"+xl+"]",vd="[^"+xl.replace("\\.","")+"]",Md=/((?:WC+[\/:])*)/.source.replace("WC",yl),bd=/(WCOD+)?/.source.replace("WCOD",vd),Sd=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",yl),wd=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",yl),Ed=new RegExp("^"+Md+bd+Sd+wd+"$"),Td=["material","materials","bones","map"],ko=class{constructor(e,t,n){let s=n||ct.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},ct=class i{constructor(e,t,n){this.path=t,this.parsedPath=n||i.parseTrackName(t),this.node=i.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 i.Composite(e,t,n):new i(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(yd,"")}static parseTrackName(e){let t=Ed.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);Td.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.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){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let a=0;a<r.length;a++){let o=r[a];if(o.name===t||o.uuid===t)return o;let c=n(o.children);if(c)return c}return null},s=n(e.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)e[t++]=n[s]}_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){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=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,t=this.parsedPath,n=t.objectName,s=t.propertyName,r=t.propertyIndex;if(e||(e=i.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ie("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ue("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){Ue("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ue("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){Ue("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){Ue("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let a=e[s];if(a===void 0){let l=t.nodeName;Ue("PropertyBinding: Trying to update property for track: "+l+"."+s+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!e.geometry){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ue("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=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=s;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};ct.Composite=ko;ct.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ct.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ct.prototype.GetterByBindingType=[ct.prototype._getValue_direct,ct.prototype._getValue_array,ct.prototype._getValue_arrayElement,ct.prototype._getValue_toArray];ct.prototype.SetterByBindingTypeAndVersioning=[[ct.prototype._setValue_direct,ct.prototype._setValue_direct_setNeedsUpdate,ct.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_array,ct.prototype._setValue_array_setNeedsUpdate,ct.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_arrayElement,ct.prototype._setValue_arrayElement_setNeedsUpdate,ct.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_fromArray,ct.prototype._setValue_fromArray_setNeedsUpdate,ct.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var $_=new Float32Array(1);var Qi=class{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=We(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(We(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var El=class El{constructor(e,t,n,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,s){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=s,this}};El.prototype.isMatrix2=!0;var Vo=El;var Us=class extends dn{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){this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function vl(i,e,t,n){let s=Ad(n);switch(t){case rl:return i*e;case ol:return i*e/s.components*s.byteLength;case xa:return i*e/s.components*s.byteLength;case ai:return i*e*2/s.components*s.byteLength;case ya:return i*e*2/s.components*s.byteLength;case al:return i*e*3/s.components*s.byteLength;case gn:return i*e*4/s.components*s.byteLength;case va:return i*e*4/s.components*s.byteLength;case zs:case ks:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Vs:case Gs:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case ba:case wa:return Math.max(i,16)*Math.max(e,8)/4;case Ma:case Sa:return Math.max(i,8)*Math.max(e,8)/2;case Ea:case Ta:case Ra:case Ca:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Aa:case Hs:case Pa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ia:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case La:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Da:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Na:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Ua:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Fa:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Oa:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Ba:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case za:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case ka:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Va:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Ga:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Ha:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Wa:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Xa:case qa:case Ya:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Za:case $a:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Ws:case Ja:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Ad(i){switch(i){case Xt:case tl:return{byteLength:1,components:1};case is:case nl:case mn:return{byteLength:2,components:1};case ga:case _a:return{byteLength:2,components:4};case fn:case ma:case pn:return{byteLength:4,components:1};case il:case sl:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"187"}}));typeof window<"u"&&(window.__THREE__?Ie("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="187");function kh(){let i=null,e=!1,t=null,n=null;function s(r,a){n=i.requestAnimationFrame(s),t(r,a)}return{start:function(){e!==!0&&t!==null&&i!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function Cd(i){let e=new WeakMap;function t(o,c){let l=o.array,h=o.usage,d=l.byteLength,u=i.createBuffer();i.bindBuffer(c,u),i.bufferData(c,l,h),o.onUploadCallback();let m;if(l instanceof Float32Array)m=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)m=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?m=i.HALF_FLOAT:m=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)m=i.SHORT;else if(l instanceof Uint32Array)m=i.UNSIGNED_INT;else if(l instanceof Int32Array)m=i.INT;else if(l instanceof Int8Array)m=i.BYTE;else if(l instanceof Uint8Array)m=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)m=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:u,type:m,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:d}}function n(o,c,l){let h=c.array,d=c.updateRanges;if(i.bindBuffer(l,o),d.length===0)i.bufferSubData(l,0,h);else{d.sort((m,_)=>m.start-_.start);let u=0;for(let m=1;m<d.length;m++){let _=d[u],y=d[m];y.start<=_.start+_.count+1?_.count=Math.max(_.count,y.start+y.count-_.start):(++u,d[u]=y)}d.length=u+1;for(let m=0,_=d.length;m<_;m++){let y=d[m];i.bufferSubData(l,y.start*h.BYTES_PER_ELEMENT,h,y.start,y.count)}c.clearUpdateRanges()}c.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);let c=e.get(o);c&&(i.deleteBuffer(c.buffer),e.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){let h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let l=e.get(o);if(l===void 0)e.set(o,t(o,c));else if(l.version<o.version){if(l.size!==o.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,o,c),l.version=o.version}}return{get:s,remove:r,update:a}}var Pd=`#ifdef USE_ALPHAHASH
|
|
6
6
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
7
|
-
#endif`,
|
|
7
|
+
#endif`,Id=`#ifdef USE_ALPHAHASH
|
|
8
8
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
9
9
|
float hash2D( vec2 value ) {
|
|
10
10
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
@@ -39,20 +39,20 @@
|
|
|
39
39
|
: cases.z;
|
|
40
40
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
41
41
|
}
|
|
42
|
-
#endif`,
|
|
42
|
+
#endif`,Ld=`#ifdef USE_ALPHAMAP
|
|
43
43
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
44
|
-
#endif`,
|
|
44
|
+
#endif`,Dd=`#ifdef USE_ALPHAMAP
|
|
45
45
|
uniform sampler2D alphaMap;
|
|
46
|
-
#endif`,
|
|
46
|
+
#endif`,Nd=`#ifdef USE_ALPHATEST
|
|
47
47
|
#ifdef ALPHA_TO_COVERAGE
|
|
48
48
|
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
49
49
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
50
50
|
#else
|
|
51
51
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
52
52
|
#endif
|
|
53
|
-
#endif`,
|
|
53
|
+
#endif`,Ud=`#ifdef USE_ALPHATEST
|
|
54
54
|
uniform float alphaTest;
|
|
55
|
-
#endif`,
|
|
55
|
+
#endif`,Fd=`#ifdef USE_AOMAP
|
|
56
56
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
57
57
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
58
58
|
#if defined( USE_CLEARCOAT )
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
66
66
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
67
67
|
#endif
|
|
68
|
-
#endif`,
|
|
68
|
+
#endif`,Od=`#ifdef USE_AOMAP
|
|
69
69
|
uniform sampler2D aoMap;
|
|
70
70
|
uniform float aoMapIntensity;
|
|
71
|
-
#endif`,
|
|
71
|
+
#endif`,Bd=`#ifdef USE_BATCHING
|
|
72
72
|
#if ! defined( GL_ANGLE_multi_draw )
|
|
73
73
|
#define gl_DrawID _gl_DrawID
|
|
74
74
|
uniform int _gl_DrawID;
|
|
@@ -102,15 +102,15 @@
|
|
|
102
102
|
int y = j / size;
|
|
103
103
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
|
|
104
104
|
}
|
|
105
|
-
#endif`,
|
|
105
|
+
#endif`,zd=`#ifdef USE_BATCHING
|
|
106
106
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
107
|
-
#endif`,
|
|
107
|
+
#endif`,kd=`vec3 transformed = vec3( position );
|
|
108
108
|
#ifdef USE_ALPHAHASH
|
|
109
109
|
vPosition = vec3( position );
|
|
110
|
-
#endif`,
|
|
110
|
+
#endif`,Vd=`vec3 objectNormal = vec3( normal );
|
|
111
111
|
#ifdef USE_TANGENT
|
|
112
112
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
113
|
-
#endif`,
|
|
113
|
+
#endif`,Gd=`float G_BlinnPhong_Implicit( ) {
|
|
114
114
|
return 0.25;
|
|
115
115
|
}
|
|
116
116
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
@@ -124,7 +124,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
124
124
|
float G = G_BlinnPhong_Implicit( );
|
|
125
125
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
126
126
|
return F * ( G * D );
|
|
127
|
-
} // validated`,
|
|
127
|
+
} // validated`,Hd=`#ifdef USE_IRIDESCENCE
|
|
128
128
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
129
129
|
3.2404542, -0.9692660, 0.0556434,
|
|
130
130
|
-1.5371385, 1.8760108, -0.2040259,
|
|
@@ -187,7 +187,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
187
187
|
}
|
|
188
188
|
return max( I, vec3( 0.0 ) );
|
|
189
189
|
}
|
|
190
|
-
#endif`,
|
|
190
|
+
#endif`,Wd=`#ifdef USE_BUMPMAP
|
|
191
191
|
uniform sampler2D bumpMap;
|
|
192
192
|
uniform float bumpScale;
|
|
193
193
|
vec2 dHdxy_fwd() {
|
|
@@ -208,7 +208,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
208
208
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
209
209
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
210
210
|
}
|
|
211
|
-
#endif`,
|
|
211
|
+
#endif`,Xd=`#if NUM_CLIPPING_PLANES > 0
|
|
212
212
|
vec4 plane;
|
|
213
213
|
#ifdef ALPHA_TO_COVERAGE
|
|
214
214
|
float distanceToPlane, distanceGradient;
|
|
@@ -254,20 +254,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
254
254
|
if ( clipped ) discard;
|
|
255
255
|
#endif
|
|
256
256
|
#endif
|
|
257
|
-
#endif`,
|
|
257
|
+
#endif`,qd=`#if NUM_CLIPPING_PLANES > 0
|
|
258
258
|
varying vec3 vClipPosition;
|
|
259
259
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
260
|
-
#endif`,
|
|
260
|
+
#endif`,Yd=`#if NUM_CLIPPING_PLANES > 0
|
|
261
261
|
varying vec3 vClipPosition;
|
|
262
|
-
#endif`,
|
|
262
|
+
#endif`,Zd=`#if NUM_CLIPPING_PLANES > 0
|
|
263
263
|
vClipPosition = - mvPosition.xyz;
|
|
264
|
-
#endif
|
|
264
|
+
#endif`,$d=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
265
265
|
diffuseColor *= vColor;
|
|
266
|
-
#endif`,
|
|
266
|
+
#endif`,Jd=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
267
267
|
varying vec4 vColor;
|
|
268
|
-
#endif`,
|
|
268
|
+
#endif`,Kd=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
269
269
|
varying vec4 vColor;
|
|
270
|
-
#endif`,
|
|
270
|
+
#endif`,jd=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
271
271
|
vColor = vec4( 1.0 );
|
|
272
272
|
#endif
|
|
273
273
|
#ifdef USE_COLOR_ALPHA
|
|
@@ -280,7 +280,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
280
280
|
#endif
|
|
281
281
|
#ifdef USE_BATCHING_COLOR
|
|
282
282
|
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|
283
|
-
#endif`,
|
|
283
|
+
#endif`,Qd=`#define PI 3.141592653589793
|
|
284
284
|
#define PI2 6.283185307179586
|
|
285
285
|
#define PI_HALF 1.5707963267948966
|
|
286
286
|
#define RECIPROCAL_PI 0.3183098861837907
|
|
@@ -351,100 +351,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
|
351
351
|
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
352
352
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
353
353
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
354
|
-
} // validated`,
|
|
355
|
-
#define cubeUV_minMipLevel 4.0
|
|
356
|
-
#define cubeUV_minTileSize 16.0
|
|
357
|
-
float getFace( vec3 direction ) {
|
|
358
|
-
vec3 absDirection = abs( direction );
|
|
359
|
-
float face = - 1.0;
|
|
360
|
-
if ( absDirection.x > absDirection.z ) {
|
|
361
|
-
if ( absDirection.x > absDirection.y )
|
|
362
|
-
face = direction.x > 0.0 ? 0.0 : 3.0;
|
|
363
|
-
else
|
|
364
|
-
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
365
|
-
} else {
|
|
366
|
-
if ( absDirection.z > absDirection.y )
|
|
367
|
-
face = direction.z > 0.0 ? 2.0 : 5.0;
|
|
368
|
-
else
|
|
369
|
-
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
370
|
-
}
|
|
371
|
-
return face;
|
|
372
|
-
}
|
|
373
|
-
vec2 getUV( vec3 direction, float face ) {
|
|
374
|
-
vec2 uv;
|
|
375
|
-
if ( face == 0.0 ) {
|
|
376
|
-
uv = vec2( direction.z, direction.y ) / abs( direction.x );
|
|
377
|
-
} else if ( face == 1.0 ) {
|
|
378
|
-
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
|
|
379
|
-
} else if ( face == 2.0 ) {
|
|
380
|
-
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
|
|
381
|
-
} else if ( face == 3.0 ) {
|
|
382
|
-
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
|
|
383
|
-
} else if ( face == 4.0 ) {
|
|
384
|
-
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
|
|
385
|
-
} else {
|
|
386
|
-
uv = vec2( direction.x, direction.y ) / abs( direction.z );
|
|
387
|
-
}
|
|
388
|
-
return 0.5 * ( uv + 1.0 );
|
|
389
|
-
}
|
|
390
|
-
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
|
|
391
|
-
float face = getFace( direction );
|
|
392
|
-
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
|
|
393
|
-
mipInt = max( mipInt, cubeUV_minMipLevel );
|
|
394
|
-
float faceSize = exp2( mipInt );
|
|
395
|
-
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
|
|
396
|
-
if ( face > 2.0 ) {
|
|
397
|
-
uv.y += faceSize;
|
|
398
|
-
face -= 3.0;
|
|
399
|
-
}
|
|
400
|
-
uv.x += face * faceSize;
|
|
401
|
-
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
|
|
402
|
-
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
|
|
403
|
-
uv.x *= CUBEUV_TEXEL_WIDTH;
|
|
404
|
-
uv.y *= CUBEUV_TEXEL_HEIGHT;
|
|
405
|
-
#ifdef texture2DGradEXT
|
|
406
|
-
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
|
|
407
|
-
#else
|
|
408
|
-
return texture2D( envMap, uv ).rgb;
|
|
409
|
-
#endif
|
|
410
|
-
}
|
|
411
|
-
#define cubeUV_r0 1.0
|
|
412
|
-
#define cubeUV_m0 - 2.0
|
|
413
|
-
#define cubeUV_r1 0.8
|
|
414
|
-
#define cubeUV_m1 - 1.0
|
|
415
|
-
#define cubeUV_r4 0.4
|
|
416
|
-
#define cubeUV_m4 2.0
|
|
417
|
-
#define cubeUV_r5 0.305
|
|
418
|
-
#define cubeUV_m5 3.0
|
|
419
|
-
#define cubeUV_r6 0.21
|
|
420
|
-
#define cubeUV_m6 4.0
|
|
421
|
-
float roughnessToMip( float roughness ) {
|
|
422
|
-
float mip = 0.0;
|
|
423
|
-
if ( roughness >= cubeUV_r1 ) {
|
|
424
|
-
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
|
|
425
|
-
} else if ( roughness >= cubeUV_r4 ) {
|
|
426
|
-
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
|
|
427
|
-
} else if ( roughness >= cubeUV_r5 ) {
|
|
428
|
-
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
|
|
429
|
-
} else if ( roughness >= cubeUV_r6 ) {
|
|
430
|
-
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
|
|
431
|
-
} else {
|
|
432
|
-
mip = - 2.0 * log2( 1.16 * roughness ); }
|
|
433
|
-
return mip;
|
|
434
|
-
}
|
|
435
|
-
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
|
|
436
|
-
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
|
|
437
|
-
float mipF = fract( mip );
|
|
438
|
-
float mipInt = floor( mip );
|
|
439
|
-
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
|
|
440
|
-
if ( mipF == 0.0 ) {
|
|
441
|
-
return vec4( color0, 1.0 );
|
|
442
|
-
} else {
|
|
443
|
-
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
|
|
444
|
-
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
#endif`,Nd=`vec3 transformedNormal = objectNormal;
|
|
354
|
+
} // validated`,ef=`vec3 transformedNormal = objectNormal;
|
|
448
355
|
#ifdef USE_TANGENT
|
|
449
356
|
vec3 transformedTangent = objectTangent;
|
|
450
357
|
#endif
|
|
@@ -470,21 +377,21 @@ transformedNormal = normalMatrix * transformedNormal;
|
|
|
470
377
|
#endif
|
|
471
378
|
#ifdef USE_TANGENT
|
|
472
379
|
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
473
|
-
#endif`,
|
|
380
|
+
#endif`,tf=`#ifdef USE_DISPLACEMENTMAP
|
|
474
381
|
uniform sampler2D displacementMap;
|
|
475
382
|
uniform float displacementScale;
|
|
476
383
|
uniform float displacementBias;
|
|
477
|
-
#endif`,
|
|
384
|
+
#endif`,nf=`#ifdef USE_DISPLACEMENTMAP
|
|
478
385
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
479
|
-
#endif`,
|
|
386
|
+
#endif`,sf=`#ifdef USE_EMISSIVEMAP
|
|
480
387
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
481
388
|
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
482
389
|
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
483
390
|
#endif
|
|
484
391
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
485
|
-
#endif`,
|
|
392
|
+
#endif`,rf=`#ifdef USE_EMISSIVEMAP
|
|
486
393
|
uniform sampler2D emissiveMap;
|
|
487
|
-
#endif`,
|
|
394
|
+
#endif`,af="gl_FragColor = linearToOutputTexel( gl_FragColor );",of=`vec4 LinearTransferOETF( in vec4 value ) {
|
|
488
395
|
return value;
|
|
489
396
|
}
|
|
490
397
|
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
@@ -492,7 +399,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
|
492
399
|
}
|
|
493
400
|
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
494
401
|
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 );
|
|
495
|
-
}`,
|
|
402
|
+
}`,lf=`#ifdef USE_ENVMAP
|
|
496
403
|
#ifdef ENV_WORLDPOS
|
|
497
404
|
vec3 cameraToFrag;
|
|
498
405
|
if ( isOrthographic ) {
|
|
@@ -519,15 +426,17 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
519
426
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
520
427
|
#endif
|
|
521
428
|
#endif
|
|
522
|
-
#endif`,
|
|
429
|
+
#endif`,cf=`#ifdef USE_ENVMAP
|
|
523
430
|
uniform float envMapIntensity;
|
|
524
431
|
uniform mat3 envMapRotation;
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
432
|
+
uniform samplerCube envMap;
|
|
433
|
+
#ifdef ENVMAP_TYPE_PMREM
|
|
434
|
+
float roughnessToMip( const in float roughness ) {
|
|
435
|
+
float r = clamp( roughness, 0.0, 1.0 );
|
|
436
|
+
return ENVMAP_MAX_LOD * r * ( 2.0 - r );
|
|
437
|
+
}
|
|
529
438
|
#endif
|
|
530
|
-
#endif`,
|
|
439
|
+
#endif`,hf=`#ifdef USE_ENVMAP
|
|
531
440
|
uniform float reflectivity;
|
|
532
441
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
533
442
|
#define ENV_WORLDPOS
|
|
@@ -538,7 +447,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
538
447
|
#else
|
|
539
448
|
varying vec3 vReflect;
|
|
540
449
|
#endif
|
|
541
|
-
#endif`,
|
|
450
|
+
#endif`,uf=`#ifdef USE_ENVMAP
|
|
542
451
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
543
452
|
#define ENV_WORLDPOS
|
|
544
453
|
#endif
|
|
@@ -549,7 +458,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
549
458
|
varying vec3 vReflect;
|
|
550
459
|
uniform float refractionRatio;
|
|
551
460
|
#endif
|
|
552
|
-
#endif`,
|
|
461
|
+
#endif`,df=`#ifdef USE_ENVMAP
|
|
553
462
|
#ifdef ENV_WORLDPOS
|
|
554
463
|
vWorldPosition = worldPosition.xyz;
|
|
555
464
|
#else
|
|
@@ -566,18 +475,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
566
475
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
567
476
|
#endif
|
|
568
477
|
#endif
|
|
569
|
-
#endif`,
|
|
478
|
+
#endif`,ff=`#ifdef USE_FOG
|
|
570
479
|
vFogDepth = - mvPosition.z;
|
|
571
|
-
#endif`,
|
|
480
|
+
#endif`,pf=`#ifdef USE_FOG
|
|
572
481
|
varying float vFogDepth;
|
|
573
|
-
#endif`,
|
|
482
|
+
#endif`,mf=`#ifdef USE_FOG
|
|
574
483
|
#ifdef FOG_EXP2
|
|
575
484
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
576
485
|
#else
|
|
577
486
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
578
487
|
#endif
|
|
579
488
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
580
|
-
#endif`,
|
|
489
|
+
#endif`,gf=`#ifdef USE_FOG
|
|
581
490
|
uniform vec3 fogColor;
|
|
582
491
|
varying float vFogDepth;
|
|
583
492
|
#ifdef FOG_EXP2
|
|
@@ -586,7 +495,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
586
495
|
uniform float fogNear;
|
|
587
496
|
uniform float fogFar;
|
|
588
497
|
#endif
|
|
589
|
-
#endif
|
|
498
|
+
#endif`,_f=`#ifdef USE_GRADIENTMAP
|
|
590
499
|
uniform sampler2D gradientMap;
|
|
591
500
|
#endif
|
|
592
501
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
@@ -598,12 +507,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
|
598
507
|
vec2 fw = fwidth( coord ) * 0.5;
|
|
599
508
|
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
600
509
|
#endif
|
|
601
|
-
}`,
|
|
510
|
+
}`,xf=`#ifdef USE_LIGHTMAP
|
|
602
511
|
uniform sampler2D lightMap;
|
|
603
512
|
uniform float lightMapIntensity;
|
|
604
|
-
#endif`,
|
|
513
|
+
#endif`,yf=`LambertMaterial material;
|
|
605
514
|
material.diffuseColor = diffuseColor.rgb;
|
|
606
|
-
material.specularStrength = specularStrength;`,
|
|
515
|
+
material.specularStrength = specularStrength;`,vf=`varying vec3 vViewPosition;
|
|
607
516
|
struct LambertMaterial {
|
|
608
517
|
vec3 diffuseColor;
|
|
609
518
|
float specularStrength;
|
|
@@ -617,7 +526,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
|
|
|
617
526
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
618
527
|
}
|
|
619
528
|
#define RE_Direct RE_Direct_Lambert
|
|
620
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,
|
|
529
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Mf=`uniform bool receiveShadow;
|
|
621
530
|
uniform vec3 ambientLightColor;
|
|
622
531
|
#if defined( USE_LIGHT_PROBES )
|
|
623
532
|
uniform vec3 lightProbe[ 9 ];
|
|
@@ -746,22 +655,22 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
746
655
|
return irradiance;
|
|
747
656
|
}
|
|
748
657
|
#endif
|
|
749
|
-
#include <lightprobes_pars_fragment>`,
|
|
658
|
+
#include <lightprobes_pars_fragment>`,bf=`#ifdef USE_ENVMAP
|
|
750
659
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
751
|
-
#ifdef
|
|
660
|
+
#ifdef ENVMAP_TYPE_PMREM
|
|
752
661
|
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
|
|
753
|
-
vec4 envMapColor =
|
|
662
|
+
vec4 envMapColor = textureLod( envMap, envMapRotation * worldNormal, ENVMAP_MAX_LOD );
|
|
754
663
|
return PI * envMapColor.rgb * envMapIntensity;
|
|
755
664
|
#else
|
|
756
665
|
return vec3( 0.0 );
|
|
757
666
|
#endif
|
|
758
667
|
}
|
|
759
668
|
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
|
760
|
-
#ifdef
|
|
669
|
+
#ifdef ENVMAP_TYPE_PMREM
|
|
761
670
|
vec3 reflectVec = reflect( - viewDir, normal );
|
|
762
671
|
reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
|
|
763
672
|
reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix );
|
|
764
|
-
vec4 envMapColor =
|
|
673
|
+
vec4 envMapColor = textureLod( envMap, envMapRotation * reflectVec, roughnessToMip( roughness ) );
|
|
765
674
|
return envMapColor.rgb * envMapIntensity;
|
|
766
675
|
#else
|
|
767
676
|
return vec3( 0.0 );
|
|
@@ -769,10 +678,10 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
769
678
|
}
|
|
770
679
|
#ifdef USE_RETROREFLECTION
|
|
771
680
|
vec3 getIBLRetroRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
|
772
|
-
#ifdef
|
|
681
|
+
#ifdef ENVMAP_TYPE_PMREM
|
|
773
682
|
vec3 retroVec = normalize( mix( viewDir, normal, pow4( roughness ) ) );
|
|
774
683
|
retroVec = transformDirectionByInverseViewMatrix( retroVec, viewMatrix );
|
|
775
|
-
vec4 envMapColor =
|
|
684
|
+
vec4 envMapColor = textureLod( envMap, envMapRotation * retroVec, roughnessToMip( roughness ) );
|
|
776
685
|
return envMapColor.rgb * envMapIntensity;
|
|
777
686
|
#else
|
|
778
687
|
return vec3( 0.0 );
|
|
@@ -781,7 +690,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
781
690
|
#endif
|
|
782
691
|
#ifdef USE_ANISOTROPY
|
|
783
692
|
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
|
|
784
|
-
#ifdef
|
|
693
|
+
#ifdef ENVMAP_TYPE_PMREM
|
|
785
694
|
vec3 bentNormal = cross( bitangent, viewDir );
|
|
786
695
|
bentNormal = normalize( cross( bentNormal, bitangent ) );
|
|
787
696
|
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
|
|
@@ -792,7 +701,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
792
701
|
}
|
|
793
702
|
#ifdef USE_RETROREFLECTION
|
|
794
703
|
vec3 getIBLAnisotropyRetroRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
|
|
795
|
-
#ifdef
|
|
704
|
+
#ifdef ENVMAP_TYPE_PMREM
|
|
796
705
|
vec3 bentNormal = cross( bitangent, viewDir );
|
|
797
706
|
bentNormal = normalize( cross( bentNormal, bitangent ) );
|
|
798
707
|
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
|
|
@@ -803,8 +712,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
803
712
|
}
|
|
804
713
|
#endif
|
|
805
714
|
#endif
|
|
806
|
-
#endif`,
|
|
807
|
-
material.diffuseColor = diffuseColor.rgb;`,
|
|
715
|
+
#endif`,Sf=`ToonMaterial material;
|
|
716
|
+
material.diffuseColor = diffuseColor.rgb;`,wf=`varying vec3 vViewPosition;
|
|
808
717
|
struct ToonMaterial {
|
|
809
718
|
vec3 diffuseColor;
|
|
810
719
|
};
|
|
@@ -816,11 +725,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
|
|
|
816
725
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
817
726
|
}
|
|
818
727
|
#define RE_Direct RE_Direct_Toon
|
|
819
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,
|
|
728
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Ef=`BlinnPhongMaterial material;
|
|
820
729
|
material.diffuseColor = diffuseColor.rgb;
|
|
821
730
|
material.specularColor = specular;
|
|
822
731
|
material.specularShininess = shininess;
|
|
823
|
-
material.specularStrength = specularStrength;`,
|
|
732
|
+
material.specularStrength = specularStrength;`,Tf=`varying vec3 vViewPosition;
|
|
824
733
|
struct BlinnPhongMaterial {
|
|
825
734
|
vec3 diffuseColor;
|
|
826
735
|
vec3 specularColor;
|
|
@@ -837,14 +746,22 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
|
|
|
837
746
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
838
747
|
}
|
|
839
748
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
840
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,
|
|
749
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Af=`PhysicalMaterial material;
|
|
841
750
|
material.diffuseColor = diffuseColor.rgb;
|
|
842
751
|
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
843
752
|
material.metalness = metalnessFactor;
|
|
844
753
|
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
|
845
754
|
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
|
846
|
-
material.roughness = max( roughnessFactor, 0.
|
|
755
|
+
material.roughness = max( roughnessFactor, 0.045 );
|
|
756
|
+
material.roughness += geometryRoughness;
|
|
847
757
|
material.roughness = min( material.roughness, 1.0 );
|
|
758
|
+
#ifdef USE_DIFFUSE_ROUGHNESS
|
|
759
|
+
float diffuseRoughnessFactor = diffuseRoughness;
|
|
760
|
+
#ifdef USE_DIFFUSE_ROUGHNESSMAP
|
|
761
|
+
diffuseRoughnessFactor *= texture2D( diffuseRoughnessMap, vDiffuseRoughnessMapUv ).r;
|
|
762
|
+
#endif
|
|
763
|
+
material.diffuseRoughness = saturate( diffuseRoughnessFactor );
|
|
764
|
+
#endif
|
|
848
765
|
#ifdef IOR
|
|
849
766
|
material.ior = ior;
|
|
850
767
|
#ifdef USE_SPECULAR
|
|
@@ -880,7 +797,7 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
880
797
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
881
798
|
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
|
|
882
799
|
#endif
|
|
883
|
-
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.
|
|
800
|
+
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.045 );
|
|
884
801
|
material.clearcoatRoughness += geometryRoughness;
|
|
885
802
|
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
|
886
803
|
#endif
|
|
@@ -930,7 +847,7 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
930
847
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
931
848
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
932
849
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
933
|
-
#endif`,
|
|
850
|
+
#endif`,Rf=`uniform sampler2D dfgLUT;
|
|
934
851
|
struct PhysicalMaterial {
|
|
935
852
|
vec3 diffuseColor;
|
|
936
853
|
vec3 diffuseContribution;
|
|
@@ -942,6 +859,9 @@ struct PhysicalMaterial {
|
|
|
942
859
|
float dispersion;
|
|
943
860
|
vec2 dfg;
|
|
944
861
|
vec3 multiScatteringCompensation;
|
|
862
|
+
#ifdef USE_DIFFUSE_ROUGHNESS
|
|
863
|
+
float diffuseRoughness;
|
|
864
|
+
#endif
|
|
945
865
|
#ifdef USE_RETROREFLECTION
|
|
946
866
|
float retroreflectivity;
|
|
947
867
|
#endif
|
|
@@ -990,6 +910,42 @@ vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH )
|
|
|
990
910
|
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
|
|
991
911
|
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
|
|
992
912
|
}
|
|
913
|
+
#ifdef USE_DIFFUSE_ROUGHNESS
|
|
914
|
+
const float EON_EPSILON = 1e-7;
|
|
915
|
+
float FON_DirectionalAlbedo( const in float mu, const in float roughness, const in float A ) {
|
|
916
|
+
float muComp = 1.0 - mu;
|
|
917
|
+
float gOverPi = muComp * ( 0.0571085289 + muComp * ( 0.491881867 + muComp * ( - 0.332181442 + muComp * 0.0714429953 ) ) );
|
|
918
|
+
return A * ( 1.0 + roughness * gOverPi );
|
|
919
|
+
}
|
|
920
|
+
vec3 BRDF_EON( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 diffuseColor, const in float roughness ) {
|
|
921
|
+
vec3 rho = saturate( diffuseColor );
|
|
922
|
+
if ( roughness <= EON_EPSILON ) return BRDF_Lambert( rho );
|
|
923
|
+
float dotNL = saturate( dot( normal, lightDir ) );
|
|
924
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
925
|
+
float s = dot( lightDir, viewDir ) - dotNL * dotNV;
|
|
926
|
+
float sOverT = ( s > 0.0 ) ? s / max( max( dotNL, dotNV ), EON_EPSILON ) : s;
|
|
927
|
+
float A = 1.0 / ( 1.0 + ( 0.5 - 2.0 / ( 3.0 * PI ) ) * roughness );
|
|
928
|
+
vec3 singleScatter = rho * RECIPROCAL_PI * A * ( 1.0 + roughness * sOverT );
|
|
929
|
+
float averageAlbedo = A * ( 1.0 + ( 2.0 / 3.0 - 28.0 / ( 15.0 * PI ) ) * roughness );
|
|
930
|
+
float albedoV = FON_DirectionalAlbedo( dotNV, roughness, A );
|
|
931
|
+
float albedoL = FON_DirectionalAlbedo( dotNL, roughness, A );
|
|
932
|
+
vec3 rhoMultiScatter = rho * rho * averageAlbedo / max( vec3( EON_EPSILON ), vec3( 1.0 ) - rho * ( 1.0 - averageAlbedo ) );
|
|
933
|
+
vec3 multiScatter = rhoMultiScatter * RECIPROCAL_PI
|
|
934
|
+
* max( EON_EPSILON, 1.0 - albedoV )
|
|
935
|
+
* max( EON_EPSILON, 1.0 - albedoL )
|
|
936
|
+
/ max( EON_EPSILON, 1.0 - averageAlbedo );
|
|
937
|
+
return singleScatter + multiScatter;
|
|
938
|
+
}
|
|
939
|
+
vec3 EON_DirectionalAlbedo( const in vec3 diffuseColor, const in float roughness, const in float dotNV ) {
|
|
940
|
+
vec3 rho = saturate( diffuseColor );
|
|
941
|
+
if ( roughness <= EON_EPSILON ) return rho;
|
|
942
|
+
float A = 1.0 / ( 1.0 + ( 0.5 - 2.0 / ( 3.0 * PI ) ) * roughness );
|
|
943
|
+
float directionalAlbedo = FON_DirectionalAlbedo( dotNV, roughness, A );
|
|
944
|
+
float averageAlbedo = A * ( 1.0 + ( 2.0 / 3.0 - 28.0 / ( 15.0 * PI ) ) * roughness );
|
|
945
|
+
vec3 rhoMultiScatter = rho * rho * averageAlbedo / max( vec3( EON_EPSILON ), vec3( 1.0 ) - rho * ( 1.0 - averageAlbedo ) );
|
|
946
|
+
return rho * directionalAlbedo + rhoMultiScatter * ( 1.0 - directionalAlbedo );
|
|
947
|
+
}
|
|
948
|
+
#endif
|
|
993
949
|
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
|
994
950
|
float a2 = pow2( alpha );
|
|
995
951
|
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
|
@@ -1019,7 +975,7 @@ float D_GGX( const in float alpha, const in float dotNH ) {
|
|
|
1019
975
|
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
|
|
1020
976
|
vec3 f0 = material.clearcoatF0;
|
|
1021
977
|
float f90 = material.clearcoatF90;
|
|
1022
|
-
float roughness = material.clearcoatRoughness;
|
|
978
|
+
float roughness = max( material.clearcoatRoughness, 0.045 );
|
|
1023
979
|
float alpha = pow2( roughness );
|
|
1024
980
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
1025
981
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
@@ -1035,7 +991,7 @@ float D_GGX( const in float alpha, const in float dotNH ) {
|
|
|
1035
991
|
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
|
1036
992
|
vec3 f0 = material.specularColorBlended;
|
|
1037
993
|
float f90 = material.specularF90;
|
|
1038
|
-
float roughness = material.roughness;
|
|
994
|
+
float roughness = max( material.roughness, 0.045 );
|
|
1039
995
|
float alpha = pow2( roughness );
|
|
1040
996
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
1041
997
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
@@ -1053,8 +1009,9 @@ vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 norm
|
|
|
1053
1009
|
float dotBL = dot( material.anisotropyB, lightDir );
|
|
1054
1010
|
float dotBV = dot( material.anisotropyB, viewDir );
|
|
1055
1011
|
float dotBH = dot( material.anisotropyB, halfDir );
|
|
1056
|
-
float
|
|
1057
|
-
float
|
|
1012
|
+
float alphaT = max( material.alphaT, alpha );
|
|
1013
|
+
float V = V_GGX_SmithCorrelated_Anisotropic( alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
|
|
1014
|
+
float D = D_GGX_Anisotropic( alphaT, alpha, dotNH, dotTH, dotBH );
|
|
1058
1015
|
#else
|
|
1059
1016
|
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
1060
1017
|
float D = D_GGX( alpha, dotNH );
|
|
@@ -1237,7 +1194,12 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geome
|
|
|
1237
1194
|
vec3 retroF = F_Schlick( material.specularColor, material.specularF90, dotRetroVH );
|
|
1238
1195
|
F = mix( F, retroF, saturate( material.retroreflectivity ) );
|
|
1239
1196
|
#endif
|
|
1240
|
-
|
|
1197
|
+
#ifdef USE_DIFFUSE_ROUGHNESS
|
|
1198
|
+
vec3 diffuseBRDF = BRDF_EON( directLight.direction, geometryViewDir, geometryNormal, material.diffuseColor, material.diffuseRoughness ) * ( 1.0 - material.metalness );
|
|
1199
|
+
#else
|
|
1200
|
+
vec3 diffuseBRDF = BRDF_Lambert( material.diffuseContribution );
|
|
1201
|
+
#endif
|
|
1202
|
+
reflectedLight.directDiffuse += irradiance * diffuseBRDF * ( 1.0 - F );
|
|
1241
1203
|
}
|
|
1242
1204
|
void 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 ) {
|
|
1243
1205
|
vec3 singleScattering = vec3( 0.0 );
|
|
@@ -1247,7 +1209,13 @@ void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geomet
|
|
|
1247
1209
|
#else
|
|
1248
1210
|
computeMultiscattering( material.dfg, material.specularColor, material.specularF90, singleScattering, multiScattering );
|
|
1249
1211
|
#endif
|
|
1250
|
-
|
|
1212
|
+
#ifdef USE_DIFFUSE_ROUGHNESS
|
|
1213
|
+
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
1214
|
+
vec3 diffuseAlbedo = EON_DirectionalAlbedo( material.diffuseColor, material.diffuseRoughness, dotNV ) * ( 1.0 - material.metalness );
|
|
1215
|
+
vec3 diffuse = irradiance * RECIPROCAL_PI * diffuseAlbedo * ( 1.0 - singleScattering - multiScattering );
|
|
1216
|
+
#else
|
|
1217
|
+
vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ) * ( 1.0 - singleScattering - multiScattering );
|
|
1218
|
+
#endif
|
|
1251
1219
|
#ifdef USE_SHEEN
|
|
1252
1220
|
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
|
1253
1221
|
sheenSpecularIndirect += irradiance * material.sheenColor * sheenAlbedo * RECIPROCAL_PI;
|
|
@@ -1277,7 +1245,12 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
1277
1245
|
vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );
|
|
1278
1246
|
vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );
|
|
1279
1247
|
vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;
|
|
1280
|
-
|
|
1248
|
+
#ifdef USE_DIFFUSE_ROUGHNESS
|
|
1249
|
+
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
1250
|
+
vec3 diffuse = EON_DirectionalAlbedo( material.diffuseColor, material.diffuseRoughness, dotNV ) * ( 1.0 - material.metalness ) * ( 1.0 - totalScatteringDielectric );
|
|
1251
|
+
#else
|
|
1252
|
+
vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );
|
|
1253
|
+
#endif
|
|
1281
1254
|
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
|
1282
1255
|
vec3 indirectSpecular = radiance * singleScattering;
|
|
1283
1256
|
indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
|
@@ -1297,7 +1270,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
1297
1270
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
1298
1271
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
1299
1272
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
1300
|
-
}`,
|
|
1273
|
+
}`,Cf=`
|
|
1301
1274
|
vec3 geometryPosition = - vViewPosition;
|
|
1302
1275
|
vec3 geometryNormal = normal;
|
|
1303
1276
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
@@ -1436,22 +1409,32 @@ IncidentLight directLight;
|
|
|
1436
1409
|
}
|
|
1437
1410
|
#pragma unroll_loop_end
|
|
1438
1411
|
#endif
|
|
1439
|
-
#
|
|
1412
|
+
#if NUM_LIGHT_PROBE_GRIDS > 0
|
|
1440
1413
|
vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;
|
|
1441
1414
|
vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );
|
|
1442
|
-
|
|
1415
|
+
int probeGrid = - 1;
|
|
1416
|
+
#pragma unroll_loop_start
|
|
1417
|
+
for ( int i = 0; i < NUM_LIGHT_PROBE_GRIDS; i ++ ) {
|
|
1418
|
+
if ( isInsideLightProbeGrid( probeWorldPos, probeWorldNormal, probesMin[ i ], probesMax[ i ], probesResolution[ i ] ) ) probeGrid = UNROLLED_LOOP_INDEX;
|
|
1419
|
+
}
|
|
1420
|
+
#pragma unroll_loop_end
|
|
1421
|
+
#pragma unroll_loop_start
|
|
1422
|
+
for ( int i = 0; i < NUM_LIGHT_PROBE_GRIDS; i ++ ) {
|
|
1423
|
+
if ( probeGrid == UNROLLED_LOOP_INDEX ) irradiance += getLightProbeGridIrradiance( probesSH[ i ], probesMin[ i ], probesMax[ i ], probesResolution[ i ], probeWorldPos, probeWorldNormal );
|
|
1424
|
+
}
|
|
1425
|
+
#pragma unroll_loop_end
|
|
1443
1426
|
#endif
|
|
1444
1427
|
#endif
|
|
1445
1428
|
#if defined( RE_IndirectSpecular )
|
|
1446
1429
|
vec3 radiance = vec3( 0.0 );
|
|
1447
1430
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
1448
|
-
#endif`,
|
|
1431
|
+
#endif`,Pf=`#if defined( RE_IndirectDiffuse )
|
|
1449
1432
|
#ifdef USE_LIGHTMAP
|
|
1450
1433
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
1451
1434
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
1452
1435
|
irradiance += lightMapIrradiance;
|
|
1453
1436
|
#endif
|
|
1454
|
-
#if defined( USE_ENVMAP ) && defined(
|
|
1437
|
+
#if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_PMREM )
|
|
1455
1438
|
#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )
|
|
1456
1439
|
iblIrradiance += getIBLIrradiance( geometryNormal );
|
|
1457
1440
|
#endif
|
|
@@ -1475,7 +1458,7 @@ IncidentLight directLight;
|
|
|
1475
1458
|
#ifdef USE_CLEARCOAT
|
|
1476
1459
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
1477
1460
|
#endif
|
|
1478
|
-
#endif`,
|
|
1461
|
+
#endif`,If=`#if defined( RE_IndirectDiffuse )
|
|
1479
1462
|
#if defined( LAMBERT ) || defined( PHONG )
|
|
1480
1463
|
irradiance += iblIrradiance;
|
|
1481
1464
|
#endif
|
|
@@ -1483,19 +1466,23 @@ IncidentLight directLight;
|
|
|
1483
1466
|
#endif
|
|
1484
1467
|
#if defined( RE_IndirectSpecular )
|
|
1485
1468
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1486
|
-
#endif`,
|
|
1487
|
-
uniform highp sampler3D probesSH;
|
|
1488
|
-
uniform vec3 probesMin;
|
|
1489
|
-
uniform vec3 probesMax;
|
|
1490
|
-
uniform vec3 probesResolution;
|
|
1491
|
-
|
|
1469
|
+
#endif`,Lf=`#if NUM_LIGHT_PROBE_GRIDS > 0
|
|
1470
|
+
uniform highp sampler3D probesSH[ NUM_LIGHT_PROBE_GRIDS ];
|
|
1471
|
+
uniform vec3 probesMin[ NUM_LIGHT_PROBE_GRIDS ];
|
|
1472
|
+
uniform vec3 probesMax[ NUM_LIGHT_PROBE_GRIDS ];
|
|
1473
|
+
uniform vec3 probesResolution[ NUM_LIGHT_PROBE_GRIDS ];
|
|
1474
|
+
bool isInsideLightProbeGrid( vec3 worldPos, vec3 worldNormal, vec3 probesMin, vec3 probesMax, vec3 probesResolution ) {
|
|
1475
|
+
vec3 spacing = ( probesMax - probesMin ) / probesResolution;
|
|
1476
|
+
vec3 samplePos = worldPos + worldNormal * spacing * 0.5;
|
|
1477
|
+
vec3 margin = spacing * 0.01;
|
|
1478
|
+
return all( greaterThanEqual( samplePos, probesMin - margin ) ) && all( lessThanEqual( samplePos, probesMax + margin ) );
|
|
1479
|
+
}
|
|
1480
|
+
vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3 probesMax, vec3 probesResolution, vec3 worldPos, vec3 worldNormal ) {
|
|
1492
1481
|
vec3 res = probesResolution;
|
|
1493
1482
|
vec3 gridRange = probesMax - probesMin;
|
|
1494
|
-
vec3
|
|
1495
|
-
vec3 probeSpacing = gridRange / resMinusOne;
|
|
1483
|
+
vec3 probeSpacing = gridRange / res;
|
|
1496
1484
|
vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;
|
|
1497
|
-
vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.
|
|
1498
|
-
uvw = uvw * resMinusOne / res + 0.5 / res;
|
|
1485
|
+
vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.5 / res, 1.0 - 0.5 / res );
|
|
1499
1486
|
float nz = res.z;
|
|
1500
1487
|
float paddedSlices = nz + 2.0;
|
|
1501
1488
|
float atlasDepth = 7.0 * paddedSlices;
|
|
@@ -1528,27 +1515,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1528
1515
|
result += c8 * 0.429043 * ( x * x - y * y );
|
|
1529
1516
|
return max( result, vec3( 0.0 ) );
|
|
1530
1517
|
}
|
|
1531
|
-
#endif`,
|
|
1518
|
+
#endif`,Df=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1532
1519
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
1533
|
-
#endif`,
|
|
1520
|
+
#endif`,Nf=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1534
1521
|
uniform float logDepthBufFC;
|
|
1535
1522
|
varying float vFragDepth;
|
|
1536
1523
|
varying float vIsPerspective;
|
|
1537
|
-
#endif`,
|
|
1524
|
+
#endif`,Uf=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1538
1525
|
varying float vFragDepth;
|
|
1539
1526
|
varying float vIsPerspective;
|
|
1540
|
-
#endif`,
|
|
1527
|
+
#endif`,Ff=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1541
1528
|
vFragDepth = 1.0 + gl_Position.w;
|
|
1542
1529
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1543
|
-
#endif`,
|
|
1530
|
+
#endif`,Of=`#ifdef USE_MAP
|
|
1544
1531
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
1545
1532
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
1546
1533
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
1547
1534
|
#endif
|
|
1548
1535
|
diffuseColor *= sampledDiffuseColor;
|
|
1549
|
-
#endif`,
|
|
1536
|
+
#endif`,Bf=`#ifdef USE_MAP
|
|
1550
1537
|
uniform sampler2D map;
|
|
1551
|
-
#endif`,
|
|
1538
|
+
#endif`,zf=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1552
1539
|
#if defined( USE_POINTS_UV )
|
|
1553
1540
|
vec2 uv = vUv;
|
|
1554
1541
|
#else
|
|
@@ -1560,7 +1547,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1560
1547
|
#endif
|
|
1561
1548
|
#ifdef USE_ALPHAMAP
|
|
1562
1549
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
1563
|
-
#endif`,
|
|
1550
|
+
#endif`,kf=`#if defined( USE_POINTS_UV )
|
|
1564
1551
|
varying vec2 vUv;
|
|
1565
1552
|
#else
|
|
1566
1553
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
@@ -1572,33 +1559,37 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1572
1559
|
#endif
|
|
1573
1560
|
#ifdef USE_ALPHAMAP
|
|
1574
1561
|
uniform sampler2D alphaMap;
|
|
1575
|
-
#endif`,
|
|
1562
|
+
#endif`,Vf=`float metalnessFactor = metalness;
|
|
1576
1563
|
#ifdef USE_METALNESSMAP
|
|
1577
1564
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
1578
1565
|
metalnessFactor *= texelMetalness.b;
|
|
1579
|
-
#endif`,
|
|
1566
|
+
#endif`,Gf=`#ifdef USE_METALNESSMAP
|
|
1580
1567
|
uniform sampler2D metalnessMap;
|
|
1581
|
-
#endif`,
|
|
1568
|
+
#endif`,Hf=`#ifdef USE_INSTANCING_MORPH
|
|
1582
1569
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
1583
1570
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
1584
1571
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1585
1572
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
1586
1573
|
}
|
|
1587
|
-
#endif`,
|
|
1588
|
-
|
|
1574
|
+
#endif`,Wf=`#if defined( USE_MORPHCOLORS )
|
|
1575
|
+
#if defined( USE_COLOR_ALPHA )
|
|
1576
|
+
vColor *= morphTargetBaseInfluence;
|
|
1577
|
+
#elif defined( USE_COLOR )
|
|
1578
|
+
vColor.rgb *= morphTargetBaseInfluence;
|
|
1579
|
+
#endif
|
|
1589
1580
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1590
1581
|
#if defined( USE_COLOR_ALPHA )
|
|
1591
1582
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
|
|
1592
1583
|
#elif defined( USE_COLOR )
|
|
1593
|
-
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
1584
|
+
if ( morphTargetInfluences[ i ] != 0.0 ) vColor.rgb += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
1594
1585
|
#endif
|
|
1595
1586
|
}
|
|
1596
|
-
#endif`,
|
|
1587
|
+
#endif`,Xf=`#ifdef USE_MORPHNORMALS
|
|
1597
1588
|
objectNormal *= morphTargetBaseInfluence;
|
|
1598
1589
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1599
1590
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
1600
1591
|
}
|
|
1601
|
-
#endif`,
|
|
1592
|
+
#endif`,qf=`#ifdef USE_MORPHTARGETS
|
|
1602
1593
|
#ifndef USE_INSTANCING_MORPH
|
|
1603
1594
|
uniform float morphTargetBaseInfluence;
|
|
1604
1595
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
@@ -1612,12 +1603,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1612
1603
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
1613
1604
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
1614
1605
|
}
|
|
1615
|
-
#endif`,
|
|
1606
|
+
#endif`,Yf=`#ifdef USE_MORPHTARGETS
|
|
1616
1607
|
transformed *= morphTargetBaseInfluence;
|
|
1617
1608
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1618
1609
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
1619
1610
|
}
|
|
1620
|
-
#endif`,
|
|
1611
|
+
#endif`,Zf=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
1621
1612
|
#ifdef FLAT_SHADED
|
|
1622
1613
|
vec3 fdx = dFdx( vViewPosition );
|
|
1623
1614
|
vec3 fdy = dFdy( vViewPosition );
|
|
@@ -1658,7 +1649,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1658
1649
|
tbn2[1] *= faceDirection;
|
|
1659
1650
|
#endif
|
|
1660
1651
|
#endif
|
|
1661
|
-
vec3 nonPerturbedNormal = normal
|
|
1652
|
+
vec3 nonPerturbedNormal = normal;`,$f=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
1662
1653
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1663
1654
|
#ifdef FLIP_SIDED
|
|
1664
1655
|
normal = - normal;
|
|
@@ -1676,19 +1667,19 @@ vec3 nonPerturbedNormal = normal;`,Rf=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1676
1667
|
normal = normalize( tbn * mapN );
|
|
1677
1668
|
#elif defined( USE_BUMPMAP )
|
|
1678
1669
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
1679
|
-
#endif`,
|
|
1670
|
+
#endif`,Jf=`#ifndef FLAT_SHADED
|
|
1680
1671
|
varying vec3 vNormal;
|
|
1681
1672
|
#ifdef USE_TANGENT
|
|
1682
1673
|
varying vec3 vTangent;
|
|
1683
1674
|
varying vec3 vBitangent;
|
|
1684
1675
|
#endif
|
|
1685
|
-
#endif`,
|
|
1676
|
+
#endif`,Kf=`#ifndef FLAT_SHADED
|
|
1686
1677
|
varying vec3 vNormal;
|
|
1687
1678
|
#ifdef USE_TANGENT
|
|
1688
1679
|
varying vec3 vTangent;
|
|
1689
1680
|
varying vec3 vBitangent;
|
|
1690
1681
|
#endif
|
|
1691
|
-
#endif`,
|
|
1682
|
+
#endif`,jf=`#ifndef FLAT_SHADED
|
|
1692
1683
|
vNormal = normalize( transformedNormal );
|
|
1693
1684
|
#ifdef USE_TANGENT
|
|
1694
1685
|
vTangent = normalize( transformedTangent );
|
|
@@ -1697,7 +1688,7 @@ vec3 nonPerturbedNormal = normal;`,Rf=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1697
1688
|
vBitangent = - vBitangent;
|
|
1698
1689
|
#endif
|
|
1699
1690
|
#endif
|
|
1700
|
-
#endif`,
|
|
1691
|
+
#endif`,Qf=`#ifdef USE_NORMALMAP
|
|
1701
1692
|
uniform sampler2D normalMap;
|
|
1702
1693
|
uniform vec2 normalScale;
|
|
1703
1694
|
#endif
|
|
@@ -1719,13 +1710,13 @@ vec3 nonPerturbedNormal = normal;`,Rf=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1719
1710
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
1720
1711
|
return mat3( T * scale, B * scale, N );
|
|
1721
1712
|
}
|
|
1722
|
-
#endif`,
|
|
1713
|
+
#endif`,ep=`#ifdef USE_CLEARCOAT
|
|
1723
1714
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
1724
|
-
#endif`,
|
|
1715
|
+
#endif`,tp=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1725
1716
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1726
1717
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
1727
1718
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
1728
|
-
#endif`,
|
|
1719
|
+
#endif`,np=`#ifdef USE_CLEARCOATMAP
|
|
1729
1720
|
uniform sampler2D clearcoatMap;
|
|
1730
1721
|
#endif
|
|
1731
1722
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
@@ -1734,18 +1725,18 @@ vec3 nonPerturbedNormal = normal;`,Rf=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1734
1725
|
#endif
|
|
1735
1726
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
1736
1727
|
uniform sampler2D clearcoatRoughnessMap;
|
|
1737
|
-
#endif`,
|
|
1728
|
+
#endif`,ip=`#ifdef USE_IRIDESCENCEMAP
|
|
1738
1729
|
uniform sampler2D iridescenceMap;
|
|
1739
1730
|
#endif
|
|
1740
1731
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
1741
1732
|
uniform sampler2D iridescenceThicknessMap;
|
|
1742
|
-
#endif`,
|
|
1733
|
+
#endif`,sp=`#ifdef OPAQUE
|
|
1743
1734
|
diffuseColor.a = 1.0;
|
|
1744
1735
|
#endif
|
|
1745
1736
|
#ifdef USE_TRANSMISSION
|
|
1746
1737
|
diffuseColor.a *= material.transmissionAlpha;
|
|
1747
1738
|
#endif
|
|
1748
|
-
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,
|
|
1739
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,rp=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
1749
1740
|
return normalize( normal ) * 0.5 + 0.5;
|
|
1750
1741
|
}
|
|
1751
1742
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
@@ -1824,9 +1815,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
1824
1815
|
#else
|
|
1825
1816
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
1826
1817
|
#endif
|
|
1827
|
-
}`,
|
|
1818
|
+
}`,ap=`#ifdef PREMULTIPLIED_ALPHA
|
|
1828
1819
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
1829
|
-
#endif`,
|
|
1820
|
+
#endif`,op=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
1830
1821
|
#ifdef USE_BATCHING
|
|
1831
1822
|
mvPosition = batchingMatrix * mvPosition;
|
|
1832
1823
|
#endif
|
|
@@ -1834,22 +1825,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
1834
1825
|
mvPosition = instanceMatrix * mvPosition;
|
|
1835
1826
|
#endif
|
|
1836
1827
|
mvPosition = modelViewMatrix * mvPosition;
|
|
1837
|
-
gl_Position = projectionMatrix * mvPosition;`,
|
|
1828
|
+
gl_Position = projectionMatrix * mvPosition;`,lp=`#ifdef DITHERING
|
|
1838
1829
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
1839
|
-
#endif`,
|
|
1830
|
+
#endif`,cp=`#ifdef DITHERING
|
|
1840
1831
|
vec3 dithering( vec3 color ) {
|
|
1841
1832
|
float grid_position = rand( gl_FragCoord.xy );
|
|
1842
1833
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
1843
1834
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
1844
1835
|
return color + dither_shift_RGB;
|
|
1845
1836
|
}
|
|
1846
|
-
#endif`,
|
|
1837
|
+
#endif`,hp=`float roughnessFactor = roughness;
|
|
1847
1838
|
#ifdef USE_ROUGHNESSMAP
|
|
1848
1839
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
1849
1840
|
roughnessFactor *= texelRoughness.g;
|
|
1850
|
-
#endif`,
|
|
1841
|
+
#endif`,up=`#ifdef USE_ROUGHNESSMAP
|
|
1851
1842
|
uniform sampler2D roughnessMap;
|
|
1852
|
-
#endif`,
|
|
1843
|
+
#endif`,dp=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1853
1844
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1854
1845
|
#endif
|
|
1855
1846
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
@@ -1940,12 +1931,16 @@ gl_Position = projectionMatrix * mvPosition;`,Gf=`#ifdef DITHERING
|
|
|
1940
1931
|
float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|
1941
1932
|
float shadow = 1.0;
|
|
1942
1933
|
shadowCoord.xyz /= shadowCoord.w;
|
|
1943
|
-
|
|
1934
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
1935
|
+
shadowCoord.z -= shadowBias;
|
|
1936
|
+
#else
|
|
1937
|
+
shadowCoord.z += shadowBias;
|
|
1938
|
+
#endif
|
|
1944
1939
|
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
|
1945
1940
|
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
|
1946
1941
|
if ( frustumTest ) {
|
|
1947
1942
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
1948
|
-
|
|
1943
|
+
vec2 radius = shadowRadius * texelSize;
|
|
1949
1944
|
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;
|
|
1950
1945
|
shadow = (
|
|
1951
1946
|
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +
|
|
@@ -2052,12 +2047,14 @@ gl_Position = projectionMatrix * mvPosition;`,Gf=`#ifdef DITHERING
|
|
|
2052
2047
|
vec3 absVec = abs( lightToPosition );
|
|
2053
2048
|
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
|
|
2054
2049
|
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
|
|
2050
|
+
float lightDistance = length( lightToPosition );
|
|
2051
|
+
float depthRange = shadowCameraFar - shadowCameraNear;
|
|
2055
2052
|
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
2056
|
-
float
|
|
2057
|
-
|
|
2053
|
+
float depthA = - shadowCameraNear / depthRange - shadowBias;
|
|
2054
|
+
float depthB = shadowCameraNear * shadowCameraFar / ( depthRange * lightDistance );
|
|
2058
2055
|
#else
|
|
2059
|
-
float
|
|
2060
|
-
|
|
2056
|
+
float depthA = shadowCameraFar / depthRange + shadowBias;
|
|
2057
|
+
float depthB = - shadowCameraNear * shadowCameraFar / ( depthRange * lightDistance );
|
|
2061
2058
|
#endif
|
|
2062
2059
|
float texelSize = shadowRadius / shadowMapSize.x;
|
|
2063
2060
|
vec3 absDir = abs( bd3D );
|
|
@@ -2065,18 +2062,15 @@ gl_Position = projectionMatrix * mvPosition;`,Gf=`#ifdef DITHERING
|
|
|
2065
2062
|
tangent = normalize( cross( bd3D, tangent ) );
|
|
2066
2063
|
vec3 bitangent = cross( bd3D, tangent );
|
|
2067
2064
|
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
texture( shadowMap, vec4(
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +
|
|
2078
|
-
texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )
|
|
2079
|
-
) * 0.2;
|
|
2065
|
+
shadow = 0.0;
|
|
2066
|
+
for ( int i = 0; i < 5; i ++ ) {
|
|
2067
|
+
vec2 offset = vogelDiskSample( i, 5, phi );
|
|
2068
|
+
vec3 direction = bd3D + ( tangent * offset.x + bitangent * offset.y ) * texelSize;
|
|
2069
|
+
vec3 absDirection = abs( direction );
|
|
2070
|
+
float dp = depthA + depthB / max( max( absDirection.x, absDirection.y ), absDirection.z );
|
|
2071
|
+
shadow += texture( shadowMap, vec4( direction, dp ) );
|
|
2072
|
+
}
|
|
2073
|
+
shadow *= 0.2;
|
|
2080
2074
|
}
|
|
2081
2075
|
return mix( 1.0, shadow, shadowIntensity );
|
|
2082
2076
|
}
|
|
@@ -2100,7 +2094,7 @@ gl_Position = projectionMatrix * mvPosition;`,Gf=`#ifdef DITHERING
|
|
|
2100
2094
|
}
|
|
2101
2095
|
#endif
|
|
2102
2096
|
#endif
|
|
2103
|
-
#endif`,
|
|
2097
|
+
#endif`,fp=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
2104
2098
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
2105
2099
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
2106
2100
|
#endif
|
|
@@ -2145,7 +2139,7 @@ gl_Position = projectionMatrix * mvPosition;`,Gf=`#ifdef DITHERING
|
|
|
2145
2139
|
};
|
|
2146
2140
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
2147
2141
|
#endif
|
|
2148
|
-
#endif`,
|
|
2142
|
+
#endif`,pp=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
2149
2143
|
#ifdef HAS_NORMAL
|
|
2150
2144
|
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
|
|
2151
2145
|
#else
|
|
@@ -2185,7 +2179,7 @@ gl_Position = projectionMatrix * mvPosition;`,Gf=`#ifdef DITHERING
|
|
|
2185
2179
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
2186
2180
|
}
|
|
2187
2181
|
#pragma unroll_loop_end
|
|
2188
|
-
#endif`,
|
|
2182
|
+
#endif`,mp=`float getShadowMask() {
|
|
2189
2183
|
float shadow = 1.0;
|
|
2190
2184
|
#ifdef USE_SHADOWMAP
|
|
2191
2185
|
#if NUM_SUN_LIGHT_SHADOWS > 0
|
|
@@ -2226,12 +2220,12 @@ gl_Position = projectionMatrix * mvPosition;`,Gf=`#ifdef DITHERING
|
|
|
2226
2220
|
#endif
|
|
2227
2221
|
#endif
|
|
2228
2222
|
return shadow;
|
|
2229
|
-
}
|
|
2223
|
+
}`,gp=`#ifdef USE_SKINNING
|
|
2230
2224
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
2231
2225
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
2232
2226
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
2233
2227
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
2234
|
-
#endif`,
|
|
2228
|
+
#endif`,_p=`#ifdef USE_SKINNING
|
|
2235
2229
|
uniform mat4 bindMatrix;
|
|
2236
2230
|
uniform mat4 bindMatrixInverse;
|
|
2237
2231
|
uniform highp sampler2D boneTexture;
|
|
@@ -2246,7 +2240,7 @@ gl_Position = projectionMatrix * mvPosition;`,Gf=`#ifdef DITHERING
|
|
|
2246
2240
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
2247
2241
|
return mat4( v1, v2, v3, v4 );
|
|
2248
2242
|
}
|
|
2249
|
-
#endif`,
|
|
2243
|
+
#endif`,xp=`#ifdef USE_SKINNING
|
|
2250
2244
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
2251
2245
|
vec4 skinned = vec4( 0.0 );
|
|
2252
2246
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
@@ -2254,7 +2248,7 @@ gl_Position = projectionMatrix * mvPosition;`,Gf=`#ifdef DITHERING
|
|
|
2254
2248
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2255
2249
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2256
2250
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2257
|
-
#endif`,
|
|
2251
|
+
#endif`,yp=`#ifdef USE_SKINNING
|
|
2258
2252
|
mat4 skinMatrix = mat4( 0.0 );
|
|
2259
2253
|
skinMatrix += skinWeight.x * boneMatX;
|
|
2260
2254
|
skinMatrix += skinWeight.y * boneMatY;
|
|
@@ -2265,17 +2259,17 @@ gl_Position = projectionMatrix * mvPosition;`,Gf=`#ifdef DITHERING
|
|
|
2265
2259
|
#ifdef USE_TANGENT
|
|
2266
2260
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2267
2261
|
#endif
|
|
2268
|
-
#endif`,
|
|
2262
|
+
#endif`,vp=`float specularStrength;
|
|
2269
2263
|
#ifdef USE_SPECULARMAP
|
|
2270
2264
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
2271
2265
|
specularStrength = texelSpecular.r;
|
|
2272
2266
|
#else
|
|
2273
2267
|
specularStrength = 1.0;
|
|
2274
|
-
#endif`,
|
|
2268
|
+
#endif`,Mp=`#ifdef USE_SPECULARMAP
|
|
2275
2269
|
uniform sampler2D specularMap;
|
|
2276
|
-
#endif`,
|
|
2270
|
+
#endif`,bp=`#if defined( TONE_MAPPING )
|
|
2277
2271
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2278
|
-
#endif`,
|
|
2272
|
+
#endif`,Sp=`#ifndef saturate
|
|
2279
2273
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
2280
2274
|
#endif
|
|
2281
2275
|
uniform float toneMappingExposure;
|
|
@@ -2372,7 +2366,7 @@ vec3 NeutralToneMapping( vec3 color ) {
|
|
|
2372
2366
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
2373
2367
|
return mix( color, vec3( newPeak ), g );
|
|
2374
2368
|
}
|
|
2375
|
-
vec3 CustomToneMapping( vec3 color ) { return color; }`,
|
|
2369
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,wp=`#ifdef USE_TRANSMISSION
|
|
2376
2370
|
material.transmission = transmission;
|
|
2377
2371
|
material.transmissionAlpha = 1.0;
|
|
2378
2372
|
material.thickness = thickness;
|
|
@@ -2393,7 +2387,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,sp=`#ifdef USE_TRANSMISS
|
|
|
2393
2387
|
material.attenuationColor, material.attenuationDistance );
|
|
2394
2388
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
2395
2389
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
2396
|
-
#endif`,
|
|
2390
|
+
#endif`,Ep=`#ifdef USE_TRANSMISSION
|
|
2397
2391
|
uniform float transmission;
|
|
2398
2392
|
uniform float thickness;
|
|
2399
2393
|
uniform float attenuationDistance;
|
|
@@ -2519,7 +2513,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,sp=`#ifdef USE_TRANSMISS
|
|
|
2519
2513
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
2520
2514
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
2521
2515
|
}
|
|
2522
|
-
#endif`,
|
|
2516
|
+
#endif`,Tp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2523
2517
|
varying vec2 vUv;
|
|
2524
2518
|
#endif
|
|
2525
2519
|
#ifdef USE_MAP
|
|
@@ -2549,6 +2543,9 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,sp=`#ifdef USE_TRANSMISS
|
|
|
2549
2543
|
#ifdef USE_ROUGHNESSMAP
|
|
2550
2544
|
varying vec2 vRoughnessMapUv;
|
|
2551
2545
|
#endif
|
|
2546
|
+
#ifdef USE_DIFFUSE_ROUGHNESSMAP
|
|
2547
|
+
varying vec2 vDiffuseRoughnessMapUv;
|
|
2548
|
+
#endif
|
|
2552
2549
|
#ifdef USE_ANISOTROPYMAP
|
|
2553
2550
|
varying vec2 vAnisotropyMapUv;
|
|
2554
2551
|
#endif
|
|
@@ -2589,7 +2586,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,sp=`#ifdef USE_TRANSMISS
|
|
|
2589
2586
|
#ifdef USE_THICKNESSMAP
|
|
2590
2587
|
uniform mat3 thicknessMapTransform;
|
|
2591
2588
|
varying vec2 vThicknessMapUv;
|
|
2592
|
-
#endif`,
|
|
2589
|
+
#endif`,Ap=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2593
2590
|
varying vec2 vUv;
|
|
2594
2591
|
#endif
|
|
2595
2592
|
#ifdef USE_MAP
|
|
@@ -2632,6 +2629,10 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,sp=`#ifdef USE_TRANSMISS
|
|
|
2632
2629
|
uniform mat3 roughnessMapTransform;
|
|
2633
2630
|
varying vec2 vRoughnessMapUv;
|
|
2634
2631
|
#endif
|
|
2632
|
+
#ifdef USE_DIFFUSE_ROUGHNESSMAP
|
|
2633
|
+
uniform mat3 diffuseRoughnessMapTransform;
|
|
2634
|
+
varying vec2 vDiffuseRoughnessMapUv;
|
|
2635
|
+
#endif
|
|
2635
2636
|
#ifdef USE_ANISOTROPYMAP
|
|
2636
2637
|
uniform mat3 anisotropyMapTransform;
|
|
2637
2638
|
varying vec2 vAnisotropyMapUv;
|
|
@@ -2683,7 +2684,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,sp=`#ifdef USE_TRANSMISS
|
|
|
2683
2684
|
#ifdef USE_THICKNESSMAP
|
|
2684
2685
|
uniform mat3 thicknessMapTransform;
|
|
2685
2686
|
varying vec2 vThicknessMapUv;
|
|
2686
|
-
#endif`,
|
|
2687
|
+
#endif`,Rp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2687
2688
|
vUv = vec3( uv, 1 ).xy;
|
|
2688
2689
|
#endif
|
|
2689
2690
|
#ifdef USE_MAP
|
|
@@ -2716,6 +2717,9 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,sp=`#ifdef USE_TRANSMISS
|
|
|
2716
2717
|
#ifdef USE_ROUGHNESSMAP
|
|
2717
2718
|
vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
2718
2719
|
#endif
|
|
2720
|
+
#ifdef USE_DIFFUSE_ROUGHNESSMAP
|
|
2721
|
+
vDiffuseRoughnessMapUv = ( diffuseRoughnessMapTransform * vec3( DIFFUSE_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
2722
|
+
#endif
|
|
2719
2723
|
#ifdef USE_ANISOTROPYMAP
|
|
2720
2724
|
vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
|
|
2721
2725
|
#endif
|
|
@@ -2754,7 +2758,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,sp=`#ifdef USE_TRANSMISS
|
|
|
2754
2758
|
#endif
|
|
2755
2759
|
#ifdef USE_THICKNESSMAP
|
|
2756
2760
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
2757
|
-
#endif`,
|
|
2761
|
+
#endif`,Cp=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
2758
2762
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
2759
2763
|
#ifdef USE_BATCHING
|
|
2760
2764
|
worldPosition = batchingMatrix * worldPosition;
|
|
@@ -2763,12 +2767,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,sp=`#ifdef USE_TRANSMISS
|
|
|
2763
2767
|
worldPosition = instanceMatrix * worldPosition;
|
|
2764
2768
|
#endif
|
|
2765
2769
|
worldPosition = modelMatrix * worldPosition;
|
|
2766
|
-
#endif`,
|
|
2770
|
+
#endif`,Pp=`varying vec2 vUv;
|
|
2767
2771
|
uniform mat3 uvTransform;
|
|
2768
2772
|
void main() {
|
|
2769
2773
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
2770
2774
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
2771
|
-
}`,
|
|
2775
|
+
}`,Ip=`uniform sampler2D t2D;
|
|
2772
2776
|
uniform float backgroundIntensity;
|
|
2773
2777
|
varying vec2 vUv;
|
|
2774
2778
|
void main() {
|
|
@@ -2780,43 +2784,36 @@ void main() {
|
|
|
2780
2784
|
gl_FragColor = texColor;
|
|
2781
2785
|
#include <tonemapping_fragment>
|
|
2782
2786
|
#include <colorspace_fragment>
|
|
2783
|
-
}`,
|
|
2787
|
+
}`,Lp=`varying vec3 vWorldDirection;
|
|
2784
2788
|
#include <common>
|
|
2785
2789
|
void main() {
|
|
2786
2790
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2787
2791
|
#include <begin_vertex>
|
|
2788
2792
|
#include <project_vertex>
|
|
2789
2793
|
gl_Position.z = gl_Position.w;
|
|
2790
|
-
}`,
|
|
2791
|
-
uniform samplerCube envMap;
|
|
2792
|
-
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
2793
|
-
uniform sampler2D envMap;
|
|
2794
|
-
#endif
|
|
2795
|
-
uniform float backgroundBlurriness;
|
|
2794
|
+
}`,Dp=`uniform float backgroundBlurriness;
|
|
2796
2795
|
uniform float backgroundIntensity;
|
|
2797
2796
|
uniform mat3 backgroundRotation;
|
|
2798
2797
|
varying vec3 vWorldDirection;
|
|
2799
|
-
#include <
|
|
2798
|
+
#include <envmap_common_pars_fragment>
|
|
2800
2799
|
void main() {
|
|
2801
|
-
#ifdef
|
|
2802
|
-
vec4 texColor =
|
|
2803
|
-
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
2804
|
-
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
|
|
2800
|
+
#ifdef ENVMAP_TYPE_PMREM
|
|
2801
|
+
vec4 texColor = textureLod( envMap, backgroundRotation * vWorldDirection, roughnessToMip( backgroundBlurriness ) );
|
|
2805
2802
|
#else
|
|
2806
|
-
vec4 texColor =
|
|
2803
|
+
vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );
|
|
2807
2804
|
#endif
|
|
2808
2805
|
texColor.rgb *= backgroundIntensity;
|
|
2809
2806
|
gl_FragColor = texColor;
|
|
2810
2807
|
#include <tonemapping_fragment>
|
|
2811
2808
|
#include <colorspace_fragment>
|
|
2812
|
-
}`,
|
|
2809
|
+
}`,Np=`varying vec3 vWorldDirection;
|
|
2813
2810
|
#include <common>
|
|
2814
2811
|
void main() {
|
|
2815
2812
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2816
2813
|
#include <begin_vertex>
|
|
2817
2814
|
#include <project_vertex>
|
|
2818
2815
|
gl_Position.z = gl_Position.w;
|
|
2819
|
-
}`,
|
|
2816
|
+
}`,Up=`uniform samplerCube tCube;
|
|
2820
2817
|
uniform float tFlip;
|
|
2821
2818
|
uniform float opacity;
|
|
2822
2819
|
varying vec3 vWorldDirection;
|
|
@@ -2826,7 +2823,7 @@ void main() {
|
|
|
2826
2823
|
gl_FragColor.a *= opacity;
|
|
2827
2824
|
#include <tonemapping_fragment>
|
|
2828
2825
|
#include <colorspace_fragment>
|
|
2829
|
-
}`,
|
|
2826
|
+
}`,Fp=`#include <common>
|
|
2830
2827
|
#include <batching_pars_vertex>
|
|
2831
2828
|
#include <uv_pars_vertex>
|
|
2832
2829
|
#include <displacementmap_pars_vertex>
|
|
@@ -2853,7 +2850,7 @@ void main() {
|
|
|
2853
2850
|
#include <logdepthbuf_vertex>
|
|
2854
2851
|
#include <clipping_planes_vertex>
|
|
2855
2852
|
vHighPrecisionZW = gl_Position.zw;
|
|
2856
|
-
}`,
|
|
2853
|
+
}`,Op=`#if DEPTH_PACKING == 3200
|
|
2857
2854
|
uniform float opacity;
|
|
2858
2855
|
#endif
|
|
2859
2856
|
#include <common>
|
|
@@ -2891,7 +2888,7 @@ void main() {
|
|
|
2891
2888
|
#elif DEPTH_PACKING == 3203
|
|
2892
2889
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
2893
2890
|
#endif
|
|
2894
|
-
}`,
|
|
2891
|
+
}`,Bp=`#define DISTANCE
|
|
2895
2892
|
varying vec3 vWorldPosition;
|
|
2896
2893
|
#include <common>
|
|
2897
2894
|
#include <batching_pars_vertex>
|
|
@@ -2918,7 +2915,7 @@ void main() {
|
|
|
2918
2915
|
#include <worldpos_vertex>
|
|
2919
2916
|
#include <clipping_planes_vertex>
|
|
2920
2917
|
vWorldPosition = worldPosition.xyz;
|
|
2921
|
-
}`,
|
|
2918
|
+
}`,zp=`#define DISTANCE
|
|
2922
2919
|
uniform vec3 referencePosition;
|
|
2923
2920
|
uniform float nearDistance;
|
|
2924
2921
|
uniform float farDistance;
|
|
@@ -2941,13 +2938,13 @@ void main() {
|
|
|
2941
2938
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
2942
2939
|
dist = saturate( dist );
|
|
2943
2940
|
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
|
|
2944
|
-
}`,
|
|
2941
|
+
}`,kp=`varying vec3 vWorldDirection;
|
|
2945
2942
|
#include <common>
|
|
2946
2943
|
void main() {
|
|
2947
2944
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2948
2945
|
#include <begin_vertex>
|
|
2949
2946
|
#include <project_vertex>
|
|
2950
|
-
}`,
|
|
2947
|
+
}`,Vp=`uniform sampler2D tEquirect;
|
|
2951
2948
|
varying vec3 vWorldDirection;
|
|
2952
2949
|
#include <common>
|
|
2953
2950
|
void main() {
|
|
@@ -2956,7 +2953,7 @@ void main() {
|
|
|
2956
2953
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
2957
2954
|
#include <tonemapping_fragment>
|
|
2958
2955
|
#include <colorspace_fragment>
|
|
2959
|
-
}`,
|
|
2956
|
+
}`,Gp=`uniform float scale;
|
|
2960
2957
|
attribute float lineDistance;
|
|
2961
2958
|
varying float vLineDistance;
|
|
2962
2959
|
#include <common>
|
|
@@ -2978,7 +2975,7 @@ void main() {
|
|
|
2978
2975
|
#include <logdepthbuf_vertex>
|
|
2979
2976
|
#include <clipping_planes_vertex>
|
|
2980
2977
|
#include <fog_vertex>
|
|
2981
|
-
}`,
|
|
2978
|
+
}`,Hp=`uniform vec3 diffuse;
|
|
2982
2979
|
uniform float opacity;
|
|
2983
2980
|
uniform float dashSize;
|
|
2984
2981
|
uniform float totalSize;
|
|
@@ -3006,7 +3003,7 @@ void main() {
|
|
|
3006
3003
|
#include <colorspace_fragment>
|
|
3007
3004
|
#include <fog_fragment>
|
|
3008
3005
|
#include <premultiplied_alpha_fragment>
|
|
3009
|
-
}`,
|
|
3006
|
+
}`,Wp=`#include <common>
|
|
3010
3007
|
#include <batching_pars_vertex>
|
|
3011
3008
|
#include <uv_pars_vertex>
|
|
3012
3009
|
#include <envmap_pars_vertex>
|
|
@@ -3038,7 +3035,7 @@ void main() {
|
|
|
3038
3035
|
#include <worldpos_vertex>
|
|
3039
3036
|
#include <envmap_vertex>
|
|
3040
3037
|
#include <fog_vertex>
|
|
3041
|
-
}`,
|
|
3038
|
+
}`,Xp=`uniform vec3 diffuse;
|
|
3042
3039
|
uniform float opacity;
|
|
3043
3040
|
#ifndef FLAT_SHADED
|
|
3044
3041
|
varying vec3 vNormal;
|
|
@@ -3086,7 +3083,7 @@ void main() {
|
|
|
3086
3083
|
#include <fog_fragment>
|
|
3087
3084
|
#include <premultiplied_alpha_fragment>
|
|
3088
3085
|
#include <dithering_fragment>
|
|
3089
|
-
}`,
|
|
3086
|
+
}`,qp=`#define LAMBERT
|
|
3090
3087
|
varying vec3 vViewPosition;
|
|
3091
3088
|
#include <common>
|
|
3092
3089
|
#include <batching_pars_vertex>
|
|
@@ -3125,7 +3122,7 @@ void main() {
|
|
|
3125
3122
|
#include <envmap_vertex>
|
|
3126
3123
|
#include <shadowmap_vertex>
|
|
3127
3124
|
#include <fog_vertex>
|
|
3128
|
-
}`,
|
|
3125
|
+
}`,Yp=`#define LAMBERT
|
|
3129
3126
|
uniform vec3 diffuse;
|
|
3130
3127
|
uniform vec3 emissive;
|
|
3131
3128
|
uniform float opacity;
|
|
@@ -3140,7 +3137,6 @@ uniform float opacity;
|
|
|
3140
3137
|
#include <aomap_pars_fragment>
|
|
3141
3138
|
#include <lightmap_pars_fragment>
|
|
3142
3139
|
#include <emissivemap_pars_fragment>
|
|
3143
|
-
#include <cube_uv_reflection_fragment>
|
|
3144
3140
|
#include <envmap_common_pars_fragment>
|
|
3145
3141
|
#include <envmap_pars_fragment>
|
|
3146
3142
|
#include <envmap_physical_pars_fragment>
|
|
@@ -3183,7 +3179,7 @@ void main() {
|
|
|
3183
3179
|
#include <fog_fragment>
|
|
3184
3180
|
#include <premultiplied_alpha_fragment>
|
|
3185
3181
|
#include <dithering_fragment>
|
|
3186
|
-
}`,
|
|
3182
|
+
}`,Zp=`#define MATCAP
|
|
3187
3183
|
varying vec3 vViewPosition;
|
|
3188
3184
|
#include <common>
|
|
3189
3185
|
#include <batching_pars_vertex>
|
|
@@ -3217,7 +3213,7 @@ void main() {
|
|
|
3217
3213
|
#include <clipping_planes_vertex>
|
|
3218
3214
|
#include <fog_vertex>
|
|
3219
3215
|
vViewPosition = - mvPosition.xyz;
|
|
3220
|
-
}
|
|
3216
|
+
}`,$p=`#define MATCAP
|
|
3221
3217
|
uniform vec3 diffuse;
|
|
3222
3218
|
uniform float opacity;
|
|
3223
3219
|
uniform sampler2D matcap;
|
|
@@ -3263,7 +3259,7 @@ void main() {
|
|
|
3263
3259
|
#include <fog_fragment>
|
|
3264
3260
|
#include <premultiplied_alpha_fragment>
|
|
3265
3261
|
#include <dithering_fragment>
|
|
3266
|
-
}`,
|
|
3262
|
+
}`,Jp=`#define NORMAL
|
|
3267
3263
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3268
3264
|
varying vec3 vViewPosition;
|
|
3269
3265
|
#endif
|
|
@@ -3296,7 +3292,7 @@ void main() {
|
|
|
3296
3292
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3297
3293
|
vViewPosition = - mvPosition.xyz;
|
|
3298
3294
|
#endif
|
|
3299
|
-
}`,
|
|
3295
|
+
}`,Kp=`#define NORMAL
|
|
3300
3296
|
uniform float opacity;
|
|
3301
3297
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3302
3298
|
varying vec3 vViewPosition;
|
|
@@ -3317,7 +3313,7 @@ void main() {
|
|
|
3317
3313
|
#ifdef OPAQUE
|
|
3318
3314
|
gl_FragColor.a = 1.0;
|
|
3319
3315
|
#endif
|
|
3320
|
-
}`,
|
|
3316
|
+
}`,jp=`#define PHONG
|
|
3321
3317
|
varying vec3 vViewPosition;
|
|
3322
3318
|
#include <common>
|
|
3323
3319
|
#include <batching_pars_vertex>
|
|
@@ -3356,7 +3352,7 @@ void main() {
|
|
|
3356
3352
|
#include <envmap_vertex>
|
|
3357
3353
|
#include <shadowmap_vertex>
|
|
3358
3354
|
#include <fog_vertex>
|
|
3359
|
-
}`,
|
|
3355
|
+
}`,Qp=`#define PHONG
|
|
3360
3356
|
uniform vec3 diffuse;
|
|
3361
3357
|
uniform vec3 emissive;
|
|
3362
3358
|
uniform vec3 specular;
|
|
@@ -3373,7 +3369,6 @@ uniform float opacity;
|
|
|
3373
3369
|
#include <aomap_pars_fragment>
|
|
3374
3370
|
#include <lightmap_pars_fragment>
|
|
3375
3371
|
#include <emissivemap_pars_fragment>
|
|
3376
|
-
#include <cube_uv_reflection_fragment>
|
|
3377
3372
|
#include <envmap_common_pars_fragment>
|
|
3378
3373
|
#include <envmap_pars_fragment>
|
|
3379
3374
|
#include <envmap_physical_pars_fragment>
|
|
@@ -3416,7 +3411,7 @@ void main() {
|
|
|
3416
3411
|
#include <fog_fragment>
|
|
3417
3412
|
#include <premultiplied_alpha_fragment>
|
|
3418
3413
|
#include <dithering_fragment>
|
|
3419
|
-
}`,
|
|
3414
|
+
}`,em=`#define STANDARD
|
|
3420
3415
|
varying vec3 vViewPosition;
|
|
3421
3416
|
#ifdef USE_TRANSMISSION
|
|
3422
3417
|
varying vec3 vWorldPosition;
|
|
@@ -3459,7 +3454,7 @@ void main() {
|
|
|
3459
3454
|
#ifdef USE_TRANSMISSION
|
|
3460
3455
|
vWorldPosition = worldPosition.xyz;
|
|
3461
3456
|
#endif
|
|
3462
|
-
}`,
|
|
3457
|
+
}`,tm=`#define STANDARD
|
|
3463
3458
|
#ifdef PHYSICAL
|
|
3464
3459
|
#define IOR
|
|
3465
3460
|
#define USE_SPECULAR
|
|
@@ -3486,6 +3481,12 @@ uniform float opacity;
|
|
|
3486
3481
|
uniform float clearcoat;
|
|
3487
3482
|
uniform float clearcoatRoughness;
|
|
3488
3483
|
#endif
|
|
3484
|
+
#ifdef USE_DIFFUSE_ROUGHNESS
|
|
3485
|
+
uniform float diffuseRoughness;
|
|
3486
|
+
#ifdef USE_DIFFUSE_ROUGHNESSMAP
|
|
3487
|
+
uniform sampler2D diffuseRoughnessMap;
|
|
3488
|
+
#endif
|
|
3489
|
+
#endif
|
|
3489
3490
|
#ifdef USE_DISPERSION
|
|
3490
3491
|
uniform float dispersion;
|
|
3491
3492
|
#endif
|
|
@@ -3527,7 +3528,6 @@ varying vec3 vViewPosition;
|
|
|
3527
3528
|
#include <lightmap_pars_fragment>
|
|
3528
3529
|
#include <emissivemap_pars_fragment>
|
|
3529
3530
|
#include <iridescence_fragment>
|
|
3530
|
-
#include <cube_uv_reflection_fragment>
|
|
3531
3531
|
#include <envmap_common_pars_fragment>
|
|
3532
3532
|
#include <envmap_physical_pars_fragment>
|
|
3533
3533
|
#include <fog_pars_fragment>
|
|
@@ -3587,7 +3587,7 @@ void main() {
|
|
|
3587
3587
|
#include <fog_fragment>
|
|
3588
3588
|
#include <premultiplied_alpha_fragment>
|
|
3589
3589
|
#include <dithering_fragment>
|
|
3590
|
-
}`,
|
|
3590
|
+
}`,nm=`#define TOON
|
|
3591
3591
|
varying vec3 vViewPosition;
|
|
3592
3592
|
#include <common>
|
|
3593
3593
|
#include <batching_pars_vertex>
|
|
@@ -3624,7 +3624,7 @@ void main() {
|
|
|
3624
3624
|
#include <worldpos_vertex>
|
|
3625
3625
|
#include <shadowmap_vertex>
|
|
3626
3626
|
#include <fog_vertex>
|
|
3627
|
-
}`,
|
|
3627
|
+
}`,im=`#define TOON
|
|
3628
3628
|
uniform vec3 diffuse;
|
|
3629
3629
|
uniform vec3 emissive;
|
|
3630
3630
|
uniform float opacity;
|
|
@@ -3676,7 +3676,7 @@ void main() {
|
|
|
3676
3676
|
#include <fog_fragment>
|
|
3677
3677
|
#include <premultiplied_alpha_fragment>
|
|
3678
3678
|
#include <dithering_fragment>
|
|
3679
|
-
}`,
|
|
3679
|
+
}`,sm=`uniform float size;
|
|
3680
3680
|
uniform float scale;
|
|
3681
3681
|
#include <common>
|
|
3682
3682
|
#include <color_pars_vertex>
|
|
@@ -3707,7 +3707,7 @@ void main() {
|
|
|
3707
3707
|
#include <clipping_planes_vertex>
|
|
3708
3708
|
#include <worldpos_vertex>
|
|
3709
3709
|
#include <fog_vertex>
|
|
3710
|
-
}`,
|
|
3710
|
+
}`,rm=`uniform vec3 diffuse;
|
|
3711
3711
|
uniform float opacity;
|
|
3712
3712
|
#include <common>
|
|
3713
3713
|
#include <color_pars_fragment>
|
|
@@ -3732,7 +3732,7 @@ void main() {
|
|
|
3732
3732
|
#include <colorspace_fragment>
|
|
3733
3733
|
#include <fog_fragment>
|
|
3734
3734
|
#include <premultiplied_alpha_fragment>
|
|
3735
|
-
}`,
|
|
3735
|
+
}`,am=`#include <common>
|
|
3736
3736
|
#include <batching_pars_vertex>
|
|
3737
3737
|
#include <fog_pars_vertex>
|
|
3738
3738
|
#include <morphtarget_pars_vertex>
|
|
@@ -3755,7 +3755,7 @@ void main() {
|
|
|
3755
3755
|
#include <worldpos_vertex>
|
|
3756
3756
|
#include <shadowmap_vertex>
|
|
3757
3757
|
#include <fog_vertex>
|
|
3758
|
-
}`,
|
|
3758
|
+
}`,om=`uniform vec3 color;
|
|
3759
3759
|
uniform float opacity;
|
|
3760
3760
|
#include <common>
|
|
3761
3761
|
#include <fog_pars_fragment>
|
|
@@ -3771,7 +3771,7 @@ void main() {
|
|
|
3771
3771
|
#include <colorspace_fragment>
|
|
3772
3772
|
#include <fog_fragment>
|
|
3773
3773
|
#include <premultiplied_alpha_fragment>
|
|
3774
|
-
}`,
|
|
3774
|
+
}`,lm=`uniform float rotation;
|
|
3775
3775
|
uniform vec2 center;
|
|
3776
3776
|
#include <common>
|
|
3777
3777
|
#include <uv_pars_vertex>
|
|
@@ -3795,7 +3795,7 @@ void main() {
|
|
|
3795
3795
|
#include <logdepthbuf_vertex>
|
|
3796
3796
|
#include <clipping_planes_vertex>
|
|
3797
3797
|
#include <fog_vertex>
|
|
3798
|
-
}`,
|
|
3798
|
+
}`,cm=`uniform vec3 diffuse;
|
|
3799
3799
|
uniform float opacity;
|
|
3800
3800
|
#include <common>
|
|
3801
3801
|
#include <uv_pars_fragment>
|
|
@@ -3820,256 +3820,261 @@ void main() {
|
|
|
3820
3820
|
#include <tonemapping_fragment>
|
|
3821
3821
|
#include <colorspace_fragment>
|
|
3822
3822
|
#include <fog_fragment>
|
|
3823
|
-
}`,Gt={alphahash_fragment:cd,alphahash_pars_fragment:hd,alphamap_fragment:ud,alphamap_pars_fragment:dd,alphatest_fragment:fd,alphatest_pars_fragment:pd,aomap_fragment:md,aomap_pars_fragment:gd,batching_pars_vertex:_d,batching_vertex:xd,begin_vertex:yd,beginnormal_vertex:vd,bsdfs:Md,iridescence_fragment:Sd,bumpmap_pars_fragment:bd,clipping_planes_fragment:Ed,clipping_planes_pars_fragment:wd,clipping_planes_pars_vertex:Td,clipping_planes_vertex:Ad,color_fragment:Cd,color_pars_fragment:Rd,color_pars_vertex:Pd,color_vertex:Id,common:Ld,cube_uv_reflection_fragment:Dd,defaultnormal_vertex:Nd,displacementmap_pars_vertex:Ud,displacementmap_vertex:Fd,emissivemap_fragment:Od,emissivemap_pars_fragment:Bd,colorspace_fragment:zd,colorspace_pars_fragment:kd,envmap_fragment:Vd,envmap_common_pars_fragment:Gd,envmap_pars_fragment:Hd,envmap_pars_vertex:Wd,envmap_physical_pars_fragment:ef,envmap_vertex:Xd,fog_vertex:qd,fog_pars_vertex:Yd,fog_fragment:Zd,fog_pars_fragment:Jd,gradientmap_pars_fragment:$d,lightmap_pars_fragment:Kd,lights_lambert_fragment:jd,lights_lambert_pars_fragment:Qd,lights_pars_begin:tf,lights_toon_fragment:nf,lights_toon_pars_fragment:sf,lights_phong_fragment:rf,lights_phong_pars_fragment:af,lights_physical_fragment:of,lights_physical_pars_fragment:lf,lights_fragment_begin:cf,lights_fragment_maps:hf,lights_fragment_end:uf,lightprobes_pars_fragment:df,logdepthbuf_fragment:ff,logdepthbuf_pars_fragment:pf,logdepthbuf_pars_vertex:mf,logdepthbuf_vertex:gf,map_fragment:_f,map_pars_fragment:xf,map_particle_fragment:yf,map_particle_pars_fragment:vf,metalnessmap_fragment:Mf,metalnessmap_pars_fragment:Sf,morphinstance_vertex:bf,morphcolor_vertex:Ef,morphnormal_vertex:wf,morphtarget_pars_vertex:Tf,morphtarget_vertex:Af,normal_fragment_begin:Cf,normal_fragment_maps:Rf,normal_pars_fragment:Pf,normal_pars_vertex:If,normal_vertex:Lf,normalmap_pars_fragment:Df,clearcoat_normal_fragment_begin:Nf,clearcoat_normal_fragment_maps:Uf,clearcoat_pars_fragment:Ff,iridescence_pars_fragment:Of,opaque_fragment:Bf,packing:zf,premultiplied_alpha_fragment:kf,project_vertex:Vf,dithering_fragment:Gf,dithering_pars_fragment:Hf,roughnessmap_fragment:Wf,roughnessmap_pars_fragment:Xf,shadowmap_pars_fragment:qf,shadowmap_pars_vertex:Yf,shadowmap_vertex:Zf,shadowmask_pars_fragment:Jf,skinbase_vertex:$f,skinning_pars_vertex:Kf,skinning_vertex:jf,skinnormal_vertex:Qf,specularmap_fragment:tp,specularmap_pars_fragment:ep,tonemapping_fragment:np,tonemapping_pars_fragment:ip,transmission_fragment:sp,transmission_pars_fragment:rp,uv_pars_fragment:ap,uv_pars_vertex:op,uv_vertex:lp,worldpos_vertex:cp,background_vert:hp,background_frag:up,backgroundCube_vert:dp,backgroundCube_frag:fp,cube_vert:pp,cube_frag:mp,depth_vert:gp,depth_frag:_p,distance_vert:xp,distance_frag:yp,equirect_vert:vp,equirect_frag:Mp,linedashed_vert:Sp,linedashed_frag:bp,meshbasic_vert:Ep,meshbasic_frag:wp,meshlambert_vert:Tp,meshlambert_frag:Ap,meshmatcap_vert:Cp,meshmatcap_frag:Rp,meshnormal_vert:Pp,meshnormal_frag:Ip,meshphong_vert:Lp,meshphong_frag:Dp,meshphysical_vert:Np,meshphysical_frag:Up,meshtoon_vert:Fp,meshtoon_frag:Op,points_vert:Bp,points_frag:zp,shadow_vert:kp,shadow_frag:Vp,sprite_vert:Gp,sprite_frag:Hp},ft={common:{diffuse:{value:new Ft(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ut},alphaMap:{value:null},alphaMapTransform:{value:new Ut},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ut}},envmap:{envMap:{value:null},envMapRotation:{value:new Ut},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ut}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ut}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ut},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ut},normalScale:{value:new Nt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ut},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ut}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ut}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ut}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ft(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{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},probesSH:{value:null},probesMin:{value:new U},probesMax:{value:new U},probesResolution:{value:new U}},points:{diffuse:{value:new Ft(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ut},alphaTest:{value:0},uvTransform:{value:new Ut}},sprite:{diffuse:{value:new Ft(16777215)},opacity:{value:1},center:{value:new Nt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ut},alphaMap:{value:null},alphaMapTransform:{value:new Ut},alphaTest:{value:0}}},xn={basic:{uniforms:Le([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.fog]),vertexShader:Gt.meshbasic_vert,fragmentShader:Gt.meshbasic_frag},lambert:{uniforms:Le([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,ft.lights,{emissive:{value:new Ft(0)},envMapIntensity:{value:1}}]),vertexShader:Gt.meshlambert_vert,fragmentShader:Gt.meshlambert_frag},phong:{uniforms:Le([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,ft.lights,{emissive:{value:new Ft(0)},specular:{value:new Ft(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Gt.meshphong_vert,fragmentShader:Gt.meshphong_frag},standard:{uniforms:Le([ft.common,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.roughnessmap,ft.metalnessmap,ft.fog,ft.lights,{emissive:{value:new Ft(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Gt.meshphysical_vert,fragmentShader:Gt.meshphysical_frag},toon:{uniforms:Le([ft.common,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.gradientmap,ft.fog,ft.lights,{emissive:{value:new Ft(0)}}]),vertexShader:Gt.meshtoon_vert,fragmentShader:Gt.meshtoon_frag},matcap:{uniforms:Le([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,{matcap:{value:null}}]),vertexShader:Gt.meshmatcap_vert,fragmentShader:Gt.meshmatcap_frag},points:{uniforms:Le([ft.points,ft.fog]),vertexShader:Gt.points_vert,fragmentShader:Gt.points_frag},dashed:{uniforms:Le([ft.common,ft.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Gt.linedashed_vert,fragmentShader:Gt.linedashed_frag},depth:{uniforms:Le([ft.common,ft.displacementmap]),vertexShader:Gt.depth_vert,fragmentShader:Gt.depth_frag},normal:{uniforms:Le([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,{opacity:{value:1}}]),vertexShader:Gt.meshnormal_vert,fragmentShader:Gt.meshnormal_frag},sprite:{uniforms:Le([ft.sprite,ft.fog]),vertexShader:Gt.sprite_vert,fragmentShader:Gt.sprite_frag},background:{uniforms:{uvTransform:{value:new Ut},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Gt.background_vert,fragmentShader:Gt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ut}},vertexShader:Gt.backgroundCube_vert,fragmentShader:Gt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Gt.cube_vert,fragmentShader:Gt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Gt.equirect_vert,fragmentShader:Gt.equirect_frag},distance:{uniforms:Le([ft.common,ft.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Gt.distance_vert,fragmentShader:Gt.distance_frag},shadow:{uniforms:Le([ft.lights,ft.fog,{color:{value:new Ft(0)},opacity:{value:1}}]),vertexShader:Gt.shadow_vert,fragmentShader:Gt.shadow_frag}};xn.physical={uniforms:Le([xn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ut},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ut},clearcoatNormalScale:{value:new Nt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ut},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ut},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ut},sheen:{value:0},sheenColor:{value:new Ft(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ut},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ut},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ut},transmissionSamplerSize:{value:new Nt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ut},attenuationDistance:{value:0},attenuationColor:{value:new Ft(0)},specularColor:{value:new Ft(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ut},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ut},anisotropyVector:{value:new Nt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ut}}]),vertexShader:Gt.meshphysical_vert,fragmentShader:Gt.meshphysical_frag};var ka={r:0,b:0,g:0},Wp=new ce,Rh=new Ut;Rh.set(-1,0,0,0,1,0,0,0,1);function Xp(i,t,e,n,s,r){let a=new Ft(0),o=s===!0?0:1,c,l,h=null,d=0,u=null;function p(T){let L=T.isScene===!0?T.background:null;if(L&&L.isTexture){let M=T.backgroundBlurriness>0;L=t.get(L,M)}return L}function _(T){let L=!1,M=p(T);M===null?g(a,o):M&&M.isColor&&(g(M,1),L=!0);let b=i.xr.getEnvironmentBlendMode();b==="additive"?e.buffers.color.setClear(0,0,0,1,r):b==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,r),(i.autoClear||L)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function v(T,L){let M=p(L);M&&(M.isCubeTexture||M.mapping===Ts)?(l===void 0&&(l=new Ve(new zi(1,1,1),new $e({name:"BackgroundCubeMaterial",uniforms:hi(xn.backgroundCube.uniforms),vertexShader:xn.backgroundCube.vertexShader,fragmentShader:xn.backgroundCube.fragmentShader,side:Fe,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(b,E,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=L.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=L.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Wp.makeRotationFromEuler(L.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Rh),l.material.toneMapped=Yt.getTransfer(M.colorSpace)!==Qt,(h!==M||d!==M.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),l.layers.enableAll(),T.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new Ve(new _s(2,2),new $e({name:"BackgroundMaterial",uniforms:hi(xn.background.uniforms),vertexShader:xn.background.vertexShader,fragmentShader:xn.background.fragmentShader,side:Zn,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=M,c.material.uniforms.backgroundIntensity.value=L.backgroundIntensity,c.material.toneMapped=Yt.getTransfer(M.colorSpace)!==Qt,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||d!==M.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),c.layers.enableAll(),T.unshift(c,c.geometry,c.material,0,0,null))}function g(T,L){T.getRGB(ka,il(i)),e.buffers.color.setClear(ka.r,ka.g,ka.b,L,r)}function f(){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 a},setClearColor:function(T,L=1){a.set(T),o=L,g(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(T){o=T,g(a,o)},render:_,addToRenderList:v,dispose:f}}function qp(i,t){let e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,a=!1;function o(O,V,H,R,W){let $=!1,K=d(O,R,H,V);r!==K&&(r=K,l(r.object)),$=p(O,R,H,W),$&&_(O,R,H,W),W!==null&&t.update(W,i.ELEMENT_ARRAY_BUFFER),($||a)&&(a=!1,M(O,V,H,R),W!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(W).buffer))}function c(){return i.createVertexArray()}function l(O){return i.bindVertexArray(O)}function h(O){return i.deleteVertexArray(O)}function d(O,V,H,R){let W=R.wireframe===!0,$=n[V.id];$===void 0&&($={},n[V.id]=$);let K=O.isInstancedMesh===!0?O.id:0,st=$[K];st===void 0&&(st={},$[K]=st);let Y=st[H.id];Y===void 0&&(Y={},st[H.id]=Y);let et=Y[W];return et===void 0&&(et=u(c()),Y[W]=et),et}function u(O){let V=[],H=[],R=[];for(let W=0;W<e;W++)V[W]=0,H[W]=0,R[W]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:V,enabledAttributes:H,attributeDivisors:R,object:O,attributes:{},index:null}}function p(O,V,H,R){let W=r.attributes,$=V.attributes,K=0,st=H.getAttributes();for(let Y in st)if(st[Y].location>=0){let it=W[Y],Ct=$[Y];if(Ct===void 0&&(Y==="instanceMatrix"&&O.instanceMatrix&&(Ct=O.instanceMatrix),Y==="instanceColor"&&O.instanceColor&&(Ct=O.instanceColor)),it===void 0||it.attribute!==Ct||Ct&&it.data!==Ct.data)return!0;K++}return r.attributesNum!==K||r.index!==R}function _(O,V,H,R){let W={},$=V.attributes,K=0,st=H.getAttributes();for(let Y in st)if(st[Y].location>=0){let it=$[Y];it===void 0&&(Y==="instanceMatrix"&&O.instanceMatrix&&(it=O.instanceMatrix),Y==="instanceColor"&&O.instanceColor&&(it=O.instanceColor));let Ct={};Ct.attribute=it,it&&it.data&&(Ct.data=it.data),W[Y]=Ct,K++}r.attributes=W,r.attributesNum=K,r.index=R}function v(){let O=r.newAttributes;for(let V=0,H=O.length;V<H;V++)O[V]=0}function g(O){f(O,0)}function f(O,V){let H=r.newAttributes,R=r.enabledAttributes,W=r.attributeDivisors;H[O]=1,R[O]===0&&(i.enableVertexAttribArray(O),R[O]=1),W[O]!==V&&(i.vertexAttribDivisor(O,V),W[O]=V)}function T(){let O=r.newAttributes,V=r.enabledAttributes;for(let H=0,R=V.length;H<R;H++)V[H]!==O[H]&&(i.disableVertexAttribArray(H),V[H]=0)}function L(O,V,H,R,W,$,K){K===!0?i.vertexAttribIPointer(O,V,H,W,$):i.vertexAttribPointer(O,V,H,R,W,$)}function M(O,V,H,R){v();let W=R.attributes,$=H.getAttributes(),K=V.defaultAttributeValues;for(let st in $){let Y=$[st];if(Y.location>=0){let et=W[st];if(et===void 0&&(st==="instanceMatrix"&&O.instanceMatrix&&(et=O.instanceMatrix),st==="instanceColor"&&O.instanceColor&&(et=O.instanceColor)),et!==void 0){let it=et.normalized,Ct=et.itemSize,Et=t.get(et);if(Et===void 0)continue;let ee=Et.buffer,Lt=Et.type,Wt=Et.bytesPerElement,j=Lt===i.INT||Lt===i.UNSIGNED_INT||et.gpuType===ea;if(et.isInterleavedBufferAttribute){let Q=et.data,_t=Q.stride,St=et.offset;if(Q.isInstancedInterleavedBuffer){for(let pt=0;pt<Y.locationSize;pt++)f(Y.location+pt,Q.meshPerAttribute);O.isInstancedMesh!==!0&&R._maxInstanceCount===void 0&&(R._maxInstanceCount=Q.meshPerAttribute*Q.count)}else for(let pt=0;pt<Y.locationSize;pt++)g(Y.location+pt);i.bindBuffer(i.ARRAY_BUFFER,ee);for(let pt=0;pt<Y.locationSize;pt++)L(Y.location+pt,Ct/Y.locationSize,Lt,it,_t*Wt,(St+Ct/Y.locationSize*pt)*Wt,j)}else{if(et.isInstancedBufferAttribute){for(let Q=0;Q<Y.locationSize;Q++)f(Y.location+Q,et.meshPerAttribute);O.isInstancedMesh!==!0&&R._maxInstanceCount===void 0&&(R._maxInstanceCount=et.meshPerAttribute*et.count)}else for(let Q=0;Q<Y.locationSize;Q++)g(Y.location+Q);i.bindBuffer(i.ARRAY_BUFFER,ee);for(let Q=0;Q<Y.locationSize;Q++)L(Y.location+Q,Ct/Y.locationSize,Lt,it,Ct*Wt,Ct/Y.locationSize*Q*Wt,j)}}else if(K!==void 0){let it=K[st];if(it!==void 0)switch(it.length){case 2:i.vertexAttrib2fv(Y.location,it);break;case 3:i.vertexAttrib3fv(Y.location,it);break;case 4:i.vertexAttrib4fv(Y.location,it);break;default:i.vertexAttrib1fv(Y.location,it)}}}}T()}function b(){w();for(let O in n){let V=n[O];for(let H in V){let R=V[H];for(let W in R){let $=R[W];for(let K in $)h($[K].object),delete $[K];delete R[W]}}delete n[O]}}function E(O){if(n[O.id]===void 0)return;let V=n[O.id];for(let H in V){let R=V[H];for(let W in R){let $=R[W];for(let K in $)h($[K].object),delete $[K];delete R[W]}}delete n[O.id]}function A(O){for(let V in n){let H=n[V];for(let R in H){let W=H[R];if(W[O.id]===void 0)continue;let $=W[O.id];for(let K in $)h($[K].object),delete $[K];delete W[O.id]}}}function x(O){for(let V in n){let H=n[V],R=O.isInstancedMesh===!0?O.id:0,W=H[R];if(W!==void 0){for(let $ in W){let K=W[$];for(let st in K)h(K[st].object),delete K[st];delete W[$]}delete H[R],Object.keys(H).length===0&&delete n[V]}}}function w(){D(),a=!0,r!==s&&(r=s,l(r.object))}function D(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:w,resetDefaultState:D,dispose:b,releaseStatesOfGeometry:E,releaseStatesOfObject:x,releaseStatesOfProgram:A,initAttributes:v,enableAttribute:g,disableUnusedAttributes:T}}function Yp(i,t,e){let n;function s(c){n=c}function r(c,l){i.drawArrays(n,c,l),e.update(l,n,1)}function a(c,l,h){h!==0&&(i.drawArraysInstanced(n,c,l,h),e.update(l,n,h))}function o(c,l,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let u=0;for(let p=0;p<h;p++)u+=l[p];e.update(u,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function Zp(i,t,e,n){let s;function r(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){let A=t.get("EXT_texture_filter_anisotropic");s=i.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(A){return!(A!==tn&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(A){let x=A===hn&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(A!==Ge&&A!==cn&&!x&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE))}function c(A){if(A==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp",h=c(l);h!==l&&(It("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);let d=e.logarithmicDepthBuffer===!0,u=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&u===!1&&It("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let p=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_TEXTURE_SIZE),g=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),f=i.getParameter(i.MAX_VERTEX_ATTRIBS),T=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),L=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),b=i.getParameter(i.MAX_SAMPLES),E=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:p,maxVertexTextures:_,maxTextureSize:v,maxCubemapSize:g,maxAttributes:f,maxVertexUniforms:T,maxVaryings:L,maxFragmentUniforms:M,maxSamples:b,samples:E}}function Jp(i){let t=this,e=null,n=0,s=!1,r=!1,a=new Ze,o=new Ut,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let p=d.length!==0||u||n!==0||s;return s=u,n=d.length,p},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){e=h(d,u,0)},this.setState=function(d,u,p){let _=d.clippingPlanes,v=d.clipIntersection,g=d.clipShadows,f=i.get(d);if(!s||_===null||_.length===0||r&&!g)r?h(null):l();else{let T=r?0:n,L=T*4,M=f.clippingState||null;c.value=M,M=h(_,u,L,p);for(let b=0;b!==L;++b)M[b]=e[b];f.clippingState=M,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=T}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(d,u,p,_){let v=d!==null?d.length:0,g=null;if(v!==0){if(g=c.value,_!==!0||g===null){let f=p+v*4,T=u.matrixWorldInverse;o.getNormalMatrix(T),(g===null||g.length<f)&&(g=new Float32Array(f));for(let L=0,M=p;L!==v;++L,M+=4)a.copy(d[L]).applyMatrix4(T,o),a.normal.toArray(g,M),g[M+3]=a.constant}c.value=g,c.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,g}}var Zi=4,$p=6,Kp=20,jp=256,Ns=new Xn,oh=new Ft,dl=null,fl=0,pl=0,ml=!1,Qp=new U,ui=new U,Ga=class{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=.1,s=100,r={}){let{size:a=256,position:o=Qp}=r;dl=this._renderer.getRenderTarget(),fl=this._renderer.getActiveCubeFace(),pl=this._renderer.getActiveMipmapLevel(),ml=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);let c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,n,s,c,o),e>0&&this._blur(c,0,0,e),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=hh(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ch(),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(t){this._lodMax=Math.floor(Math.log2(t)),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 t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(dl,fl,pl),this._renderer.xr.enabled=ml,t.scissorTest=!1,Yi(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Jn||t.mapping===ci?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),dl=this._renderer.getRenderTarget(),fl=this._renderer.getActiveCubeFace(),pl=this._renderer.getActiveMipmapLevel(),ml=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Te,minFilter:Te,generateMipmaps:!1,type:hn,format:tn,colorSpace:ss,depthBuffer:!1},s=lh(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=lh(t,e,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=tm(r)),this._blurMaterial=nm(r,t,e),this._ggxMaterial=em(r,t,e)}return s}_compileMaterial(t){let e=new Ve(new ke,t);this._renderer.compile(e,Ns)}_sceneToCubeUV(t,e,n,s,r){let c=new Ie(90,1,e,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,u=d.autoClear,p=d.toneMapping;d.getClearColor(oh),d.toneMapping=on,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(s),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Ve(new zi,new ds({name:"PMREM.Background",side:Fe,depthWrite:!1,depthTest:!1})));let v=this._backgroundBox,g=v.material,f=!1,T=t.background;T?T.isColor&&(g.color.copy(T),t.background=null,f=!0):(g.color.copy(oh),f=!0);for(let L=0;L<6;L++){let M=L%3;M===0?(c.up.set(0,l[L],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[L],r.y,r.z)):M===1?(c.up.set(0,0,l[L]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[L],r.z)):(c.up.set(0,l[L],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[L]));let b=this._cubeSize;Yi(s,M*b,L>2?b:0,b,b),d.setRenderTarget(s),f&&d.render(v,c),d.render(t,c)}d.toneMapping=p,d.autoClear=u,t.background=T}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===Jn||t.mapping===ci;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=hh()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ch());let r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;let o=r.uniforms;o.envMap.value=t;let c=this._cubeSize;Yi(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,Ns)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(t,r-1,r);e.autoClear=n}_applyGGXFilter(t,e,n){let s=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;let c=a.uniforms,l=n/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),d=Math.sqrt(l*l-h*h),u=l*1.25,p=d*u,{_lodMax:_}=this,v=this._sizeLods[n],g=3*v*(n>_-Zi?n-_+Zi:0),f=4*(this._cubeSize-v);c.envMap.value=t.texture,c.roughness.value=p,c.mipInt.value=_-e,Yi(r,g,f,3*v,2*v),s.setRenderTarget(r),s.render(o,Ns),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=_-n,Yi(t,g,f,3*v,2*v),s.setRenderTarget(t),s.render(o,Ns)}_blur(t,e,n,s){let r=this._pingPongRenderTarget,a=Math.min(s,Math.PI)/Math.SQRT2;this._blurPass(t,r,e,n,a),this._blurPass(r,t,n,n,a)}_blurPass(t,e,n,s,r){let a=this._renderer,o=this._blurMaterial,c=this._lodMeshes[s];c.material=o;let l=o.uniforms;l.envMap.value=t.texture,l.sigma.value=r,l.mipInt.value=this._lodMax-n;let h=this._sizeLods[s],d=3*h*(s>this._lodMax-Zi?s-this._lodMax+Zi:0),u=4*(this._cubeSize-h);Yi(e,d,u,3*h,2*h),a.setRenderTarget(e),a.render(c,Ns)}};function tm(i){let t=[],e=[],n=i,s=i-Zi+1+$p;for(let r=0;r<s;r++){let a=Math.pow(2,n);t.push(a);let o=1/(a-2),c=-o,l=1+o,h=[c,c,l,c,l,l,c,c,l,l,c,l],d=6,u=6,p=3,_=new Float32Array(p*u*d),v=new Float32Array(p*u*d);for(let f=0;f<d;f++){let T=f%3*2/3-1,L=f>2?0:-1,M=[T,L,0,T+2/3,L,0,T+2/3,L+1,0,T,L,0,T+2/3,L+1,0,T,L+1,0];_.set(M,p*u*f);for(let b=0;b<u;b++){let E=h[b*2]*2-1,A=h[b*2+1]*2-1;f===0?ui.set(1,A,E):f===1?ui.set(-E,1,-A):f===2?ui.set(-E,A,1):f===3?ui.set(-1,A,-E):f===4?ui.set(-E,-1,A):ui.set(E,A,-1),ui.toArray(v,(f*u+b)*p)}}let g=new ke;g.setAttribute("position",new Oe(_,p)),g.setAttribute("outputDirection",new Oe(v,p)),e.push(new Ve(g,null)),n>Zi&&n--}return{lodMeshes:e,sizeLods:t}}function lh(i,t,e){let n=new ze(i,t,e);return n.texture.mapping=Ts,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Yi(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function em(i,t,e){return new $e({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:jp,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Xa(),fragmentShader:`
|
|
3823
|
+
}`,He={alphahash_fragment:Pd,alphahash_pars_fragment:Id,alphamap_fragment:Ld,alphamap_pars_fragment:Dd,alphatest_fragment:Nd,alphatest_pars_fragment:Ud,aomap_fragment:Fd,aomap_pars_fragment:Od,batching_pars_vertex:Bd,batching_vertex:zd,begin_vertex:kd,beginnormal_vertex:Vd,bsdfs:Gd,iridescence_fragment:Hd,bumpmap_pars_fragment:Wd,clipping_planes_fragment:Xd,clipping_planes_pars_fragment:qd,clipping_planes_pars_vertex:Yd,clipping_planes_vertex:Zd,color_fragment:$d,color_pars_fragment:Jd,color_pars_vertex:Kd,color_vertex:jd,common:Qd,defaultnormal_vertex:ef,displacementmap_pars_vertex:tf,displacementmap_vertex:nf,emissivemap_fragment:sf,emissivemap_pars_fragment:rf,colorspace_fragment:af,colorspace_pars_fragment:of,envmap_fragment:lf,envmap_common_pars_fragment:cf,envmap_pars_fragment:hf,envmap_pars_vertex:uf,envmap_physical_pars_fragment:bf,envmap_vertex:df,fog_vertex:ff,fog_pars_vertex:pf,fog_fragment:mf,fog_pars_fragment:gf,gradientmap_pars_fragment:_f,lightmap_pars_fragment:xf,lights_lambert_fragment:yf,lights_lambert_pars_fragment:vf,lights_pars_begin:Mf,lights_toon_fragment:Sf,lights_toon_pars_fragment:wf,lights_phong_fragment:Ef,lights_phong_pars_fragment:Tf,lights_physical_fragment:Af,lights_physical_pars_fragment:Rf,lights_fragment_begin:Cf,lights_fragment_maps:Pf,lights_fragment_end:If,lightprobes_pars_fragment:Lf,logdepthbuf_fragment:Df,logdepthbuf_pars_fragment:Nf,logdepthbuf_pars_vertex:Uf,logdepthbuf_vertex:Ff,map_fragment:Of,map_pars_fragment:Bf,map_particle_fragment:zf,map_particle_pars_fragment:kf,metalnessmap_fragment:Vf,metalnessmap_pars_fragment:Gf,morphinstance_vertex:Hf,morphcolor_vertex:Wf,morphnormal_vertex:Xf,morphtarget_pars_vertex:qf,morphtarget_vertex:Yf,normal_fragment_begin:Zf,normal_fragment_maps:$f,normal_pars_fragment:Jf,normal_pars_vertex:Kf,normal_vertex:jf,normalmap_pars_fragment:Qf,clearcoat_normal_fragment_begin:ep,clearcoat_normal_fragment_maps:tp,clearcoat_pars_fragment:np,iridescence_pars_fragment:ip,opaque_fragment:sp,packing:rp,premultiplied_alpha_fragment:ap,project_vertex:op,dithering_fragment:lp,dithering_pars_fragment:cp,roughnessmap_fragment:hp,roughnessmap_pars_fragment:up,shadowmap_pars_fragment:dp,shadowmap_pars_vertex:fp,shadowmap_vertex:pp,shadowmask_pars_fragment:mp,skinbase_vertex:gp,skinning_pars_vertex:_p,skinning_vertex:xp,skinnormal_vertex:yp,specularmap_fragment:vp,specularmap_pars_fragment:Mp,tonemapping_fragment:bp,tonemapping_pars_fragment:Sp,transmission_fragment:wp,transmission_pars_fragment:Ep,uv_pars_fragment:Tp,uv_pars_vertex:Ap,uv_vertex:Rp,worldpos_vertex:Cp,background_vert:Pp,background_frag:Ip,backgroundCube_vert:Lp,backgroundCube_frag:Dp,cube_vert:Np,cube_frag:Up,depth_vert:Fp,depth_frag:Op,distance_vert:Bp,distance_frag:zp,equirect_vert:kp,equirect_frag:Vp,linedashed_vert:Gp,linedashed_frag:Hp,meshbasic_vert:Wp,meshbasic_frag:Xp,meshlambert_vert:qp,meshlambert_frag:Yp,meshmatcap_vert:Zp,meshmatcap_frag:$p,meshnormal_vert:Jp,meshnormal_frag:Kp,meshphong_vert:jp,meshphong_frag:Qp,meshphysical_vert:em,meshphysical_frag:tm,meshtoon_vert:nm,meshtoon_frag:im,points_vert:sm,points_frag:rm,shadow_vert:am,shadow_frag:om,sprite_vert:lm,sprite_frag:cm},me={common:{diffuse:{value:new ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Oe},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Oe}},envmap:{envMap:{value:null},envMapRotation:{value:new Oe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Oe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Oe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Oe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Oe},normalScale:{value:new Fe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Oe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Oe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Oe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Oe}},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:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{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},probesSH:{value:[]},probesMin:{value:[]},probesMax:{value:[]},probesResolution:{value:[]}},points:{diffuse:{value:new ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0},uvTransform:{value:new Oe}},sprite:{diffuse:{value:new ze(16777215)},opacity:{value:1},center:{value:new Fe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Oe},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0}}},En={basic:{uniforms:Ut([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.fog]),vertexShader:He.meshbasic_vert,fragmentShader:He.meshbasic_frag},lambert:{uniforms:Ut([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new ze(0)},envMapIntensity:{value:1}}]),vertexShader:He.meshlambert_vert,fragmentShader:He.meshlambert_frag},phong:{uniforms:Ut([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new ze(0)},specular:{value:new ze(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:He.meshphong_vert,fragmentShader:He.meshphong_frag},standard:{uniforms:Ut([me.common,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.roughnessmap,me.metalnessmap,me.fog,me.lights,{emissive:{value:new ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:He.meshphysical_vert,fragmentShader:He.meshphysical_frag},toon:{uniforms:Ut([me.common,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.gradientmap,me.fog,me.lights,{emissive:{value:new ze(0)}}]),vertexShader:He.meshtoon_vert,fragmentShader:He.meshtoon_frag},matcap:{uniforms:Ut([me.common,me.bumpmap,me.normalmap,me.displacementmap,me.fog,{matcap:{value:null}}]),vertexShader:He.meshmatcap_vert,fragmentShader:He.meshmatcap_frag},points:{uniforms:Ut([me.points,me.fog]),vertexShader:He.points_vert,fragmentShader:He.points_frag},dashed:{uniforms:Ut([me.common,me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:He.linedashed_vert,fragmentShader:He.linedashed_frag},depth:{uniforms:Ut([me.common,me.displacementmap]),vertexShader:He.depth_vert,fragmentShader:He.depth_frag},normal:{uniforms:Ut([me.common,me.bumpmap,me.normalmap,me.displacementmap,{opacity:{value:1}}]),vertexShader:He.meshnormal_vert,fragmentShader:He.meshnormal_frag},sprite:{uniforms:Ut([me.sprite,me.fog]),vertexShader:He.sprite_vert,fragmentShader:He.sprite_frag},background:{uniforms:{uvTransform:{value:new Oe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:He.background_vert,fragmentShader:He.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Oe}},vertexShader:He.backgroundCube_vert,fragmentShader:He.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:He.cube_vert,fragmentShader:He.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:He.equirect_vert,fragmentShader:He.equirect_frag},distance:{uniforms:Ut([me.common,me.displacementmap,{referencePosition:{value:new B},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:He.distance_vert,fragmentShader:He.distance_frag},shadow:{uniforms:Ut([me.lights,me.fog,{color:{value:new ze(0)},opacity:{value:1}}]),vertexShader:He.shadow_vert,fragmentShader:He.shadow_frag}};En.physical={uniforms:Ut([En.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Oe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Oe},clearcoatNormalScale:{value:new Fe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Oe},diffuseRoughness:{value:0},diffuseRoughnessMap:{value:null},diffuseRoughnessMapTransform:{value:new Oe},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Oe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Oe},sheen:{value:0},sheenColor:{value:new ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Oe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Oe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Oe},transmissionSamplerSize:{value:new Fe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Oe},attenuationDistance:{value:0},attenuationColor:{value:new ze(0)},specularColor:{value:new ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Oe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Oe},anisotropyVector:{value:new Fe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Oe}}]),vertexShader:He.meshphysical_vert,fragmentShader:He.meshphysical_frag};var ja={r:0,b:0,g:0},hm=new ht,Vh=new Oe;Vh.set(-1,0,0,0,1,0,0,0,1);function um(i,e,t,n,s,r){let a=new ze(0),o=s===!0?0:1,c,l,h=null,d=0,u=null;function m(S){let A=S.isScene===!0?S.background:null;if(A&&A.isTexture){let b=S.backgroundBlurriness>0;A=e.get(A,b)}return A}function _(S){let A=!1,b=m(S);b===null?p(a,o):b&&b.isColor&&(p(b,1),A=!0);let T=i.xr.getEnvironmentBlendMode();T==="additive"?t.buffers.color.setClear(0,0,0,1,r):T==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||A)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function y(S,A){let b=m(A);b&&b.isCubeTexture?(l===void 0&&(l=new en(new $i(1,1,1),new Mn({name:"BackgroundCubeMaterial",uniforms:wi(En.backgroundCube.uniforms),vertexShader:En.backgroundCube.vertexShader,fragmentShader:En.backgroundCube.fragmentShader,side:Vt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(T,w,g){this.matrixWorld.copyPosition(g.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=b,l.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(hm.makeRotationFromEuler(A.backgroundRotation)).transpose(),b.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Vh),l.material.toneMapped=Ze.getTransfer(b.colorSpace)!==nt,(h!==b||d!==b.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=b,d=b.version,u=i.toneMapping),l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null)):b&&b.isTexture&&(c===void 0&&(c=new en(new Ps(2,2),new Mn({name:"BackgroundMaterial",uniforms:wi(En.background.uniforms),vertexShader:En.background.vertexShader,fragmentShader:En.background.fragmentShader,side:ri,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=b,c.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,c.material.toneMapped=Ze.getTransfer(b.colorSpace)!==nt,b.matrixAutoUpdate===!0&&b.updateMatrix(),c.material.uniforms.uvTransform.value.copy(b.matrix),(h!==b||d!==b.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=b,d=b.version,u=i.toneMapping),c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null))}function p(S,A){S.getRGB(ja,_l(i)),t.buffers.color.setClear(ja.r,ja.g,ja.b,A,r)}function f(){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 a},setClearColor:function(S,A=1){a.set(S),o=A,p(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(S){o=S,p(a,o)},render:_,addToRenderList:y,dispose:f}}function dm(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,a=!1;function o(D,F,H,C,Y){let J=!1,z=d(D,C,H,F);r!==z&&(r=z,l(r.object)),J=m(D,C,H,Y),J&&_(D,C,H,Y),Y!==null&&e.update(Y,i.ELEMENT_ARRAY_BUFFER),(J||a)&&(a=!1,b(D,F,H,C),Y!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(Y).buffer))}function c(){return i.createVertexArray()}function l(D){return i.bindVertexArray(D)}function h(D){return i.deleteVertexArray(D)}function d(D,F,H,C){let Y=C.wireframe===!0,J=n[F.id];J===void 0&&(J={},n[F.id]=J);let z=D.isInstancedMesh===!0?D.id:0,te=J[z];te===void 0&&(te={},J[z]=te);let W=te[H.id];W===void 0&&(W={},te[H.id]=W);let $=W[Y];return $===void 0&&($=u(c()),W[Y]=$),$}function u(D){let F=[],H=[],C=[];for(let Y=0;Y<t;Y++)F[Y]=0,H[Y]=0,C[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:H,attributeDivisors:C,object:D,attributes:{},index:null}}function m(D,F,H,C){let Y=r.attributes,J=F.attributes,z=0,te=H.getAttributes();for(let W in te)if(te[W].location>=0){let ae=Y[W],_e=J[W];if(_e===void 0&&(W==="instanceMatrix"&&D.instanceMatrix&&(_e=D.instanceMatrix),W==="instanceColor"&&D.instanceColor&&(_e=D.instanceColor)),ae===void 0||ae.attribute!==_e||_e&&ae.data!==_e.data)return!0;z++}return r.attributesNum!==z||r.index!==C}function _(D,F,H,C){let Y={},J=F.attributes,z=0,te=H.getAttributes();for(let W in te)if(te[W].location>=0){let ae=J[W];ae===void 0&&(W==="instanceMatrix"&&D.instanceMatrix&&(ae=D.instanceMatrix),W==="instanceColor"&&D.instanceColor&&(ae=D.instanceColor));let _e={};_e.attribute=ae,ae&&ae.data&&(_e.data=ae.data),Y[W]=_e,z++}r.attributes=Y,r.attributesNum=z,r.index=C}function y(){let D=r.newAttributes;for(let F=0,H=D.length;F<H;F++)D[F]=0}function p(D){f(D,0)}function f(D,F){let H=r.newAttributes,C=r.enabledAttributes,Y=r.attributeDivisors;H[D]=1,C[D]===0&&(i.enableVertexAttribArray(D),C[D]=1),Y[D]!==F&&(i.vertexAttribDivisor(D,F),Y[D]=F)}function S(){let D=r.newAttributes,F=r.enabledAttributes;for(let H=0,C=F.length;H<C;H++)F[H]!==D[H]&&(i.disableVertexAttribArray(H),F[H]=0)}function A(D,F,H,C,Y,J,z){z===!0?i.vertexAttribIPointer(D,F,H,Y,J):i.vertexAttribPointer(D,F,H,C,Y,J)}function b(D,F,H,C){y();let Y=C.attributes,J=H.getAttributes(),z=F.defaultAttributeValues;for(let te in J){let W=J[te];if(W.location>=0){let $=Y[te];if($===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&($=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&($=D.instanceColor)),$!==void 0){let ae=$.normalized,_e=$.itemSize,De=e.get($);if(De===void 0)continue;let j=De.buffer,pe=De.type,ye=De.bytesPerElement,Re=pe===i.INT||pe===i.UNSIGNED_INT||$.gpuType===ma;if($.isInterleavedBufferAttribute){let fe=$.data,Le=fe.isInterleavedBuffer===!0?fe.stride:fe.itemSize,pt=$.offset;if(fe.isInstancedInterleavedBuffer||fe.isInstancedBufferAttribute){for(let be=0;be<W.locationSize;be++)f(W.location+be,fe.meshPerAttribute);D.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=fe.meshPerAttribute*fe.count)}else for(let be=0;be<W.locationSize;be++)p(W.location+be);i.bindBuffer(i.ARRAY_BUFFER,j);for(let be=0;be<W.locationSize;be++)A(W.location+be,_e/W.locationSize,pe,ae,Le*ye,(pt+_e/W.locationSize*be)*ye,Re)}else{if($.isInstancedBufferAttribute){for(let fe=0;fe<W.locationSize;fe++)f(W.location+fe,$.meshPerAttribute);D.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=$.meshPerAttribute*$.count)}else for(let fe=0;fe<W.locationSize;fe++)p(W.location+fe);i.bindBuffer(i.ARRAY_BUFFER,j);for(let fe=0;fe<W.locationSize;fe++)A(W.location+fe,_e/W.locationSize,pe,ae,_e*ye,_e/W.locationSize*fe*ye,Re)}}else if(z!==void 0){let ae=z[te];if(ae!==void 0)switch(ae.length){case 2:i.vertexAttrib2fv(W.location,ae);break;case 3:i.vertexAttrib3fv(W.location,ae);break;case 4:i.vertexAttrib4fv(W.location,ae);break;default:i.vertexAttrib1fv(W.location,ae)}}}}S()}function T(){U();for(let D in n){let F=n[D];for(let H in F){let C=F[H];for(let Y in C){let J=C[Y];for(let z in J)h(J[z].object),delete J[z];delete C[Y]}}delete n[D]}}function w(D){if(n[D.id]===void 0)return;let F=n[D.id];for(let H in F){let C=F[H];for(let Y in C){let J=C[Y];for(let z in J)h(J[z].object),delete J[z];delete C[Y]}}delete n[D.id]}function g(D){for(let F in n){let H=n[F];for(let C in H){let Y=H[C];if(Y[D.id]===void 0)continue;let J=Y[D.id];for(let z in J)h(J[z].object),delete J[z];delete Y[D.id]}}}function M(D){for(let F in n){let H=n[F],C=D.isInstancedMesh===!0?D.id:0,Y=H[C];if(Y!==void 0){for(let J in Y){let z=Y[J];for(let te in z)h(z[te].object),delete z[te];delete Y[J]}delete H[C],Object.keys(H).length===0&&delete n[F]}}}function U(){I(),a=!0,r!==s&&(r=s,l(r.object))}function I(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:U,resetDefaultState:I,dispose:T,releaseStatesOfGeometry:w,releaseStatesOfObject:M,releaseStatesOfProgram:g,initAttributes:y,enableAttribute:p,disableUnusedAttributes:S}}function fm(i,e,t){let n;function s(c){n=c}function r(c,l){i.drawArrays(n,c,l),t.update(l,n,1)}function a(c,l,h){h!==0&&(i.drawArraysInstanced(n,c,l,h),t.update(l,n,h))}function o(c,l,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let u=0;for(let m=0;m<h;m++)u+=l[m];t.update(u,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function pm(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){let g=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(g.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(g){return!(g!==gn&&n.convert(g)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(g){let M=g===mn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(g!==Xt&&g!==pn&&!M&&n.convert(g)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE))}function c(g){if(g==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";g="mediump"}return g==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",h=c(l);h!==l&&(Ie("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);let d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),u=t.logarithmicDepthBuffer===!0&&d===!1;t.reversedDepthBuffer===!0&&d===!1&&Ie("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),t.logarithmicDepthBuffer===!0&&d===!0&&Ie("WebGLRenderer: Logarithmic depth buffer is ignored when reversed depth buffer is enabled.");let m=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=i.getParameter(i.MAX_TEXTURE_SIZE),p=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),f=i.getParameter(i.MAX_VERTEX_ATTRIBS),S=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),A=i.getParameter(i.MAX_VARYING_VECTORS),b=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),T=i.getParameter(i.MAX_SAMPLES),w=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:m,maxVertexTextures:_,maxTextureSize:y,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:S,maxVaryings:A,maxFragmentUniforms:b,maxSamples:T,samples:w}}function mm(i){let e=this,t=null,n=0,s=!1,r=!1,a=new Kt,o=new Oe,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let m=d.length!==0||u||n!==0||s;return s=u,n=d.length,m},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,m){let _=d.clippingPlanes,y=d.clipIntersection,p=d.clipShadows,f=i.get(d);if(!s||_===null||_.length===0||r&&!p)r?h(null):l();else{let S=r?0:n,A=S*4,b=f.clippingState||null;c.value=b,b=h(_,u,A,m);for(let T=0;T!==A;++T)b[T]=t[T];f.clippingState=b,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=S}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,u,m,_){let y=d!==null?d.length:0,p=null;if(y!==0){if(p=c.value,_!==!0||p===null){let f=m+y*4,S=u.matrixWorldInverse;o.getNormalMatrix(S),(p===null||p.length<f)&&(p=new Float32Array(f));for(let A=0,b=m;A!==y;++A,b+=4)a.copy(d[A]).applyMatrix4(S,o),a.normal.toArray(p,b),p[b+3]=a.constant}c.value=p,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,p}}var Ys=class extends Qt{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new Ts(s),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;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
3824
3824
|
|
|
3825
|
-
|
|
3826
|
-
precision highp int;
|
|
3825
|
+
varying vec3 vWorldDirection;
|
|
3827
3826
|
|
|
3828
|
-
|
|
3827
|
+
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
3829
3828
|
|
|
3830
|
-
|
|
3831
|
-
uniform float roughness;
|
|
3832
|
-
uniform float mipInt;
|
|
3829
|
+
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
3833
3830
|
|
|
3834
|
-
|
|
3835
|
-
#include <cube_uv_reflection_fragment>
|
|
3831
|
+
}
|
|
3836
3832
|
|
|
3837
|
-
|
|
3833
|
+
void main() {
|
|
3838
3834
|
|
|
3839
|
-
|
|
3840
|
-
float radicalInverse_VdC(uint bits) {
|
|
3841
|
-
bits = (bits << 16u) | (bits >> 16u);
|
|
3842
|
-
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
|
|
3843
|
-
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
|
|
3844
|
-
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
|
|
3845
|
-
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
|
|
3846
|
-
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
|
|
3847
|
-
}
|
|
3835
|
+
vWorldDirection = transformDirection( position, modelMatrix );
|
|
3848
3836
|
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
return vec2(float(i) / float(N), radicalInverse_VdC(i));
|
|
3852
|
-
}
|
|
3837
|
+
#include <begin_vertex>
|
|
3838
|
+
#include <project_vertex>
|
|
3853
3839
|
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
// https://jcgt.org/published/0007/04/01/
|
|
3857
|
-
vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
|
|
3858
|
-
float alpha = roughness * roughness;
|
|
3840
|
+
}
|
|
3841
|
+
`,fragmentShader:`
|
|
3859
3842
|
|
|
3860
|
-
|
|
3861
|
-
vec3 T1 = vec3(1.0, 0.0, 0.0);
|
|
3862
|
-
vec3 T2 = cross(V, T1);
|
|
3843
|
+
uniform sampler2D tEquirect;
|
|
3863
3844
|
|
|
3864
|
-
|
|
3865
|
-
float r = sqrt(Xi.x);
|
|
3866
|
-
float phi = 2.0 * PI * Xi.y;
|
|
3867
|
-
float t1 = r * cos(phi);
|
|
3868
|
-
float t2 = r * sin(phi);
|
|
3869
|
-
float s = 0.5 * (1.0 + V.z);
|
|
3870
|
-
t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
|
|
3845
|
+
varying vec3 vWorldDirection;
|
|
3871
3846
|
|
|
3872
|
-
|
|
3873
|
-
vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;
|
|
3847
|
+
#include <common>
|
|
3874
3848
|
|
|
3875
|
-
|
|
3876
|
-
return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
|
|
3877
|
-
}
|
|
3849
|
+
void main() {
|
|
3878
3850
|
|
|
3879
|
-
|
|
3880
|
-
vec3 N = normalize(vOutputDirection);
|
|
3881
|
-
vec3 V = N; // Assume view direction equals normal for pre-filtering
|
|
3851
|
+
vec3 direction = normalize( vWorldDirection );
|
|
3882
3852
|
|
|
3883
|
-
|
|
3884
|
-
|
|
3853
|
+
vec2 sampleUV = equirectUv( direction );
|
|
3854
|
+
|
|
3855
|
+
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
3885
3856
|
|
|
3886
|
-
// For very low roughness, just sample the environment directly
|
|
3887
|
-
if (roughness < 0.001) {
|
|
3888
|
-
gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
|
|
3889
|
-
return;
|
|
3890
3857
|
}
|
|
3858
|
+
`},s=new $i(5,5,5),r=new Mn({name:"CubemapFromEquirect",uniforms:wi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Vt,blending:vi});r.uniforms.tEquirect.value=t;let a=new en(s,r),o=t.minFilter;return t.minFilter===Gn&&(t.minFilter=kt),new ji(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){let r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,s);e.setRenderTarget(r)}},yh=256,gm=3,_m=20,Gh=256,Hh=16,xm=3,ym=new B,vm=new ze,eo=class i{constructor(e){this._renderer=e,this._cubeSize=0,this._sourceTarget=null,this._cubeCamera=new ji(1,10,null),this._boxMesh=new en(new $i(5,5,5),null),this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null,this._integrationMaterial=null}fromScene(e,t=0,n=.1,s=100,r={}){let{size:a=256,position:o=ym}=r,c=this._renderer;this._setSize(a);let l=this._allocateTarget(),h=this._getSourceTarget(!0);t>0&&(h.texture.mipmapsAutoUpdate=!1);let d=c.autoClear,u=c.autoClearColor,m=c.autoClearDepth,_=c.autoClearStencil,y=e.background;c.autoClear=!0,c.autoClearColor=!0,c.autoClearDepth=!0,c.autoClearStencil=!0,y===null&&(e.background=c.getClearColor(vm));let p=new ji(n,s,h);return p.position.copy(o),p.update(c,e),c.autoClear=d,c.autoClearColor=u,c.autoClearDepth=m,c.autoClearStencil=_,e.background=y,t>0&&(h.texture.mipmapsAutoUpdate=!0,this._blur(l,t)),this._applyPMREM(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=bh(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Mh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._sourceTarget!==null&&this._sourceTarget.dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._integrationMaterial!==null&&this._integrationMaterial.dispose(),this._boxMesh.geometry.dispose()}static lodToRoughness(e,t){return t>0?1-Math.sqrt(1-e/t):0}_setSize(e){this._cubeSize=Math.max(yh,pl(e))}_fromTexture(e,t){e.mapping===bi||e.mapping===ns?this._setSize(e.image.length===0?yh:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4);let n=t||this._allocateTarget();return this._textureToCubemap(e),this._applyPMREM(n),n}_allocateTarget(){let e=this._cubeSize,t=vh(e,!1,!1),n=Math.log2(e)-gm;for(let s=0;s<=n;s++)t.texture.mipmaps.push({width:e>>s,height:e>>s});return t.texture.name="PMREM",t.texture.isPMREMTexture=!0,t}_getSourceTarget(e=!1){let t=this._cubeSize,n=this._sourceTarget;return(n===null||n.width!==t||e&&n.depthBuffer===!1)&&(n!==null&&n.dispose(),this._sourceTarget=vh(t,!0,e)),this._sourceTarget}_compileMaterial(e){this._boxMesh.material=e,this._renderer.compile(this._boxMesh,this._cubeCamera.children[0])}_renderCube(e,t,n){let s=this._boxMesh,r=this._cubeCamera;s.material=n,r.renderTarget=e,r.activeMipmapLevel=t;let a=e.width>>t;e.viewport.set(0,0,a,a),r.update(this._renderer,s),e.viewport.set(0,0,e.width,e.height)}_textureToCubemap(e){let t;e.mapping===bi||e.mapping===ns?(this._cubemapMaterial===null&&(this._cubemapMaterial=bh()),t=this._cubemapMaterial,t.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):(this._equirectMaterial===null&&(this._equirectMaterial=Mh()),t=this._equirectMaterial),t.uniforms.envMap.value=e,this._renderCube(this._getSourceTarget(),0,t)}_applyPMREM(e){this._ggxMaterial===null&&(this._ggxMaterial=Mm(),this._integrationMaterial=bm());let t=this._cubeSize,n=e.texture.mipmaps.length-1,s=this._ggxMaterial.uniforms;s.envMap.value=this._sourceTarget.texture;let r=this._integrationMaterial.uniforms;r.envMap.value=this._sourceTarget.texture,r.sourceLod.value=Math.log2(t/Hh);for(let a=0;a<=n;a++){let o=i.lodToRoughness(a,n);if(a>n-xm)r.roughness.value=o,this._renderCube(e,a,this._integrationMaterial);else{let c=o>0?Math.log2(t)+.5*Math.log2(6/(Gh*Math.pow(o,4)))+.5:0;s.roughness.value=o,s.lodBias.value=c,this._renderCube(e,a,this._ggxMaterial)}}}_blur(e,t){this._blurMaterial===null&&(this._blurMaterial=Sm());let n=this._blurMaterial,s=n.uniforms,r=this._sourceTarget;s.sigma.value=Math.min(t,Math.PI)/Math.SQRT2,s.envMap.value=r.texture,this._renderCube(e,0,n),s.envMap.value=e.texture,this._renderCube(r,0,n)}};function vh(i,e,t){return new Ys(i,{minFilter:Gn,generateMipmaps:e,type:mn,colorSpace:xs,depthBuffer:t})}function Zs(i,e,t){return new Mn({name:i,uniforms:e,vertexShader:He.cube_vert,fragmentShader:t,side:Vt,blending:vi,depthTest:!1,depthWrite:!1})}function Mm(){return Zs("PMREMGGXConvolution",{envMap:{value:null},roughness:{value:0},lodBias:{value:0}},`
|
|
3891
3859
|
|
|
3892
|
-
|
|
3893
|
-
vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
|
|
3894
|
-
vec3 tangent = normalize(cross(up, N));
|
|
3895
|
-
vec3 bitangent = cross(N, tangent);
|
|
3860
|
+
#define GGX_SAMPLES ${Gh}u
|
|
3896
3861
|
|
|
3897
|
-
|
|
3898
|
-
vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
|
|
3862
|
+
varying vec3 vWorldDirection;
|
|
3899
3863
|
|
|
3900
|
-
|
|
3901
|
-
|
|
3864
|
+
uniform samplerCube envMap;
|
|
3865
|
+
uniform float roughness;
|
|
3866
|
+
uniform float lodBias;
|
|
3902
3867
|
|
|
3903
|
-
|
|
3904
|
-
vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
|
|
3905
|
-
vec3 L = normalize(2.0 * dot(V, H) * H - V);
|
|
3868
|
+
#include <common>
|
|
3906
3869
|
|
|
3907
|
-
|
|
3870
|
+
// Van der Corput radical inverse
|
|
3871
|
+
float radicalInverse_VdC( uint bits ) {
|
|
3908
3872
|
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3873
|
+
bits = ( bits << 16u ) | ( bits >> 16u );
|
|
3874
|
+
bits = ( ( bits & 0x55555555u ) << 1u ) | ( ( bits & 0xAAAAAAAAu ) >> 1u );
|
|
3875
|
+
bits = ( ( bits & 0x33333333u ) << 2u ) | ( ( bits & 0xCCCCCCCCu ) >> 2u );
|
|
3876
|
+
bits = ( ( bits & 0x0F0F0F0Fu ) << 4u ) | ( ( bits & 0xF0F0F0F0u ) >> 4u );
|
|
3877
|
+
bits = ( ( bits & 0x00FF00FFu ) << 8u ) | ( ( bits & 0xFF00FF00u ) >> 8u );
|
|
3878
|
+
return float( bits ) * 2.3283064365386963e-10; // / 0x100000000
|
|
3913
3879
|
|
|
3914
|
-
|
|
3915
|
-
// VNDF PDF naturally accounts for the visible microfacet distribution
|
|
3916
|
-
prefilteredColor += sampleColor * NdotL;
|
|
3917
|
-
totalWeight += NdotL;
|
|
3918
|
-
}
|
|
3919
|
-
}
|
|
3880
|
+
}
|
|
3920
3881
|
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3882
|
+
// Hammersley sequence
|
|
3883
|
+
vec2 hammersley( uint i, uint N ) {
|
|
3884
|
+
|
|
3885
|
+
return vec2( float( i ) / float( N ), radicalInverse_VdC( i ) );
|
|
3886
|
+
|
|
3887
|
+
}
|
|
3888
|
+
|
|
3889
|
+
void main() {
|
|
3890
|
+
|
|
3891
|
+
vec3 N = normalize( vWorldDirection );
|
|
3892
|
+
|
|
3893
|
+
// For very low roughness, just sample the environment directly
|
|
3894
|
+
if ( roughness < 0.001 ) {
|
|
3895
|
+
|
|
3896
|
+
gl_FragColor = vec4( textureLod( envMap, N, 0.0 ).rgb, 1.0 );
|
|
3897
|
+
return;
|
|
3924
3898
|
|
|
3925
|
-
gl_FragColor = vec4(prefilteredColor, 1.0);
|
|
3926
3899
|
}
|
|
3927
|
-
`,blending:gn,depthTest:!1,depthWrite:!1})}function nm(i,t,e){return new $e({name:"SphericalGaussianBlur",defines:{SAMPLES:Kp,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:Xa(),fragmentShader:`
|
|
3928
3900
|
|
|
3929
|
-
|
|
3930
|
-
|
|
3901
|
+
float alpha = roughness * roughness;
|
|
3902
|
+
float alpha2 = alpha * alpha;
|
|
3931
3903
|
|
|
3932
|
-
|
|
3904
|
+
// Tangent space basis for VNDF sampling
|
|
3905
|
+
vec3 up = abs( N.z ) < 0.999 ? vec3( 0.0, 0.0, 1.0 ) : vec3( 1.0, 0.0, 0.0 );
|
|
3906
|
+
vec3 tangent = normalize( cross( up, N ) );
|
|
3907
|
+
vec3 bitangent = cross( N, tangent );
|
|
3933
3908
|
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
uniform float mipInt;
|
|
3909
|
+
vec3 prefilteredColor = vec3( 0.0 );
|
|
3910
|
+
float totalWeight = 0.0;
|
|
3937
3911
|
|
|
3938
|
-
|
|
3939
|
-
#include <cube_uv_reflection_fragment>
|
|
3912
|
+
for ( uint i = 0u; i < GGX_SAMPLES; i ++ ) {
|
|
3940
3913
|
|
|
3941
|
-
|
|
3942
|
-
#define GOLDEN_ANGLE 2.39996322973
|
|
3914
|
+
vec2 Xi = hammersley( i, GGX_SAMPLES );
|
|
3943
3915
|
|
|
3944
|
-
|
|
3916
|
+
// With V = N, sample the reflected direction directly.
|
|
3917
|
+
float invQ = 1.0 / ( 1.0 - Xi.x + alpha2 * Xi.x );
|
|
3918
|
+
float NdotL = ( 1.0 - Xi.x - alpha2 * Xi.x ) * invQ;
|
|
3945
3919
|
|
|
3946
|
-
if (
|
|
3920
|
+
if ( NdotL > 0.0 ) {
|
|
3947
3921
|
|
|
3948
|
-
|
|
3949
|
-
|
|
3922
|
+
float phi = 2.0 * PI * Xi.y;
|
|
3923
|
+
float sinTheta = 2.0 * alpha * sqrt( Xi.x * ( 1.0 - Xi.x ) ) * invQ;
|
|
3924
|
+
vec3 L = N * NdotL + ( tangent * cos( phi ) + bitangent * sin( phi ) ) * sinTheta;
|
|
3925
|
+
|
|
3926
|
+
// Match the source mip to the sample's solid angle. The terms
|
|
3927
|
+
// independent of the sample are precomputed in lodBias.
|
|
3928
|
+
float d = alpha2 * invQ;
|
|
3929
|
+
float lod = max( log2( d ) + lodBias, 0.0 );
|
|
3930
|
+
|
|
3931
|
+
// Weight by NdotL for the split-sum approximation
|
|
3932
|
+
prefilteredColor += textureLod( envMap, L, lod ).rgb * NdotL;
|
|
3933
|
+
totalWeight += NdotL;
|
|
3950
3934
|
|
|
3951
3935
|
}
|
|
3952
3936
|
|
|
3953
|
-
|
|
3937
|
+
}
|
|
3954
3938
|
|
|
3955
|
-
|
|
3956
|
-
vec3 tangent = normalize( cross( up, outputDirection ) );
|
|
3957
|
-
vec3 bitangent = cross( outputDirection, tangent );
|
|
3939
|
+
gl_FragColor = vec4( prefilteredColor / totalWeight, 1.0 );
|
|
3958
3940
|
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
float truncation = 1.0 - exp( - 0.5 * thetaMax * thetaMax / ( sigma * sigma ) );
|
|
3941
|
+
}
|
|
3942
|
+
`)}function bm(){return Zs("PMREMGGXIntegration",{envMap:{value:null},roughness:{value:0},sourceLod:{value:0},sourceSize:{value:Hh}},`
|
|
3962
3943
|
|
|
3963
|
-
|
|
3964
|
-
float accumWeight = 0.0;
|
|
3944
|
+
varying vec3 vWorldDirection;
|
|
3965
3945
|
|
|
3966
|
-
|
|
3946
|
+
uniform samplerCube envMap;
|
|
3947
|
+
uniform float roughness;
|
|
3948
|
+
uniform float sourceLod;
|
|
3949
|
+
uniform int sourceSize;
|
|
3967
3950
|
|
|
3968
|
-
|
|
3969
|
-
float stratum = ( float( i ) + 0.5 ) / float( SAMPLES );
|
|
3970
|
-
float theta = sigma * sqrt( - 2.0 * log( 1.0 - stratum * truncation ) );
|
|
3971
|
-
float phi = float( i ) * GOLDEN_ANGLE;
|
|
3951
|
+
void main() {
|
|
3972
3952
|
|
|
3973
|
-
|
|
3974
|
-
vec3 sampleDirection = cos( theta ) * outputDirection + sin( theta ) * offset;
|
|
3953
|
+
vec3 N = normalize( vWorldDirection );
|
|
3975
3954
|
|
|
3976
|
-
|
|
3977
|
-
|
|
3955
|
+
float alpha = roughness * roughness;
|
|
3956
|
+
float alpha2 = alpha * alpha;
|
|
3978
3957
|
|
|
3979
|
-
|
|
3980
|
-
accumWeight += weight;
|
|
3958
|
+
float texelSize = 2.0 / float( sourceSize );
|
|
3981
3959
|
|
|
3982
|
-
|
|
3960
|
+
vec3 prefilteredColor = vec3( 0.0 );
|
|
3961
|
+
float totalWeight = 0.0;
|
|
3983
3962
|
|
|
3984
|
-
|
|
3963
|
+
// Pair opposite texels: only the one in N's hemisphere contributes.
|
|
3964
|
+
for ( int face = 0; face < 3; face ++ ) {
|
|
3985
3965
|
|
|
3986
|
-
|
|
3987
|
-
`,blending:gn,depthTest:!1,depthWrite:!1})}function ch(){return new $e({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Xa(),fragmentShader:`
|
|
3966
|
+
for ( int y = 0; y < sourceSize; y ++ ) {
|
|
3988
3967
|
|
|
3989
|
-
|
|
3990
|
-
precision mediump int;
|
|
3968
|
+
for ( int x = 0; x < sourceSize; x ++ ) {
|
|
3991
3969
|
|
|
3992
|
-
|
|
3970
|
+
vec2 uv = ( vec2( x, y ) + 0.5 ) * texelSize - 1.0;
|
|
3971
|
+
vec3 texelDirection = face == 0 ? vec3( 1.0, uv ) : ( face == 1 ? vec3( uv.x, 1.0, uv.y ) : vec3( uv, 1.0 ) );
|
|
3993
3972
|
|
|
3994
|
-
|
|
3973
|
+
float invDistance = inversesqrt( 1.0 + dot( uv, uv ) );
|
|
3974
|
+
float NdotL = dot( N, texelDirection );
|
|
3975
|
+
texelDirection *= NdotL < 0.0 ? - 1.0 : 1.0;
|
|
3976
|
+
NdotL = abs( NdotL ) * invDistance;
|
|
3995
3977
|
|
|
3996
|
-
|
|
3978
|
+
// With V = N, NdotH squared is ( 1 + NdotL ) / 2. Common factors
|
|
3979
|
+
// in the GGX distribution and texel solid angle cancel when normalized.
|
|
3980
|
+
float d = 1.0 + alpha2 + ( alpha2 - 1.0 ) * NdotL;
|
|
3981
|
+
float weight = NdotL * invDistance * invDistance * invDistance / ( d * d );
|
|
3997
3982
|
|
|
3998
|
-
|
|
3983
|
+
prefilteredColor += textureLod( envMap, texelDirection, sourceLod ).rgb * weight;
|
|
3984
|
+
totalWeight += weight;
|
|
3999
3985
|
|
|
4000
|
-
|
|
4001
|
-
vec2 uv = equirectUv( outputDirection );
|
|
3986
|
+
}
|
|
4002
3987
|
|
|
4003
|
-
|
|
3988
|
+
}
|
|
4004
3989
|
|
|
4005
3990
|
}
|
|
4006
|
-
`,blending:gn,depthTest:!1,depthWrite:!1})}function hh(){return new $e({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Xa(),fragmentShader:`
|
|
4007
3991
|
|
|
4008
|
-
|
|
4009
|
-
precision mediump int;
|
|
3992
|
+
gl_FragColor = vec4( prefilteredColor / totalWeight, 1.0 );
|
|
4010
3993
|
|
|
4011
|
-
|
|
3994
|
+
}
|
|
3995
|
+
`)}function Sm(){return Zs("PMREMSphericalGaussianBlur",{envMap:{value:null},sigma:{value:0}},`
|
|
4012
3996
|
|
|
4013
|
-
|
|
3997
|
+
#define SAMPLES ${_m}
|
|
3998
|
+
#define GOLDEN_ANGLE 2.39996322973
|
|
4014
3999
|
|
|
4015
|
-
|
|
4000
|
+
varying vec3 vWorldDirection;
|
|
4016
4001
|
|
|
4017
|
-
|
|
4002
|
+
uniform samplerCube envMap;
|
|
4003
|
+
uniform float sigma;
|
|
4018
4004
|
|
|
4019
|
-
|
|
4005
|
+
#include <common>
|
|
4020
4006
|
|
|
4021
|
-
|
|
4022
|
-
`,blending:gn,depthTest:!1,depthWrite:!1})}function Xa(){return`
|
|
4007
|
+
void main() {
|
|
4023
4008
|
|
|
4024
|
-
|
|
4025
|
-
precision mediump int;
|
|
4009
|
+
vec3 outputDirection = normalize( vWorldDirection );
|
|
4026
4010
|
|
|
4027
|
-
|
|
4011
|
+
vec3 up = abs( outputDirection.z ) < 0.999 ? vec3( 0.0, 0.0, 1.0 ) : vec3( 1.0, 0.0, 0.0 );
|
|
4012
|
+
vec3 tangent = normalize( cross( up, outputDirection ) );
|
|
4013
|
+
vec3 bitangent = cross( outputDirection, tangent );
|
|
4028
4014
|
|
|
4029
|
-
|
|
4015
|
+
// Truncate the kernel at three standard deviations or at the antipode.
|
|
4016
|
+
float thetaMax = min( 3.0 * sigma, PI );
|
|
4017
|
+
float truncation = 1.0 - exp( - 0.5 * thetaMax * thetaMax / ( sigma * sigma ) );
|
|
4030
4018
|
|
|
4031
|
-
|
|
4019
|
+
vec3 accumColor = vec3( 0.0 );
|
|
4020
|
+
float accumWeight = 0.0;
|
|
4032
4021
|
|
|
4033
|
-
|
|
4034
|
-
gl_Position = vec4( position, 1.0 );
|
|
4022
|
+
for ( int i = 0; i < SAMPLES; i ++ ) {
|
|
4035
4023
|
|
|
4036
|
-
|
|
4037
|
-
|
|
4024
|
+
// Stratified inverse-CDF sampling of the Gaussian, placed on a golden-angle spiral.
|
|
4025
|
+
float stratum = ( float( i ) + 0.5 ) / float( SAMPLES );
|
|
4026
|
+
float theta = sigma * sqrt( - 2.0 * log( 1.0 - stratum * truncation ) );
|
|
4027
|
+
float phi = float( i ) * GOLDEN_ANGLE;
|
|
4038
4028
|
|
|
4039
|
-
|
|
4029
|
+
vec3 offset = cos( phi ) * tangent + sin( phi ) * bitangent;
|
|
4030
|
+
vec3 sampleDirection = cos( theta ) * outputDirection + sin( theta ) * offset;
|
|
4040
4031
|
|
|
4041
|
-
|
|
4032
|
+
// Correct the planar sample density to solid angle.
|
|
4033
|
+
float weight = sin( theta ) / theta;
|
|
4042
4034
|
|
|
4043
|
-
|
|
4035
|
+
accumColor += weight * textureLod( envMap, sampleDirection, 0.0 ).rgb;
|
|
4036
|
+
accumWeight += weight;
|
|
4044
4037
|
|
|
4045
|
-
|
|
4038
|
+
}
|
|
4046
4039
|
|
|
4047
|
-
|
|
4040
|
+
gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
|
|
4048
4041
|
|
|
4049
|
-
|
|
4042
|
+
}
|
|
4043
|
+
`)}function Mh(){return Zs("PMREMEquirectangularToCubemap",{envMap:{value:null}},`
|
|
4050
4044
|
|
|
4051
|
-
|
|
4052
|
-
#include <project_vertex>
|
|
4045
|
+
varying vec3 vWorldDirection;
|
|
4053
4046
|
|
|
4054
|
-
|
|
4055
|
-
`,fragmentShader:`
|
|
4047
|
+
uniform sampler2D envMap;
|
|
4056
4048
|
|
|
4057
|
-
|
|
4049
|
+
#include <common>
|
|
4058
4050
|
|
|
4059
|
-
|
|
4051
|
+
void main() {
|
|
4060
4052
|
|
|
4061
|
-
|
|
4053
|
+
// Average four subpixel samples to preserve small, bright features.
|
|
4054
|
+
vec3 direction = normalize( vWorldDirection );
|
|
4055
|
+
vec3 dx = dFdx( direction ) * 0.25;
|
|
4056
|
+
vec3 dy = dFdy( direction ) * 0.25;
|
|
4062
4057
|
|
|
4063
|
-
|
|
4058
|
+
vec3 color = textureLod( envMap, equirectUv( normalize( direction - dx - dy ) ), 0.0 ).rgb;
|
|
4059
|
+
color += textureLod( envMap, equirectUv( normalize( direction + dx - dy ) ), 0.0 ).rgb;
|
|
4060
|
+
color += textureLod( envMap, equirectUv( normalize( direction - dx + dy ) ), 0.0 ).rgb;
|
|
4061
|
+
color += textureLod( envMap, equirectUv( normalize( direction + dx + dy ) ), 0.0 ).rgb;
|
|
4062
|
+
gl_FragColor = vec4( color * 0.25, 1.0 );
|
|
4064
4063
|
|
|
4065
|
-
|
|
4064
|
+
}
|
|
4065
|
+
`)}function bh(){return Zs("PMREMCubemapToCubemap",{envMap:{value:null},flipEnvMap:{value:-1}},`
|
|
4066
4066
|
|
|
4067
|
-
|
|
4067
|
+
varying vec3 vWorldDirection;
|
|
4068
4068
|
|
|
4069
|
-
|
|
4069
|
+
uniform samplerCube envMap;
|
|
4070
|
+
uniform float flipEnvMap;
|
|
4070
4071
|
|
|
4071
|
-
|
|
4072
|
-
|
|
4072
|
+
void main() {
|
|
4073
|
+
|
|
4074
|
+
gl_FragColor = vec4( textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ).rgb, 1.0 );
|
|
4075
|
+
|
|
4076
|
+
}
|
|
4077
|
+
`)}function wm(i){let e=new WeakMap,t=new WeakMap,n=null;function s(u,m=!1){return u==null?null:m?a(u):r(u)}function r(u){if(u&&u.isTexture){let m=u.mapping;if(m===da||m===fa)if(e.has(u)){let _=e.get(u).texture;return o(_,u.mapping)}else{let _=u.image;if(_&&_.height>0){let y=new Ys(_.height);return y.fromEquirectangularTexture(i,u),e.set(u,y),u.addEventListener("dispose",l),o(y.texture,u.mapping)}else return null}}return u}function a(u){if(u&&u.isTexture&&u.isPMREMTexture!==!0){let m=u.mapping,_=m===da||m===fa,y=m===bi||m===ns;if(_||y){let p=t.get(u),f=p!==void 0?p.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==f)return n===null&&(n=new eo(i)),p=_?n.fromEquirectangular(u,p):n.fromCubemap(u,p),p.texture.pmremVersion=u.pmremVersion,t.set(u,p),p.texture;if(p!==void 0)return p.texture;{let S=u.image;return _&&S&&S.height>0||y&&S&&c(S)?(n===null&&(n=new eo(i)),p=_?n.fromEquirectangular(u):n.fromCubemap(u),p.texture.pmremVersion=u.pmremVersion,t.set(u,p),u.addEventListener("dispose",h),p.texture):null}}}return u}function o(u,m){return m===da?u.mapping=bi:m===fa&&(u.mapping=ns),u}function c(u){let m=0,_=6;for(let y=0;y<_;y++)u[y]!==void 0&&m++;return m===_}function l(u){let m=u.target;m.removeEventListener("dispose",l);let _=e.get(m);_!==void 0&&(e.delete(m),_.dispose())}function h(u){let m=u.target;m.removeEventListener("dispose",h);let _=t.get(m);_!==void 0&&(t.delete(m),_.dispose())}function d(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:d}}function Em(i){let e={};function t(n){if(e[n]!==void 0)return e[n];let s=i.getExtension(n);return e[n]=s,s}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){let s=t(n);return s===null&&ms("WebGLRenderer: "+n+" extension not supported."),s}}}function Tm(i,e,t,n){let s={},r=new WeakMap,a=new FinalizationRegistry(_=>delete s[_]);function o(_){c(_.target)}function c(_){_.index!==null&&e.remove(_.index);for(let p in _.attributes)e.remove(_.attributes[p]);_.removeEventListener("dispose",o),delete s[_.id],a.unregister(_);let y=r.get(_);y&&(e.remove(y),r.delete(_)),n.releaseStatesOfGeometry(_),_.isInstancedBufferGeometry===!0&&delete _._maxInstanceCount,t.memory.geometries--}function l(_,y){return s[y.id]!==void 0||(y.addEventListener("dispose",o),s[y.id]=new WeakRef(y),a.register(y,y.id,y),t.memory.geometries++),y}function h(_){let y=_.attributes;for(let p in y)e.update(y[p],i.ARRAY_BUFFER)}function d(_){let y=_.index,p=_.attributes.position,f=0;if(p===void 0)return;let S=y!==null?y.array.length:p.array.length/3-1,A=p.count>=65535?Es:ws,b=new A(Math.ceil(S/3)*6,1),T=b.array;if(y!==null){let g=y.array;f=y.version;for(let M=0,U=0;M<S;M+=3){let I=g[M+0],D=g[M+1],F=g[M+2];T[U++]=I,T[U++]=D,T[U++]=D,T[U++]=F,T[U++]=F,T[U++]=I}}else{f=p.version;for(let g=0,M=0;g<S;g+=3){let U=g+0,I=g+1,D=g+2;T[M++]=U,T[M++]=I,T[M++]=I,T[M++]=D,T[M++]=D,T[M++]=U}}b.version=f;let w=r.get(_);w&&e.remove(w),r.set(_,b)}function u(_){let y=r.get(_);if(y){let p=_.index;p!==null&&y.version<p.version&&d(_)}else d(_);return r.get(_)}function m(){for(let _ in s){let y=s[_].deref();y!==void 0&&c(y)}}return{get:l,update:h,getWireframeAttribute:u,dispose:m}}function Am(i,e,t){let n;function s(d){n=d}let r,a;function o(d){r=d.type,a=d.bytesPerElement}function c(d,u){i.drawElements(n,u,r,d*a),t.update(u,n,1)}function l(d,u,m){m!==0&&(i.drawElementsInstanced(n,u,r,d*a,m),t.update(u,n,m))}function h(d,u,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,u,0,r,d,0,m);let y=0;for(let p=0;p<m;p++)y+=u[p];t.update(y,n,1)}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function Rm(i){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(r/3);break;case i.LINES:t.lines+=o*(r/2);break;case i.LINE_STRIP:t.lines+=o*(r-1);break;case i.LINE_LOOP:t.lines+=o*r;break;case i.POINTS:t.points+=o*r;break;default:Ue("WebGLInfo: Unknown draw mode:",a);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function Cm(i,e,t){let n=new WeakMap,s=new dt;function r(a,o,c){let l=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=h!==void 0?h.length:0,u=n.get(o);if(u===void 0||u.count!==d){let U=function(){g.dispose(),n.delete(o),o.removeEventListener("dispose",U)};u!==void 0&&u.texture.dispose();let m=o.morphAttributes.position!==void 0,_=o.morphAttributes.normal!==void 0,y=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],S=o.morphAttributes.color||[],A=0;m===!0&&(A=1),_===!0&&(A=2),y===!0&&(A=3);let b=o.attributes.position.count*A,T=1;b>e.maxTextureSize&&(T=Math.ceil(b/e.maxTextureSize),b=e.maxTextureSize);let w=new Float32Array(b*T*4*d),g=new Ms(w,b,T,d);g.type=pn,g.needsUpdate=!0;let M=A*4;for(let I=0;I<d;I++){let D=p[I],F=f[I],H=S[I],C=b*T*4*I;for(let Y=0;Y<D.count;Y++){let J=Y*M;m===!0&&(s.fromBufferAttribute(D,Y),w[C+J+0]=s.x,w[C+J+1]=s.y,w[C+J+2]=s.z,w[C+J+3]=0),_===!0&&(s.fromBufferAttribute(F,Y),w[C+J+4]=s.x,w[C+J+5]=s.y,w[C+J+6]=s.z,w[C+J+7]=0),y===!0&&(s.fromBufferAttribute(H,Y),w[C+J+8]=s.x,w[C+J+9]=s.y,w[C+J+10]=s.z,w[C+J+11]=H.itemSize===4?s.w:1)}}u={count:d,texture:g,size:new Fe(b,T)},n.set(o,u),o.addEventListener("dispose",U)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let m=0;for(let y=0;y<l.length;y++)m+=l[y];let _=o.morphTargetsRelative?1:1-m;c.getUniforms().setValue(i,"morphTargetBaseInfluence",_),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",u.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",u.size)}return{update:r}}function Pm(i,e,t,n,s){let r=new WeakMap;function a(l){let h=s.render.frame,d=l.geometry,u=e.get(l,d);if(r.get(u)!==h&&(e.update(u),r.set(u,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==h&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,h))),l.isSkinnedMesh){let m=l.skeleton;r.get(m)!==h&&(m.update(),r.set(m,h))}return u}function o(){r=new WeakMap}function c(l){let h=l.target;h.removeEventListener("dispose",c),n.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:a,dispose:o}}var Im={[Zo]:"LINEAR_TONE_MAPPING",[$o]:"REINHARD_TONE_MAPPING",[Jo]:"CINEON_TONE_MAPPING",[Ko]:"ACES_FILMIC_TONE_MAPPING",[Qo]:"AGX_TONE_MAPPING",[Os]:"NEUTRAL_TONE_MAPPING",[jo]:"CUSTOM_TONE_MAPPING"};function Lm(i,e,t,n,s,r){let a=new Qt(e,t,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),o=null,c=null,l=null,h=new Wt;h.setAttribute("position",new zt([-1,3,0,-1,-1,0,3,-1,0],3)),h.setAttribute("uv",new zt([0,2,0,0,2,0],2));let d=new $r({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
4073
4078
|
precision highp float;
|
|
4074
4079
|
|
|
4075
4080
|
uniform mat4 modelViewMatrix;
|
|
@@ -4115,17 +4120,17 @@ void main() {
|
|
|
4115
4120
|
#ifdef SRGB_TRANSFER
|
|
4116
4121
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
4117
4122
|
#endif
|
|
4118
|
-
}`,depthTest:!1,depthWrite:!1}),d=new Ve(l,h),u=new Xn(-1,1,1,-1,0,1),p=null,_=null,v=!1,g,f=null,T=[],L=!1;this.setSize=function(M,b){a.setSize(M,b),o!==null&&o.setSize(M,b),c!==null&&c.setSize(M,b);for(let E=0;E<T.length;E++){let A=T[E];A.setSize&&A.setSize(M,b)}},this.setEffects=function(M){T=M,L=T.length>0&&T[0].isRenderPass===!0;let b=a.width,E=a.height;T.length>0&&o===null&&(o=new ze(b,E,{type:hn,depthBuffer:!1,stencilBuffer:!1}),c=new ze(b,E,{type:hn,depthBuffer:!1,stencilBuffer:!1}));for(let A=0;A<T.length;A++){let x=T[A];x.setSize&&x.setSize(b,E)}},this.begin=function(M,b){if(v||M.toneMapping===on&&T.length===0)return!1;if(f=b,b!==null){let E=b.width,A=b.height;(a.width!==E||a.height!==A)&&this.setSize(E,A)}return L===!1&&M.setRenderTarget(a),g=M.toneMapping,M.toneMapping=on,!0},this.hasRenderPass=function(){return L},this.end=function(M,b){M.toneMapping=g,v=!0;let E=a,A=o;for(let x=0;x<T.length;x++){let w=T[x];w.enabled!==!1&&(w.render(M,A,E,b),w.needsSwap!==!1&&(E=A,A=A===o?c:o))}if(p!==M.outputColorSpace||_!==M.toneMapping){p=M.outputColorSpace,_=M.toneMapping,h.defines={},Yt.getTransfer(p)===Qt&&(h.defines.SRGB_TRANSFER="");let x=hm[_];x&&(h.defines[x]=""),h.needsUpdate=!0}h.uniforms.tDiffuse.value=E.texture,M.setRenderTarget(f),M.render(d,u),f=null,v=!1},this.isCompositing=function(){return v},this.dispose=function(){a.dispose(),o!==null&&o.dispose(),c!==null&&c.dispose(),l.dispose(),h.dispose()}}var Ph=new Be,xl=new Vn(1,1),Ih=new os,Lh=new Cr,Dh=new ps,uh=[],dh=[],fh=new Float32Array(16),ph=new Float32Array(9),mh=new Float32Array(4);function $i(i,t,e){let n=i[0];if(n<=0||n>0)return i;let s=t*e,r=uh[s];if(r===void 0&&(r=new Float32Array(s),uh[s]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(r,o)}return r}function ye(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function ve(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function qa(i,t){let e=dh[t];e===void 0&&(e=new Int32Array(t),dh[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function dm(i,t){let e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function fm(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ye(e,t))return;i.uniform2fv(this.addr,t),ve(e,t)}}function pm(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(ye(e,t))return;i.uniform3fv(this.addr,t),ve(e,t)}}function mm(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ye(e,t))return;i.uniform4fv(this.addr,t),ve(e,t)}}function gm(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(ye(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),ve(e,t)}else{if(ye(e,n))return;mh.set(n),i.uniformMatrix2fv(this.addr,!1,mh),ve(e,n)}}function _m(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(ye(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),ve(e,t)}else{if(ye(e,n))return;ph.set(n),i.uniformMatrix3fv(this.addr,!1,ph),ve(e,n)}}function xm(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(ye(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),ve(e,t)}else{if(ye(e,n))return;fh.set(n),i.uniformMatrix4fv(this.addr,!1,fh),ve(e,n)}}function ym(i,t){let e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function vm(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ye(e,t))return;i.uniform2iv(this.addr,t),ve(e,t)}}function Mm(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(ye(e,t))return;i.uniform3iv(this.addr,t),ve(e,t)}}function Sm(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ye(e,t))return;i.uniform4iv(this.addr,t),ve(e,t)}}function bm(i,t){let e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function Em(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ye(e,t))return;i.uniform2uiv(this.addr,t),ve(e,t)}}function wm(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(ye(e,t))return;i.uniform3uiv(this.addr,t),ve(e,t)}}function Tm(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ye(e,t))return;i.uniform4uiv(this.addr,t),ve(e,t)}}function Am(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(xl.compareFunction=e.isReversedDepthBuffer()?za:Ba,r=xl):r=Ph,e.setTexture2D(t||r,s)}function Cm(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture3D(t||Lh,s)}function Rm(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTextureCube(t||Dh,s)}function Pm(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2DArray(t||Ih,s)}function Im(i){switch(i){case 5126:return dm;case 35664:return fm;case 35665:return pm;case 35666:return mm;case 35674:return gm;case 35675:return _m;case 35676:return xm;case 5124:case 35670:return ym;case 35667:case 35671:return vm;case 35668:case 35672:return Mm;case 35669:case 35673:return Sm;case 5125:return bm;case 36294:return Em;case 36295:return wm;case 36296:return Tm;case 35678:case 36198:case 36298:case 36306:case 35682:return Am;case 35679:case 36299:case 36307:return Cm;case 35680:case 36300:case 36308:case 36293:return Rm;case 36289:case 36303:case 36311:case 36292:return Pm}}function Lm(i,t){i.uniform1fv(this.addr,t)}function Dm(i,t){let e=$i(t,this.size,2);i.uniform2fv(this.addr,e)}function Nm(i,t){let e=$i(t,this.size,3);i.uniform3fv(this.addr,e)}function Um(i,t){let e=$i(t,this.size,4);i.uniform4fv(this.addr,e)}function Fm(i,t){let e=$i(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function Om(i,t){let e=$i(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function Bm(i,t){let e=$i(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function zm(i,t){i.uniform1iv(this.addr,t)}function km(i,t){i.uniform2iv(this.addr,t)}function Vm(i,t){i.uniform3iv(this.addr,t)}function Gm(i,t){i.uniform4iv(this.addr,t)}function Hm(i,t){i.uniform1uiv(this.addr,t)}function Wm(i,t){i.uniform2uiv(this.addr,t)}function Xm(i,t){i.uniform3uiv(this.addr,t)}function qm(i,t){i.uniform4uiv(this.addr,t)}function Ym(i,t,e){let n=this.cache,s=t.length,r=qa(e,s);ye(n,r)||(i.uniform1iv(this.addr,r),ve(n,r));let a;this.type===i.SAMPLER_2D_SHADOW?a=xl:a=Ph;for(let o=0;o!==s;++o)e.setTexture2D(t[o]||a,r[o])}function Zm(i,t,e){let n=this.cache,s=t.length,r=qa(e,s);ye(n,r)||(i.uniform1iv(this.addr,r),ve(n,r));for(let a=0;a!==s;++a)e.setTexture3D(t[a]||Lh,r[a])}function Jm(i,t,e){let n=this.cache,s=t.length,r=qa(e,s);ye(n,r)||(i.uniform1iv(this.addr,r),ve(n,r));for(let a=0;a!==s;++a)e.setTextureCube(t[a]||Dh,r[a])}function $m(i,t,e){let n=this.cache,s=t.length,r=qa(e,s);ye(n,r)||(i.uniform1iv(this.addr,r),ve(n,r));for(let a=0;a!==s;++a)e.setTexture2DArray(t[a]||Ih,r[a])}function Km(i){switch(i){case 5126:return Lm;case 35664:return Dm;case 35665:return Nm;case 35666:return Um;case 35674:return Fm;case 35675:return Om;case 35676:return Bm;case 5124:case 35670:return zm;case 35667:case 35671:return km;case 35668:case 35672:return Vm;case 35669:case 35673:return Gm;case 5125:return Hm;case 36294:return Wm;case 36295:return Xm;case 36296:return qm;case 35678:case 36198:case 36298:case 36306:case 35682:return Ym;case 35679:case 36299:case 36307:return Zm;case 35680:case 36300:case 36308:case 36293:return Jm;case 36289:case 36303:case 36311:case 36292:return $m}}var yl=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=Im(e.type)}},vl=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=Km(e.type)}},Ml=class{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){let s=this.seq;for(let r=0,a=s.length;r!==a;++r){let o=s[r];o.setValue(t,e[o.id],n)}}},gl=/(\w+)(\])?(\[|\.)?/g;function gh(i,t){i.seq.push(t),i.map[t.id]=t}function jm(i,t,e){let n=i.name,s=n.length;for(gl.lastIndex=0;;){let r=gl.exec(n),a=gl.lastIndex,o=r[1],c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){gh(e,l===void 0?new yl(o,i,t):new vl(o,i,t));break}else{let d=e.map[o];d===void 0&&(d=new Ml(o),gh(e,d)),e=d}}}var Ji=class{constructor(t,e){this.seq=[],this.map={};let n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){let o=t.getActiveUniform(e,a),c=t.getUniformLocation(e,o.name);jm(o,c,this)}let s=[],r=[];for(let a of this.seq)a.type===t.SAMPLER_2D_SHADOW||a.type===t.SAMPLER_CUBE_SHADOW||a.type===t.SAMPLER_2D_ARRAY_SHADOW?s.push(a):r.push(a);s.length>0&&(this.seq=s.concat(r))}setValue(t,e,n,s){let r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){let s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){for(let r=0,a=e.length;r!==a;++r){let o=e[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(t,c.value,s)}}static seqWithValue(t,e){let n=[];for(let s=0,r=t.length;s!==r;++s){let a=t[s];a.id in e&&n.push(a)}return n}};function _h(i,t,e){let n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}var Qm=37297,tg=0;function eg(i,t){let e=i.split(`
|
|
4119
|
-
`),n=[],s=Math.max(
|
|
4120
|
-
`)}var
|
|
4123
|
+
}`,depthTest:!1,depthWrite:!1}),u=new en(h,d),m=new yi(-1,1,1,-1,0,1),_=null,y=null,p=!1,f,S=null,A=[],b=!1;this.setSize=function(T,w){a.setSize(T,w),o!==null&&o.setSize(T,w),c!==null&&c.setSize(T,w);for(let g=0;g<A.length;g++){let M=A[g];M.setSize&&M.setSize(T,w)}},this.setEffects=function(T){A=T,b=A.length>0&&A[0].isRenderPass===!0;let w=a.width,g=a.height;A.length>0&&o===null&&(o=new Qt(w,g,{type:mn,depthBuffer:!1,stencilBuffer:!1}),c=new Qt(w,g,{type:mn,depthBuffer:!1,stencilBuffer:!1}));let M=s===!0&&A.some(U=>U.needsDepthTexture===!0);M!==(a.depthTexture!==null)&&(M===!0&&l===null&&(l=new Vn(w,g),r===!0&&(l.format=Hn,l.type=Si)),a.dispose(),a.depthTexture=M?l:null,a.resolveDepthBuffer=M,a.storeMultisampledDepthBuffer=M);for(let U=0;U<A.length;U++){let I=A[U];I.setSize&&I.setSize(w,g),M&&I.needsDepthTexture===!0&&I.setDepthTexture&&I.setDepthTexture(l)}},this.begin=function(T,w){if(p||T.toneMapping===Sn&&A.length===0)return!1;if(S=w,w!==null){let g=w.width,M=w.height;(a.width!==g||a.height!==M)&&this.setSize(g,M)}return b===!1&&T.setRenderTarget(a),f=T.toneMapping,T.toneMapping=Sn,!0},this.hasRenderPass=function(){return b},this.end=function(T,w){T.toneMapping=f,p=!0;let g=a,M=o;for(let U=0;U<A.length;U++){let I=A[U];I.enabled!==!1&&(I.render(T,M,g,w),I.needsSwap!==!1&&(g=M,M=M===o?c:o))}if(_!==T.outputColorSpace||y!==T.toneMapping){_=T.outputColorSpace,y=T.toneMapping,d.defines={},Ze.getTransfer(_)===nt&&(d.defines.SRGB_TRANSFER="");let U=Im[y];U&&(d.defines[U]=""),d.needsUpdate=!0}d.uniforms.tDiffuse.value=g.texture,T.setRenderTarget(S),T.render(u,m),S=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){a.dispose(),o!==null&&o.dispose(),c!==null&&c.dispose(),h.dispose(),d.dispose()}}var Wh=new Ht,Xh=new Vn(1,1),qh=new As(1),Yh=new Ms,Zh=new Gr,$h=new Ts,Sh=[],wh=[],Eh=new Float32Array(16),Th=new Float32Array(9),Ah=new Float32Array(4);function as(i,e,t){let n=i[0];if(n<=0||n>0)return i;let s=e*t,r=Sh[s];if(r===void 0&&(r=new Float32Array(s),Sh[s]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(r,o)}return r}function vt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function Mt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function no(i,e){let t=wh[e];t===void 0&&(t=new Int32Array(e),wh[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function Dm(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function Nm(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(vt(t,e))return;i.uniform2fv(this.addr,e),Mt(t,e)}}function Um(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.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)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(vt(t,e))return;i.uniform3fv(this.addr,e),Mt(t,e)}}function Fm(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.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(vt(t,e))return;i.uniform4fv(this.addr,e),Mt(t,e)}}function Om(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(vt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Mt(t,e)}else{if(vt(t,n))return;Ah.set(n),i.uniformMatrix2fv(this.addr,!1,Ah),Mt(t,n)}}function Bm(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(vt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Mt(t,e)}else{if(vt(t,n))return;Th.set(n),i.uniformMatrix3fv(this.addr,!1,Th),Mt(t,n)}}function zm(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(vt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Mt(t,e)}else{if(vt(t,n))return;Eh.set(n),i.uniformMatrix4fv(this.addr,!1,Eh),Mt(t,n)}}function km(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function Vm(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(vt(t,e))return;i.uniform2iv(this.addr,e),Mt(t,e)}}function Gm(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(vt(t,e))return;i.uniform3iv(this.addr,e),Mt(t,e)}}function Hm(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.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(vt(t,e))return;i.uniform4iv(this.addr,e),Mt(t,e)}}function Wm(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Xm(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(vt(t,e))return;i.uniform2uiv(this.addr,e),Mt(t,e)}}function qm(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(vt(t,e))return;i.uniform3uiv(this.addr,e),Mt(t,e)}}function Ym(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.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(vt(t,e))return;i.uniform4uiv(this.addr,e),Mt(t,e)}}function io(i){return i.version===0&&(i.compareFunction=hl,i.needsUpdate=!0),i}function Zm(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?r=io(Xh):r=Wh,t.setTexture2D(e||r,s)}function $m(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||Zh,s)}function Jm(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_CUBE_SHADOW?r=io(qh):r=$h,t.setTextureCube(e||r,s)}function Km(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||Yh,s)}function jm(i){switch(i){case 5126:return Dm;case 35664:return Nm;case 35665:return Um;case 35666:return Fm;case 35674:return Om;case 35675:return Bm;case 35676:return zm;case 5124:case 35670:return km;case 35667:case 35671:return Vm;case 35668:case 35672:return Gm;case 35669:case 35673:return Hm;case 5125:return Wm;case 36294:return Xm;case 36295:return qm;case 36296:return Ym;case 35678:case 36198:case 36298:case 36306:case 35682:return Zm;case 35679:case 36299:case 36307:return $m;case 35680:case 36300:case 36308:case 36293:return Jm;case 36289:case 36303:case 36311:case 36292:return Km}}function Qm(i,e){i.uniform1fv(this.addr,e)}function eg(i,e){let t=as(e,this.size,2);i.uniform2fv(this.addr,t)}function tg(i,e){let t=as(e,this.size,3);i.uniform3fv(this.addr,t)}function ng(i,e){let t=as(e,this.size,4);i.uniform4fv(this.addr,t)}function ig(i,e){let t=as(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function sg(i,e){let t=as(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function rg(i,e){let t=as(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function ag(i,e){i.uniform1iv(this.addr,e)}function og(i,e){i.uniform2iv(this.addr,e)}function lg(i,e){i.uniform3iv(this.addr,e)}function cg(i,e){i.uniform4iv(this.addr,e)}function hg(i,e){i.uniform1uiv(this.addr,e)}function ug(i,e){i.uniform2uiv(this.addr,e)}function dg(i,e){i.uniform3uiv(this.addr,e)}function fg(i,e){i.uniform4uiv(this.addr,e)}function pg(i,e,t){let n=this.cache,s=e.length,r=no(t,s);vt(n,r)||(i.uniform1iv(this.addr,r),Mt(n,r));let a;this.type===i.SAMPLER_2D_SHADOW?a=io(Xh):a=Wh;for(let o=0;o!==s;++o)t.setTexture2D(e[o]||a,r[o])}function mg(i,e,t){let n=this.cache,s=e.length,r=no(t,s);vt(n,r)||(i.uniform1iv(this.addr,r),Mt(n,r));for(let a=0;a!==s;++a)t.setTexture3D(e[a]||Zh,r[a])}function gg(i,e,t){let n=this.cache,s=e.length,r=no(t,s);vt(n,r)||(i.uniform1iv(this.addr,r),Mt(n,r));let a;this.type===i.SAMPLER_CUBE_SHADOW?a=io(qh):a=$h;for(let o=0;o!==s;++o)t.setTextureCube(e[o]||a,r[o])}function _g(i,e,t){let n=this.cache,s=e.length,r=no(t,s);vt(n,r)||(i.uniform1iv(this.addr,r),Mt(n,r));for(let a=0;a!==s;++a)t.setTexture2DArray(e[a]||Yh,r[a])}function xg(i){switch(i){case 5126:return Qm;case 35664:return eg;case 35665:return tg;case 35666:return ng;case 35674:return ig;case 35675:return sg;case 35676:return rg;case 5124:case 35670:return ag;case 35667:case 35671:return og;case 35668:case 35672:return lg;case 35669:case 35673:return cg;case 5125:return hg;case 36294:return ug;case 36295:return dg;case 36296:return fg;case 35678:case 36198:case 36298:case 36306:case 35682:return pg;case 35679:case 36299:case 36307:return mg;case 35680:case 36300:case 36308:case 36293:return gg;case 36289:case 36303:case 36311:case 36292:return _g}}var Rl=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=jm(t.type)}},Cl=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=xg(t.type)}},Pl=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let s=this.seq;for(let r=0,a=s.length;r!==a;++r){let o=s[r];o.setValue(e,t[o.id],n)}}},Tl=/(\w+)(\])?(\[|\.)?/g;function Rh(i,e){i.seq.push(e),i.map[e.id]=e}function yg(i,e,t){let n=i.name,s=n.length;for(Tl.lastIndex=0;;){let r=Tl.exec(n),a=Tl.lastIndex,o=r[1],c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){Rh(t,l===void 0?new Rl(o,i,e):new Cl(o,i,e));break}else{let d=t.map[o];d===void 0&&(d=new Pl(o),Rh(t,d)),t=d}}}var rs=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){let o=e.getActiveUniform(t,a),c=e.getUniformLocation(t,o.name);yg(o,c,this)}let s=[],r=[];for(let a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?s.push(a):r.push(a);s.length>0&&(this.seq=s.concat(r))}setValue(e,t,n,s){let r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){let s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,a=t.length;r!==a;++r){let o=t[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,s)}}static seqWithValue(e,t){let n=[];for(let s=0,r=e.length;s!==r;++s){let a=e[s];a.id in t&&n.push(a)}return n}};function Ch(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var vg=37297,Mg=0;function bg(i,e){let t=i.split(`
|
|
4124
|
+
`),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a<r;a++){let o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
|
|
4125
|
+
`)}var Ph=new Oe;function Sg(i){Ze._getMatrix(Ph,Ze.workingColorSpace,i);let e=`mat3( ${Ph.elements.map(t=>t.toFixed(4))} )`;switch(Ze.getTransfer(i)){case ys:return[e,"LinearTransferOETF"];case nt:return[e,"sRGBTransferOETF"];default:return Ie("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function Ih(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";let a=/ERROR: 0:(\d+)/.exec(r);if(a){let o=parseInt(a[1]);return t.toUpperCase()+`
|
|
4121
4126
|
|
|
4122
4127
|
`+r+`
|
|
4123
4128
|
|
|
4124
|
-
`+
|
|
4125
|
-
`)}var
|
|
4126
|
-
`)}function
|
|
4127
|
-
`)}function
|
|
4128
|
-
`)}function
|
|
4129
|
+
`+bg(i.getShaderSource(e),o)}else return r}function wg(i,e){let t=Sg(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( ${t[0]} * value.rgb, value.a ) );`,"}"].join(`
|
|
4130
|
+
`)}var Eg={[Zo]:"Linear",[$o]:"Reinhard",[Jo]:"Cineon",[Ko]:"ACESFilmic",[Qo]:"AgX",[Os]:"Neutral",[jo]:"Custom"};function Tg(i,e){let t=Eg[e];return t===void 0?(Ie("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var Qa=new B;function Ag(){Ze.getLuminanceCoefficients(Qa);let i=Qa.x.toFixed(4),e=Qa.y.toFixed(4),t=Qa.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
4131
|
+
`)}function Rg(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(qs).join(`
|
|
4132
|
+
`)}function Cg(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|
4133
|
+
`)}function Pg(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let r=i.getActiveAttrib(e,s),a=r.name,o=1;r.type===i.FLOAT_MAT2&&(o=2),r.type===i.FLOAT_MAT3&&(o=3),r.type===i.FLOAT_MAT4&&(o=4),t[a]={type:r.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function qs(i){return i!==""}function Lh(i,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_SUN_LIGHTS/g,e.numSunLights).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_SUN_LIGHT_SHADOWS/g,e.numSunLightShadows).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).replace(/NUM_LIGHT_PROBE_GRIDS/g,e.numLightProbeGrids)}function Dh(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var Ig=/^[ \t]*#include +<([\w\d./]+)>/gm;function Il(i){return i.replace(Ig,Lg)}function Lg(i,e){let t=He[e];if(t===void 0)throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">");return Il(t)}var Dg=/#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 Nh(i){return i.replace(Dg,Ng)}function Ng(i,e,t,n){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Uh(i){let e=`precision ${i.precision} float;
|
|
4129
4134
|
precision ${i.precision} int;
|
|
4130
4135
|
precision ${i.precision} sampler2D;
|
|
4131
4136
|
precision ${i.precision} samplerCube;
|
|
@@ -4142,33 +4147,33 @@ void main() {
|
|
|
4142
4147
|
precision ${i.precision} usampler3D;
|
|
4143
4148
|
precision ${i.precision} usamplerCube;
|
|
4144
4149
|
precision ${i.precision} usampler2DArray;
|
|
4145
|
-
`;return i.precision==="highp"?
|
|
4146
|
-
#define HIGH_PRECISION`:i.precision==="mediump"?
|
|
4147
|
-
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(
|
|
4148
|
-
#define LOW_PRECISION`),
|
|
4149
|
-
`:"";
|
|
4150
|
-
`),
|
|
4151
|
-
`),
|
|
4152
|
-
`),
|
|
4153
|
-
`)):(
|
|
4154
|
-
`].filter(
|
|
4155
|
-
`),
|
|
4156
|
-
`].filter(
|
|
4157
|
-
`)),a=
|
|
4158
|
-
`,
|
|
4150
|
+
`;return i.precision==="highp"?e+=`
|
|
4151
|
+
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
|
|
4152
|
+
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
|
|
4153
|
+
#define LOW_PRECISION`),e}var Ug={[Fs]:"SHADOWMAP_TYPE_PCF",[es]:"SHADOWMAP_TYPE_VSM"};function Fg(i){return Ug[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var Og={[ns]:"ENVMAP_MODE_REFRACTION"};function Bg(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":Og[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}var zg={[ua]:"ENVMAP_BLENDING_MULTIPLY",[Kc]:"ENVMAP_BLENDING_MIX",[jc]:"ENVMAP_BLENDING_ADD"};function kg(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":zg[i.combine]||"ENVMAP_BLENDING_NONE"}function Vg(i,e,t,n){let s=i.getContext(),r=t.defines,a=t.vertexShader,o=t.fragmentShader,c=Fg(t),l=t.envMapPMREM===!0?"ENVMAP_TYPE_PMREM":"ENVMAP_TYPE_CUBE",h=Bg(t),d=kg(t),u=Rg(t),m=Cg(r),_=s.createProgram(),y,p,f=t.glslVersion?"#version "+t.glslVersion+`
|
|
4154
|
+
`:"";t.isRawShaderMaterial?(y=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(qs).join(`
|
|
4155
|
+
`),y.length>0&&(y+=`
|
|
4156
|
+
`),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(qs).join(`
|
|
4157
|
+
`),p.length>0&&(p+=`
|
|
4158
|
+
`)):(y=[Uh(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 "+h:"",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.diffuseRoughnessMap?"#define USE_DIFFUSE_ROUGHNESSMAP":"",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.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.diffuseRoughnessMapUv?"#define DIFFUSE_ROUGHNESSMAP_UV "+t.diffuseRoughnessMapUv:"",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.vertexNormals?"#define HAS_NORMAL":"",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",`
|
|
4159
|
+
`].filter(qs).join(`
|
|
4160
|
+
`),p=[Uh(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 "+h:"",t.envMap?"#define "+d:"",t.envMapPMREM?"#define ENVMAP_MAX_LOD "+t.envMapMaxLod+".0":"",t.envMapPMREM?"#define ENVMAP_SIZE "+t.envMapSize+".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.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",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.diffuseRoughness?"#define USE_DIFFUSE_ROUGHNESS":"",t.diffuseRoughnessMap?"#define USE_DIFFUSE_ROUGHNESSMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.retroreflection?"#define USE_RETROREFLECTION":"",t.iridescence?"#define USE_IRIDESCENCE":"",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!==Sn?"#define TONE_MAPPING":"",t.toneMapping!==Sn?He.tonemapping_pars_fragment:"",t.toneMapping!==Sn?Tg("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",He.colorspace_pars_fragment,wg("linearToOutputTexel",t.outputColorSpace),Ag(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
4161
|
+
`].filter(qs).join(`
|
|
4162
|
+
`)),a=Il(a),a=Lh(a,t),a=Dh(a,t),o=Il(o),o=Lh(o,t),o=Dh(o,t),a=Nh(a),o=Nh(o),t.isRawShaderMaterial!==!0&&(f=`#version 300 es
|
|
4163
|
+
`,y=[u,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
4159
4164
|
`)+`
|
|
4160
|
-
`+
|
|
4165
|
+
`+y,p=["#define varying in",t.glslVersion===ul?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===ul?"":"#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(`
|
|
4161
4166
|
`)+`
|
|
4162
|
-
`+
|
|
4167
|
+
`+p);let S=f+y+a,A=f+p+o,b=Ch(s,s.VERTEX_SHADER,S),T=Ch(s,s.FRAGMENT_SHADER,A);s.attachShader(_,b),s.attachShader(_,T),t.index0AttributeName!==void 0?s.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function w(I){if(i.debug.checkShaderErrors){let D=s.getProgramInfoLog(_)||"",F=s.getShaderInfoLog(b)||"",H=s.getShaderInfoLog(T)||"",C=D.trim(),Y=F.trim(),J=H.trim(),z=!0,te=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(z=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,b,T);else{let W=Ih(s,b,"vertex"),$=Ih(s,T,"fragment");Ue("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+`
|
|
4163
4168
|
|
|
4164
|
-
Material Name: `+
|
|
4165
|
-
Material Type: `+
|
|
4169
|
+
Material Name: `+I.name+`
|
|
4170
|
+
Material Type: `+I.type+`
|
|
4166
4171
|
|
|
4167
|
-
Program Info Log: `+
|
|
4168
|
-
`+
|
|
4169
|
-
`+it)}else W!==""?It("WebGLProgram: Program Info Log:",W):($===""||K==="")&&(Y=!1);Y&&(O.diagnostics={runnable:st,programLog:W,vertexShader:{log:$,prefix:g},fragmentShader:{log:K,prefix:f}})}s.deleteShader(b),s.deleteShader(E),x=new Ji(s,v),w=cg(s,v)}let x;this.getUniforms=function(){return x===void 0&&A(this),x};let w;this.getAttributes=function(){return w===void 0&&A(this),w};let D=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=s.getProgramParameter(v,Qm)),D},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(v),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=tg++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=b,this.fragmentShader=E,this}var wg=0,bl=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){let s=this._getShaderCacheForMaterial(t);return s.has(e)===!1&&(s.add(e),e.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new El(t),e.set(t,n)),n}},El=class{constructor(t){this.id=wg++,this.code=t,this.usedTimes=0}};function Tg(i){return i===jn||i===Ls||i===Ds}function Ag(i,t,e,n,s,r){let a=new ls,o=new bl,c=new Set,l=[],h=new Map,d=n.logarithmicDepthBuffer,u=n.precision,p={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 _(x){return c.add(x),x===0?"uv":`uv${x}`}function v(x,w,D,O,V,H){let R=O.fog,W=V.geometry,$=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?O.environment:null,K=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,st=t.get(x.envMap||$,K),Y=st&&st.mapping===Ts?st.image.height:null,et=p[x.type];x.precision!==null&&(u=n.getMaxPrecision(x.precision),u!==x.precision&&It("WebGLProgram.getParameters:",x.precision,"not supported, using",u,"instead."));let it=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,Ct=it!==void 0?it.length:0,Et=0;W.morphAttributes.position!==void 0&&(Et=1),W.morphAttributes.normal!==void 0&&(Et=2),W.morphAttributes.color!==void 0&&(Et=3);let ee,Lt,Wt,j;if(et){let yt=xn[et];ee=yt.vertexShader,Lt=yt.fragmentShader}else{ee=x.vertexShader,Lt=x.fragmentShader;let yt=o.getVertexShaderStage(x),kt=o.getFragmentShaderStage(x);o.update(x,yt,kt),Wt=yt.id,j=kt.id}let Q=i.getRenderTarget(),_t=i.state.buffers.depth.getReversed(),St=V.isInstancedMesh===!0,pt=V.isBatchedMesh===!0,Ot=!!x.map,pe=!!x.matcap,Bt=!!st,Zt=!!x.aoMap,$t=!!x.lightMap,zt=!!x.bumpMap&&x.wireframe===!1,ie=!!x.normalMap,ue=!!x.displacementMap,me=!!x.emissiveMap,re=!!x.metalnessMap,de=!!x.roughnessMap,I=x.anisotropy>0,fe=x.clearcoat>0,Xt=x.dispersion>0,S=x.retroreflectivity>0,m=x.iridescence>0,F=x.sheen>0,G=x.transmission>0,J=I&&!!x.anisotropyMap,lt=fe&&!!x.clearcoatMap,N=fe&&!!x.clearcoatNormalMap,k=fe&&!!x.clearcoatRoughnessMap,q=m&&!!x.iridescenceMap,nt=m&&!!x.iridescenceThicknessMap,ht=F&&!!x.sheenColorMap,at=F&&!!x.sheenRoughnessMap,ot=!!x.specularMap,xt=!!x.specularColorMap,ut=!!x.specularIntensityMap,Pt=G&&!!x.transmissionMap,C=G&&!!x.thicknessMap,rt=!!x.gradientMap,Z=!!x.alphaMap,ct=x.alphaTest>0,dt=!!x.alphaHash,tt=!!x.extensions,wt=on;x.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(wt=i.toneMapping);let bt={shaderID:et,shaderType:x.type,shaderName:x.name,vertexShader:ee,fragmentShader:Lt,defines:x.defines,customVertexShaderID:Wt,customFragmentShaderID:j,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:u,batching:pt,batchingColor:pt&&V._colorsTexture!==null,instancing:St,instancingColor:St&&V.instanceColor!==null,instancingMorph:St&&V.morphTexture!==null,outputColorSpace:Q===null?i.outputColorSpace:Q.isXRRenderTarget===!0?Q.texture.colorSpace:Yt.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Ot,matcap:pe,envMap:Bt,envMapMode:Bt&&st.mapping,envMapCubeUVHeight:Y,aoMap:Zt,lightMap:$t,bumpMap:zt,normalMap:ie,displacementMap:ue,emissiveMap:me,normalMapObjectSpace:ie&&x.normalMapType===Wc,normalMapTangentSpace:ie&&x.normalMapType===Oa,packedNormalMap:ie&&x.normalMapType===Oa&&Tg(x.normalMap.format),metalnessMap:re,roughnessMap:de,anisotropy:I,anisotropyMap:J,clearcoat:fe,clearcoatMap:lt,clearcoatNormalMap:N,clearcoatRoughnessMap:k,dispersion:Xt,retroreflection:S,iridescence:m,iridescenceMap:q,iridescenceThicknessMap:nt,sheen:F,sheenColorMap:ht,sheenRoughnessMap:at,specularMap:ot,specularColorMap:xt,specularIntensityMap:ut,transmission:G,transmissionMap:Pt,thicknessMap:C,gradientMap:rt,opaque:x.transparent===!1&&x.blending===Hi&&x.alphaToCoverage===!1,alphaMap:Z,alphaTest:ct,alphaHash:dt,combine:x.combine,mapUv:Ot&&_(x.map.channel),aoMapUv:Zt&&_(x.aoMap.channel),lightMapUv:$t&&_(x.lightMap.channel),bumpMapUv:zt&&_(x.bumpMap.channel),normalMapUv:ie&&_(x.normalMap.channel),displacementMapUv:ue&&_(x.displacementMap.channel),emissiveMapUv:me&&_(x.emissiveMap.channel),metalnessMapUv:re&&_(x.metalnessMap.channel),roughnessMapUv:de&&_(x.roughnessMap.channel),anisotropyMapUv:J&&_(x.anisotropyMap.channel),clearcoatMapUv:lt&&_(x.clearcoatMap.channel),clearcoatNormalMapUv:N&&_(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:k&&_(x.clearcoatRoughnessMap.channel),iridescenceMapUv:q&&_(x.iridescenceMap.channel),iridescenceThicknessMapUv:nt&&_(x.iridescenceThicknessMap.channel),sheenColorMapUv:ht&&_(x.sheenColorMap.channel),sheenRoughnessMapUv:at&&_(x.sheenRoughnessMap.channel),specularMapUv:ot&&_(x.specularMap.channel),specularColorMapUv:xt&&_(x.specularColorMap.channel),specularIntensityMapUv:ut&&_(x.specularIntensityMap.channel),transmissionMapUv:Pt&&_(x.transmissionMap.channel),thicknessMapUv:C&&_(x.thicknessMap.channel),alphaMapUv:Z&&_(x.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(ie||I),vertexNormals:!!W.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:V.isPoints===!0&&!!W.attributes.uv&&(Ot||Z),fog:!!R,useFog:x.fog===!0,fogExp2:!!R&&R.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||W.attributes.normal===void 0&&ie===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:_t,skinning:V.isSkinnedMesh===!0,hasPositionAttribute:W.attributes.position!==void 0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:Ct,morphTextureStride:Et,numSunLights:w.sun.length,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numSunLightShadows:w.sunShadowMap.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numLightProbeGrids:H.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:x.dithering,shadowMapEnabled:i.shadowMap.enabled&&D.length>0,shadowMapType:i.shadowMap.type,toneMapping:wt,decodeVideoTexture:Ot&&x.map.isVideoTexture===!0&&Yt.getTransfer(x.map.colorSpace)===Qt,decodeVideoTextureEmissive:me&&x.emissiveMap.isVideoTexture===!0&&Yt.getTransfer(x.emissiveMap.colorSpace)===Qt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===mn,flipSided:x.side===Fe,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:tt&&x.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(tt&&x.extensions.multiDraw===!0||pt)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return bt.vertexUv1s=c.has(1),bt.vertexUv2s=c.has(2),bt.vertexUv3s=c.has(3),c.clear(),bt}function g(x){let w=[];if(x.shaderID?w.push(x.shaderID):(w.push(x.customVertexShaderID),w.push(x.customFragmentShaderID)),x.defines!==void 0)for(let D in x.defines)w.push(D),w.push(x.defines[D]);return x.isRawShaderMaterial===!1&&(f(w,x),T(w,x),w.push(i.outputColorSpace)),w.push(x.customProgramCacheKey),w.join()}function f(x,w){x.push(w.precision),x.push(w.outputColorSpace),x.push(w.envMapMode),x.push(w.envMapCubeUVHeight),x.push(w.mapUv),x.push(w.alphaMapUv),x.push(w.lightMapUv),x.push(w.aoMapUv),x.push(w.bumpMapUv),x.push(w.normalMapUv),x.push(w.displacementMapUv),x.push(w.emissiveMapUv),x.push(w.metalnessMapUv),x.push(w.roughnessMapUv),x.push(w.anisotropyMapUv),x.push(w.clearcoatMapUv),x.push(w.clearcoatNormalMapUv),x.push(w.clearcoatRoughnessMapUv),x.push(w.iridescenceMapUv),x.push(w.iridescenceThicknessMapUv),x.push(w.sheenColorMapUv),x.push(w.sheenRoughnessMapUv),x.push(w.specularMapUv),x.push(w.specularColorMapUv),x.push(w.specularIntensityMapUv),x.push(w.transmissionMapUv),x.push(w.thicknessMapUv),x.push(w.combine),x.push(w.fogExp2),x.push(w.sizeAttenuation),x.push(w.morphTargetsCount),x.push(w.morphAttributeCount),x.push(w.numSunLights),x.push(w.numDirLights),x.push(w.numPointLights),x.push(w.numSpotLights),x.push(w.numSpotLightMaps),x.push(w.numHemiLights),x.push(w.numRectAreaLights),x.push(w.numSunLightShadows),x.push(w.numDirLightShadows),x.push(w.numPointLightShadows),x.push(w.numSpotLightShadows),x.push(w.numSpotLightShadowsWithMaps),x.push(w.numLightProbes),x.push(w.shadowMapType),x.push(w.toneMapping),x.push(w.numClippingPlanes),x.push(w.numClipIntersection),x.push(w.depthPacking)}function T(x,w){a.disableAll(),w.instancing&&a.enable(0),w.instancingColor&&a.enable(1),w.instancingMorph&&a.enable(2),w.matcap&&a.enable(3),w.envMap&&a.enable(4),w.normalMapObjectSpace&&a.enable(5),w.normalMapTangentSpace&&a.enable(6),w.clearcoat&&a.enable(7),w.iridescence&&a.enable(8),w.alphaTest&&a.enable(9),w.vertexColors&&a.enable(10),w.vertexAlphas&&a.enable(11),w.vertexUv1s&&a.enable(12),w.vertexUv2s&&a.enable(13),w.vertexUv3s&&a.enable(14),w.vertexTangents&&a.enable(15),w.anisotropy&&a.enable(16),w.alphaHash&&a.enable(17),w.batching&&a.enable(18),w.dispersion&&a.enable(19),w.retroreflection&&a.enable(24),w.batchingColor&&a.enable(20),w.gradientMap&&a.enable(21),w.packedNormalMap&&a.enable(22),w.vertexNormals&&a.enable(23),x.push(a.mask),a.disableAll(),w.fog&&a.enable(0),w.useFog&&a.enable(1),w.flatShading&&a.enable(2),w.logarithmicDepthBuffer&&a.enable(3),w.reversedDepthBuffer&&a.enable(4),w.skinning&&a.enable(5),w.morphTargets&&a.enable(6),w.morphNormals&&a.enable(7),w.morphColors&&a.enable(8),w.premultipliedAlpha&&a.enable(9),w.shadowMapEnabled&&a.enable(10),w.doubleSided&&a.enable(11),w.flipSided&&a.enable(12),w.useDepthPacking&&a.enable(13),w.dithering&&a.enable(14),w.transmission&&a.enable(15),w.sheen&&a.enable(16),w.opaque&&a.enable(17),w.pointsUvs&&a.enable(18),w.decodeVideoTexture&&a.enable(19),w.decodeVideoTextureEmissive&&a.enable(20),w.alphaToCoverage&&a.enable(21),w.numLightProbeGrids>0&&a.enable(22),w.hasPositionAttribute&&a.enable(23),x.push(a.mask)}function L(x){let w=p[x.type],D;if(w){let O=xn[w];D=sh.clone(O.uniforms)}else D=x.uniforms;return D}function M(x,w){let D=h.get(w);return D!==void 0?++D.usedTimes:(D=new Eg(i,w,x,s),l.push(D),h.set(w,D)),D}function b(x){if(--x.usedTimes===0){let w=l.indexOf(x);l[w]=l[l.length-1],l.pop(),h.delete(x.cacheKey),x.destroy()}}function E(x){o.remove(x)}function A(){o.dispose()}return{getParameters:v,getProgramCacheKey:g,getUniforms:L,acquireProgram:M,releaseProgram:b,releaseShaderCache:E,programs:l,dispose:A}}function Cg(){let i=new WeakMap;function t(a){return i.has(a)}function e(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:r}}function Rg(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.materialVariant!==t.materialVariant?i.materialVariant-t.materialVariant:i.z!==t.z?i.z-t.z:i.id-t.id}function Eh(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function wh(){let i=[],t=0,e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function a(u){let p=0;return u.isInstancedMesh&&(p+=2),u.isSkinnedMesh&&(p+=1),p}function o(u,p,_,v,g,f){let T=i[t];return T===void 0?(T={id:u.id,object:u,geometry:p,material:_,materialVariant:a(u),groupOrder:v,renderOrder:u.renderOrder,z:g,group:f},i[t]=T):(T.id=u.id,T.object=u,T.geometry=p,T.material=_,T.materialVariant=a(u),T.groupOrder=v,T.renderOrder=u.renderOrder,T.z=g,T.group=f),t++,T}function c(u,p,_,v,g,f,T){T.reversedDepth===!0&&(g=-g);let L=o(u,p,_,v,g,f);_.transmission>0?n.push(L):_.transparent===!0?s.push(L):e.push(L)}function l(u,p,_,v,g,f){let T=o(u,p,_,v,g,f);_.transmission>0?n.unshift(T):_.transparent===!0?s.unshift(T):e.unshift(T)}function h(u,p){e.length>1&&e.sort(u||Rg),n.length>1&&n.sort(p||Eh),s.length>1&&s.sort(p||Eh)}function d(){for(let u=t,p=i.length;u<p;u++){let _=i[u];if(_.id===null)break;_.id=null,_.object=null,_.geometry=null,_.material=null,_.group=null}}return{opaque:e,transmissive:n,transparent:s,init:r,push:c,unshift:l,finish:d,sort:h}}function Pg(){let i=new WeakMap;function t(n,s){let r=i.get(n),a;return r===void 0?(a=new wh,i.set(n,[a])):s>=r.length?(a=new wh,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function Ig(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"SunLight":case"DirectionalLight":e={direction:new U,color:new Ft};break;case"SpotLight":e={position:new U,direction:new U,color:new Ft,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new U,color:new Ft,distance:0,decay:0};break;case"HemisphereLight":e={direction:new U,skyColor:new Ft,groundColor:new Ft};break;case"RectAreaLight":e={color:new Ft,position:new U,halfWidth:new U,halfHeight:new U};break}return i[t.id]=e,e}}}function Lg(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"SunLight":case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var Dg=0;function Ng(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Ug(i){let t=new Ig,e=Lg(),n={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],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 U);let s=new U,r=new ce,a=new ce;function o(l){let h=0,d=0,u=0;for(let V=0;V<9;V++)n.probe[V].set(0,0,0);let p=0,_=0,v=0,g=0,f=0,T=0,L=0,M=0,b=0,E=0,A=0,x=0,w=0,D=0;l.sort(Ng);for(let V=0,H=l.length;V<H;V++){let R=l[V],W=R.color,$=R.intensity,K=R.distance,st=null;if(R.shadow&&R.shadow.map&&(R.shadow.map.texture.format===jn?st=R.shadow.map.texture:st=R.shadow.map.depthTexture||R.shadow.map.texture),R.isAmbientLight)h+=W.r*$,d+=W.g*$,u+=W.b*$;else if(R.isLightProbe){for(let Y=0;Y<9;Y++)n.probe[Y].addScaledVector(R.sh.coefficients[Y],$);D++}else if(R.isSunLight){let Y=t.get(R);if(Y.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){let et=R.shadow,it=e.get(R);it.shadowIntensity=et.intensity,it.shadowBias=et.bias,it.shadowNormalBias=et.normalBias,it.shadowRadius=et.radius,it.shadowMapSize.copy(et.mapSize).multiply(et.getFrameExtents()),n.sunShadow[_]=it,n.sunShadowMap[_]=st;let Ct=et.getViewportCount();for(let Et=0;Et<Ct;Et++)n.sunShadowMatrix[v+Et]=et.getMatrix(Et),n.sunShadowCascade[v+Et]=et._cascadeData[Et];v+=Ct,_++}n.sun[p]=Y,p++}else if(R.isDirectionalLight){let Y=t.get(R);if(Y.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){let et=R.shadow,it=e.get(R);it.shadowIntensity=et.intensity,it.shadowBias=et.bias,it.shadowNormalBias=et.normalBias,it.shadowRadius=et.radius,it.shadowMapSize=et.mapSize,n.directionalShadow[g]=it,n.directionalShadowMap[g]=st,n.directionalShadowMatrix[g]=R.shadow.matrix,b++}n.directional[g]=Y,g++}else if(R.isSpotLight){let Y=t.get(R);Y.position.setFromMatrixPosition(R.matrixWorld),Y.color.copy(W).multiplyScalar($),Y.distance=K,Y.coneCos=Math.cos(R.angle),Y.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),Y.decay=R.decay,n.spot[T]=Y;let et=R.shadow;if(R.map&&(n.spotLightMap[x]=R.map,x++,et.updateMatrices(R),R.castShadow&&w++),n.spotLightMatrix[T]=et.matrix,R.castShadow){let it=e.get(R);it.shadowIntensity=et.intensity,it.shadowBias=et.bias,it.shadowNormalBias=et.normalBias,it.shadowRadius=et.radius,it.shadowMapSize=et.mapSize,n.spotShadow[T]=it,n.spotShadowMap[T]=st,A++}T++}else if(R.isRectAreaLight){let Y=t.get(R);Y.color.copy(W).multiplyScalar($),Y.halfWidth.set(R.width*.5,0,0),Y.halfHeight.set(0,R.height*.5,0),n.rectArea[L]=Y,L++}else if(R.isPointLight){let Y=t.get(R);if(Y.color.copy(R.color).multiplyScalar(R.intensity),Y.distance=R.distance,Y.decay=R.decay,R.castShadow){let et=R.shadow,it=e.get(R);it.shadowIntensity=et.intensity,it.shadowBias=et.bias,it.shadowNormalBias=et.normalBias,it.shadowRadius=et.radius,it.shadowMapSize=et.mapSize,it.shadowCameraNear=et.camera.near,it.shadowCameraFar=et.camera.far,n.pointShadow[f]=it,n.pointShadowMap[f]=st,n.pointShadowMatrix[f]=R.shadow.matrix,E++}n.point[f]=Y,f++}else if(R.isHemisphereLight){let Y=t.get(R);Y.skyColor.copy(R.color).multiplyScalar($),Y.groundColor.copy(R.groundColor).multiplyScalar($),n.hemi[M]=Y,M++}}L>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ft.LTC_FLOAT_1,n.rectAreaLTC2=ft.LTC_FLOAT_2):(n.rectAreaLTC1=ft.LTC_HALF_1,n.rectAreaLTC2=ft.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let O=n.hash;(O.sunLength!==p||O.directionalLength!==g||O.pointLength!==f||O.spotLength!==T||O.rectAreaLength!==L||O.hemiLength!==M||O.numSunShadows!==_||O.numDirectionalShadows!==b||O.numPointShadows!==E||O.numSpotShadows!==A||O.numSpotMaps!==x||O.numLightProbes!==D)&&(n.sun.length=p,n.directional.length=g,n.spot.length=T,n.rectArea.length=L,n.point.length=f,n.hemi.length=M,n.sunShadow.length=_,n.sunShadowMap.length=_,n.sunShadowMatrix.length=v,n.sunShadowCascade.length=v,n.directionalShadow.length=b,n.directionalShadowMap.length=b,n.directionalShadowMatrix.length=b,n.pointShadow.length=E,n.pointShadowMap.length=E,n.pointShadowMatrix.length=E,n.spotShadow.length=A,n.spotShadowMap.length=A,n.spotLightMatrix.length=A+x-w,n.spotLightMap.length=x,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=D,O.sunLength=p,O.directionalLength=g,O.pointLength=f,O.spotLength=T,O.rectAreaLength=L,O.hemiLength=M,O.numSunShadows=_,O.numDirectionalShadows=b,O.numPointShadows=E,O.numSpotShadows=A,O.numSpotMaps=x,O.numLightProbes=D,n.version=Dg++)}function c(l,h){let d=0,u=0,p=0,_=0,v=0,g=0,f=h.matrixWorldInverse;for(let T=0,L=l.length;T<L;T++){let M=l[T];if(M.isSunLight){let b=n.sun[d];b.direction.setFromMatrixPosition(M.matrixWorld),b.direction.transformDirection(f),d++}else if(M.isDirectionalLight){let b=n.directional[u];b.direction.setFromMatrixPosition(M.matrixWorld),s.setFromMatrixPosition(M.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(f),u++}else if(M.isSpotLight){let b=n.spot[_];b.position.setFromMatrixPosition(M.matrixWorld),b.position.applyMatrix4(f),b.direction.setFromMatrixPosition(M.matrixWorld),s.setFromMatrixPosition(M.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(f),_++}else if(M.isRectAreaLight){let b=n.rectArea[v];b.position.setFromMatrixPosition(M.matrixWorld),b.position.applyMatrix4(f),a.identity(),r.copy(M.matrixWorld),r.premultiply(f),a.extractRotation(r),b.halfWidth.set(M.width*.5,0,0),b.halfHeight.set(0,M.height*.5,0),b.halfWidth.applyMatrix4(a),b.halfHeight.applyMatrix4(a),v++}else if(M.isPointLight){let b=n.point[p];b.position.setFromMatrixPosition(M.matrixWorld),b.position.applyMatrix4(f),p++}else if(M.isHemisphereLight){let b=n.hemi[g];b.direction.setFromMatrixPosition(M.matrixWorld),b.direction.transformDirection(f),g++}}}return{setup:o,setupView:c,state:n}}function Th(i){let t=new Ug(i),e=[],n=[],s=[];function r(u){d.camera=u,e.length=0,n.length=0,s.length=0}function a(u){e.push(u)}function o(u){n.push(u)}function c(u){s.push(u)}function l(){t.setup(e)}function h(u){t.setupView(e,u)}let d={lightsArray:e,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:d,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function Fg(i){let t=new WeakMap;function e(s,r=0){let a=t.get(s),o;return a===void 0?(o=new Th(i),t.set(s,[o])):r>=a.length?(o=new Th(i),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}var Og=`void main() {
|
|
4172
|
+
Program Info Log: `+C+`
|
|
4173
|
+
`+W+`
|
|
4174
|
+
`+$)}else C!==""?Ie("WebGLProgram: Program Info Log:",C):(Y===""||J==="")&&(te=!1);te&&(I.diagnostics={runnable:z,programLog:C,vertexShader:{log:Y,prefix:y},fragmentShader:{log:J,prefix:p}})}s.deleteShader(b),s.deleteShader(T),g=new rs(s,_),M=Pg(s,_)}let g;this.getUniforms=function(){return g===void 0&&w(this),g};let M;this.getAttributes=function(){return M===void 0&&w(this),M};let U=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return U===!1&&(U=s.getProgramParameter(_,vg)),U},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Mg++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=b,this.fragmentShader=T,this}var Gg=0,Ll=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new Dl(e),t.set(e,n)),n}},Dl=class{constructor(e){this.id=Gg++,this.code=e,this.usedTimes=0}};function Hg(i){return i===ai||i===Hs||i===Ws}function Wg(i,e,t,n,s,r){let a=new bs,o=new Ll,c=new Set,l=[],h=new Map,d=n.logarithmicDepthBuffer,u={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(g){return c.add(g),g===0?"uv":`uv${g}`}function _(g,M,U,I,D,F){let H=I.fog,C=D.geometry,Y=g.isMeshStandardMaterial||g.isMeshLambertMaterial||g.isMeshPhongMaterial?I.environment:null,J=g.isMeshStandardMaterial||g.isMeshLambertMaterial&&!g.envMap||g.isMeshPhongMaterial&&!g.envMap,z=e.get(g.envMap||Y,J),te=u[g.type],W=n.precision;g.precision!==null&&(W=n.getMaxPrecision(g.precision),W!==g.precision&&Ie("WebGLProgram.getParameters:",g.precision,"not supported, using",W,"instead."));let $=C.morphAttributes.position||C.morphAttributes.normal||C.morphAttributes.color,ae=$!==void 0?$.length:0,_e=0;C.morphAttributes.position!==void 0&&(_e=1),C.morphAttributes.normal!==void 0&&(_e=2),C.morphAttributes.color!==void 0&&(_e=3);let De,j,pe,ye;if(te){let ie=En[te];De=ie.vertexShader,j=ie.fragmentShader}else{De=g.vertexShader,j=g.fragmentShader;let ie=o.getVertexShaderStage(g),Ne=o.getFragmentShaderStage(g);o.update(g,ie,Ne),pe=ie.id,ye=Ne.id}let Re=i.getRenderTarget(),fe=i.state.buffers.depth.getReversed(),Le=D.isInstancedMesh===!0,pt=D.isBatchedMesh===!0,be=!!g.map,$e=!!g.matcap,it=!!z,ke=it&&z.isPMREMTexture===!0,lt=!!g.aoMap,Ge=!!g.lightMap,mt=!!g.bumpMap&&g.wireframe===!1,at=!!g.normalMap,nn=!!g.displacementMap,gt=!!g.emissiveMap,Ft=!!g.metalnessMap,Tt=!!g.roughnessMap,Pt=g.anisotropy>0,N=g.clearcoat>0,At=g.diffuseRoughness>0,Qe=g.dispersion>0,st=g.retroreflectivity>0,ue=g.iridescence>0,ut=g.sheen>0,Te=g.transmission>0,Ce=Pt&&!!g.anisotropyMap,E=N&&!!g.clearcoatMap,x=N&&!!g.clearcoatNormalMap,k=N&&!!g.clearcoatRoughnessMap,oe=At&&!!g.diffuseRoughnessMap,ee=ue&&!!g.iridescenceMap,le=ue&&!!g.iridescenceThicknessMap,ce=ut&&!!g.sheenColorMap,K=ut&&!!g.sheenRoughnessMap,P=!!g.specularMap,Q=!!g.specularColorMap,R=!!g.specularIntensityMap,X=Te&&!!g.transmissionMap,O=Te&&!!g.thicknessMap,q=!!g.gradientMap,ne=!!g.alphaMap,se=g.alphaTest>0,xe=!!g.alphaHash,Pe=!!g.extensions,re=Sn;g.toneMapped&&(Re===null||Re.isXRRenderTarget===!0)&&(re=i.toneMapping);let ve=ke?z.isCompressedCubeTexture?z.image[0].mipmaps:z.mipmaps:null,Ae={shaderID:te,shaderType:g.type,shaderName:g.name,vertexShader:De,fragmentShader:j,defines:g.defines,customVertexShaderID:pe,customFragmentShaderID:ye,isRawShaderMaterial:g.isRawShaderMaterial===!0,glslVersion:g.glslVersion,precision:W,batching:pt,batchingColor:pt&&D._colorsTexture!==null,instancing:Le,instancingColor:Le&&D.instanceColor!==null,instancingMorph:Le&&D.morphTexture!==null,outputColorSpace:Re===null?i.outputColorSpace:Re.isXRRenderTarget===!0?Re.texture.colorSpace:Ze.workingColorSpace,alphaToCoverage:!!g.alphaToCoverage,map:be,matcap:$e,envMap:it,envMapMode:it&&z.mapping,envMapPMREM:ke,envMapMaxLod:ke?ve.length-1:null,envMapSize:ke?ve[0].width:null,aoMap:lt,lightMap:Ge,bumpMap:mt,normalMap:at,displacementMap:nn,emissiveMap:gt,normalMapObjectSpace:at&&g.normalMapType===th,normalMapTangentSpace:at&&g.normalMapType===Ka,packedNormalMap:at&&g.normalMapType===Ka&&Hg(g.normalMap.format),metalnessMap:Ft,roughnessMap:Tt,anisotropy:Pt,anisotropyMap:Ce,clearcoat:N,clearcoatMap:E,clearcoatNormalMap:x,clearcoatRoughnessMap:k,diffuseRoughness:At,diffuseRoughnessMap:oe,dispersion:Qe,retroreflection:st,iridescence:ue,iridescenceMap:ee,iridescenceThicknessMap:le,sheen:ut,sheenColorMap:ce,sheenRoughnessMap:K,specularMap:P,specularColorMap:Q,specularIntensityMap:R,transmission:Te,transmissionMap:X,thicknessMap:O,gradientMap:q,opaque:g.transparent===!1&&g.blending===ts&&g.alphaToCoverage===!1,alphaMap:ne,alphaTest:se,alphaHash:xe,combine:g.combine,mapUv:be&&m(g.map.channel),aoMapUv:lt&&m(g.aoMap.channel),lightMapUv:Ge&&m(g.lightMap.channel),bumpMapUv:mt&&m(g.bumpMap.channel),normalMapUv:at&&m(g.normalMap.channel),displacementMapUv:nn&&m(g.displacementMap.channel),emissiveMapUv:gt&&m(g.emissiveMap.channel),metalnessMapUv:Ft&&m(g.metalnessMap.channel),roughnessMapUv:Tt&&m(g.roughnessMap.channel),anisotropyMapUv:Ce&&m(g.anisotropyMap.channel),clearcoatMapUv:E&&m(g.clearcoatMap.channel),clearcoatNormalMapUv:x&&m(g.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:k&&m(g.clearcoatRoughnessMap.channel),diffuseRoughnessMapUv:oe&&m(g.diffuseRoughnessMap.channel),iridescenceMapUv:ee&&m(g.iridescenceMap.channel),iridescenceThicknessMapUv:le&&m(g.iridescenceThicknessMap.channel),sheenColorMapUv:ce&&m(g.sheenColorMap.channel),sheenRoughnessMapUv:K&&m(g.sheenRoughnessMap.channel),specularMapUv:P&&m(g.specularMap.channel),specularColorMapUv:Q&&m(g.specularColorMap.channel),specularIntensityMapUv:R&&m(g.specularIntensityMap.channel),transmissionMapUv:X&&m(g.transmissionMap.channel),thicknessMapUv:O&&m(g.thicknessMap.channel),alphaMapUv:ne&&m(g.alphaMap.channel),vertexTangents:!!C.attributes.tangent&&(at||Pt),vertexNormals:!!C.attributes.normal,vertexColors:g.vertexColors,vertexAlphas:g.vertexColors===!0&&!!C.attributes.color&&C.attributes.color.itemSize===4,pointsUvs:D.isPoints===!0&&!!C.attributes.uv&&(be||ne),fog:!!H,useFog:g.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:g.wireframe===!1&&(g.flatShading===!0||C.attributes.normal===void 0&&at===!1&&(g.isMeshLambertMaterial||g.isMeshPhongMaterial||g.isMeshStandardMaterial||g.isMeshPhysicalMaterial)),sizeAttenuation:g.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:fe,skinning:D.isSkinnedMesh===!0,hasPositionAttribute:C.attributes.position!==void 0,morphTargets:C.morphAttributes.position!==void 0,morphNormals:C.morphAttributes.normal!==void 0,morphColors:C.morphAttributes.color!==void 0,morphTargetsCount:ae,morphTextureStride:_e,numSunLights:M.sun.length,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numSunLightShadows:M.sunShadowMap.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numLightProbeGrids:F.filter(ie=>ie.texture!==null).length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:g.dithering,shadowMapEnabled:i.shadowMap.enabled&&U.length>0,shadowMapType:i.shadowMap.type,toneMapping:re,decodeVideoTexture:be&&g.map.isVideoTexture===!0&&Ze.getTransfer(g.map.colorSpace)===nt,decodeVideoTextureEmissive:gt&&g.emissiveMap.isVideoTexture===!0&&Ze.getTransfer(g.emissiveMap.colorSpace)===nt,premultipliedAlpha:g.premultipliedAlpha,doubleSided:g.side===bn,flipSided:g.side===Vt,useDepthPacking:g.depthPacking>=0,depthPacking:g.depthPacking||0,index0AttributeName:g.index0AttributeName,extensionClipCullDistance:Pe&&g.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Pe&&g.extensions.multiDraw===!0||pt)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:g.customProgramCacheKey()};return Ae.vertexUv1s=c.has(1),Ae.vertexUv2s=c.has(2),Ae.vertexUv3s=c.has(3),c.clear(),Ae}function y(g){let M=[];if(g.shaderID?M.push(g.shaderID):(M.push(g.customVertexShaderID),M.push(g.customFragmentShaderID)),g.defines!==void 0)for(let U in g.defines)M.push(U),M.push(g.defines[U]);return g.isRawShaderMaterial===!1&&(p(M,g),f(M,g),M.push(i.outputColorSpace)),M.push(g.customProgramCacheKey),M.join()}function p(g,M){g.push(M.precision),g.push(M.outputColorSpace),g.push(M.envMapMode),g.push(M.envMapPMREM),g.push(M.envMapMaxLod),g.push(M.envMapSize),g.push(M.mapUv),g.push(M.alphaMapUv),g.push(M.lightMapUv),g.push(M.aoMapUv),g.push(M.bumpMapUv),g.push(M.normalMapUv),g.push(M.displacementMapUv),g.push(M.emissiveMapUv),g.push(M.metalnessMapUv),g.push(M.roughnessMapUv),g.push(M.anisotropyMapUv),g.push(M.clearcoatMapUv),g.push(M.clearcoatNormalMapUv),g.push(M.clearcoatRoughnessMapUv),g.push(M.diffuseRoughnessMapUv),g.push(M.iridescenceMapUv),g.push(M.iridescenceThicknessMapUv),g.push(M.sheenColorMapUv),g.push(M.sheenRoughnessMapUv),g.push(M.specularMapUv),g.push(M.specularColorMapUv),g.push(M.specularIntensityMapUv),g.push(M.transmissionMapUv),g.push(M.thicknessMapUv),g.push(M.combine),g.push(M.fogExp2),g.push(M.sizeAttenuation),g.push(M.morphTargetsCount),g.push(M.numSunLights),g.push(M.numDirLights),g.push(M.numPointLights),g.push(M.numSpotLights),g.push(M.numSpotLightMaps),g.push(M.numHemiLights),g.push(M.numRectAreaLights),g.push(M.numSunLightShadows),g.push(M.numDirLightShadows),g.push(M.numPointLightShadows),g.push(M.numSpotLightShadows),g.push(M.numSpotLightShadowsWithMaps),g.push(M.numLightProbes),g.push(M.numLightProbeGrids),g.push(M.shadowMapType),g.push(M.toneMapping),g.push(M.numClippingPlanes),g.push(M.numClipIntersection),g.push(M.depthPacking)}function f(g,M){a.disableAll(),M.instancing&&a.enable(0),M.instancingColor&&a.enable(1),M.instancingMorph&&a.enable(2),M.matcap&&a.enable(3),M.envMap&&a.enable(4),M.normalMapObjectSpace&&a.enable(5),M.normalMapTangentSpace&&a.enable(6),M.clearcoat&&a.enable(7),M.iridescence&&a.enable(8),M.alphaTest&&a.enable(9),M.vertexColors&&a.enable(10),M.vertexAlphas&&a.enable(11),M.vertexUv1s&&a.enable(12),M.vertexUv2s&&a.enable(13),M.vertexUv3s&&a.enable(14),M.vertexTangents&&a.enable(15),M.anisotropy&&a.enable(16),M.alphaHash&&a.enable(17),M.batching&&a.enable(18),M.dispersion&&a.enable(19),M.retroreflection&&a.enable(24),M.diffuseRoughness&&a.enable(25),M.batchingColor&&a.enable(20),M.gradientMap&&a.enable(21),M.packedNormalMap&&a.enable(22),M.vertexNormals&&a.enable(23),g.push(a.mask),a.disableAll(),M.fog&&a.enable(0),M.useFog&&a.enable(1),M.flatShading&&a.enable(2),M.logarithmicDepthBuffer&&a.enable(3),M.reversedDepthBuffer&&a.enable(4),M.skinning&&a.enable(5),M.morphTargets&&a.enable(6),M.morphNormals&&a.enable(7),M.morphColors&&a.enable(8),M.premultipliedAlpha&&a.enable(9),M.shadowMapEnabled&&a.enable(10),M.doubleSided&&a.enable(11),M.flipSided&&a.enable(12),M.useDepthPacking&&a.enable(13),M.dithering&&a.enable(14),M.transmission&&a.enable(15),M.sheen&&a.enable(16),M.opaque&&a.enable(17),M.pointsUvs&&a.enable(18),M.decodeVideoTexture&&a.enable(19),M.decodeVideoTextureEmissive&&a.enable(20),M.alphaToCoverage&&a.enable(21),M.numLightProbeGrids>0&&a.enable(22),M.hasPositionAttribute&&a.enable(23),g.push(a.mask)}function S(g){let M=u[g.type],U;if(M){let I=En[M];U=gh.clone(I.uniforms)}else U=g.uniforms;return U}function A(g,M){let U=h.get(M);return U!==void 0?++U.usedTimes:(U=new Vg(i,M,g,s),l.push(U),h.set(M,U)),U}function b(g){if(--g.usedTimes===0){let M=l.indexOf(g);l[M]=l[l.length-1],l.pop(),h.delete(g.cacheKey),g.destroy()}}function T(g){o.remove(g)}function w(){o.dispose()}return{getParameters:_,getProgramCacheKey:y,getUniforms:S,acquireProgram:A,releaseProgram:b,releaseShaderCache:T,programs:l,dispose:w}}function Xg(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function qg(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function Fh(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Oh(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function a(u){let m=0;return u.isInstancedMesh&&(m+=2),u.isSkinnedMesh&&(m+=1),m}function o(u,m,_,y,p,f){let S=i[e];return S===void 0?(S={id:u.id,object:u,geometry:m,material:_,materialVariant:a(u),groupOrder:y,renderOrder:u.renderOrder,z:p,group:f},i[e]=S):(S.id=u.id,S.object=u,S.geometry=m,S.material=_,S.materialVariant=a(u),S.groupOrder=y,S.renderOrder=u.renderOrder,S.z=p,S.group=f),e++,S}function c(u,m,_,y,p,f,S){S.reversedDepth===!0&&(p=-p);let A=o(u,m,_,y,p,f);_.transmission>0?n.push(A):_.transparent===!0?s.push(A):t.push(A)}function l(u,m,_,y,p,f){let S=o(u,m,_,y,p,f);_.transmission>0?n.unshift(S):_.transparent===!0?s.unshift(S):t.unshift(S)}function h(u,m){t.length>1&&t.sort(u||qg),n.length>1&&n.sort(m||Fh),s.length>1&&s.sort(m||Fh)}function d(){for(let u=e,m=i.length;u<m;u++){let _=i[u];if(_.id===null)break;_.id=null,_.object=null,_.geometry=null,_.material=null,_.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:c,unshift:l,finish:d,sort:h}}function Yg(){let i=new WeakMap;function e(n,s){let r=i.get(n),a;return r===void 0?(a=new Oh,i.set(n,[a])):s>=r.length?(a=new Oh,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function Zg(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={direction:new B,color:new ze};break;case"SpotLight":t={position:new B,direction:new B,color:new ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new B,color:new ze,distance:0,decay:0};break;case"HemisphereLight":t={direction:new B,skyColor:new ze,groundColor:new ze};break;case"RectAreaLight":t={color:new ze,position:new B,halfWidth:new B,halfHeight:new B};break}return i[e.id]=t,t}}}function $g(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var Jg=0;function Kg(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function jg(i){let e=new Zg,t=$g(),n={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],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 B);let s=new B,r=new ht,a=new ht;function o(l){let h=0,d=0,u=0;for(let F=0;F<9;F++)n.probe[F].set(0,0,0);let m=0,_=0,y=0,p=0,f=0,S=0,A=0,b=0,T=0,w=0,g=0,M=0,U=0,I=0;l.sort(Kg);for(let F=0,H=l.length;F<H;F++){let C=l[F],Y=C.color,J=C.intensity,z=C.distance,te=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===ai?te=C.shadow.map.texture:te=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=Y.r*J,d+=Y.g*J,u+=Y.b*J;else if(C.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(C.sh.coefficients[W],J);I++}else if(C.isSunLight){let W=e.get(C);if(W.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let $=C.shadow,ae=t.get(C);ae.shadowIntensity=$.intensity,ae.shadowBias=$.bias,ae.shadowNormalBias=$.normalBias,ae.shadowRadius=$.radius,ae.shadowMapSize.copy($.mapSize).multiply($.getFrameExtents()),n.sunShadow[_]=ae,n.sunShadowMap[_]=te;let _e=$.getViewportCount();for(let De=0;De<_e;De++)n.sunShadowMatrix[y+De]=$.getMatrix(De),n.sunShadowCascade[y+De]=$._cascadeData[De];y+=_e,_++}n.sun[m]=W,m++}else if(C.isDirectionalLight){let W=e.get(C);if(W.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let $=C.shadow,ae=t.get(C);ae.shadowIntensity=$.intensity,ae.shadowBias=$.bias,ae.shadowNormalBias=$.normalBias,ae.shadowRadius=$.radius,ae.shadowMapSize=$.mapSize,n.directionalShadow[p]=ae,n.directionalShadowMap[p]=te,n.directionalShadowMatrix[p]=C.shadow.matrix,T++}n.directional[p]=W,p++}else if(C.isSpotLight){let W=e.get(C);W.position.setFromMatrixPosition(C.matrixWorld),W.color.copy(Y).multiplyScalar(J),W.distance=z,W.coneCos=Math.cos(C.angle),W.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),W.decay=C.decay,n.spot[S]=W;let $=C.shadow;if(C.map&&(n.spotLightMap[M]=C.map,M++,$.updateMatrices(C),C.castShadow&&U++),n.spotLightMatrix[S]=$.matrix,C.castShadow){let ae=t.get(C);ae.shadowIntensity=$.intensity,ae.shadowBias=$.bias,ae.shadowNormalBias=$.normalBias,ae.shadowRadius=$.radius,ae.shadowMapSize=$.mapSize,n.spotShadow[S]=ae,n.spotShadowMap[S]=te,g++}S++}else if(C.isRectAreaLight){let W=e.get(C);W.color.copy(Y).multiplyScalar(J),W.halfWidth.set(C.width*.5,0,0),W.halfHeight.set(0,C.height*.5,0),n.rectArea[A]=W,A++}else if(C.isPointLight){let W=e.get(C);if(W.color.copy(C.color).multiplyScalar(C.intensity),W.distance=C.distance,W.decay=C.decay,C.castShadow){let $=C.shadow,ae=t.get(C);ae.shadowIntensity=$.intensity,ae.shadowBias=$.bias,ae.shadowNormalBias=$.normalBias,ae.shadowRadius=$.radius,ae.shadowMapSize=$.mapSize,ae.shadowCameraNear=$.camera.near,ae.shadowCameraFar=$.camera.far,n.pointShadow[f]=ae,n.pointShadowMap[f]=te,n.pointShadowMatrix[f]=C.shadow.matrix,w++}n.point[f]=W,f++}else if(C.isHemisphereLight){let W=e.get(C);W.skyColor.copy(C.color).multiplyScalar(J),W.groundColor.copy(C.groundColor).multiplyScalar(J),n.hemi[b]=W,b++}}A>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=me.LTC_FLOAT_1,n.rectAreaLTC2=me.LTC_FLOAT_2):(n.rectAreaLTC1=me.LTC_HALF_1,n.rectAreaLTC2=me.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let D=n.hash;(D.sunLength!==m||D.directionalLength!==p||D.pointLength!==f||D.spotLength!==S||D.rectAreaLength!==A||D.hemiLength!==b||D.numSunShadows!==_||D.numDirectionalShadows!==T||D.numPointShadows!==w||D.numSpotShadows!==g||D.numSpotMaps!==M||D.numLightProbes!==I)&&(n.sun.length=m,n.directional.length=p,n.spot.length=S,n.rectArea.length=A,n.point.length=f,n.hemi.length=b,n.sunShadow.length=_,n.sunShadowMap.length=_,n.sunShadowMatrix.length=y,n.sunShadowCascade.length=y,n.directionalShadow.length=T,n.directionalShadowMap.length=T,n.directionalShadowMatrix.length=T,n.pointShadow.length=w,n.pointShadowMap.length=w,n.pointShadowMatrix.length=w,n.spotShadow.length=g,n.spotShadowMap.length=g,n.spotLightMatrix.length=g+M-U,n.spotLightMap.length=M,n.numSpotLightShadowsWithMaps=U,n.numLightProbes=I,D.sunLength=m,D.directionalLength=p,D.pointLength=f,D.spotLength=S,D.rectAreaLength=A,D.hemiLength=b,D.numSunShadows=_,D.numDirectionalShadows=T,D.numPointShadows=w,D.numSpotShadows=g,D.numSpotMaps=M,D.numLightProbes=I,n.version=Jg++)}function c(l,h){let d=0,u=0,m=0,_=0,y=0,p=0,f=h.matrixWorldInverse;for(let S=0,A=l.length;S<A;S++){let b=l[S];if(b.isSunLight){let T=n.sun[d];T.direction.setFromMatrixPosition(b.matrixWorld),T.direction.transformDirection(f),d++}else if(b.isDirectionalLight){let T=n.directional[u];T.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),T.direction.sub(s),T.direction.transformDirection(f),u++}else if(b.isSpotLight){let T=n.spot[_];T.position.setFromMatrixPosition(b.matrixWorld),T.position.applyMatrix4(f),T.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),T.direction.sub(s),T.direction.transformDirection(f),_++}else if(b.isRectAreaLight){let T=n.rectArea[y];T.position.setFromMatrixPosition(b.matrixWorld),T.position.applyMatrix4(f),a.identity(),r.copy(b.matrixWorld),r.premultiply(f),a.extractRotation(r),T.halfWidth.set(b.width*.5,0,0),T.halfHeight.set(0,b.height*.5,0),T.halfWidth.applyMatrix4(a),T.halfHeight.applyMatrix4(a),y++}else if(b.isPointLight){let T=n.point[m];T.position.setFromMatrixPosition(b.matrixWorld),T.position.applyMatrix4(f),m++}else if(b.isHemisphereLight){let T=n.hemi[p];T.direction.setFromMatrixPosition(b.matrixWorld),T.direction.transformDirection(f),p++}}}return{setup:o,setupView:c,state:n}}function Bh(i){let e=new jg(i),t=[],n=[],s=[];function r(d){h.camera=d,t.length=0,n.length=0,s.length=0}function a(d){d.isLightProbeGrid?s.push(d):t.push(d)}function o(d){n.push(d)}function c(){e.setup(t),s.sort((d,u)=>d.priority-u.priority||d.id-u.id)}function l(d){e.setupView(t,d)}let h={lightsArray:t,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:h,setupLights:c,setupLightsView:l,pushLight:a,pushShadow:o}}function Qg(i){let e=new WeakMap;function t(s,r=0){let a=e.get(s),o;return a===void 0?(o=new Bh(i),e.set(s,[o])):r>=a.length?(o=new Bh(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}var e_=`void main() {
|
|
4170
4175
|
gl_Position = vec4( position, 1.0 );
|
|
4171
|
-
}`,
|
|
4176
|
+
}`,t_=`uniform sampler2D shadow_pass;
|
|
4172
4177
|
uniform vec2 resolution;
|
|
4173
4178
|
uniform float radius;
|
|
4174
4179
|
void main() {
|
|
@@ -4193,12 +4198,12 @@ void main() {
|
|
|
4193
4198
|
squared_mean = squared_mean / samples;
|
|
4194
4199
|
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
|
4195
4200
|
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
|
4196
|
-
}`,zg=[new U(1,0,0),new U(-1,0,0),new U(0,1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1)],kg=[new U(0,-1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1),new U(0,-1,0),new U(0,-1,0)],Ah=new ce,Us=new U,_l=new U;function Vg(i,t,e){let n=new Oi,s=new Nt,r=new Nt,a=new he,o=new Ur,c=new Fr,l={},h=e.maxTextureSize,d={[Zn]:Fe,[Fe]:Zn,[mn]:mn},u=new $e({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Nt},radius:{value:4}},vertexShader:Og,fragmentShader:Bg}),p=u.clone();p.defines.HORIZONTAL_PASS=1;let _=new ke;_.setAttribute("position",new Oe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let v=new Ve(_,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Es;let f=this.type;this.render=function(E,A,x){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||E.length===0)return;this.type===Mc&&(It("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Es);let w=i.getRenderTarget(),D=i.getActiveCubeFace(),O=i.getActiveMipmapLevel(),V=i.state;V.setBlending(gn),V.buffers.depth.getReversed()===!0?V.buffers.color.setClear(0,0,0,0):V.buffers.color.setClear(1,1,1,1),V.buffers.depth.setTest(!0),V.setScissorTest(!1);let H=f!==this.type;H&&A.traverse(function(R){R.material&&(Array.isArray(R.material)?R.material.forEach(W=>W.needsUpdate=!0):R.material.needsUpdate=!0)});for(let R=0,W=E.length;R<W;R++){let $=E[R],K=$.shadow;if(K===void 0){It("WebGLShadowMap:",$,"has no shadow.");continue}if(K.autoUpdate===!1&&K.needsUpdate===!1)continue;s.copy(K.mapSize);let st=K.getFrameExtents();s.multiply(st),r.copy(K.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/st.x),s.x=r.x*st.x,K.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/st.y),s.y=r.y*st.y,K.mapSize.y=r.y));let Y=i.state.buffers.depth.getReversed();if(K.camera._reversedDepth=Y,K.map===null||H===!0){if(K.map!==null&&(K.map.depthTexture!==null&&(K.map.depthTexture.dispose(),K.map.depthTexture=null),K.map.dispose()),this.type===Gi){if($.isPointLight){It("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}K.map=new ze(s.x,s.y,{format:jn,type:hn,minFilter:Te,magFilter:Te,generateMipmaps:!1}),K.map.texture.name=$.name+".shadowMap",K.map.depthTexture=new Vn(s.x,s.y,cn),K.map.depthTexture.name=$.name+".shadowMapDepth",K.map.depthTexture.format=pn,K.map.depthTexture.compareFunction=null,K.map.depthTexture.minFilter=Ee,K.map.depthTexture.magFilter=Ee}else $.isPointLight?(K.map=new Ha(s.x),K.map.depthTexture=new Dr(s.x,ln)):(K.map=new ze(s.x,s.y),K.map.depthTexture=new Vn(s.x,s.y,ln)),K.map.depthTexture.name=$.name+".shadowMap",K.map.depthTexture.format=pn,this.type===Es?(K.map.depthTexture.compareFunction=Y?za:Ba,K.map.depthTexture.minFilter=Te,K.map.depthTexture.magFilter=Te):(K.map.depthTexture.compareFunction=null,K.map.depthTexture.minFilter=Ee,K.map.depthTexture.magFilter=Ee);K.camera.updateProjectionMatrix()}K.map.isWebGLCubeRenderTarget!==!0&&(K.map.width!==s.x||K.map.height!==s.y)&&K.map.setSize(s.x,s.y);let et=K.map.isWebGLCubeRenderTarget?6:K.getViewportCount();$.isPointLight!==!0&&K.updateMatrices($,x);for(let it=0;it<et;it++){let Ct=K.getCamera(it);if($.isPointLight){let Et=K.camera,ee=K.matrix,Lt=$.distance||Et.far;Lt!==Et.far&&(Et.far=Lt,Et.updateProjectionMatrix()),Us.setFromMatrixPosition($.matrixWorld),Et.position.copy(Us),_l.copy(Et.position),_l.add(zg[it]),Et.up.copy(kg[it]),Et.lookAt(_l),Et.updateMatrixWorld(),ee.makeTranslation(-Us.x,-Us.y,-Us.z),Ah.multiplyMatrices(Et.projectionMatrix,Et.matrixWorldInverse),K._frustum.setFromProjectionMatrix(Ah,Et.coordinateSystem,Et.reversedDepth)}if(K.map.isWebGLCubeRenderTarget)i.setRenderTarget(K.map,it),i.clear();else{it===0&&(i.setRenderTarget(K.map),i.clear());let Et=K.getViewport(it);a.set(r.x*Et.x,r.y*Et.y,r.x*Et.z,r.y*Et.w),V.viewport(a)}n=K.getFrustum(it),M(A,x,Ct,$,this.type)}K.isPointLightShadow!==!0&&this.type===Gi&&T(K,x),K.needsUpdate=!1}f=this.type,g.needsUpdate=!1,i.setRenderTarget(w,D,O)};function T(E,A){let x=t.update(v);u.defines.VSM_SAMPLES!==E.blurSamples&&(u.defines.VSM_SAMPLES=E.blurSamples,p.defines.VSM_SAMPLES=E.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),E.mapPass===null?E.mapPass=new ze(s.x,s.y,{format:jn,type:hn}):(E.mapPass.width!==E.map.width||E.mapPass.height!==E.map.height)&&E.mapPass.setSize(E.map.width,E.map.height),u.uniforms.shadow_pass.value=E.map.depthTexture,u.uniforms.resolution.value.set(E.map.width,E.map.height),u.uniforms.radius.value=E.radius,i.setRenderTarget(E.mapPass),i.clear(),i.renderBufferDirect(A,null,x,u,v,null),p.uniforms.shadow_pass.value=E.mapPass.texture,p.uniforms.resolution.value.set(E.map.width,E.map.height),p.uniforms.radius.value=E.radius,i.setRenderTarget(E.map),i.clear(),i.renderBufferDirect(A,null,x,p,v,null)}function L(E,A,x,w){let D=null,O=x.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(O!==void 0)D=O;else if(D=x.isPointLight===!0?c:o,i.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let V=D.uuid,H=A.uuid,R=l[V];R===void 0&&(R={},l[V]=R);let W=R[H];W===void 0&&(W=D.clone(),R[H]=W,A.addEventListener("dispose",b)),D=W}if(D.visible=A.visible,D.wireframe=A.wireframe,w===Gi?D.side=A.shadowSide!==null?A.shadowSide:A.side:D.side=A.shadowSide!==null?A.shadowSide:d[A.side],D.alphaMap=A.alphaMap,D.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,D.map=A.map,D.clipShadows=A.clipShadows,D.clippingPlanes=A.clippingPlanes,D.clipIntersection=A.clipIntersection,D.displacementMap=A.displacementMap,D.displacementScale=A.displacementScale,D.displacementBias=A.displacementBias,D.wireframeLinewidth=A.wireframeLinewidth,D.linewidth=A.linewidth,x.isPointLight===!0&&D.isMeshDistanceMaterial===!0){let V=i.properties.get(D);V.light=x}return D}function M(E,A,x,w,D){if(E.visible===!1)return;if(E.layers.test(A.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&D===Gi)&&(!E.frustumCulled||E.intersectsFrustum(n))){E.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,E.matrixWorld);let H=t.update(E),R=E.material;if(Array.isArray(R)){let W=H.groups;for(let $=0,K=W.length;$<K;$++){let st=W[$],Y=R[st.materialIndex];if(Y&&Y.visible){let et=L(E,Y,w,D);E.onBeforeShadow(i,E,A,x,H,et,st),i.renderBufferDirect(x,null,H,et,E,st),E.onAfterShadow(i,E,A,x,H,et,st)}}}else if(R.visible){let W=L(E,R,w,D);E.onBeforeShadow(i,E,A,x,H,W,null),i.renderBufferDirect(x,null,H,W,E,null),E.onAfterShadow(i,E,A,x,H,W,null)}}let V=E.children;for(let H=0,R=V.length;H<R;H++)M(V[H],A,x,w,D)}function b(E){E.target.removeEventListener("dispose",b);for(let x in l){let w=l[x],D=E.target.uuid;D in w&&(w[D].dispose(),delete w[D])}}}function Gg(i,t){function e(){let C=!1,rt=new he,Z=null,ct=new he(0,0,0,0);return{setMask:function(dt){Z!==dt&&!C&&(i.colorMask(dt,dt,dt,dt),Z=dt)},setLocked:function(dt){C=dt},setClear:function(dt,tt,wt,bt,yt){yt===!0&&(dt*=bt,tt*=bt,wt*=bt),rt.set(dt,tt,wt,bt),ct.equals(rt)===!1&&(i.clearColor(dt,tt,wt,bt),ct.copy(rt))},reset:function(){C=!1,Z=null,ct.set(-1,0,0,0)}}}function n(){let C=!1,rt=!1,Z=null,ct=null,dt=null;return{setReversed:function(tt){if(rt!==tt){let wt=t.get("EXT_clip_control");tt?wt.clipControlEXT(wt.LOWER_LEFT_EXT,wt.ZERO_TO_ONE_EXT):wt.clipControlEXT(wt.LOWER_LEFT_EXT,wt.NEGATIVE_ONE_TO_ONE_EXT),rt=tt;let bt=dt;dt=null,this.setClear(bt)}},getReversed:function(){return rt},setTest:function(tt){tt?Q(i.DEPTH_TEST):_t(i.DEPTH_TEST)},setMask:function(tt){Z!==tt&&!C&&(i.depthMask(tt),Z=tt)},setFunc:function(tt){if(rt&&(tt=nh[tt]),ct!==tt){switch(tt){case gr:i.depthFunc(i.NEVER);break;case _r:i.depthFunc(i.ALWAYS);break;case xr:i.depthFunc(i.LESS);break;case Ii:i.depthFunc(i.LEQUAL);break;case yr:i.depthFunc(i.EQUAL);break;case vr:i.depthFunc(i.GEQUAL);break;case Mr:i.depthFunc(i.GREATER);break;case Sr:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ct=tt}},setLocked:function(tt){C=tt},setClear:function(tt){dt!==tt&&(dt=tt,rt&&(tt=1-tt),i.clearDepth(tt))},reset:function(){C=!1,Z=null,ct=null,dt=null,rt=!1}}}function s(){let C=!1,rt=null,Z=null,ct=null,dt=null,tt=null,wt=null,bt=null,yt=null;return{setTest:function(kt){C||(kt?Q(i.STENCIL_TEST):_t(i.STENCIL_TEST))},setMask:function(kt){rt!==kt&&!C&&(i.stencilMask(kt),rt=kt)},setFunc:function(kt,we,We){(Z!==kt||ct!==we||dt!==We)&&(i.stencilFunc(kt,we,We),Z=kt,ct=we,dt=We)},setOp:function(kt,we,We){(tt!==kt||wt!==we||bt!==We)&&(i.stencilOp(kt,we,We),tt=kt,wt=we,bt=We)},setLocked:function(kt){C=kt},setClear:function(kt){yt!==kt&&(i.clearStencil(kt),yt=kt)},reset:function(){C=!1,rt=null,Z=null,ct=null,dt=null,tt=null,wt=null,bt=null,yt=null}}}let r=new e,a=new n,o=new s,c=new WeakMap,l=new WeakMap,h={},d={},u={},p=new WeakMap,_=[],v=null,g=!1,f=null,T=null,L=null,M=null,b=null,E=null,A=null,x=new Ft(0,0,0),w=0,D=!1,O=null,V=null,H=null,R=null,W=null,$=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),K=!1,st=0,Y=i.getParameter(i.VERSION);Y.indexOf("WebGL")!==-1?(st=parseFloat(/^WebGL (\d)/.exec(Y)[1]),K=st>=1):Y.indexOf("OpenGL ES")!==-1&&(st=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),K=st>=2);let et=null,it={},Ct=i.getParameter(i.SCISSOR_BOX),Et=i.getParameter(i.VIEWPORT),ee=new he().fromArray(Ct),Lt=new he().fromArray(Et);function Wt(C,rt,Z,ct){let dt=new Uint8Array(4),tt=i.createTexture();i.bindTexture(C,tt),i.texParameteri(C,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(C,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let wt=0;wt<Z;wt++)C===i.TEXTURE_3D||C===i.TEXTURE_2D_ARRAY?i.texImage3D(rt,0,i.RGBA,1,1,ct,0,i.RGBA,i.UNSIGNED_BYTE,dt):i.texImage2D(rt+wt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,dt);return tt}let j={};j[i.TEXTURE_2D]=Wt(i.TEXTURE_2D,i.TEXTURE_2D,1),j[i.TEXTURE_CUBE_MAP]=Wt(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),j[i.TEXTURE_2D_ARRAY]=Wt(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),j[i.TEXTURE_3D]=Wt(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),Q(i.DEPTH_TEST),a.setFunc(Ii),zt(!1),ie(Do),Q(i.CULL_FACE),Zt(gn);function Q(C){h[C]!==!0&&(i.enable(C),h[C]=!0)}function _t(C){h[C]!==!1&&(i.disable(C),h[C]=!1)}function St(C,rt){return u[C]!==rt?(i.bindFramebuffer(C,rt),u[C]=rt,C===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=rt),C===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=rt),!0):!1}function pt(C,rt){let Z=_,ct=!1;if(C){Z=p.get(rt),Z===void 0&&(Z=[],p.set(rt,Z));let dt=C.textures;if(Z.length!==dt.length||Z[0]!==i.COLOR_ATTACHMENT0){for(let tt=0,wt=dt.length;tt<wt;tt++)Z[tt]=i.COLOR_ATTACHMENT0+tt;Z.length=dt.length,ct=!0}}else Z[0]!==i.BACK&&(Z[0]=i.BACK,ct=!0);ct&&i.drawBuffers(Z)}function Ot(C){return v!==C?(i.useProgram(C),v=C,!0):!1}let pe={[li]:i.FUNC_ADD,[bc]:i.FUNC_SUBTRACT,[Ec]:i.FUNC_REVERSE_SUBTRACT};pe[wc]=i.MIN,pe[Tc]=i.MAX;let Bt={[Ac]:i.ZERO,[Cc]:i.ONE,[Rc]:i.SRC_COLOR,[Oo]:i.SRC_ALPHA,[Uc]:i.SRC_ALPHA_SATURATE,[Dc]:i.DST_COLOR,[Ic]:i.DST_ALPHA,[Pc]:i.ONE_MINUS_SRC_COLOR,[Bo]:i.ONE_MINUS_SRC_ALPHA,[Nc]:i.ONE_MINUS_DST_COLOR,[Lc]:i.ONE_MINUS_DST_ALPHA,[Fc]:i.CONSTANT_COLOR,[Oc]:i.ONE_MINUS_CONSTANT_COLOR,[Bc]:i.CONSTANT_ALPHA,[zc]:i.ONE_MINUS_CONSTANT_ALPHA};function Zt(C,rt,Z,ct,dt,tt,wt,bt,yt,kt){if(C===gn){g===!0&&(_t(i.BLEND),g=!1);return}if(g===!1&&(Q(i.BLEND),g=!0),C!==Sc){if(C!==f||kt!==D){if((T!==li||b!==li)&&(i.blendEquation(i.FUNC_ADD),T=li,b=li),kt)switch(C){case Hi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case No:i.blendFunc(i.ONE,i.ONE);break;case Uo:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Fo:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Dt("WebGLState: Invalid blending: ",C);break}else switch(C){case Hi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case No:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Uo:Dt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Fo:Dt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Dt("WebGLState: Invalid blending: ",C);break}L=null,M=null,E=null,A=null,x.set(0,0,0),w=0,f=C,D=kt}return}dt=dt||rt,tt=tt||Z,wt=wt||ct,(rt!==T||dt!==b)&&(i.blendEquationSeparate(pe[rt],pe[dt]),T=rt,b=dt),(Z!==L||ct!==M||tt!==E||wt!==A)&&(i.blendFuncSeparate(Bt[Z],Bt[ct],Bt[tt],Bt[wt]),L=Z,M=ct,E=tt,A=wt),(bt.equals(x)===!1||yt!==w)&&(i.blendColor(bt.r,bt.g,bt.b,yt),x.copy(bt),w=yt),f=C,D=!1}function $t(C,rt){C.side===mn?_t(i.CULL_FACE):Q(i.CULL_FACE);let Z=C.side===Fe;rt&&(Z=!Z),zt(Z),C.blending===Hi&&C.transparent===!1?Zt(gn):Zt(C.blending,C.blendEquation,C.blendSrc,C.blendDst,C.blendEquationAlpha,C.blendSrcAlpha,C.blendDstAlpha,C.blendColor,C.blendAlpha,C.premultipliedAlpha),a.setFunc(C.depthFunc),a.setTest(C.depthTest),a.setMask(C.depthWrite),r.setMask(C.colorWrite);let ct=C.stencilWrite;o.setTest(ct),ct&&(o.setMask(C.stencilWriteMask),o.setFunc(C.stencilFunc,C.stencilRef,C.stencilFuncMask),o.setOp(C.stencilFail,C.stencilZFail,C.stencilZPass)),me(C.polygonOffset,C.polygonOffsetFactor,C.polygonOffsetUnits),C.alphaToCoverage===!0?Q(i.SAMPLE_ALPHA_TO_COVERAGE):_t(i.SAMPLE_ALPHA_TO_COVERAGE)}function zt(C){O!==C&&(C?i.frontFace(i.CW):i.frontFace(i.CCW),O=C)}function ie(C){C!==yc?(Q(i.CULL_FACE),C!==V&&(C===Do?i.cullFace(i.BACK):C===vc?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):_t(i.CULL_FACE),V=C}function ue(C){C!==H&&(K&&i.lineWidth(C),H=C)}function me(C,rt,Z){C?(Q(i.POLYGON_OFFSET_FILL),(R!==rt||W!==Z)&&(R=rt,W=Z,a.getReversed()&&(rt=-rt),i.polygonOffset(rt,Z))):_t(i.POLYGON_OFFSET_FILL)}function re(C){C?Q(i.SCISSOR_TEST):_t(i.SCISSOR_TEST)}function de(C){C===void 0&&(C=i.TEXTURE0+$-1),et!==C&&(i.activeTexture(C),et=C)}function I(C,rt,Z){Z===void 0&&(et===null?Z=i.TEXTURE0+$-1:Z=et);let ct=it[Z];ct===void 0&&(ct={type:void 0,texture:void 0},it[Z]=ct),(ct.type!==C||ct.texture!==rt)&&(et!==Z&&(i.activeTexture(Z),et=Z),i.bindTexture(C,rt||j[C]),ct.type=C,ct.texture=rt)}function fe(){let C=it[et];C!==void 0&&C.type!==void 0&&(i.bindTexture(C.type,null),C.type=void 0,C.texture=void 0)}function Xt(){try{i.compressedTexImage2D(...arguments)}catch(C){Dt("WebGLState:",C)}}function S(){try{i.compressedTexImage3D(...arguments)}catch(C){Dt("WebGLState:",C)}}function m(){try{i.texSubImage2D(...arguments)}catch(C){Dt("WebGLState:",C)}}function F(){try{i.texSubImage3D(...arguments)}catch(C){Dt("WebGLState:",C)}}function G(){try{i.compressedTexSubImage2D(...arguments)}catch(C){Dt("WebGLState:",C)}}function J(){try{i.compressedTexSubImage3D(...arguments)}catch(C){Dt("WebGLState:",C)}}function lt(){try{i.texStorage2D(...arguments)}catch(C){Dt("WebGLState:",C)}}function N(){try{i.texStorage3D(...arguments)}catch(C){Dt("WebGLState:",C)}}function k(){try{i.texImage2D(...arguments)}catch(C){Dt("WebGLState:",C)}}function q(){try{i.texImage3D(...arguments)}catch(C){Dt("WebGLState:",C)}}function nt(C){return d[C]!==void 0?d[C]:i.getParameter(C)}function ht(C,rt){d[C]!==rt&&(i.pixelStorei(C,rt),d[C]=rt)}function at(C){ee.equals(C)===!1&&(i.scissor(C.x,C.y,C.z,C.w),ee.copy(C))}function ot(C){Lt.equals(C)===!1&&(i.viewport(C.x,C.y,C.z,C.w),Lt.copy(C))}function xt(C,rt){let Z=l.get(rt);Z===void 0&&(Z=new WeakMap,l.set(rt,Z));let ct=Z.get(C);ct===void 0&&(ct=i.getUniformBlockIndex(rt,C.name),Z.set(C,ct))}function ut(C,rt){let ct=l.get(rt).get(C);c.get(rt)!==ct&&(i.uniformBlockBinding(rt,ct,C.__bindingPointIndex),c.set(rt,ct))}function Pt(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),h={},d={},et=null,it={},u={},p=new WeakMap,_=[],v=null,g=!1,f=null,T=null,L=null,M=null,b=null,E=null,A=null,x=new Ft(0,0,0),w=0,D=!1,O=null,V=null,H=null,R=null,W=null,ee.set(0,0,i.canvas.width,i.canvas.height),Lt.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:Q,disable:_t,bindFramebuffer:St,drawBuffers:pt,useProgram:Ot,setBlending:Zt,setMaterial:$t,setFlipSided:zt,setCullFace:ie,setLineWidth:ue,setPolygonOffset:me,setScissorTest:re,activeTexture:de,bindTexture:I,unbindTexture:fe,compressedTexImage2D:Xt,compressedTexImage3D:S,texImage2D:k,texImage3D:q,pixelStorei:ht,getParameter:nt,updateUBOMapping:xt,uniformBlockBinding:ut,texStorage2D:lt,texStorage3D:N,texSubImage2D:m,texSubImage3D:F,compressedTexSubImage2D:G,compressedTexSubImage3D:J,scissor:at,viewport:ot,reset:Pt}}function Hg(i,t,e,n,s,r,a){let o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Nt,h=new WeakMap,d=new Set,u,p=new WeakMap,_=!1;try{_=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(S,m){return _?new OffscreenCanvas(S,m):as("canvas")}function g(S,m,F){let G=1,J=Xt(S);if((J.width>F||J.height>F)&&(G=F/Math.max(J.width,J.height)),G<1)if(typeof HTMLImageElement<"u"&&S instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&S instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&S instanceof ImageBitmap||typeof VideoFrame<"u"&&S instanceof VideoFrame){let lt=Math.floor(G*J.width),N=Math.floor(G*J.height);u===void 0&&(u=v(lt,N));let k=m?v(lt,N):u;return k.width=lt,k.height=N,k.getContext("2d").drawImage(S,0,0,lt,N),It("WebGLRenderer: Texture has been resized from ("+J.width+"x"+J.height+") to ("+lt+"x"+N+")."),k}else return"data"in S&&It("WebGLRenderer: Image in DataTexture is too big ("+J.width+"x"+J.height+")."),S;return S}function f(S){return S.generateMipmaps}function T(S){i.generateMipmap(S)}function L(S){return S.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:S.isWebGL3DRenderTarget?i.TEXTURE_3D:S.isWebGLArrayRenderTarget||S.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(S,m,F,G,J,lt=!1){if(S!==null){if(i[S]!==void 0)return i[S];It("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+S+"'")}let N;G&&(N=t.get("EXT_texture_norm16"),N||It("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let k=m;if(m===i.RED&&(F===i.FLOAT&&(k=i.R32F),F===i.HALF_FLOAT&&(k=i.R16F),F===i.UNSIGNED_BYTE&&(k=i.R8),F===i.UNSIGNED_SHORT&&N&&(k=N.R16_EXT),F===i.SHORT&&N&&(k=N.R16_SNORM_EXT)),m===i.RED_INTEGER&&(F===i.UNSIGNED_BYTE&&(k=i.R8UI),F===i.UNSIGNED_SHORT&&(k=i.R16UI),F===i.UNSIGNED_INT&&(k=i.R32UI),F===i.BYTE&&(k=i.R8I),F===i.SHORT&&(k=i.R16I),F===i.INT&&(k=i.R32I)),m===i.RG&&(F===i.FLOAT&&(k=i.RG32F),F===i.HALF_FLOAT&&(k=i.RG16F),F===i.UNSIGNED_BYTE&&(k=i.RG8),F===i.UNSIGNED_SHORT&&N&&(k=N.RG16_EXT),F===i.SHORT&&N&&(k=N.RG16_SNORM_EXT)),m===i.RG_INTEGER&&(F===i.UNSIGNED_BYTE&&(k=i.RG8UI),F===i.UNSIGNED_SHORT&&(k=i.RG16UI),F===i.UNSIGNED_INT&&(k=i.RG32UI),F===i.BYTE&&(k=i.RG8I),F===i.SHORT&&(k=i.RG16I),F===i.INT&&(k=i.RG32I)),m===i.RGB_INTEGER&&(F===i.UNSIGNED_BYTE&&(k=i.RGB8UI),F===i.UNSIGNED_SHORT&&(k=i.RGB16UI),F===i.UNSIGNED_INT&&(k=i.RGB32UI),F===i.BYTE&&(k=i.RGB8I),F===i.SHORT&&(k=i.RGB16I),F===i.INT&&(k=i.RGB32I)),m===i.RGBA_INTEGER&&(F===i.UNSIGNED_BYTE&&(k=i.RGBA8UI),F===i.UNSIGNED_SHORT&&(k=i.RGBA16UI),F===i.UNSIGNED_INT&&(k=i.RGBA32UI),F===i.BYTE&&(k=i.RGBA8I),F===i.SHORT&&(k=i.RGBA16I),F===i.INT&&(k=i.RGBA32I)),m===i.RGB&&(F===i.UNSIGNED_SHORT&&N&&(k=N.RGB16_EXT),F===i.SHORT&&N&&(k=N.RGB16_SNORM_EXT),F===i.UNSIGNED_INT_5_9_9_9_REV&&(k=i.RGB9_E5),F===i.UNSIGNED_INT_10F_11F_11F_REV&&(k=i.R11F_G11F_B10F)),m===i.RGBA){let q=lt?rs:Yt.getTransfer(J);F===i.FLOAT&&(k=i.RGBA32F),F===i.HALF_FLOAT&&(k=i.RGBA16F),F===i.UNSIGNED_BYTE&&(k=q===Qt?i.SRGB8_ALPHA8:i.RGBA8),F===i.UNSIGNED_SHORT&&N&&(k=N.RGBA16_EXT),F===i.SHORT&&N&&(k=N.RGBA16_SNORM_EXT),F===i.UNSIGNED_SHORT_4_4_4_4&&(k=i.RGBA4),F===i.UNSIGNED_SHORT_5_5_5_1&&(k=i.RGB5_A1)}return(k===i.R16F||k===i.R32F||k===i.RG16F||k===i.RG32F||k===i.RGBA16F||k===i.RGBA32F)&&t.get("EXT_color_buffer_float"),k}function b(S,m){let F;return S?m===null||m===ln||m===Xi?F=i.DEPTH24_STENCIL8:m===cn?F=i.DEPTH32F_STENCIL8:m===Wi&&(F=i.DEPTH24_STENCIL8,It("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):m===null||m===ln||m===Xi?F=i.DEPTH_COMPONENT24:m===cn?F=i.DEPTH_COMPONENT32F:m===Wi&&(F=i.DEPTH_COMPONENT16),F}function E(S,m){return f(S)===!0||S.isFramebufferTexture&&S.minFilter!==Ee&&S.minFilter!==Te?Math.log2(Math.max(m.width,m.height))+1:S.mipmaps!==void 0&&S.mipmaps.length>0?S.mipmaps.length:S.isCompressedTexture&&Array.isArray(S.image)?m.mipmaps.length:1}function A(S){let m=S.target;m.removeEventListener("dispose",A),w(m),m.isVideoTexture&&h.delete(m),m.isHTMLTexture&&d.delete(m)}function x(S){let m=S.target;m.removeEventListener("dispose",x),O(m)}function w(S){let m=n.get(S);if(m.__webglInit===void 0)return;let F=S.source,G=p.get(F);if(G){let J=G[m.__cacheKey];J.usedTimes--,J.usedTimes===0&&D(S),Object.keys(G).length===0&&p.delete(F)}n.remove(S)}function D(S){let m=n.get(S);i.deleteTexture(m.__webglTexture);let F=S.source,G=p.get(F);delete G[m.__cacheKey],a.memory.textures--}function O(S){let m=n.get(S);if(S.depthTexture&&(S.depthTexture.dispose(),n.remove(S.depthTexture)),S.isWebGLCubeRenderTarget)for(let G=0;G<6;G++){if(Array.isArray(m.__webglFramebuffer[G]))for(let J=0;J<m.__webglFramebuffer[G].length;J++)i.deleteFramebuffer(m.__webglFramebuffer[G][J]);else i.deleteFramebuffer(m.__webglFramebuffer[G]);m.__webglDepthbuffer&&i.deleteRenderbuffer(m.__webglDepthbuffer[G])}else{if(Array.isArray(m.__webglFramebuffer))for(let G=0;G<m.__webglFramebuffer.length;G++)i.deleteFramebuffer(m.__webglFramebuffer[G]);else i.deleteFramebuffer(m.__webglFramebuffer);if(m.__webglDepthbuffer&&i.deleteRenderbuffer(m.__webglDepthbuffer),m.__webglMultisampledFramebuffer&&i.deleteFramebuffer(m.__webglMultisampledFramebuffer),m.__webglColorRenderbuffer)for(let G=0;G<m.__webglColorRenderbuffer.length;G++)m.__webglColorRenderbuffer[G]&&i.deleteRenderbuffer(m.__webglColorRenderbuffer[G]);m.__webglDepthRenderbuffer&&i.deleteRenderbuffer(m.__webglDepthRenderbuffer)}let F=S.textures;for(let G=0,J=F.length;G<J;G++){let lt=n.get(F[G]);lt.__webglTexture&&(i.deleteTexture(lt.__webglTexture),a.memory.textures--),n.remove(F[G])}n.remove(S)}let V=0;function H(){V=0}function R(){return V}function W(S){V=S}function $(){let S=V;return S>=s.maxTextures&&It("WebGLTextures: Trying to use "+(S+1)+" texture units while this GPU supports only "+s.maxTextures),V+=1,S}function K(S){let m=[];return m.push(S.wrapS),m.push(S.wrapT),m.push(S.wrapR||0),m.push(S.magFilter),m.push(S.minFilter),m.push(S.anisotropy),m.push(S.internalFormat),m.push(S.format),m.push(S.type),m.push(S.generateMipmaps),m.push(S.premultiplyAlpha),m.push(S.flipY),m.push(S.unpackAlignment),m.push(S.colorSpace),m.join()}function st(S,m){let F=n.get(S);if(S.isVideoTexture&&I(S),S.isRenderTargetTexture===!1&&S.isExternalTexture!==!0&&S.version>0&&F.__version!==S.version){let G=S.image;if(G===null)It("WebGLRenderer: Texture marked for update but no image data found.");else if(G.complete===!1)It("WebGLRenderer: Texture marked for update but image is incomplete");else{_t(F,S,m);return}}else S.isExternalTexture&&(F.__webglTexture=S.sourceTexture?S.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,F.__webglTexture,i.TEXTURE0+m)}function Y(S,m){let F=n.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&F.__version!==S.version){_t(F,S,m);return}else S.isExternalTexture&&(F.__webglTexture=S.sourceTexture?S.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,F.__webglTexture,i.TEXTURE0+m)}function et(S,m){let F=n.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&F.__version!==S.version){_t(F,S,m);return}e.bindTexture(i.TEXTURE_3D,F.__webglTexture,i.TEXTURE0+m)}function it(S,m){let F=n.get(S);if(S.isCubeDepthTexture!==!0&&S.version>0&&F.__version!==S.version){St(F,S,m);return}e.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+m)}let Ct={[br]:i.REPEAT,[fn]:i.CLAMP_TO_EDGE,[Er]:i.MIRRORED_REPEAT},Et={[Ee]:i.NEAREST,[Gc]:i.NEAREST_MIPMAP_NEAREST,[As]:i.NEAREST_MIPMAP_LINEAR,[Te]:i.LINEAR,[ta]:i.LINEAR_MIPMAP_NEAREST,[$n]:i.LINEAR_MIPMAP_LINEAR},ee={[qc]:i.NEVER,[Kc]:i.ALWAYS,[Yc]:i.LESS,[Ba]:i.LEQUAL,[Zc]:i.EQUAL,[za]:i.GEQUAL,[Jc]:i.GREATER,[$c]:i.NOTEQUAL};function Lt(S,m){if(m.type===cn&&t.has("OES_texture_float_linear")===!1&&(m.magFilter===Te||m.magFilter===ta||m.magFilter===As||m.magFilter===$n||m.minFilter===Te||m.minFilter===ta||m.minFilter===As||m.minFilter===$n)&&It("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(S,i.TEXTURE_WRAP_S,Ct[m.wrapS]),i.texParameteri(S,i.TEXTURE_WRAP_T,Ct[m.wrapT]),(S===i.TEXTURE_3D||S===i.TEXTURE_2D_ARRAY)&&i.texParameteri(S,i.TEXTURE_WRAP_R,Ct[m.wrapR]),i.texParameteri(S,i.TEXTURE_MAG_FILTER,Et[m.magFilter]),i.texParameteri(S,i.TEXTURE_MIN_FILTER,Et[m.minFilter]),m.compareFunction&&(i.texParameteri(S,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(S,i.TEXTURE_COMPARE_FUNC,ee[m.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(m.magFilter===Ee||m.minFilter!==As&&m.minFilter!==$n||m.type===cn&&t.has("OES_texture_float_linear")===!1)return;if(m.anisotropy>1||n.get(m).__currentAnisotropy){let F=t.get("EXT_texture_filter_anisotropic");i.texParameterf(S,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(m.anisotropy,s.getMaxAnisotropy())),n.get(m).__currentAnisotropy=m.anisotropy}}}function Wt(S,m){let F=!1;S.__webglInit===void 0&&(S.__webglInit=!0,m.addEventListener("dispose",A));let G=m.source,J=p.get(G);J===void 0&&(J={},p.set(G,J));let lt=K(m);if(lt!==S.__cacheKey){J[lt]===void 0&&(J[lt]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,F=!0),J[lt].usedTimes++;let N=J[S.__cacheKey];N!==void 0&&(J[S.__cacheKey].usedTimes--,N.usedTimes===0&&D(m)),S.__cacheKey=lt,S.__webglTexture=J[lt].texture}return F}function j(S,m,F){return Math.floor(Math.floor(S/F)/m)}function Q(S,m,F,G){let lt=S.updateRanges;if(lt.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,m.width,m.height,F,G,m.data);else{lt.sort((ht,at)=>ht.start-at.start);let N=0;for(let ht=1;ht<lt.length;ht++){let at=lt[N],ot=lt[ht],xt=at.start+at.count,ut=j(ot.start,m.width,4),Pt=j(at.start,m.width,4);ot.start<=xt+1&&ut===Pt&&j(ot.start+ot.count-1,m.width,4)===ut?at.count=Math.max(at.count,ot.start+ot.count-at.start):(++N,lt[N]=ot)}lt.length=N+1;let k=e.getParameter(i.UNPACK_ROW_LENGTH),q=e.getParameter(i.UNPACK_SKIP_PIXELS),nt=e.getParameter(i.UNPACK_SKIP_ROWS);e.pixelStorei(i.UNPACK_ROW_LENGTH,m.width);for(let ht=0,at=lt.length;ht<at;ht++){let ot=lt[ht],xt=Math.floor(ot.start/4),ut=Math.ceil(ot.count/4),Pt=xt%m.width,C=Math.floor(xt/m.width),rt=ut,Z=1;e.pixelStorei(i.UNPACK_SKIP_PIXELS,Pt),e.pixelStorei(i.UNPACK_SKIP_ROWS,C),e.texSubImage2D(i.TEXTURE_2D,0,Pt,C,rt,Z,F,G,m.data)}S.clearUpdateRanges(),e.pixelStorei(i.UNPACK_ROW_LENGTH,k),e.pixelStorei(i.UNPACK_SKIP_PIXELS,q),e.pixelStorei(i.UNPACK_SKIP_ROWS,nt)}}function _t(S,m,F){let G=i.TEXTURE_2D;(m.isDataArrayTexture||m.isCompressedArrayTexture)&&(G=i.TEXTURE_2D_ARRAY),m.isData3DTexture&&(G=i.TEXTURE_3D);let J=Wt(S,m),lt=m.source;e.bindTexture(G,S.__webglTexture,i.TEXTURE0+F);let N=n.get(lt);if(lt.version!==N.__version||J===!0){if(e.activeTexture(i.TEXTURE0+F),(typeof ImageBitmap<"u"&&m.image instanceof ImageBitmap)===!1){let Z=Yt.getPrimaries(Yt.workingColorSpace),ct=m.colorSpace===Pn?null:Yt.getPrimaries(m.colorSpace),dt=m.colorSpace===Pn||Z===ct?i.NONE:i.BROWSER_DEFAULT_WEBGL;e.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,m.flipY),e.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,m.premultiplyAlpha),e.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,dt)}e.pixelStorei(i.UNPACK_ALIGNMENT,m.unpackAlignment);let q=g(m.image,!1,s.maxTextureSize);q=fe(m,q);let nt=r.convert(m.format,m.colorSpace),ht=r.convert(m.type),at=M(m.internalFormat,nt,ht,m.normalized,m.colorSpace,m.isVideoTexture);Lt(G,m);let ot,xt=m.mipmaps,ut=m.isVideoTexture!==!0,Pt=N.__version===void 0||J===!0,C=lt.dataReady,rt=E(m,q);if(m.isDepthTexture)at=b(m.format===Kn,m.type),Pt&&(ut?e.texStorage2D(i.TEXTURE_2D,1,at,q.width,q.height):e.texImage2D(i.TEXTURE_2D,0,at,q.width,q.height,0,nt,ht,null));else if(m.isDataTexture)if(xt.length>0){ut&&Pt&&e.texStorage2D(i.TEXTURE_2D,rt,at,xt[0].width,xt[0].height);for(let Z=0,ct=xt.length;Z<ct;Z++)ot=xt[Z],ut?C&&e.texSubImage2D(i.TEXTURE_2D,Z,0,0,ot.width,ot.height,nt,ht,ot.data):e.texImage2D(i.TEXTURE_2D,Z,at,ot.width,ot.height,0,nt,ht,ot.data);m.generateMipmaps=!1}else ut?(Pt&&e.texStorage2D(i.TEXTURE_2D,rt,at,q.width,q.height),C&&Q(m,q,nt,ht)):e.texImage2D(i.TEXTURE_2D,0,at,q.width,q.height,0,nt,ht,q.data);else if(m.isCompressedTexture)if(m.isCompressedArrayTexture){ut&&Pt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,rt,at,xt[0].width,xt[0].height,q.depth);for(let Z=0,ct=xt.length;Z<ct;Z++)if(ot=xt[Z],m.format!==tn)if(nt!==null)if(ut){if(C)if(m.layerUpdates.size>0){let dt=al(ot.width,ot.height,m.format,m.type);for(let tt of m.layerUpdates){let wt=ot.data.subarray(tt*dt/ot.data.BYTES_PER_ELEMENT,(tt+1)*dt/ot.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,tt,ot.width,ot.height,1,nt,wt)}}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,0,ot.width,ot.height,q.depth,nt,ot.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,Z,at,ot.width,ot.height,q.depth,0,ot.data,0,0);else It("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ut?C&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,0,ot.width,ot.height,q.depth,nt,ht,ot.data):e.texImage3D(i.TEXTURE_2D_ARRAY,Z,at,ot.width,ot.height,q.depth,0,nt,ht,ot.data);m.layerUpdates.size>0&&m.clearLayerUpdates()}else{ut&&Pt&&e.texStorage2D(i.TEXTURE_2D,rt,at,xt[0].width,xt[0].height);for(let Z=0,ct=xt.length;Z<ct;Z++)ot=xt[Z],m.format!==tn?nt!==null?ut?C&&e.compressedTexSubImage2D(i.TEXTURE_2D,Z,0,0,ot.width,ot.height,nt,ot.data):e.compressedTexImage2D(i.TEXTURE_2D,Z,at,ot.width,ot.height,0,ot.data):It("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ut?C&&e.texSubImage2D(i.TEXTURE_2D,Z,0,0,ot.width,ot.height,nt,ht,ot.data):e.texImage2D(i.TEXTURE_2D,Z,at,ot.width,ot.height,0,nt,ht,ot.data)}else if(m.isDataArrayTexture)if(ut){if(Pt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,rt,at,q.width,q.height,q.depth),C)if(m.layerUpdates.size>0){let Z=al(q.width,q.height,m.format,m.type);for(let ct of m.layerUpdates){let dt=q.data.subarray(ct*Z/q.data.BYTES_PER_ELEMENT,(ct+1)*Z/q.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ct,q.width,q.height,1,nt,ht,dt)}m.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,q.width,q.height,q.depth,nt,ht,q.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,at,q.width,q.height,q.depth,0,nt,ht,q.data);else if(m.isData3DTexture)ut?(Pt&&e.texStorage3D(i.TEXTURE_3D,rt,at,q.width,q.height,q.depth),C&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,q.width,q.height,q.depth,nt,ht,q.data)):e.texImage3D(i.TEXTURE_3D,0,at,q.width,q.height,q.depth,0,nt,ht,q.data);else if(m.isFramebufferTexture){if(Pt)if(ut)e.texStorage2D(i.TEXTURE_2D,rt,at,q.width,q.height);else{let Z=q.width,ct=q.height;for(let dt=0;dt<rt;dt++)e.texImage2D(i.TEXTURE_2D,dt,at,Z,ct,0,nt,ht,null),Z>>=1,ct>>=1}}else if(m.isHTMLTexture){if("texElementImage2D"in i){let Z=i.canvas;if(Z.hasAttribute("layoutsubtree")||Z.setAttribute("layoutsubtree","true"),q.parentNode!==Z){Z.appendChild(q),d.add(m),Z.onpaint=ct=>{let dt=ct.changedElements;for(let tt of d)dt.includes(tt.image)&&(tt.needsUpdate=!0)},Z.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,q);else{let dt=i.RGBA,tt=i.RGBA,wt=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,dt,tt,wt,q)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(xt.length>0){if(ut&&Pt){let Z=Xt(xt[0]);e.texStorage2D(i.TEXTURE_2D,rt,at,Z.width,Z.height)}for(let Z=0,ct=xt.length;Z<ct;Z++)ot=xt[Z],ut?C&&e.texSubImage2D(i.TEXTURE_2D,Z,0,0,nt,ht,ot):e.texImage2D(i.TEXTURE_2D,Z,at,nt,ht,ot);m.generateMipmaps=!1}else if(ut){if(Pt){let Z=Xt(q);e.texStorage2D(i.TEXTURE_2D,rt,at,Z.width,Z.height)}C&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,nt,ht,q)}else e.texImage2D(i.TEXTURE_2D,0,at,nt,ht,q);f(m)&&T(G),N.__version=lt.version,m.onUpdate&&m.onUpdate(m)}S.__version=m.version}function St(S,m,F){if(m.image.length!==6)return;let G=Wt(S,m),J=m.source;e.bindTexture(i.TEXTURE_CUBE_MAP,S.__webglTexture,i.TEXTURE0+F);let lt=n.get(J);if(J.version!==lt.__version||G===!0){e.activeTexture(i.TEXTURE0+F);let N=Yt.getPrimaries(Yt.workingColorSpace),k=m.colorSpace===Pn?null:Yt.getPrimaries(m.colorSpace),q=m.colorSpace===Pn||N===k?i.NONE:i.BROWSER_DEFAULT_WEBGL;e.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,m.flipY),e.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,m.premultiplyAlpha),e.pixelStorei(i.UNPACK_ALIGNMENT,m.unpackAlignment),e.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,q);let nt=m.isCompressedTexture||m.image[0].isCompressedTexture,ht=m.image[0]&&m.image[0].isDataTexture,at=[];for(let tt=0;tt<6;tt++)!nt&&!ht?at[tt]=g(m.image[tt],!0,s.maxCubemapSize):at[tt]=ht?m.image[tt].image:m.image[tt],at[tt]=fe(m,at[tt]);let ot=at[0],xt=r.convert(m.format,m.colorSpace),ut=r.convert(m.type),Pt=M(m.internalFormat,xt,ut,m.normalized,m.colorSpace),C=m.isVideoTexture!==!0,rt=lt.__version===void 0||G===!0,Z=J.dataReady,ct=E(m,ot);Lt(i.TEXTURE_CUBE_MAP,m);let dt;if(nt){C&&rt&&e.texStorage2D(i.TEXTURE_CUBE_MAP,ct,Pt,ot.width,ot.height);for(let tt=0;tt<6;tt++){dt=at[tt].mipmaps;for(let wt=0;wt<dt.length;wt++){let bt=dt[wt];m.format!==tn?xt!==null?C?Z&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt,0,0,bt.width,bt.height,xt,bt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt,Pt,bt.width,bt.height,0,bt.data):It("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):C?Z&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt,0,0,bt.width,bt.height,xt,ut,bt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt,Pt,bt.width,bt.height,0,xt,ut,bt.data)}}}else{if(dt=m.mipmaps,C&&rt){dt.length>0&&ct++;let tt=Xt(at[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,ct,Pt,tt.width,tt.height)}for(let tt=0;tt<6;tt++)if(ht){C?Z&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,at[tt].width,at[tt].height,xt,ut,at[tt].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,Pt,at[tt].width,at[tt].height,0,xt,ut,at[tt].data);for(let wt=0;wt<dt.length;wt++){let yt=dt[wt].image[tt].image;C?Z&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt+1,0,0,yt.width,yt.height,xt,ut,yt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt+1,Pt,yt.width,yt.height,0,xt,ut,yt.data)}}else{C?Z&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,xt,ut,at[tt]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,Pt,xt,ut,at[tt]);for(let wt=0;wt<dt.length;wt++){let bt=dt[wt];C?Z&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt+1,0,0,xt,ut,bt.image[tt]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt+1,Pt,xt,ut,bt.image[tt])}}}f(m)&&T(i.TEXTURE_CUBE_MAP),lt.__version=J.version,m.onUpdate&&m.onUpdate(m)}S.__version=m.version}function pt(S,m,F,G,J,lt){let N=r.convert(F.format,F.colorSpace),k=r.convert(F.type),q=M(F.internalFormat,N,k,F.normalized,F.colorSpace),nt=n.get(m),ht=n.get(F);if(ht.__renderTarget=m,!nt.__hasExternalTextures){let at=Math.max(1,m.width>>lt),ot=Math.max(1,m.height>>lt);J===i.TEXTURE_3D||J===i.TEXTURE_2D_ARRAY?e.texImage3D(J,lt,q,at,ot,m.depth,0,N,k,null):e.texImage2D(J,lt,q,at,ot,0,N,k,null)}e.bindFramebuffer(i.FRAMEBUFFER,S),de(m)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,G,J,ht.__webglTexture,0,re(m)):(J===i.TEXTURE_2D||J>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&J<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,G,J,ht.__webglTexture,lt),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Ot(S,m,F){if(i.bindRenderbuffer(i.RENDERBUFFER,S),m.depthBuffer){let G=m.depthTexture,J=G&&G.isDepthTexture?G.type:null,lt=b(m.stencilBuffer,J),N=m.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;de(m)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,re(m),lt,m.width,m.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,re(m),lt,m.width,m.height):i.renderbufferStorage(i.RENDERBUFFER,lt,m.width,m.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,N,i.RENDERBUFFER,S)}else{let G=m.textures;for(let J=0;J<G.length;J++){let lt=G[J],N=r.convert(lt.format,lt.colorSpace),k=r.convert(lt.type),q=M(lt.internalFormat,N,k,lt.normalized,lt.colorSpace);de(m)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,re(m),q,m.width,m.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,re(m),q,m.width,m.height):i.renderbufferStorage(i.RENDERBUFFER,q,m.width,m.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function pe(S,m,F){let G=m.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(i.FRAMEBUFFER,S),!(m.depthTexture&&m.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let J=n.get(m.depthTexture);if(J.__renderTarget=m,(!J.__webglTexture||m.depthTexture.image.width!==m.width||m.depthTexture.image.height!==m.height)&&(m.depthTexture.image.width=m.width,m.depthTexture.image.height=m.height,m.depthTexture.needsUpdate=!0),G){if(J.__webglInit===void 0&&(J.__webglInit=!0,m.depthTexture.addEventListener("dispose",A)),J.__webglTexture===void 0){J.__webglTexture=i.createTexture(),e.bindTexture(i.TEXTURE_CUBE_MAP,J.__webglTexture),Lt(i.TEXTURE_CUBE_MAP,m.depthTexture);let nt=r.convert(m.depthTexture.format),ht=r.convert(m.depthTexture.type),at;m.depthTexture.format===pn?at=i.DEPTH_COMPONENT24:m.depthTexture.format===Kn&&(at=i.DEPTH24_STENCIL8);for(let ot=0;ot<6;ot++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,at,m.width,m.height,0,nt,ht,null)}}else st(m.depthTexture,0);let lt=J.__webglTexture,N=re(m),k=G?i.TEXTURE_CUBE_MAP_POSITIVE_X+F:i.TEXTURE_2D,q=m.depthTexture.format===Kn?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(m.depthTexture.format===pn)de(m)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,q,k,lt,0,N):i.framebufferTexture2D(i.FRAMEBUFFER,q,k,lt,0);else if(m.depthTexture.format===Kn)de(m)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,q,k,lt,0,N):i.framebufferTexture2D(i.FRAMEBUFFER,q,k,lt,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Bt(S){let m=n.get(S),F=S.isWebGLCubeRenderTarget===!0;if(m.__boundDepthTexture!==S.depthTexture){let G=S.depthTexture;if(m.__depthDisposeCallback&&m.__depthDisposeCallback(),G){let J=()=>{delete m.__boundDepthTexture,delete m.__depthDisposeCallback,G.removeEventListener("dispose",J)};G.addEventListener("dispose",J),m.__depthDisposeCallback=J}m.__boundDepthTexture=G}if(S.depthTexture&&!m.__autoAllocateDepthBuffer)if(F)for(let G=0;G<6;G++)pe(m.__webglFramebuffer[G],S,G);else{let G=S.texture.mipmaps;G&&G.length>0?pe(m.__webglFramebuffer[0],S,0):pe(m.__webglFramebuffer,S,0)}else if(F){m.__webglDepthbuffer=[];for(let G=0;G<6;G++)if(e.bindFramebuffer(i.FRAMEBUFFER,m.__webglFramebuffer[G]),m.__webglDepthbuffer[G]===void 0)m.__webglDepthbuffer[G]=i.createRenderbuffer(),Ot(m.__webglDepthbuffer[G],S,!1);else{let J=S.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,lt=m.__webglDepthbuffer[G];i.bindRenderbuffer(i.RENDERBUFFER,lt),i.framebufferRenderbuffer(i.FRAMEBUFFER,J,i.RENDERBUFFER,lt)}}else{let G=S.texture.mipmaps;if(G&&G.length>0?e.bindFramebuffer(i.FRAMEBUFFER,m.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,m.__webglFramebuffer),m.__webglDepthbuffer===void 0)m.__webglDepthbuffer=i.createRenderbuffer(),Ot(m.__webglDepthbuffer,S,!1);else{let J=S.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,lt=m.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,lt),i.framebufferRenderbuffer(i.FRAMEBUFFER,J,i.RENDERBUFFER,lt)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Zt(S,m,F){let G=n.get(S);m!==void 0&&pt(G.__webglFramebuffer,S,S.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),F!==void 0&&Bt(S)}function $t(S){let m=S.texture,F=n.get(S),G=n.get(m);S.addEventListener("dispose",x);let J=S.textures,lt=S.isWebGLCubeRenderTarget===!0,N=J.length>1;if(N||(G.__webglTexture===void 0&&(G.__webglTexture=i.createTexture()),G.__version=m.version,a.memory.textures++),lt){F.__webglFramebuffer=[];for(let k=0;k<6;k++)if(m.mipmaps&&m.mipmaps.length>0){F.__webglFramebuffer[k]=[];for(let q=0;q<m.mipmaps.length;q++)F.__webglFramebuffer[k][q]=i.createFramebuffer()}else F.__webglFramebuffer[k]=i.createFramebuffer()}else{if(m.mipmaps&&m.mipmaps.length>0){F.__webglFramebuffer=[];for(let k=0;k<m.mipmaps.length;k++)F.__webglFramebuffer[k]=i.createFramebuffer()}else F.__webglFramebuffer=i.createFramebuffer();if(N)for(let k=0,q=J.length;k<q;k++){let nt=n.get(J[k]);nt.__webglTexture===void 0&&(nt.__webglTexture=i.createTexture(),a.memory.textures++)}if(S.samples>0&&de(S)===!1){F.__webglMultisampledFramebuffer=i.createFramebuffer(),F.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let k=0;k<J.length;k++){let q=J[k];F.__webglColorRenderbuffer[k]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,F.__webglColorRenderbuffer[k]);let nt=r.convert(q.format,q.colorSpace),ht=r.convert(q.type),at=M(q.internalFormat,nt,ht,q.normalized,q.colorSpace,S.isXRRenderTarget===!0),ot=re(S);i.renderbufferStorageMultisample(i.RENDERBUFFER,ot,at,S.width,S.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+k,i.RENDERBUFFER,F.__webglColorRenderbuffer[k])}i.bindRenderbuffer(i.RENDERBUFFER,null),S.depthBuffer&&(F.__webglDepthRenderbuffer=i.createRenderbuffer(),Ot(F.__webglDepthRenderbuffer,S,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(lt){e.bindTexture(i.TEXTURE_CUBE_MAP,G.__webglTexture),Lt(i.TEXTURE_CUBE_MAP,m);for(let k=0;k<6;k++)if(m.mipmaps&&m.mipmaps.length>0)for(let q=0;q<m.mipmaps.length;q++)pt(F.__webglFramebuffer[k][q],S,m,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+k,q);else pt(F.__webglFramebuffer[k],S,m,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+k,0);f(m)&&T(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(N){for(let k=0,q=J.length;k<q;k++){let nt=J[k],ht=n.get(nt),at=i.TEXTURE_2D;(S.isWebGL3DRenderTarget||S.isWebGLArrayRenderTarget)&&(at=S.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(at,ht.__webglTexture),Lt(at,nt),pt(F.__webglFramebuffer,S,nt,i.COLOR_ATTACHMENT0+k,at,0),f(nt)&&T(at)}e.unbindTexture()}else{let k=i.TEXTURE_2D;if((S.isWebGL3DRenderTarget||S.isWebGLArrayRenderTarget)&&(k=S.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(k,G.__webglTexture),Lt(k,m),m.mipmaps&&m.mipmaps.length>0)for(let q=0;q<m.mipmaps.length;q++)pt(F.__webglFramebuffer[q],S,m,i.COLOR_ATTACHMENT0,k,q);else pt(F.__webglFramebuffer,S,m,i.COLOR_ATTACHMENT0,k,0);f(m)&&T(k),e.unbindTexture()}S.depthBuffer&&Bt(S)}function zt(S){let m=S.textures;for(let F=0,G=m.length;F<G;F++){let J=m[F];if(f(J)){let lt=L(S),N=n.get(J).__webglTexture;e.bindTexture(lt,N),T(lt),e.unbindTexture()}}}let ie=[],ue=[];function me(S){if(S.samples>0){if(de(S)===!1){let m=S.textures,F=S.width,G=S.height,J=i.COLOR_BUFFER_BIT,lt=S.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,N=n.get(S),k=m.length>1;if(k)for(let nt=0;nt<m.length;nt++)e.bindFramebuffer(i.FRAMEBUFFER,N.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+nt,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,N.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+nt,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,N.__webglMultisampledFramebuffer);let q=S.texture.mipmaps;q&&q.length>0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,N.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,N.__webglFramebuffer);for(let nt=0;nt<m.length;nt++){if(S.resolveDepthBuffer&&(S.depthBuffer&&(J|=i.DEPTH_BUFFER_BIT),S.stencilBuffer&&S.resolveStencilBuffer&&(J|=i.STENCIL_BUFFER_BIT)),k){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,N.__webglColorRenderbuffer[nt]);let ht=n.get(m[nt]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,ht,0)}i.blitFramebuffer(0,0,F,G,0,0,F,G,J,i.NEAREST),c===!0&&(ie.length=0,ue.length=0,ie.push(i.COLOR_ATTACHMENT0+nt),S.depthBuffer&&S.storeMultisampledDepthBuffer===!1&&(ie.push(lt),ue.push(lt),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,ue)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,ie))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),k)for(let nt=0;nt<m.length;nt++){e.bindFramebuffer(i.FRAMEBUFFER,N.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+nt,i.RENDERBUFFER,N.__webglColorRenderbuffer[nt]);let ht=n.get(m[nt]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,N.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+nt,i.TEXTURE_2D,ht,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,N.__webglMultisampledFramebuffer)}else if(S.depthBuffer&&S.storeMultisampledDepthBuffer===!1&&c){let m=S.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[m])}}}function re(S){return Math.min(s.maxSamples,S.samples)}function de(S){let m=n.get(S);return S.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&m.__useRenderToTexture!==!1}function I(S){let m=a.render.frame;h.get(S)!==m&&(h.set(S,m),S.update())}function fe(S,m){let F=S.colorSpace,G=S.format,J=S.type;return S.isCompressedTexture===!0||S.isVideoTexture===!0||F!==ss&&F!==Pn&&(Yt.getTransfer(F)===Qt?(G!==tn||J!==Ge)&&It("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Dt("WebGLTextures: Unsupported texture color space:",F)),m}function Xt(S){return typeof HTMLImageElement<"u"&&S instanceof HTMLImageElement?(l.width=S.naturalWidth||S.width,l.height=S.naturalHeight||S.height):typeof VideoFrame<"u"&&S instanceof VideoFrame?(l.width=S.displayWidth,l.height=S.displayHeight):(l.width=S.width,l.height=S.height),l}this.allocateTextureUnit=$,this.resetTextureUnits=H,this.getTextureUnits=R,this.setTextureUnits=W,this.setTexture2D=st,this.setTexture2DArray=Y,this.setTexture3D=et,this.setTextureCube=it,this.rebindTextures=Zt,this.setupRenderTarget=$t,this.updateRenderTargetMipmap=zt,this.updateMultisampleRenderTarget=me,this.setupDepthRenderbuffer=Bt,this.setupFrameBufferTexture=pt,this.useMultisampledRTT=de,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function Wg(i,t){function e(n,s=Pn){let r,a=Yt.getTransfer(s);if(n===Ge)return i.UNSIGNED_BYTE;if(n===na)return i.UNSIGNED_SHORT_4_4_4_4;if(n===ia)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Zo)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Jo)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===qo)return i.BYTE;if(n===Yo)return i.SHORT;if(n===Wi)return i.UNSIGNED_SHORT;if(n===ea)return i.INT;if(n===ln)return i.UNSIGNED_INT;if(n===cn)return i.FLOAT;if(n===hn)return i.HALF_FLOAT;if(n===$o)return i.ALPHA;if(n===Ko)return i.RGB;if(n===tn)return i.RGBA;if(n===pn)return i.DEPTH_COMPONENT;if(n===Kn)return i.DEPTH_STENCIL;if(n===jo)return i.RED;if(n===sa)return i.RED_INTEGER;if(n===jn)return i.RG;if(n===ra)return i.RG_INTEGER;if(n===aa)return i.RGBA_INTEGER;if(n===Cs||n===Rs||n===Ps||n===Is)if(a===Qt)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Cs)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Rs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ps)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Is)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Cs)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Rs)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ps)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Is)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===oa||n===la||n===ca||n===ha)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===oa)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===la)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ca)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===ha)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ua||n===da||n===fa||n===pa||n===ma||n===Ls||n===ga)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===ua||n===da)return a===Qt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===fa)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===pa)return r.COMPRESSED_R11_EAC;if(n===ma)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Ls)return r.COMPRESSED_RG11_EAC;if(n===ga)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===_a||n===xa||n===ya||n===va||n===Ma||n===Sa||n===ba||n===Ea||n===wa||n===Ta||n===Aa||n===Ca||n===Ra||n===Pa)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===_a)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===xa)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ya)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===va)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ma)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Sa)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===ba)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ea)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===wa)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Ta)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Aa)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ca)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ra)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Pa)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Ia||n===La||n===Da)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===Ia)return a===Qt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===La)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Da)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Na||n===Ua||n===Ds||n===Fa)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===Na)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Ua)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ds)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Fa)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Xi?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}var Xg=`
|
|
4201
|
+
}`,n_=[new B(1,0,0),new B(-1,0,0),new B(0,1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1)],i_=[new B(0,-1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1),new B(0,-1,0),new B(0,-1,0)],zh=new ht,Xs=new B,Al=new B;function s_(i,e,t){let n=new Qn,s=new Fe,r=new Fe,a=new dt,o=new Jr,c=new Kr,l={},h=t.maxTextureSize,d={[ri]:Vt,[Vt]:ri,[bn]:bn},u=new Mn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Fe},radius:{value:4}},vertexShader:e_,fragmentShader:t_}),m=u.clone();m.defines.HORIZONTAL_PASS=1;let _=new Wt;_.setAttribute("position",new Gt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new en(_,u),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Fs;let f=this.type;this.render=function(w,g,M){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||w.length===0)return;this.type===Lc&&(Ie("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Fs);let U=i.getRenderTarget(),I=i.getActiveCubeFace(),D=i.getActiveMipmapLevel(),F=i.state;F.setBlending(vi),F.buffers.depth.getReversed()===!0?F.buffers.color.setClear(0,0,0,0):F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);let H=f!==this.type;H&&g.traverse(function(C){C.material&&(Array.isArray(C.material)?C.material.forEach(Y=>Y.needsUpdate=!0):C.material.needsUpdate=!0)});for(let C=0,Y=w.length;C<Y;C++){let J=w[C],z=J.shadow;if(z===void 0){Ie("WebGLShadowMap:",J,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;s.copy(z.mapSize);let te=z.getFrameExtents();s.multiply(te),r.copy(z.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/te.x),s.x=r.x*te.x,z.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/te.y),s.y=r.y*te.y,z.mapSize.y=r.y));let W=i.state.buffers.depth.getReversed();if(z.camera._reversedDepth=W,z.map===null||H===!0){if(z.map!==null&&(z.map.depthTexture!==null&&(z.map.depthTexture.dispose(),z.map.depthTexture=null),z.map.dispose()),this.type===es){if(J.isPointLight){Ie("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}z.map=new Qt(s.x,s.y,{format:ai,type:mn,minFilter:kt,magFilter:kt,generateMipmaps:!1}),z.map.texture.name=J.name+".shadowMap",z.map.depthTexture=new Vn(s.x,s.y,pn),z.map.depthTexture.name=J.name+".shadowMapDepth",z.map.depthTexture.format=Bn,z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Et,z.map.depthTexture.magFilter=Et}else J.isPointLight?(z.map=new Ys(s.x),z.map.depthTexture=new As(s.x,fn)):(z.map=new Qt(s.x,s.y),z.map.depthTexture=new Vn(s.x,s.y,fn)),z.map.depthTexture.name=J.name+".shadowMap",z.map.depthTexture.format=Bn,this.type===Fs?(z.map.depthTexture.compareFunction=W?cl:ll,z.map.depthTexture.minFilter=kt,z.map.depthTexture.magFilter=kt):(z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Et,z.map.depthTexture.magFilter=Et);z.camera.updateProjectionMatrix()}z.map.isWebGLCubeRenderTarget!==!0&&(z.map.width!==s.x||z.map.height!==s.y)&&z.map.setSize(s.x,s.y);let $=z.map.isWebGLCubeRenderTarget?6:z.getViewportCount();J.isPointLight!==!0&&z.updateMatrices(J,M);let ae=(z.camera.layers.mask&4294967294)!==0?z.camera.layers:M.layers;for(let _e=0;_e<$;_e++){let De=z.getCamera(_e);if(J.isPointLight){let j=z.camera,pe=z.matrix,ye=J.distance||j.far;ye!==j.far&&(j.far=ye,j.updateProjectionMatrix()),Xs.setFromMatrixPosition(J.matrixWorld),j.position.copy(Xs),Al.copy(j.position),Al.add(n_[_e]),j.up.copy(i_[_e]),j.lookAt(Al),j.updateMatrixWorld(),pe.makeTranslation(-Xs.x,-Xs.y,-Xs.z),zh.multiplyMatrices(j.projectionMatrix,j.matrixWorldInverse),z._frustum.setFromProjectionMatrix(zh,j.coordinateSystem,j.reversedDepth)}if(z.map.isWebGLCubeRenderTarget)i.setRenderTarget(z.map,_e),i.clear();else{_e===0&&(i.setRenderTarget(z.map),i.clear());let j=z.getViewport(_e);a.set(r.x*j.x,r.y*j.y,r.x*j.z,r.y*j.w),F.viewport(a)}n=z.getFrustum(_e),b(g,M,De,J,ae,this.type)}z.isPointLightShadow!==!0&&this.type===es&&S(z,M),z.needsUpdate=!1}f=this.type,p.needsUpdate=!1,i.setRenderTarget(U,I,D)};function S(w,g){let M=e.update(y);u.defines.VSM_SAMPLES!==w.blurSamples&&(u.defines.VSM_SAMPLES=w.blurSamples,m.defines.VSM_SAMPLES=w.blurSamples,u.needsUpdate=!0,m.needsUpdate=!0),w.mapPass===null?w.mapPass=new Qt(s.x,s.y,{format:ai,type:mn}):(w.mapPass.width!==w.map.width||w.mapPass.height!==w.map.height)&&w.mapPass.setSize(w.map.width,w.map.height),u.uniforms.shadow_pass.value=w.map.depthTexture,u.uniforms.resolution.value.set(w.map.width,w.map.height),u.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(g,null,M,u,y,null),m.uniforms.shadow_pass.value=w.mapPass.texture,m.uniforms.resolution.value.set(w.map.width,w.map.height),m.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(g,null,M,m,y,null)}function A(w,g,M,U){let I=null,D=M.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(D!==void 0)I=D;else if(I=M.isPointLight===!0?c:o,i.localClippingEnabled&&g.clipShadows===!0&&Array.isArray(g.clippingPlanes)&&g.clippingPlanes.length!==0||g.displacementMap&&g.displacementScale!==0||g.alphaMap&&g.alphaTest>0||g.map&&g.alphaTest>0||g.alphaToCoverage===!0){let F=I.uuid,H=g.uuid,C=l[F];C===void 0&&(C={},l[F]=C);let Y=C[H];Y===void 0&&(Y=I.clone(),C[H]=Y,g.addEventListener("dispose",T)),I=Y}if(I.visible=g.visible,I.wireframe=g.wireframe,U===es?I.side=g.shadowSide!==null?g.shadowSide:g.side:I.side=g.shadowSide!==null?g.shadowSide:d[g.side],I.alphaMap=g.alphaMap,I.alphaTest=g.alphaToCoverage===!0?.5:g.alphaTest,I.map=g.map,I.clipShadows=g.clipShadows,I.clippingPlanes=g.clippingPlanes,I.clipIntersection=g.clipIntersection,I.displacementMap=g.displacementMap,I.displacementScale=g.displacementScale,I.displacementBias=g.displacementBias,I.wireframeLinewidth=g.wireframeLinewidth,I.linewidth=g.linewidth,M.isPointLight===!0&&I.isMeshDistanceMaterial===!0){let F=i.properties.get(I);F.light=M}return I}function b(w,g,M,U,I,D){if(w.visible===!1)return;if(w.layers.test(I)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&D===es)&&(!w.frustumCulled||w.intersectsFrustum(n))){w.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,w.matrixWorld);let C=e.update(w),Y=w.material;if(Array.isArray(Y)){let J=C.groups;for(let z=0,te=J.length;z<te;z++){let W=J[z],$=Y[W.materialIndex];if($&&$.visible){let ae=A(w,$,U,D);w.onBeforeShadow(i,w,g,M,C,ae,W),i.renderBufferDirect(M,null,C,ae,w,W),w.onAfterShadow(i,w,g,M,C,ae,W)}}}else if(Y.visible){let J=A(w,Y,U,D);w.onBeforeShadow(i,w,g,M,C,J,null),i.renderBufferDirect(M,null,C,J,w,null),w.onAfterShadow(i,w,g,M,C,J,null)}}let H=w.children;for(let C=0,Y=H.length;C<Y;C++)b(H[C],g,M,U,I,D)}function T(w){w.target.removeEventListener("dispose",T);for(let M in l){let U=l[M],I=w.target.uuid;I in U&&(U[I].dispose(),delete U[I])}}}function r_(i,e){function t(){let R=!1,X=new dt,O=null,q=new dt(0,0,0,0);return{setMask:function(ne){O!==ne&&!R&&(i.colorMask(ne,ne,ne,ne),O=ne)},setLocked:function(ne){R=ne},setClear:function(ne,se,xe,Pe,re){re===!0&&(ne*=Pe,se*=Pe,xe*=Pe),X.set(ne,se,xe,Pe),q.equals(X)===!1&&(i.clearColor(ne,se,xe,Pe),q.copy(X))},reset:function(){R=!1,O=null,q.set(-1,0,0,0)}}}function n(){let R=!1,X=!1,O=null,q=null,ne=null;return{setReversed:function(se){if(X!==se){let xe=e.get("EXT_clip_control");se?xe.clipControlEXT(xe.LOWER_LEFT_EXT,xe.ZERO_TO_ONE_EXT):xe.clipControlEXT(xe.LOWER_LEFT_EXT,xe.NEGATIVE_ONE_TO_ONE_EXT),X=se;let Pe=ne;ne=null,this.setClear(Pe)}},getReversed:function(){return X},setTest:function(se){se?fe(i.DEPTH_TEST):Le(i.DEPTH_TEST)},setMask:function(se){O!==se&&!R&&(i.depthMask(se),O=se)},setFunc:function(se){if(X&&(se=dh[se]),q!==se){switch(se){case Pr:i.depthFunc(i.NEVER);break;case Ir:i.depthFunc(i.ALWAYS);break;case Lr:i.depthFunc(i.LESS);break;case Gi:i.depthFunc(i.LEQUAL);break;case Dr:i.depthFunc(i.EQUAL);break;case Nr:i.depthFunc(i.GEQUAL);break;case Ur:i.depthFunc(i.GREATER);break;case Fr:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}q=se}},setLocked:function(se){R=se},setClear:function(se){ne!==se&&(ne=se,X&&(se=1-se),i.clearDepth(se))},reset:function(){R=!1,O=null,q=null,ne=null,X=!1}}}function s(){let R=!1,X=null,O=null,q=null,ne=null,se=null,xe=null,Pe=null,re=null;return{setTest:function(ve){R||(ve?fe(i.STENCIL_TEST):Le(i.STENCIL_TEST))},setMask:function(ve){X!==ve&&!R&&(i.stencilMask(ve),X=ve)},setFunc:function(ve,Ae,ie){(O!==ve||q!==Ae||ne!==ie)&&(i.stencilFunc(ve,Ae,ie),O=ve,q=Ae,ne=ie)},setOp:function(ve,Ae,ie){(se!==ve||xe!==Ae||Pe!==ie)&&(i.stencilOp(ve,Ae,ie),se=ve,xe=Ae,Pe=ie)},setLocked:function(ve){R=ve},setClear:function(ve){re!==ve&&(i.clearStencil(ve),re=ve)},reset:function(){R=!1,X=null,O=null,q=null,ne=null,se=null,xe=null,Pe=null,re=null}}}let r=new t,a=new n,o=new s,c={},l=new WeakMap,h={},d={},u={},m=new WeakMap,_=[],y=null,p=!1,f=null,S=null,A=null,b=null,T=null,w=null,g=null,M=new ze(0,0,0),U=0,I=!1,D=null,F=null,H=null,C=null,Y=null,J=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),z=!1,te=0,W=i.getParameter(i.VERSION);W.indexOf("WebGL")!==-1?(te=parseFloat(/^WebGL (\d)/.exec(W)[1]),z=te>=1):W.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(W)[1]),z=te>=2);let $=null,ae={},_e=i.getParameter(i.SCISSOR_BOX),De=i.getParameter(i.VIEWPORT),j=new dt().fromArray(_e),pe=new dt().fromArray(De);function ye(R,X,O,q){let ne=new Uint8Array(4),se=i.createTexture();i.bindTexture(R,se),i.texParameteri(R,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(R,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let xe=0;xe<O;xe++)R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY?i.texImage3D(X,0,i.RGBA,1,1,q,0,i.RGBA,i.UNSIGNED_BYTE,ne):i.texImage2D(X+xe,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,ne);return se}let Re={};Re[i.TEXTURE_2D]=ye(i.TEXTURE_2D,i.TEXTURE_2D,1),Re[i.TEXTURE_CUBE_MAP]=ye(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),Re[i.TEXTURE_2D_ARRAY]=ye(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),Re[i.TEXTURE_3D]=ye(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),fe(i.DEPTH_TEST),a.setFunc(Gi),mt(!1),at(Go),fe(i.CULL_FACE),lt(vi);function fe(R){h[R]!==!0&&(i.enable(R),h[R]=!0)}function Le(R){h[R]!==!1&&(i.disable(R),h[R]=!1)}function pt(R,X){return u[R]!==X?(i.bindFramebuffer(R,X),u[R]=X,R===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=X),R===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=X),!0):!1}function be(R,X){let O=_,q=!1;if(R){O=m.get(X),O===void 0&&(O=[],m.set(X,O));let ne=R.textures;if(O.length!==ne.length||O[0]!==i.COLOR_ATTACHMENT0){for(let se=0,xe=ne.length;se<xe;se++)O[se]=i.COLOR_ATTACHMENT0+se;O.length=ne.length,q=!0}}else O[0]!==i.BACK&&(O[0]=i.BACK,q=!0);q&&i.drawBuffers(O)}function $e(R){return y!==R?(i.useProgram(R),y=R,!0):!1}let it={[Mi]:i.FUNC_ADD,[Nc]:i.FUNC_SUBTRACT,[Uc]:i.FUNC_REVERSE_SUBTRACT};it[Fc]=i.MIN,it[Oc]=i.MAX;let ke={[Bc]:i.ZERO,[zc]:i.ONE,[kc]:i.SRC_COLOR,[qo]:i.SRC_ALPHA,[qc]:i.SRC_ALPHA_SATURATE,[Wc]:i.DST_COLOR,[Gc]:i.DST_ALPHA,[Vc]:i.ONE_MINUS_SRC_COLOR,[Yo]:i.ONE_MINUS_SRC_ALPHA,[Xc]:i.ONE_MINUS_DST_COLOR,[Hc]:i.ONE_MINUS_DST_ALPHA,[Yc]:i.CONSTANT_COLOR,[Zc]:i.ONE_MINUS_CONSTANT_COLOR,[$c]:i.CONSTANT_ALPHA,[Jc]:i.ONE_MINUS_CONSTANT_ALPHA};function lt(R,X,O,q,ne,se,xe,Pe,re,ve){if(R===vi){p===!0&&(Le(i.BLEND),p=!1);return}if(p===!1&&(fe(i.BLEND),p=!0),R!==Dc){if(R!==f||ve!==I){if((S!==Mi||T!==Mi)&&(i.blendEquation(i.FUNC_ADD),S=Mi,T=Mi),ve)switch(R){case ts:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Ho:i.blendFunc(i.ONE,i.ONE);break;case Wo:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Xo:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Ue("WebGLState: Invalid blending: ",R);break}else switch(R){case ts:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Ho:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Wo:Ue("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Xo:Ue("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ue("WebGLState: Invalid blending: ",R);break}A=null,b=null,w=null,g=null,M.set(0,0,0),U=0,f=R,I=ve}return}ne=ne||X,se=se||O,xe=xe||q,(X!==S||ne!==T)&&(i.blendEquationSeparate(it[X],it[ne]),S=X,T=ne),(O!==A||q!==b||se!==w||xe!==g)&&(i.blendFuncSeparate(ke[O],ke[q],ke[se],ke[xe]),A=O,b=q,w=se,g=xe),(Pe.equals(M)===!1||re!==U)&&(i.blendColor(Pe.r,Pe.g,Pe.b,re),M.copy(Pe),U=re),f=R,I=!1}function Ge(R,X){R.side===bn?Le(i.CULL_FACE):fe(i.CULL_FACE);let O=R.side===Vt;X&&(O=!O),mt(O),R.blending===ts&&R.transparent===!1?lt(vi):lt(R.blending,R.blendEquation,R.blendSrc,R.blendDst,R.blendEquationAlpha,R.blendSrcAlpha,R.blendDstAlpha,R.blendColor,R.blendAlpha,R.premultipliedAlpha),a.setFunc(R.depthFunc),a.setTest(R.depthTest),a.setMask(R.depthWrite),r.setMask(R.colorWrite);let q=R.stencilWrite;o.setTest(q),q&&(o.setMask(R.stencilWriteMask),o.setFunc(R.stencilFunc,R.stencilRef,R.stencilFuncMask),o.setOp(R.stencilFail,R.stencilZFail,R.stencilZPass)),gt(R.polygonOffset,R.polygonOffsetFactor,R.polygonOffsetUnits),R.alphaToCoverage===!0?fe(i.SAMPLE_ALPHA_TO_COVERAGE):Le(i.SAMPLE_ALPHA_TO_COVERAGE)}function mt(R){D!==R&&(R?i.frontFace(i.CW):i.frontFace(i.CCW),D=R)}function at(R){R!==Pc?(fe(i.CULL_FACE),R!==F&&(R===Go?i.cullFace(i.BACK):R===Ic?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Le(i.CULL_FACE),F=R}function nn(R){R!==H&&(z&&i.lineWidth(R),H=R)}function gt(R,X,O){R?(fe(i.POLYGON_OFFSET_FILL),(C!==X||Y!==O)&&(C=X,Y=O,a.getReversed()&&(X=-X,O=-O),i.polygonOffset(X,O))):Le(i.POLYGON_OFFSET_FILL)}function Ft(R){R?fe(i.SCISSOR_TEST):Le(i.SCISSOR_TEST)}function Tt(R){R===void 0&&(R=i.TEXTURE0+J-1),$!==R&&(i.activeTexture(R),$=R)}function Pt(R,X,O){O===void 0&&($===null?O=i.TEXTURE0+J-1:O=$);let q=ae[O];q===void 0&&(q={type:void 0,texture:void 0},ae[O]=q),(q.type!==R||q.texture!==X)&&($!==O&&(i.activeTexture(O),$=O),i.bindTexture(R,X||Re[R]),q.type=R,q.texture=X)}function N(){let R=ae[$];R!==void 0&&R.type!==void 0&&(i.bindTexture(R.type,null),R.type=void 0,R.texture=void 0)}function At(){try{i.compressedTexImage2D(...arguments)}catch(R){Ue("WebGLState:",R)}}function Qe(){try{i.compressedTexImage3D(...arguments)}catch(R){Ue("WebGLState:",R)}}function st(){try{i.texSubImage2D(...arguments)}catch(R){Ue("WebGLState:",R)}}function ue(){try{i.texSubImage3D(...arguments)}catch(R){Ue("WebGLState:",R)}}function ut(){try{i.compressedTexSubImage2D(...arguments)}catch(R){Ue("WebGLState:",R)}}function Te(){try{i.compressedTexSubImage3D(...arguments)}catch(R){Ue("WebGLState:",R)}}function Ce(){try{i.texStorage2D(...arguments)}catch(R){Ue("WebGLState:",R)}}function E(){try{i.texStorage3D(...arguments)}catch(R){Ue("WebGLState:",R)}}function x(){try{i.texImage2D(...arguments)}catch(R){Ue("WebGLState:",R)}}function k(){try{i.texImage3D(...arguments)}catch(R){Ue("WebGLState:",R)}}function oe(R){return d[R]!==void 0?d[R]:i.getParameter(R)}function ee(R,X){d[R]!==X&&(i.pixelStorei(R,X),d[R]=X)}function le(R){j.equals(R)===!1&&(i.scissor(R.x,R.y,R.z,R.w),j.copy(R))}function ce(R){pe.equals(R)===!1&&(i.viewport(R.x,R.y,R.z,R.w),pe.copy(R))}function K(R,X){let O=l.get(X);O===void 0&&(O=new WeakMap,l.set(X,O));let q=O.get(R);q===void 0&&(q=i.getUniformBlockIndex(X,R.name),i.uniformBlockBinding(X,q,q),O.set(R,q))}function P(R,X,O){let ne=l.get(X).get(R);c[ne]!==O&&(i.bindBufferBase(i.UNIFORM_BUFFER,ne,O),c[ne]=O)}function Q(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),h={},d={},$=null,ae={},u={},c={},m=new WeakMap,_=[],y=null,p=!1,f=null,S=null,A=null,b=null,T=null,w=null,g=null,M=new ze(0,0,0),U=0,I=!1,D=null,F=null,H=null,C=null,Y=null,j.set(0,0,i.canvas.width,i.canvas.height),pe.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:fe,disable:Le,bindFramebuffer:pt,drawBuffers:be,useProgram:$e,setBlending:lt,setMaterial:Ge,setFlipSided:mt,setCullFace:at,setLineWidth:nn,setPolygonOffset:gt,setScissorTest:Ft,activeTexture:Tt,bindTexture:Pt,unbindTexture:N,compressedTexImage2D:At,compressedTexImage3D:Qe,texImage2D:x,texImage3D:k,pixelStorei:ee,getParameter:oe,updateUBOMapping:K,uniformBlockBinding:P,texStorage2D:Ce,texStorage3D:E,texSubImage2D:st,texSubImage3D:ue,compressedTexSubImage2D:ut,compressedTexSubImage3D:Te,scissor:le,viewport:ce,reset:Q}}function a_(i,e,t,n,s,r,a){let o=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 Fe,h=new WeakMap,d=new Set,u,m=new WeakMap,_=new Set,y=new FinalizationRegistry(E=>_.delete(E)),p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function f(E,x){return p?new OffscreenCanvas(E,x):vs("canvas")}function S(E,x,k){let oe=1,ee=Ce(E);if((ee.width>k||ee.height>k)&&(oe=k/Math.max(ee.width,ee.height)),oe<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){let le=Math.floor(oe*ee.width),ce=Math.floor(oe*ee.height);u===void 0&&(u=f(le,ce));let K=x?f(le,ce):u;return K.width=le,K.height=ce,K.getContext("2d").drawImage(E,0,0,le,ce),Ie("WebGLRenderer: Texture has been resized from ("+ee.width+"x"+ee.height+") to ("+le+"x"+ce+")."),K}else return"data"in E&&Ie("WebGLRenderer: Image in DataTexture is too big ("+ee.width+"x"+ee.height+")."),E;return E}function A(E){return E.generateMipmaps}function b(E){i.generateMipmap(E)}function T(E){return E.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:E.isWebGL3DRenderTarget?i.TEXTURE_3D:E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function w(E,x,k,oe,ee,le=!1){if(E!==null){if(i[E]!==void 0)return i[E];Ie("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let ce;oe&&(ce=e.get("EXT_texture_norm16"),ce||Ie("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let K=x;if(x===i.RED&&(k===i.FLOAT&&(K=i.R32F),k===i.HALF_FLOAT&&(K=i.R16F),k===i.UNSIGNED_BYTE&&(K=i.R8),k===i.UNSIGNED_SHORT&&ce&&(K=ce.R16_EXT),k===i.SHORT&&ce&&(K=ce.R16_SNORM_EXT)),x===i.RED_INTEGER&&(k===i.UNSIGNED_BYTE&&(K=i.R8UI),k===i.UNSIGNED_SHORT&&(K=i.R16UI),k===i.UNSIGNED_INT&&(K=i.R32UI),k===i.BYTE&&(K=i.R8I),k===i.SHORT&&(K=i.R16I),k===i.INT&&(K=i.R32I)),x===i.RG&&(k===i.FLOAT&&(K=i.RG32F),k===i.HALF_FLOAT&&(K=i.RG16F),k===i.UNSIGNED_BYTE&&(K=i.RG8),k===i.UNSIGNED_SHORT&&ce&&(K=ce.RG16_EXT),k===i.SHORT&&ce&&(K=ce.RG16_SNORM_EXT)),x===i.RG_INTEGER&&(k===i.UNSIGNED_BYTE&&(K=i.RG8UI),k===i.UNSIGNED_SHORT&&(K=i.RG16UI),k===i.UNSIGNED_INT&&(K=i.RG32UI),k===i.BYTE&&(K=i.RG8I),k===i.SHORT&&(K=i.RG16I),k===i.INT&&(K=i.RG32I)),x===i.RGB_INTEGER&&(k===i.UNSIGNED_BYTE&&(K=i.RGB8UI),k===i.UNSIGNED_SHORT&&(K=i.RGB16UI),k===i.UNSIGNED_INT&&(K=i.RGB32UI),k===i.BYTE&&(K=i.RGB8I),k===i.SHORT&&(K=i.RGB16I),k===i.INT&&(K=i.RGB32I)),x===i.RGBA_INTEGER&&(k===i.UNSIGNED_BYTE&&(K=i.RGBA8UI),k===i.UNSIGNED_SHORT&&(K=i.RGBA16UI),k===i.UNSIGNED_INT&&(K=i.RGBA32UI),k===i.BYTE&&(K=i.RGBA8I),k===i.SHORT&&(K=i.RGBA16I),k===i.INT&&(K=i.RGBA32I)),x===i.RGB&&(k===i.UNSIGNED_SHORT&&ce&&(K=ce.RGB16_EXT),k===i.SHORT&&ce&&(K=ce.RGB16_SNORM_EXT),k===i.UNSIGNED_INT_5_9_9_9_REV&&(K=i.RGB9_E5),k===i.UNSIGNED_INT_10F_11F_11F_REV&&(K=i.R11F_G11F_B10F)),x===i.RGBA){let P=le?ys:Ze.getTransfer(ee);k===i.FLOAT&&(K=i.RGBA32F),k===i.HALF_FLOAT&&(K=i.RGBA16F),k===i.UNSIGNED_BYTE&&(K=P===nt?i.SRGB8_ALPHA8:i.RGBA8),k===i.UNSIGNED_SHORT&&ce&&(K=ce.RGBA16_EXT),k===i.SHORT&&ce&&(K=ce.RGBA16_SNORM_EXT),k===i.UNSIGNED_SHORT_4_4_4_4&&(K=i.RGBA4),k===i.UNSIGNED_SHORT_5_5_5_1&&(K=i.RGB5_A1)}return(K===i.R16F||K===i.R32F||K===i.RG16F||K===i.RG32F||K===i.RGBA16F||K===i.RGBA32F)&&e.get("EXT_color_buffer_float"),K}function g(E,x){let k;return E?x===null||x===fn||x===Si?k=i.DEPTH24_STENCIL8:x===pn?k=i.DEPTH32F_STENCIL8:x===is&&(k=i.DEPTH24_STENCIL8,Ie("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===fn||x===Si?k=i.DEPTH_COMPONENT24:x===pn?k=i.DEPTH_COMPONENT32F:x===is&&(k=i.DEPTH_COMPONENT16),k}function M(E,x){return A(E)===!0||E.isFramebufferTexture&&E.minFilter!==Et&&E.minFilter!==kt?Math.log2(Math.max(x.width,x.height))+1:E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?x.mipmaps.length:1}function U(E){let x=new WeakRef(E);n.get(E).__ref=x,_.add(x),y.register(E,x,x)}function I(E){let x=n.get(E).__ref;x!==void 0&&(_.delete(x),y.unregister(x))}function D(E){H(E.target)}function F(E){C(E.target)}function H(E){E.removeEventListener("dispose",D),I(E),J(E),E.isVideoTexture&&h.delete(E),E.isHTMLTexture&&d.delete(E)}function C(E){E.removeEventListener("dispose",F),I(E),te(E)}function Y(){for(let E of _){let x=E.deref();x!==void 0&&(x.isRenderTarget===!0?C(x):H(x))}_.clear(),d.clear()}function J(E){let x=n.get(E);if(x.__webglInit===void 0)return;let k=E.source,oe=m.get(k);if(oe){let ee=oe[x.__cacheKey];ee.usedTimes--,ee.usedTimes===0&&z(E),Object.keys(oe).length===0&&m.delete(k)}n.remove(E)}function z(E){let x=n.get(E);i.deleteTexture(x.__webglTexture);let k=E.source,oe=m.get(k);delete oe[x.__cacheKey],a.memory.textures--}function te(E){let x=n.get(E);x.__depthDisposeCallback&&x.__depthDisposeCallback();let k=E.depthTexture;if(k&&k.renderTarget===E&&H(k),E.isWebGLCubeRenderTarget)for(let ee=0;ee<6;ee++){if(Array.isArray(x.__webglFramebuffer[ee]))for(let le=0;le<x.__webglFramebuffer[ee].length;le++)i.deleteFramebuffer(x.__webglFramebuffer[ee][le]);else i.deleteFramebuffer(x.__webglFramebuffer[ee]);x.__webglDepthbuffer&&i.deleteRenderbuffer(x.__webglDepthbuffer[ee])}else{if(Array.isArray(x.__webglFramebuffer))for(let ee=0;ee<x.__webglFramebuffer.length;ee++)i.deleteFramebuffer(x.__webglFramebuffer[ee]);else i.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&i.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&i.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let ee=0;ee<x.__webglColorRenderbuffer.length;ee++)x.__webglColorRenderbuffer[ee]&&i.deleteRenderbuffer(x.__webglColorRenderbuffer[ee]);x.__webglDepthRenderbuffer&&i.deleteRenderbuffer(x.__webglDepthRenderbuffer)}let oe=E.textures;for(let ee=0,le=oe.length;ee<le;ee++){let ce=n.get(oe[ee]);ce.__webglTexture&&(i.deleteTexture(ce.__webglTexture),a.memory.textures--),n.remove(oe[ee])}n.remove(E)}let W=0;function $(){W=0}function ae(){return W}function _e(E){W=E}function De(){let E=W;return E>=s.maxTextures&&Ie("WebGLTextures: Trying to use "+(E+1)+" texture units while this GPU supports only "+s.maxTextures),W+=1,E}function j(E){let x=[];return x.push(E.wrapS),x.push(E.wrapT),x.push(E.wrapR||0),x.push(E.magFilter),x.push(E.minFilter),x.push(E.anisotropy),x.push(E.internalFormat),x.push(E.format),x.push(E.type),x.push(E.generateMipmaps),x.push(E.mipmapsAutoUpdate),x.push(E.premultiplyAlpha),x.push(E.flipY),x.push(E.unpackAlignment),x.push(E.colorSpace),x.join()}function pe(E,x){let k=n.get(E);if(E.isVideoTexture&&ut(E),E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&k.__version!==E.version){let oe=E.image;if(oe===null)Ie("WebGLRenderer: Texture marked for update but no image data found.");else if(oe.complete===!1)Ie("WebGLRenderer: Texture marked for update but image is incomplete");else{Ge(k,E,x);return}}else E.isExternalTexture&&(k.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,k.__webglTexture,i.TEXTURE0+x)}function ye(E,x){let k=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&k.__version!==E.version){Ge(k,E,x);return}else E.isExternalTexture&&(k.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,k.__webglTexture,i.TEXTURE0+x)}function Re(E,x){let k=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&k.__version!==E.version){Ge(k,E,x);return}t.bindTexture(i.TEXTURE_3D,k.__webglTexture,i.TEXTURE0+x)}function fe(E,x){let k=n.get(E);if(E.version>0&&k.__version!==E.version){mt(k,E,x);return}t.bindTexture(i.TEXTURE_CUBE_MAP,k.__webglTexture,i.TEXTURE0+x)}let Le={[Or]:i.REPEAT,[vn]:i.CLAMP_TO_EDGE,[Br]:i.MIRRORED_REPEAT},pt={[Et]:i.NEAREST,[Qc]:i.NEAREST_MIPMAP_NEAREST,[Bs]:i.NEAREST_MIPMAP_LINEAR,[kt]:i.LINEAR,[pa]:i.LINEAR_MIPMAP_NEAREST,[Gn]:i.LINEAR_MIPMAP_LINEAR},be={[ih]:i.NEVER,[hl]:i.ALWAYS,[sh]:i.LESS,[ll]:i.LEQUAL,[rh]:i.EQUAL,[cl]:i.GEQUAL,[ah]:i.GREATER,[oh]:i.NOTEQUAL};function $e(E,x){if(x.type===pn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===kt||x.magFilter===pa||x.magFilter===Bs||x.magFilter===Gn||x.minFilter===kt||x.minFilter===pa||x.minFilter===Bs||x.minFilter===Gn)&&Ie("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(E,i.TEXTURE_WRAP_S,Le[x.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,Le[x.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,Le[x.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,pt[x.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,pt[x.minFilter]),x.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,be[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Et||x.minFilter!==Bs&&x.minFilter!==Gn||x.type===pn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||n.get(x).__currentAnisotropy){let k=e.get("EXT_texture_filter_anisotropic");i.texParameterf(E,k.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),n.get(x).__currentAnisotropy=x.anisotropy}}}function it(E,x){let k=!1;E.__webglInit===void 0&&(E.__webglInit=!0,x.addEventListener("dispose",D),U(x));let oe=x.source,ee=m.get(oe);ee===void 0&&(ee={},m.set(oe,ee));let le=j(x);if(le!==E.__cacheKey){ee[le]===void 0&&(ee[le]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,k=!0),ee[le].usedTimes++;let ce=ee[E.__cacheKey];ce!==void 0&&(ee[E.__cacheKey].usedTimes--,ce.usedTimes===0&&z(x)),E.__cacheKey=le,E.__webglTexture=ee[le].texture}return k}function ke(E,x,k){return Math.floor(Math.floor(E/k)/x)}function lt(E,x,k,oe){let le=E.updateRanges;if(le.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,x.width,x.height,k,oe,x.data);else{le.sort((R,X)=>R.start-X.start);let ce=0;for(let R=1;R<le.length;R++){let X=le[ce],O=le[R],q=X.start+X.count,ne=ke(O.start,x.width,4),se=ke(X.start,x.width,4);O.start<=q+1&&ne===se&&ke(O.start+O.count-1,x.width,4)===ne?X.count=Math.max(X.count,O.start+O.count-X.start):(++ce,le[ce]=O)}le.length=ce+1;let K=t.getParameter(i.UNPACK_ROW_LENGTH),P=t.getParameter(i.UNPACK_SKIP_PIXELS),Q=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,x.width);for(let R=0,X=le.length;R<X;R++){let O=le[R],q=Math.floor(O.start/4),ne=Math.ceil(O.count/4),se=q%x.width,xe=Math.floor(q/x.width),Pe=ne,re=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,se),t.pixelStorei(i.UNPACK_SKIP_ROWS,xe),t.texSubImage2D(i.TEXTURE_2D,0,se,xe,Pe,re,k,oe,x.data)}E.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,K),t.pixelStorei(i.UNPACK_SKIP_PIXELS,P),t.pixelStorei(i.UNPACK_SKIP_ROWS,Q)}}function Ge(E,x,k){let oe=i.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(oe=i.TEXTURE_2D_ARRAY),x.isData3DTexture&&(oe=i.TEXTURE_3D);let ee=it(E,x),le=x.source;t.bindTexture(oe,E.__webglTexture,i.TEXTURE0+k);let ce=n.get(le);if(le.version!==ce.__version||ee===!0){if(t.activeTexture(i.TEXTURE0+k),(typeof ImageBitmap<"u"&&x.image instanceof ImageBitmap)===!1){let re=Ze.getPrimaries(Ze.workingColorSpace),ve=x.colorSpace===Wn?null:Ze.getPrimaries(x.colorSpace),Ae=x.colorSpace===Wn||re===ve?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,x.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ae)}t.pixelStorei(i.UNPACK_ALIGNMENT,x.unpackAlignment);let P=S(x.image,!1,s.maxTextureSize);P=Te(x,P);let Q=r.convert(x.format,x.colorSpace),R=r.convert(x.type),X=w(x.internalFormat,Q,R,x.normalized,x.colorSpace,x.isVideoTexture);$e(oe,x);let O,q=x.mipmaps,ne=x.isVideoTexture!==!0,se=ce.__version===void 0||ee===!0,xe=le.dataReady,Pe=M(x,P);if(x.isDepthTexture)X=g(x.format===Hn,x.type),se&&(ne?t.texStorage2D(i.TEXTURE_2D,1,X,P.width,P.height):t.texImage2D(i.TEXTURE_2D,0,X,P.width,P.height,0,Q,R,null));else if(x.isDataTexture)if(q.length>0){ne&&se&&t.texStorage2D(i.TEXTURE_2D,Pe,X,q[0].width,q[0].height);for(let re=0,ve=q.length;re<ve;re++)O=q[re],ne?xe&&t.texSubImage2D(i.TEXTURE_2D,re,0,0,O.width,O.height,Q,R,O.data):t.texImage2D(i.TEXTURE_2D,re,X,O.width,O.height,0,Q,R,O.data);x.generateMipmaps=!1}else ne?(se&&t.texStorage2D(i.TEXTURE_2D,Pe,X,P.width,P.height),xe&<(x,P,Q,R)):t.texImage2D(i.TEXTURE_2D,0,X,P.width,P.height,0,Q,R,P.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){ne&&se&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Pe,X,q[0].width,q[0].height,P.depth);for(let re=0,ve=q.length;re<ve;re++)if(O=q[re],x.format!==gn)if(Q!==null)if(ne){if(xe)if(x.layerUpdates.size>0){let Ae=vl(O.width,O.height,x.format,x.type);for(let ie of x.layerUpdates){let Ne=O.data.subarray(ie*Ae/O.data.BYTES_PER_ELEMENT,(ie+1)*Ae/O.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,re,0,0,ie,O.width,O.height,1,Q,Ne)}}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,re,0,0,0,O.width,O.height,P.depth,Q,O.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,re,X,O.width,O.height,P.depth,0,O.data,0,0);else Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ne?xe&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,re,0,0,0,O.width,O.height,P.depth,Q,R,O.data):t.texImage3D(i.TEXTURE_2D_ARRAY,re,X,O.width,O.height,P.depth,0,Q,R,O.data);x.layerUpdates.size>0&&x.clearLayerUpdates()}else{ne&&se&&t.texStorage2D(i.TEXTURE_2D,Pe,X,q[0].width,q[0].height);for(let re=0,ve=q.length;re<ve;re++)O=q[re],x.format!==gn?Q!==null?ne?xe&&t.compressedTexSubImage2D(i.TEXTURE_2D,re,0,0,O.width,O.height,Q,O.data):t.compressedTexImage2D(i.TEXTURE_2D,re,X,O.width,O.height,0,O.data):Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ne?xe&&t.texSubImage2D(i.TEXTURE_2D,re,0,0,O.width,O.height,Q,R,O.data):t.texImage2D(i.TEXTURE_2D,re,X,O.width,O.height,0,Q,R,O.data)}else if(x.isDataArrayTexture)if(ne){if(se&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Pe,X,P.width,P.height,P.depth),xe)if(x.layerUpdates.size>0){let re=vl(P.width,P.height,x.format,x.type);for(let ve of x.layerUpdates){let Ae=P.data.subarray(ve*re/P.data.BYTES_PER_ELEMENT,(ve+1)*re/P.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ve,P.width,P.height,1,Q,R,Ae)}x.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,P.width,P.height,P.depth,Q,R,P.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,X,P.width,P.height,P.depth,0,Q,R,P.data);else if(x.isData3DTexture)ne?(se&&t.texStorage3D(i.TEXTURE_3D,Pe,X,P.width,P.height,P.depth),xe&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,P.width,P.height,P.depth,Q,R,P.data)):t.texImage3D(i.TEXTURE_3D,0,X,P.width,P.height,P.depth,0,Q,R,P.data);else if(x.isFramebufferTexture){if(se)if(ne)t.texStorage2D(i.TEXTURE_2D,Pe,X,P.width,P.height);else{let re=P.width,ve=P.height;for(let Ae=0;Ae<Pe;Ae++)t.texImage2D(i.TEXTURE_2D,Ae,X,re,ve,0,Q,R,null),re>>=1,ve>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in i){let re=i.canvas;if(re.hasAttribute("layoutsubtree")||re.setAttribute("layoutsubtree","true"),P.parentNode!==re){re.appendChild(P),d.add(x),re.onpaint=ve=>{let Ae=ve.changedElements;for(let ie of d)Ae.includes(ie.image)&&(ie.needsUpdate=!0)},re.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,P);else{let Ae=i.RGBA,ie=i.RGBA,Ne=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,Ae,ie,Ne,P)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(q.length>0){if(ne&&se){let re=Ce(q[0]);t.texStorage2D(i.TEXTURE_2D,Pe,X,re.width,re.height)}for(let re=0,ve=q.length;re<ve;re++)O=q[re],ne?xe&&t.texSubImage2D(i.TEXTURE_2D,re,0,0,Q,R,O):t.texImage2D(i.TEXTURE_2D,re,X,Q,R,O);x.generateMipmaps=!1}else if(ne){if(se){let re=Ce(P);t.texStorage2D(i.TEXTURE_2D,Pe,X,re.width,re.height)}xe&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Q,R,P)}else t.texImage2D(i.TEXTURE_2D,0,X,Q,R,P);A(x)&&x.mipmapsAutoUpdate===!0&&b(oe),ce.__version=le.version,x.onUpdate&&x.onUpdate(x)}E.__version=x.version}function mt(E,x,k){if(x.image.length!==6)return;let oe=it(E,x),ee=x.source;t.bindTexture(i.TEXTURE_CUBE_MAP,E.__webglTexture,i.TEXTURE0+k);let le=n.get(ee);if(ee.version!==le.__version||oe===!0){t.activeTexture(i.TEXTURE0+k);let ce=Ze.getPrimaries(Ze.workingColorSpace),K=x.colorSpace===Wn?null:Ze.getPrimaries(x.colorSpace),P=x.colorSpace===Wn||ce===K?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,x.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,x.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,P);let Q=x.isCompressedTexture||x.image[0].isCompressedTexture,R=x.image[0]&&x.image[0].isDataTexture,X=[];for(let ie=0;ie<6;ie++)!Q&&!R?X[ie]=S(x.image[ie],!0,s.maxCubemapSize):X[ie]=R?x.image[ie].image:x.image[ie],X[ie]=Te(x,X[ie]);let O=X[0],q=r.convert(x.format,x.colorSpace),ne=r.convert(x.type),se=w(x.internalFormat,q,ne,x.normalized,x.colorSpace),xe=x.isVideoTexture!==!0,Pe=le.__version===void 0||oe===!0,re=ee.dataReady,ve=M(x,O);$e(i.TEXTURE_CUBE_MAP,x);let Ae;if(x.isDepthTexture){if(se=g(x.format===Hn,x.type),Pe)if(xe)t.texStorage2D(i.TEXTURE_CUBE_MAP,1,se,O.width,O.height);else for(let ie=0;ie<6;ie++)t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,se,O.width,O.height,0,q,ne,null)}else if(Q){xe&&Pe&&t.texStorage2D(i.TEXTURE_CUBE_MAP,ve,se,O.width,O.height);for(let ie=0;ie<6;ie++){Ae=X[ie].mipmaps;for(let Ne=0;Ne<Ae.length;Ne++){let Je=Ae[Ne];x.format!==gn?q!==null?xe?re&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne,0,0,Je.width,Je.height,q,Je.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne,se,Je.width,Je.height,0,Je.data):Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):xe?re&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne,0,0,Je.width,Je.height,q,ne,Je.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne,se,Je.width,Je.height,0,q,ne,Je.data)}}}else{if(Ae=x.mipmaps,xe&&Pe){Ae.length>0&&ve++;let ie=Ce(X[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,ve,se,ie.width,ie.height)}for(let ie=0;ie<6;ie++)if(R){xe?re&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,0,0,X[ie].width,X[ie].height,q,ne,X[ie].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,se,X[ie].width,X[ie].height,0,q,ne,X[ie].data);for(let Ne=0;Ne<Ae.length;Ne++){let Xe=Ae[Ne].image[ie].image;xe?re&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne+1,0,0,Xe.width,Xe.height,q,ne,Xe.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne+1,se,Xe.width,Xe.height,0,q,ne,Xe.data)}}else{xe?re&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,0,0,q,ne,X[ie]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,se,q,ne,X[ie]);for(let Ne=0;Ne<Ae.length;Ne++){let Je=Ae[Ne];xe?re&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne+1,0,0,q,ne,Je.image[ie]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne+1,se,q,ne,Je.image[ie])}}}A(x)&&x.mipmapsAutoUpdate===!0&&b(i.TEXTURE_CUBE_MAP),le.__version=ee.version,x.onUpdate&&x.onUpdate(x)}E.__version=x.version}function at(E,x,k,oe,ee,le){let ce=r.convert(k.format,k.colorSpace),K=r.convert(k.type),P=w(k.internalFormat,ce,K,k.normalized,k.colorSpace),Q=n.get(x),R=n.get(k);if(R.__renderTarget=x,!Q.__hasExternalTextures){let X=Math.max(1,x.width>>le),O=Math.max(1,x.height>>le);ee===i.TEXTURE_3D||ee===i.TEXTURE_2D_ARRAY?t.texImage3D(ee,le,P,X,O,x.depth,0,ce,K,null):t.texImage2D(ee,le,P,X,O,0,ce,K,null)}t.bindFramebuffer(i.FRAMEBUFFER,E),ue(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,oe,ee,R.__webglTexture,0,st(x)):(ee===i.TEXTURE_2D||ee>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&ee<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,oe,ee,R.__webglTexture,le),t.bindFramebuffer(i.FRAMEBUFFER,null)}function nn(E,x,k){if(i.bindRenderbuffer(i.RENDERBUFFER,E),x.depthBuffer){let oe=x.depthTexture,ee=oe&&oe.isDepthTexture?oe.type:null,le=g(x.stencilBuffer,ee),ce=x.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;ue(x)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,st(x),le,x.width,x.height):k?i.renderbufferStorageMultisample(i.RENDERBUFFER,st(x),le,x.width,x.height):i.renderbufferStorage(i.RENDERBUFFER,le,x.width,x.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ce,i.RENDERBUFFER,E)}else{let oe=x.textures;for(let ee=0;ee<oe.length;ee++){let le=oe[ee],ce=r.convert(le.format,le.colorSpace),K=r.convert(le.type),P=w(le.internalFormat,ce,K,le.normalized,le.colorSpace);ue(x)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,st(x),P,x.width,x.height):k?i.renderbufferStorageMultisample(i.RENDERBUFFER,st(x),P,x.width,x.height):i.renderbufferStorage(i.RENDERBUFFER,P,x.width,x.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function gt(E,x,k){let oe=x.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,E),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ee=n.get(x.depthTexture);ee.__renderTarget=x;let le=oe?x.depthTexture.image[0]:x.depthTexture.image;(!ee.__webglTexture||le.width!==x.width||le.height!==x.height)&&(le.width=x.width,le.height=x.height,x.depthTexture.needsUpdate=!0),oe?fe(x.depthTexture,0):pe(x.depthTexture,0);let ce=ee.__webglTexture,K=st(x),P=oe?i.TEXTURE_CUBE_MAP_POSITIVE_X+k:i.TEXTURE_2D,Q=x.depthTexture.format===Hn?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(x.depthTexture.format===Bn)ue(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,P,ce,0,K):i.framebufferTexture2D(i.FRAMEBUFFER,Q,P,ce,0);else if(x.depthTexture.format===Hn)ue(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,P,ce,0,K):i.framebufferTexture2D(i.FRAMEBUFFER,Q,P,ce,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ft(E){let x=n.get(E),k=E.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==E.depthTexture){let oe=E.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),oe){let ee=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,oe.removeEventListener("dispose",ee)};oe.addEventListener("dispose",ee),x.__depthDisposeCallback=ee}x.__boundDepthTexture=oe}if(E.depthTexture&&!x.__autoAllocateDepthBuffer)if(k)for(let oe=0;oe<6;oe++)gt(x.__webglFramebuffer[oe],E,oe);else E.texture.mipmaps.length>0?gt(x.__webglFramebuffer[0],E,0):gt(x.__webglFramebuffer,E,0);else if(k){x.__webglDepthbuffer=[];for(let oe=0;oe<6;oe++)if(t.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer[oe]),x.__webglDepthbuffer[oe]===void 0)x.__webglDepthbuffer[oe]=i.createRenderbuffer(),nn(x.__webglDepthbuffer[oe],E,!1);else{let ee=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,le=x.__webglDepthbuffer[oe];i.bindRenderbuffer(i.RENDERBUFFER,le),i.framebufferRenderbuffer(i.FRAMEBUFFER,ee,i.RENDERBUFFER,le)}}else if(E.texture.mipmaps.length>0?t.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=i.createRenderbuffer(),nn(x.__webglDepthbuffer,E,!1);else{let ee=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,le=x.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,le),i.framebufferRenderbuffer(i.FRAMEBUFFER,ee,i.RENDERBUFFER,le)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Tt(E,x,k){let oe=n.get(E);x!==void 0&&at(oe.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),k!==void 0&&Ft(E)}function Pt(E){let x=E.texture,k=n.get(E),oe=n.get(x);E.addEventListener("dispose",F),U(E);let ee=E.textures,le=E.isWebGLCubeRenderTarget===!0,ce=ee.length>1;if(ce||(oe.__webglTexture===void 0&&(oe.__webglTexture=i.createTexture()),oe.__version=x.version,a.memory.textures++),le){k.__webglFramebuffer=[];for(let K=0;K<6;K++)if(x.mipmaps.length>0){k.__webglFramebuffer[K]=[];for(let P=0;P<x.mipmaps.length;P++)k.__webglFramebuffer[K][P]=i.createFramebuffer()}else k.__webglFramebuffer[K]=i.createFramebuffer()}else{if(x.mipmaps.length>0){k.__webglFramebuffer=[];for(let K=0;K<x.mipmaps.length;K++)k.__webglFramebuffer[K]=i.createFramebuffer()}else k.__webglFramebuffer=i.createFramebuffer();if(ce)for(let K=0,P=ee.length;K<P;K++){let Q=n.get(ee[K]);Q.__webglTexture===void 0&&(Q.__webglTexture=i.createTexture(),a.memory.textures++)}if(E.samples>0&&ue(E)===!1){k.__webglMultisampledFramebuffer=i.createFramebuffer(),k.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,k.__webglMultisampledFramebuffer);for(let K=0;K<ee.length;K++){let P=ee[K];k.__webglColorRenderbuffer[K]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,k.__webglColorRenderbuffer[K]);let Q=r.convert(P.format,P.colorSpace),R=r.convert(P.type),X=w(P.internalFormat,Q,R,P.normalized,P.colorSpace,E.isXRRenderTarget===!0),O=st(E);i.renderbufferStorageMultisample(i.RENDERBUFFER,O,X,E.width,E.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+K,i.RENDERBUFFER,k.__webglColorRenderbuffer[K])}i.bindRenderbuffer(i.RENDERBUFFER,null),E.depthBuffer&&(k.__webglDepthRenderbuffer=i.createRenderbuffer(),nn(k.__webglDepthRenderbuffer,E,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(le){t.bindTexture(i.TEXTURE_CUBE_MAP,oe.__webglTexture),$e(i.TEXTURE_CUBE_MAP,x);for(let K=0;K<6;K++)if(x.mipmaps.length>0)for(let P=0;P<x.mipmaps.length;P++)at(k.__webglFramebuffer[K][P],E,x,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+K,P);else at(k.__webglFramebuffer[K],E,x,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0);A(x)?b(i.TEXTURE_CUBE_MAP):x.mipmaps.length>0&&i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,x.mipmaps.length-1),t.unbindTexture()}else if(ce){for(let K=0,P=ee.length;K<P;K++){let Q=ee[K],R=n.get(Q),X=i.TEXTURE_2D;(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(X=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(X,R.__webglTexture),$e(X,Q),at(k.__webglFramebuffer,E,Q,i.COLOR_ATTACHMENT0+K,X,0),A(Q)&&b(X)}t.unbindTexture()}else{let K=i.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(K=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(K,oe.__webglTexture),$e(K,x),x.mipmaps.length>0)for(let P=0;P<x.mipmaps.length;P++)at(k.__webglFramebuffer[P],E,x,i.COLOR_ATTACHMENT0,K,P);else at(k.__webglFramebuffer,E,x,i.COLOR_ATTACHMENT0,K,0);A(x)?b(K):x.mipmaps.length>0&&i.texParameteri(K,i.TEXTURE_MAX_LEVEL,x.mipmaps.length-1),t.unbindTexture()}E.depthBuffer&&Ft(E)}function N(E){let x=E.textures;for(let k=0,oe=x.length;k<oe;k++){let ee=x[k];if(A(ee)&&ee.mipmapsAutoUpdate===!0){let le=T(E),ce=n.get(ee).__webglTexture;t.bindTexture(le,ce),b(le),t.unbindTexture()}}}let At=[];function Qe(E){if(E.samples>0){if(ue(E)===!1){let x=E.textures,k=E.width,oe=E.height,ee=i.COLOR_BUFFER_BIT,le=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ce=n.get(E),K=x.length>1;if(K)for(let Q=0;Q<x.length;Q++)t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Q,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Q,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,ce.__webglMultisampledFramebuffer),E.texture.mipmaps.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ce.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ce.__webglFramebuffer);for(let Q=0;Q<x.length;Q++){if(E.resolveDepthBuffer&&(E.depthBuffer&&(ee|=i.DEPTH_BUFFER_BIT),E.stencilBuffer&&E.resolveStencilBuffer&&(ee|=i.STENCIL_BUFFER_BIT)),K){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ce.__webglColorRenderbuffer[Q]);let R=n.get(x[Q]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,R,0)}i.blitFramebuffer(0,0,k,oe,0,0,k,oe,ee,i.NEAREST),c===!0&&(At.length=0,At.push(i.COLOR_ATTACHMENT0+Q),E.depthBuffer&&E.storeMultisampledDepthBuffer===!1&&At.push(le),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,At))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),K)for(let Q=0;Q<x.length;Q++){t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Q,i.RENDERBUFFER,ce.__webglColorRenderbuffer[Q]);let R=n.get(x[Q]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Q,i.TEXTURE_2D,R,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ce.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.storeMultisampledDepthBuffer===!1&&c){let x=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[x])}}}function st(E){return Math.min(s.maxSamples,E.samples)}function ue(E){let x=n.get(E);return E.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function ut(E){let x=a.render.frame;h.get(E)!==x&&(h.set(E,x),E.update())}function Te(E,x){let k=E.colorSpace,oe=E.format,ee=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||k!==xs&&k!==Wn&&(Ze.getTransfer(k)===nt?(oe!==gn||ee!==Xt)&&Ie("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ue("WebGLTextures: Unsupported texture color space:",k)),x}function Ce(E){return typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height):typeof VideoFrame<"u"&&E instanceof VideoFrame?(l.width=E.displayWidth,l.height=E.displayHeight):(l.width=E.width,l.height=E.height),l}this.allocateTextureUnit=De,this.resetTextureUnits=$,this.getTextureUnits=ae,this.setTextureUnits=_e,this.setTexture2D=pe,this.setTexture2DArray=ye,this.setTexture3D=Re,this.setTextureCube=fe,this.rebindTextures=Tt,this.setupRenderTarget=Pt,this.updateRenderTargetMipmap=N,this.updateMultisampleRenderTarget=Qe,this.setupDepthRenderbuffer=Ft,this.setupFrameBufferTexture=at,this.useMultisampledRTT=ue,this.dispose=Y}function o_(i,e){function t(n,s=Wn){let r,a=Ze.getTransfer(s);if(n===Xt)return i.UNSIGNED_BYTE;if(n===ga)return i.UNSIGNED_SHORT_4_4_4_4;if(n===_a)return i.UNSIGNED_SHORT_5_5_5_1;if(n===il)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===sl)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===tl)return i.BYTE;if(n===nl)return i.SHORT;if(n===is)return i.UNSIGNED_SHORT;if(n===ma)return i.INT;if(n===fn)return i.UNSIGNED_INT;if(n===pn)return i.FLOAT;if(n===mn)return i.HALF_FLOAT;if(n===rl)return i.ALPHA;if(n===al)return i.RGB;if(n===gn)return i.RGBA;if(n===Bn)return i.DEPTH_COMPONENT;if(n===Hn)return i.DEPTH_STENCIL;if(n===ol)return i.RED;if(n===xa)return i.RED_INTEGER;if(n===ai)return i.RG;if(n===ya)return i.RG_INTEGER;if(n===va)return i.RGBA_INTEGER;if(n===zs||n===ks||n===Vs||n===Gs)if(a===nt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===zs)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ks)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Vs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Gs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===zs)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ks)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Vs)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Gs)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ma||n===ba||n===Sa||n===wa)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Ma)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ba)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Sa)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===wa)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ea||n===Ta||n===Aa||n===Ra||n===Ca||n===Hs||n===Pa)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Ea||n===Ta)return a===nt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Aa)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Ra)return r.COMPRESSED_R11_EAC;if(n===Ca)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Hs)return r.COMPRESSED_RG11_EAC;if(n===Pa)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Ia||n===La||n===Da||n===Na||n===Ua||n===Fa||n===Oa||n===Ba||n===za||n===ka||n===Va||n===Ga||n===Ha||n===Wa)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Ia)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===La)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Da)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Na)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ua)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Fa)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Oa)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ba)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===za)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ka)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Va)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ga)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ha)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Wa)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Xa||n===qa||n===Ya)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===Xa)return a===nt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===qa)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Ya)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Za||n===$a||n===Ws||n===Ja)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===Za)return r.COMPRESSED_RED_RGTC1_EXT;if(n===$a)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ws)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Ja)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Si?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var l_=`
|
|
4197
4202
|
void main() {
|
|
4198
4203
|
|
|
4199
4204
|
gl_Position = vec4( position, 1.0 );
|
|
4200
4205
|
|
|
4201
|
-
}`,
|
|
4206
|
+
}`,c_=`
|
|
4202
4207
|
uniform sampler2DArray depthColor;
|
|
4203
4208
|
uniform float depthWidth;
|
|
4204
4209
|
uniform float depthHeight;
|
|
@@ -4217,4 +4222,4 @@ void main() {
|
|
|
4217
4222
|
|
|
4218
4223
|
}
|
|
4219
4224
|
|
|
4220
|
-
}`,wl=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){let n=new ms(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){let e=t.cameras[0].viewport,n=new $e({vertexShader:Xg,fragmentShader:qg,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Ve(new _s(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Tl=class extends an{constructor(t,e){super();let n=this,s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,d=null,u=null,p=null,_=null,v=typeof XRWebGLBinding<"u",g=new wl,f={},T=e.getContextAttributes(),L=null,M=null,b=[],E=[],A=new Nt,x=null,w=null,D=new Ie;D.viewport=new he;let O=new Ie;O.viewport=new he;let V=[D,O],H=new Jr,R=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(j){let Q=b[j];return Q===void 0&&(Q=new Fi,b[j]=Q),Q.getTargetRaySpace()},this.getControllerGrip=function(j){let Q=b[j];return Q===void 0&&(Q=new Fi,b[j]=Q),Q.getGripSpace()},this.getHand=function(j){let Q=b[j];return Q===void 0&&(Q=new Fi,b[j]=Q),Q.getHandSpace()};function $(j){let Q=E.indexOf(j.inputSource);if(Q===-1)return;let _t=b[Q];_t!==void 0&&(_t.update(j.inputSource,j.frame,l||a),_t.dispatchEvent({type:j.type,data:j.inputSource}))}function K(){s.removeEventListener("select",$),s.removeEventListener("selectstart",$),s.removeEventListener("selectend",$),s.removeEventListener("squeeze",$),s.removeEventListener("squeezestart",$),s.removeEventListener("squeezeend",$),s.removeEventListener("end",K),s.removeEventListener("inputsourceschange",st);for(let j=0;j<b.length;j++){let Q=E[j];Q!==null&&(E[j]=null,b[j].disconnect(Q))}R=null,W=null,g.reset();for(let j in f)delete f[j];if(t.setRenderTarget(L),p=null,u=null,d=null,s=null,M=null,Wt.stop(),n.isPresenting=!1,t.setPixelRatio(x),t.setSize(A.width,A.height,!1),w!==null){let j=w.camera;j.fov=w.fov,j.zoom=w.zoom,j.updateProjectionMatrix(),w=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){r=j,n.isPresenting===!0&&It("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){o=j,n.isPresenting===!0&&It("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(j){l=j},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return d===null&&v&&(d=new XRWebGLBinding(s,e)),d},this.getFrame=function(){return _},this.getSession=function(){return s},this.setSession=async function(j){if(s=j,s!==null){if(L=t.getRenderTarget(),s.addEventListener("select",$),s.addEventListener("selectstart",$),s.addEventListener("selectend",$),s.addEventListener("squeeze",$),s.addEventListener("squeezestart",$),s.addEventListener("squeezeend",$),s.addEventListener("end",K),s.addEventListener("inputsourceschange",st),T.xrCompatible!==!0&&await e.makeXRCompatible(),x=t.getPixelRatio(),t.getSize(A),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let _t=null,St=null,pt=null;T.depth&&(pt=T.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,_t=T.stencil?Kn:pn,St=T.stencil?Xi:ln);let Ot={colorFormat:e.RGBA8,depthFormat:pt,scaleFactor:r};d=this.getBinding(),u=d.createProjectionLayer(Ot),s.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),M=new ze(u.textureWidth,u.textureHeight,{format:tn,type:Ge,depthTexture:new Vn(u.textureWidth,u.textureHeight,St,void 0,void 0,void 0,void 0,void 0,void 0,_t),stencilBuffer:T.stencil,colorSpace:t.outputColorSpace,samples:T.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1,storeMultisampledDepthBuffer:u.ignoreDepthValues===!1,storeMultisampledStencilBuffer:u.ignoreDepthValues===!1})}else{let _t={antialias:T.antialias,alpha:!0,depth:T.depth,stencil:T.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(s,e,_t),s.updateRenderState({baseLayer:p}),t.setPixelRatio(1),t.setSize(p.framebufferWidth,p.framebufferHeight,!1),M=new ze(p.framebufferWidth,p.framebufferHeight,{format:tn,type:Ge,colorSpace:t.outputColorSpace,stencilBuffer:T.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1,storeMultisampledDepthBuffer:p.ignoreDepthValues===!1,storeMultisampledStencilBuffer:p.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await s.requestReferenceSpace(o),Wt.setContext(s),Wt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function st(j){for(let Q=0;Q<j.removed.length;Q++){let _t=j.removed[Q],St=E.indexOf(_t);St>=0&&(E[St]=null,b[St].disconnect(_t))}for(let Q=0;Q<j.added.length;Q++){let _t=j.added[Q],St=E.indexOf(_t);if(St===-1){for(let Ot=0;Ot<b.length;Ot++)if(Ot>=E.length){E.push(_t),St=Ot;break}else if(E[Ot]===null){E[Ot]=_t,St=Ot;break}if(St===-1)break}let pt=b[St];pt&&pt.connect(_t)}}let Y=new U,et=new U;function it(j,Q,_t){Y.setFromMatrixPosition(Q.matrixWorld),et.setFromMatrixPosition(_t.matrixWorld);let St=Y.distanceTo(et),pt=Q.projectionMatrix.elements,Ot=_t.projectionMatrix.elements,pe=pt[14]/(pt[10]-1),Bt=pt[14]/(pt[10]+1),Zt=(pt[9]+1)/pt[5],$t=(pt[9]-1)/pt[5],zt=(pt[8]-1)/pt[0],ie=(Ot[8]+1)/Ot[0],ue=pe*zt,me=pe*ie,re=St/(-zt+ie),de=re*-zt;if(Q.matrixWorld.decompose(j.position,j.quaternion,j.scale),j.translateX(de),j.translateZ(re),j.matrixWorld.compose(j.position,j.quaternion,j.scale),j.matrixWorldInverse.copy(j.matrixWorld).invert(),pt[10]===-1)j.projectionMatrix.copy(Q.projectionMatrix),j.projectionMatrixInverse.copy(Q.projectionMatrixInverse);else{let I=pe+re,fe=Bt+re,Xt=ue-de,S=me+(St-de),m=Zt*Bt/fe*I,F=$t*Bt/fe*I;j.projectionMatrix.makePerspective(Xt,S,m,F,I,fe),j.projectionMatrixInverse.copy(j.projectionMatrix).invert()}}function Ct(j,Q){Q===null?j.matrixWorld.copy(j.matrix):j.matrixWorld.multiplyMatrices(Q.matrixWorld,j.matrix),j.matrixWorldInverse.copy(j.matrixWorld).invert()}this.updateCamera=function(j){if(s===null)return;let Q=j.near,_t=j.far;g.texture!==null&&(g.depthNear>0&&(Q=g.depthNear),g.depthFar>0&&(_t=g.depthFar)),H.near=O.near=D.near=Q,H.far=O.far=D.far=_t,(R!==H.near||W!==H.far)&&(s.updateRenderState({depthNear:H.near,depthFar:H.far}),R=H.near,W=H.far),H.layers.mask=j.layers.mask|6,D.layers.mask=H.layers.mask&-5,O.layers.mask=H.layers.mask&-3;let St=j.parent,pt=H.cameras;Ct(H,St);for(let Ot=0;Ot<pt.length;Ot++)Ct(pt[Ot],St);pt.length===2?it(H,D,O):H.projectionMatrix.copy(D.projectionMatrix),w===null&&j.isPerspectiveCamera&&(w={camera:j,fov:j.fov,zoom:j.zoom}),Et(j,H,St)};function Et(j,Q,_t){_t===null?j.matrix.copy(Q.matrixWorld):(j.matrix.copy(_t.matrixWorld),j.matrix.invert(),j.matrix.multiply(Q.matrixWorld)),j.matrix.decompose(j.position,j.quaternion,j.scale),j.updateMatrixWorld(!0),j.projectionMatrix.copy(Q.projectionMatrix),j.projectionMatrixInverse.copy(Q.projectionMatrixInverse),j.isPerspectiveCamera&&(j.fov=Ni*2*Math.atan(1/j.projectionMatrix.elements[5]),j.zoom=1)}this.getCamera=function(){return H},this.getFoveation=function(){if(!(u===null&&p===null))return c},this.setFoveation=function(j){c=j,u!==null&&(u.fixedFoveation=j),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=j)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(H)},this.getCameraTexture=function(j){return f[j]};let ee=null;function Lt(j,Q){if(h=Q.getViewerPose(l||a),_=Q,h!==null){let _t=h.views;p!==null&&(t.setRenderTargetFramebuffer(M,p.framebuffer),t.setRenderTarget(M));let St=!1;_t.length!==H.cameras.length&&(H.cameras.length=0,St=!0);for(let Bt=0;Bt<_t.length;Bt++){let Zt=_t[Bt],$t=null;if(p!==null)$t=p.getViewport(Zt);else{let ie=d.getViewSubImage(u,Zt);$t=ie.viewport,Bt===0&&(t.setRenderTargetTextures(M,ie.colorTexture,ie.depthStencilTexture),t.setRenderTarget(M))}let zt=V[Bt];zt===void 0&&(zt=new Ie,zt.layers.enable(Bt),zt.viewport=new he,V[Bt]=zt),zt.matrix.fromArray(Zt.transform.matrix),zt.matrix.decompose(zt.position,zt.quaternion,zt.scale),zt.projectionMatrix.fromArray(Zt.projectionMatrix),zt.projectionMatrixInverse.copy(zt.projectionMatrix).invert(),zt.viewport.set($t.x,$t.y,$t.width,$t.height),Bt===0&&(H.matrix.copy(zt.matrix),H.matrix.decompose(H.position,H.quaternion,H.scale)),St===!0&&H.cameras.push(zt)}let pt=s.enabledFeatures;if(pt&&pt.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&v){d=n.getBinding();let Bt=d.getDepthInformation(_t[0]);Bt&&Bt.isValid&&Bt.texture&&g.init(Bt,s.renderState)}if(pt&&pt.includes("camera-access")&&v){t.state.unbindTexture(),d=n.getBinding();for(let Bt=0;Bt<_t.length;Bt++){let Zt=_t[Bt].camera;if(Zt){let $t=f[Zt];$t||($t=new ms,f[Zt]=$t);let zt=d.getCameraImage(Zt);$t.sourceTexture=zt}}}}for(let _t=0;_t<b.length;_t++){let St=E[_t],pt=b[_t];St!==null&&pt!==void 0&&pt.update(St,Q,l||a)}ee&&ee(j,Q),Q.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Q}),_=null}let Wt=new Ch;Wt.setAnimationLoop(Lt),this.setAnimationLoop=function(j){ee=j},this.dispose=function(){}}},Yg=new ce,Nh=new Ut;Nh.set(-1,0,0,0,1,0,0,0,1);function Zg(i,t){function e(g,f){g.matrixAutoUpdate===!0&&g.updateMatrix(),f.value.copy(g.matrix)}function n(g,f){f.color.getRGB(g.fogColor.value,il(i)),f.isFog?(g.fogNear.value=f.near,g.fogFar.value=f.far):f.isFogExp2&&(g.fogDensity.value=f.density)}function s(g,f,T,L,M){f.isNodeMaterial?f.uniformsNeedUpdate=!1:f.isMeshBasicMaterial?r(g,f):f.isMeshLambertMaterial?(r(g,f),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(r(g,f),d(g,f)):f.isMeshPhongMaterial?(r(g,f),h(g,f),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(r(g,f),u(g,f),f.isMeshPhysicalMaterial&&p(g,f,M)):f.isMeshMatcapMaterial?(r(g,f),_(g,f)):f.isMeshDepthMaterial?r(g,f):f.isMeshDistanceMaterial?(r(g,f),v(g,f)):f.isMeshNormalMaterial?r(g,f):f.isLineBasicMaterial?(a(g,f),f.isLineDashedMaterial&&o(g,f)):f.isPointsMaterial?c(g,f,T,L):f.isSpriteMaterial?l(g,f):f.isShadowMaterial?(g.color.value.copy(f.color),g.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function r(g,f){g.opacity.value=f.opacity,f.color&&g.diffuse.value.copy(f.color),f.emissive&&g.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(g.map.value=f.map,e(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,e(f.alphaMap,g.alphaMapTransform)),f.bumpMap&&(g.bumpMap.value=f.bumpMap,e(f.bumpMap,g.bumpMapTransform),g.bumpScale.value=f.bumpScale,f.side===Fe&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,e(f.normalMap,g.normalMapTransform),g.normalScale.value.copy(f.normalScale),f.side===Fe&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,e(f.displacementMap,g.displacementMapTransform),g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap,e(f.emissiveMap,g.emissiveMapTransform)),f.specularMap&&(g.specularMap.value=f.specularMap,e(f.specularMap,g.specularMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);let T=t.get(f),L=T.envMap,M=T.envMapRotation;L&&(g.envMap.value=L,g.envMapRotation.value.setFromMatrix4(Yg.makeRotationFromEuler(M)).transpose(),L.isCubeTexture&&L.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(Nh),g.reflectivity.value=f.reflectivity,g.ior.value=f.ior,g.refractionRatio.value=f.refractionRatio),f.lightMap&&(g.lightMap.value=f.lightMap,g.lightMapIntensity.value=f.lightMapIntensity,e(f.lightMap,g.lightMapTransform)),f.aoMap&&(g.aoMap.value=f.aoMap,g.aoMapIntensity.value=f.aoMapIntensity,e(f.aoMap,g.aoMapTransform))}function a(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,f.map&&(g.map.value=f.map,e(f.map,g.mapTransform))}function o(g,f){g.dashSize.value=f.dashSize,g.totalSize.value=f.dashSize+f.gapSize,g.scale.value=f.scale}function c(g,f,T,L){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.size.value=f.size*T,g.scale.value=L*.5,f.map&&(g.map.value=f.map,e(f.map,g.uvTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,e(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function l(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.rotation.value=f.rotation,f.map&&(g.map.value=f.map,e(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,e(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function h(g,f){g.specular.value.copy(f.specular),g.shininess.value=Math.max(f.shininess,1e-4)}function d(g,f){f.gradientMap&&(g.gradientMap.value=f.gradientMap)}function u(g,f){g.metalness.value=f.metalness,f.metalnessMap&&(g.metalnessMap.value=f.metalnessMap,e(f.metalnessMap,g.metalnessMapTransform)),g.roughness.value=f.roughness,f.roughnessMap&&(g.roughnessMap.value=f.roughnessMap,e(f.roughnessMap,g.roughnessMapTransform)),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)}function p(g,f,T){g.ior.value=f.ior,f.sheen>0&&(g.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),g.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(g.sheenColorMap.value=f.sheenColorMap,e(f.sheenColorMap,g.sheenColorMapTransform)),f.sheenRoughnessMap&&(g.sheenRoughnessMap.value=f.sheenRoughnessMap,e(f.sheenRoughnessMap,g.sheenRoughnessMapTransform))),f.clearcoat>0&&(g.clearcoat.value=f.clearcoat,g.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(g.clearcoatMap.value=f.clearcoatMap,e(f.clearcoatMap,g.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,e(f.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(g.clearcoatNormalMap.value=f.clearcoatNormalMap,e(f.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Fe&&g.clearcoatNormalScale.value.negate())),f.dispersion>0&&(g.dispersion.value=f.dispersion),f.retroreflectivity>0&&(g.retroreflectivity.value=f.retroreflectivity),f.iridescence>0&&(g.iridescence.value=f.iridescence,g.iridescenceIOR.value=f.iridescenceIOR,g.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(g.iridescenceMap.value=f.iridescenceMap,e(f.iridescenceMap,g.iridescenceMapTransform)),f.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=f.iridescenceThicknessMap,e(f.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),f.transmission>0&&(g.transmission.value=f.transmission,g.transmissionSamplerMap.value=T.texture,g.transmissionSamplerSize.value.set(T.width,T.height),f.transmissionMap&&(g.transmissionMap.value=f.transmissionMap,e(f.transmissionMap,g.transmissionMapTransform)),g.thickness.value=f.thickness,f.thicknessMap&&(g.thicknessMap.value=f.thicknessMap,e(f.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=f.attenuationDistance,g.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(g.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(g.anisotropyMap.value=f.anisotropyMap,e(f.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=f.specularIntensity,g.specularColor.value.copy(f.specularColor),f.specularColorMap&&(g.specularColorMap.value=f.specularColorMap,e(f.specularColorMap,g.specularColorMapTransform)),f.specularIntensityMap&&(g.specularIntensityMap.value=f.specularIntensityMap,e(f.specularIntensityMap,g.specularIntensityMapTransform))}function _(g,f){f.matcap&&(g.matcap.value=f.matcap)}function v(g,f){let T=t.get(f).light;g.referencePosition.value.setFromMatrixPosition(T.matrixWorld),g.nearDistance.value=T.shadow.camera.near,g.farDistance.value=T.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Jg(i,t,e,n){let s={},r={},a=[],o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,b){let E=b.program;n.uniformBlockBinding(M,E)}function l(M,b){let E=s[M.id];E===void 0&&(g(M),E=h(M),s[M.id]=E,M.addEventListener("dispose",T));let A=b.program;n.updateUBOMapping(M,A);let x=t.render.frame;r[M.id]!==x&&(u(M),r[M.id]=x)}function h(M){let b=d();M.__bindingPointIndex=b;let E=i.createBuffer(),A=M.__size,x=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,E),i.bufferData(i.UNIFORM_BUFFER,A,x),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,b,E),E}function d(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return Dt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(M){let b=s[M.id],E=M.uniforms,A=M.__cache;i.bindBuffer(i.UNIFORM_BUFFER,b);for(let x=0,w=E.length;x<w;x++){let D=E[x];if(Array.isArray(D))for(let O=0,V=D.length;O<V;O++)p(D[O],x,O,A);else p(D,x,0,A)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(M,b,E,A){if(v(M,b,E,A)===!0){let x=M.__offset,w=M.value;if(Array.isArray(w)){let D=0;for(let O=0;O<w.length;O++){let V=w[O],H=f(V);_(V,M.__data,D),typeof V!="number"&&typeof V!="boolean"&&!V.isMatrix3&&!ArrayBuffer.isView(V)&&(D+=H.storage/Float32Array.BYTES_PER_ELEMENT)}}else _(w,M.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,x,M.__data)}}function _(M,b,E){typeof M=="number"||typeof M=="boolean"?b[0]=M:M.isMatrix3?(b[0]=M.elements[0],b[1]=M.elements[1],b[2]=M.elements[2],b[3]=0,b[4]=M.elements[3],b[5]=M.elements[4],b[6]=M.elements[5],b[7]=0,b[8]=M.elements[6],b[9]=M.elements[7],b[10]=M.elements[8],b[11]=0):ArrayBuffer.isView(M)?b.set(new M.constructor(M.buffer,M.byteOffset,b.length)):M.toArray(b,E)}function v(M,b,E,A){let x=M.value,w=b+"_"+E;if(A[w]===void 0)return typeof x=="number"||typeof x=="boolean"?A[w]=x:ArrayBuffer.isView(x)?A[w]=x.slice():A[w]=x.clone(),!0;{let D=A[w];if(typeof x=="number"||typeof x=="boolean"){if(D!==x)return A[w]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(D.equals(x)===!1)return D.copy(x),!0}}return!1}function g(M){let b=M.uniforms,E=0,A=16;for(let w=0,D=b.length;w<D;w++){let O=Array.isArray(b[w])?b[w]:[b[w]];for(let V=0,H=O.length;V<H;V++){let R=O[V],W=Array.isArray(R.value)?R.value:[R.value];for(let $=0,K=W.length;$<K;$++){let st=W[$],Y=f(st),et=E%A,it=et%Y.boundary,Ct=et+it;E+=it,Ct!==0&&A-Ct<Y.storage&&(E+=A-Ct),R.__data=new Float32Array(Y.storage/Float32Array.BYTES_PER_ELEMENT),R.__offset=E,E+=Y.storage}}}let x=E%A;return x>0&&(E+=A-x),M.__size=E,M.__cache={},this}function f(M){let b={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(b.boundary=4,b.storage=4):M.isVector2?(b.boundary=8,b.storage=8):M.isVector3||M.isColor?(b.boundary=16,b.storage=12):M.isVector4?(b.boundary=16,b.storage=16):M.isMatrix3?(b.boundary=48,b.storage=48):M.isMatrix4?(b.boundary=64,b.storage=64):M.isTexture?It("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(b.boundary=16,b.storage=M.byteLength):It("WebGLRenderer: Unsupported uniform value type.",M),b}function T(M){let b=M.target;b.removeEventListener("dispose",T);let E=a.indexOf(b.__bindingPointIndex);a.splice(E,1),i.deleteBuffer(s[b.id]),delete s[b.id],delete r[b.id]}function L(){for(let M in s)i.deleteBuffer(s[M]);a=[],s={},r={}}return{bind:c,update:l,dispose:L}}var $g=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]),_n=null;function Kg(){return _n===null&&(_n=new Rr($g,16,16,jn,hn),_n.name="DFG_LUT",_n.minFilter=Te,_n.magFilter=Te,_n.wrapS=fn,_n.wrapT=fn,_n.generateMipmaps=!1,_n.needsUpdate=!0),_n}var Wa=class{constructor(t={}){let{canvas:e=Qc(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:p=Ge}=t;this.isWebGLRenderer=!0;let _;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");_=n.getContextAttributes().alpha}else _=a;let v=p,g=new Set([aa,ra,sa]),f=new Set([Ge,ln,Wi,Xi,na,ia]),T=new Uint32Array(4),L=new Int32Array(4),M=new U,b=null,E=null,A=[],x=[],w=null;this.domElement=e,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=on,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let D=this,O=!1,V=null,H=null,R=null,W=null;this._outputColorSpace=Ye;let $=0,K=0,st=null,Y=-1,et=null,it=new he,Ct=new he,Et=null,ee=new Ft(0),Lt=0,Wt=e.width,j=e.height,Q=1,_t=null,St=null,pt=new he(0,0,Wt,j),Ot=new he(0,0,Wt,j),pe=!1,Bt=new Oi,Zt=!1,$t=!1,zt=new ce,ie=new U,ue=new he,me={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},re=!1;function de(){return st===null?Q:1}let I=n;function fe(y,P){return e.getContext(y,P)}let Xt,S,m,F,G,J,lt,N,k,q,nt,ht,at,ot,xt,ut,Pt,C,rt,Z,ct,dt,tt;try{let y={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${"186"}`),e.addEventListener("webglcontextlost",yt,!1),e.addEventListener("webglcontextrestored",kt,!1),e.addEventListener("webglcontextcreationerror",we,!1),I===null){let P="webgl2";if(I=fe(P,y),I===null)throw fe(P)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}wt()}catch(y){throw e.removeEventListener("webglcontextlost",yt,!1),e.removeEventListener("webglcontextrestored",kt,!1),e.removeEventListener("webglcontextcreationerror",we,!1),Dt("WebGLRenderer: "+y.message),y}function wt(){Xt=new sm(I),Xt.init(),ct=new Wg(I,Xt),S=new Zp(I,Xt,t,ct),m=new Gg(I,Xt),S.reversedDepthBuffer&&u&&m.buffers.depth.setReversed(!0),H=I.createFramebuffer(),R=I.createFramebuffer(),W=I.createFramebuffer(),F=new om(I),G=new Cg,J=new Hg(I,Xt,m,G,S,ct,F),lt=new im(D),N=new ld(I),dt=new qp(I,N),k=new rm(I,N,F,dt),q=new cm(I,k,N,dt,F),C=new lm(I,S,J),xt=new Jp(G),nt=new Ag(D,lt,Xt,S,dt,xt),ht=new Zg(D,G),at=new Pg,ot=new Fg(Xt),Pt=new Xp(D,lt,m,q,_,c),ut=new Vg(D,q,S),tt=new Jg(I,F,S,m),rt=new Yp(I,Xt,F),Z=new am(I,Xt,F),F.programs=nt.programs,D.capabilities=S,D.extensions=Xt,D.properties=G,D.renderLists=at,D.shadowMap=ut,D.state=m,D.info=F}v!==Ge&&(w=new um(v,e.width,e.height,o,s,r));let bt=new Tl(D,I);this.xr=bt,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){let y=Xt.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){let y=Xt.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return Q},this.setPixelRatio=function(y){y!==void 0&&(Q=y,this.setSize(Wt,j,!1))},this.getSize=function(y){return y.set(Wt,j)},this.setSize=function(y,P,X=!0){if(bt.isPresenting){It("WebGLRenderer: Can't change size while VR device is presenting.");return}Wt=y,j=P,e.width=Math.floor(y*Q),e.height=Math.floor(P*Q),X===!0&&(e.style.width=y+"px",e.style.height=P+"px"),w!==null&&w.setSize(e.width,e.height),this.setViewport(0,0,y,P)},this.getDrawingBufferSize=function(y){return y.set(Wt*Q,j*Q).floor()},this.setDrawingBufferSize=function(y,P,X){Wt=y,j=P,Q=X,e.width=Math.floor(y*X),e.height=Math.floor(P*X),this.setViewport(0,0,y,P)},this.setEffects=function(y){if(v===Ge){Dt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let P=0;P<y.length;P++)if(y[P].isOutputPass===!0){It("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}w.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(it)},this.getViewport=function(y){return y.copy(pt)},this.setViewport=function(y,P,X,B){y.isVector4?pt.set(y.x,y.y,y.z,y.w):pt.set(y,P,X,B),m.viewport(it.copy(pt).multiplyScalar(Q).round())},this.getScissor=function(y){return y.copy(Ot)},this.setScissor=function(y,P,X,B){y.isVector4?Ot.set(y.x,y.y,y.z,y.w):Ot.set(y,P,X,B),m.scissor(Ct.copy(Ot).multiplyScalar(Q).round())},this.getScissorTest=function(){return pe},this.setScissorTest=function(y){m.setScissorTest(pe=y)},this.setOpaqueSort=function(y){_t=y},this.setTransparentSort=function(y){St=y},this.getClearColor=function(y){return y.copy(Pt.getClearColor())},this.setClearColor=function(){Pt.setClearColor(...arguments)},this.getClearAlpha=function(){return Pt.getClearAlpha()},this.setClearAlpha=function(){Pt.setClearAlpha(...arguments)},this.clear=function(y=!0,P=!0,X=!0){let B=0;if(y){let z=!1;if(st!==null){let gt=st.texture.format;z=g.has(gt)}if(z){let gt=st.texture.type,Mt=f.has(gt),mt=Pt.getClearColor(),Tt=Pt.getClearAlpha(),Rt=mt.r,Vt=mt.g,qt=mt.b;Mt?(T[0]=Rt,T[1]=Vt,T[2]=qt,T[3]=Tt,I.clearBufferuiv(I.COLOR,0,T)):(L[0]=Rt,L[1]=Vt,L[2]=qt,L[3]=Tt,I.clearBufferiv(I.COLOR,0,L))}else B|=I.COLOR_BUFFER_BIT}P&&(B|=I.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),X&&(B|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&I.clear(B)},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.setNodesHandler=function(y){y.setRenderer(this),V=y},this.dispose=function(){e.removeEventListener("webglcontextlost",yt,!1),e.removeEventListener("webglcontextrestored",kt,!1),e.removeEventListener("webglcontextcreationerror",we,!1),Pt.dispose(),at.dispose(),ot.dispose(),G.dispose(),lt.dispose(),q.dispose(),dt.dispose(),tt.dispose(),nt.dispose(),bt.dispose(),bt.removeEventListener("sessionstart",Bl),bt.removeEventListener("sessionend",zl),ti.stop()};function yt(y){y.preventDefault(),tl("WebGLRenderer: Context Lost."),O=!0}function kt(){tl("WebGLRenderer: Context Restored."),O=!1;let y=F.autoReset,P=ut.enabled,X=ut.autoUpdate,B=ut.needsUpdate,z=ut.type;wt(),F.autoReset=y,ut.enabled=P,ut.autoUpdate=X,ut.needsUpdate=B,ut.type=z}function we(y){Dt("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function We(y){let P=y.target;P.removeEventListener("dispose",We),Vs(P)}function Vs(y){ru(y),G.remove(y)}function ru(y){let P=G.get(y).programs;P!==void 0&&(P.forEach(function(X){nt.releaseProgram(X)}),y.isShaderMaterial&&nt.releaseShaderCache(y))}this.renderBufferDirect=function(y,P,X,B,z,gt){P===null&&(P=me);let Mt=z.isMesh&&z.matrixWorld.determinantAffine()<0,mt=lu(y,P,X,B,z);m.setMaterial(B,Mt);let Tt=X.index,Rt=1;if(B.wireframe===!0){if(Tt=k.getWireframeAttribute(X),Tt===void 0)return;Rt=2}let Vt=X.drawRange,qt=X.attributes.position,At=Vt.start*Rt,jt=(Vt.start+Vt.count)*Rt;gt!==null&&(At=Math.max(At,gt.start*Rt),jt=Math.min(jt,(gt.start+gt.count)*Rt)),Tt!==null?(At=Math.max(At,0),jt=Math.min(jt,Tt.count)):qt!=null&&(At=Math.max(At,0),jt=Math.min(jt,qt.count));let _e=jt-At;if(_e<0||_e===1/0)return;dt.setup(z,B,mt,X,Tt);let oe,se=rt;if(Tt!==null&&(oe=N.get(Tt),se=Z,se.setIndex(oe)),z.isMesh)B.wireframe===!0?(m.setLineWidth(B.wireframeLinewidth*de()),se.setMode(I.LINES)):se.setMode(I.TRIANGLES);else if(z.isLine){let Ce=B.linewidth;Ce===void 0&&(Ce=1),m.setLineWidth(Ce*de()),z.isLineSegments?se.setMode(I.LINES):z.isLineLoop?se.setMode(I.LINE_LOOP):se.setMode(I.LINE_STRIP)}else z.isPoints?se.setMode(I.POINTS):z.isSprite&&se.setMode(I.TRIANGLES);if(z.isBatchedMesh)if(Xt.get("WEBGL_multi_draw"))se.renderMultiDraw(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount);else{let Ce=z._multiDrawStarts,vt=z._multiDrawCounts,De=z._multiDrawCount,Jt=Tt?N.get(Tt).bytesPerElement:1,je=G.get(B).currentProgram.getUniforms();for(let un=0;un<De;un++)je.setValue(I,"_gl_DrawID",un),se.render(Ce[un]/Jt,vt[un])}else if(z.isInstancedMesh)se.renderInstances(At,_e,z.count);else if(X.isInstancedBufferGeometry){let Ce=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,vt=Math.min(X.instanceCount,Ce);se.renderInstances(At,_e,vt)}else se.render(At,_e)};function Ol(y,P,X,B){V!==null&&y.isNodeMaterial&&V.setObject(B,y),Zt===!0&&xt.setState(y,X,!1),y.transparent===!0&&y.side===mn&&y.forceSinglePass===!1?(y.side=Fe,y.needsUpdate=!0,Hs(y,P,B),y.side=Zn,y.needsUpdate=!0,Hs(y,P,B),y.side=mn):Hs(y,P,B)}this.compile=function(y,P,X=null){X===null&&(X=y),V!==null&&V.renderStart(y,P,X),E=ot.get(X),E.init(P),x.push(E),X.traverseVisible(function(z){z.isLight&&z.layers.test(P.layers)&&(E.pushLight(z),z.castShadow&&E.pushShadow(z))}),y!==X&&y.traverseVisible(function(z){z.isLight&&z.layers.test(P.layers)&&(E.pushLight(z),z.castShadow&&E.pushShadow(z))}),E.setupLights(),V!==null&&V.updateLights(E.state.lightsArray),$t=this.localClippingEnabled,Zt=xt.init(this.clippingPlanes,$t),Zt===!0&&xt.setGlobalState(this.clippingPlanes,P),V!==null&&ut.render(E.state.shadowsArray,X,P);let B=new Set;return y.traverse(function(z){if(!(z.isMesh||z.isPoints||z.isLine||z.isSprite))return;let gt=z.material;if(gt)if(Array.isArray(gt))for(let Mt=0;Mt<gt.length;Mt++){let mt=gt[Mt];Ol(mt,X,P,z),B.add(mt)}else Ol(gt,X,P,z),B.add(gt)}),E=x.pop(),V!==null&&V.renderEnd(),B},this.compileAsync=function(y,P,X=null){let B=this.compile(y,P,X);return new Promise(z=>{function gt(){if(B.forEach(function(Mt){let Tt=G.get(Mt).currentProgram;(Tt===void 0||Tt.isReady())&&B.delete(Mt)}),B.size===0){z(y);return}setTimeout(gt,10)}Xt.get("KHR_parallel_shader_compile")!==null?gt():setTimeout(gt,10)})};let to=null;function au(y){to&&to(y)}function Bl(){ti.stop()}function zl(){ti.start()}let ti=new Ch;ti.setAnimationLoop(au),typeof self<"u"&&ti.setContext(self),this.setAnimationLoop=function(y){to=y,bt.setAnimationLoop(y),y===null?ti.stop():ti.start()},bt.addEventListener("sessionstart",Bl),bt.addEventListener("sessionend",zl),this.render=function(y,P){if(P!==void 0&&P.isCamera!==!0){Dt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(O===!0)return;V!==null&&V.renderStart(y,P);let X=bt.enabled===!0&&bt.isPresenting===!0,B=w!==null&&(st===null||X)&&w.begin(D,st);if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),P.parent===null&&P.matrixWorldAutoUpdate===!0&&P.updateMatrixWorld(),bt.enabled===!0&&bt.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(bt.cameraAutoUpdate===!0&&bt.updateCamera(P),P=bt.getCamera()),y.isScene===!0&&y.onBeforeRender(D,y,P,st),E=ot.get(y,x.length),E.init(P),E.state.textureUnits=J.getTextureUnits(),x.push(E),zt.multiplyMatrices(P.projectionMatrix,P.matrixWorldInverse),Bt.setFromProjectionMatrix(zt,rn,P.reversedDepth),$t=this.localClippingEnabled,Zt=xt.init(this.clippingPlanes,$t),b=at.get(y,A.length),b.init(),A.push(b),bt.enabled===!0&&bt.isPresenting===!0){let Mt=D.xr.getDepthSensingMesh();Mt!==null&&eo(Mt,P,-1/0,D.sortObjects)}eo(y,P,0,D.sortObjects),b.finish(),V!==null&&V.updateLights(E.state.lightsArray),D.sortObjects===!0&&b.sort(_t,St),re=bt.enabled===!1||bt.isPresenting===!1||bt.hasDepthSensing()===!1,re&&Pt.addToRenderList(b,y),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Zt===!0&&xt.beginShadows();let z=E.state.shadowsArray;if(ut.render(z,y,P),Zt===!0&&xt.endShadows(),(B&&w.hasRenderPass())===!1){let Mt=b.opaque,mt=b.transmissive;if(E.setupLights(),P.isArrayCamera){let Tt=P.cameras;if(mt.length>0)for(let Rt=0,Vt=Tt.length;Rt<Vt;Rt++){let qt=Tt[Rt];Vl(Mt,mt,y,qt)}re&&Pt.render(y);for(let Rt=0,Vt=Tt.length;Rt<Vt;Rt++){let qt=Tt[Rt];kl(b,y,qt,qt.viewport)}}else mt.length>0&&Vl(Mt,mt,y,P),re&&Pt.render(y),kl(b,y,P)}st!==null&&K===0&&(J.updateMultisampleRenderTarget(st),J.updateRenderTargetMipmap(st)),B&&w.end(D),y.isScene===!0&&y.onAfterRender(D,y,P),dt.resetDefaultState(),Y=-1,et=null,x.pop(),x.length>0?(E=x[x.length-1],J.setTextureUnits(E.state.textureUnits),Zt===!0&&xt.setGlobalState(D.clippingPlanes,E.state.camera)):E=null,A.pop(),A.length>0?b=A[A.length-1]:b=null,V!==null&&V.renderEnd()};function eo(y,P,X,B){if(y.visible===!1)return;if(y.layers.test(P.layers)){if(y.isGroup)X=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(P);else if(y.isLightProbeGrid)E.pushLightProbeGrid(y);else if(y.isLight)E.pushLight(y),y.castShadow&&E.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||y.intersectsFrustum(Bt)){B&&ue.setFromMatrixPosition(y.matrixWorld).applyMatrix4(zt);let Mt=q.update(y),mt=y.material;mt.visible&&b.push(y,Mt,mt,X,ue.z,null,P)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||y.intersectsFrustum(Bt))){let Mt=q.update(y),mt=y.material;if(B&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),ue.copy(y.boundingSphere.center)):(Mt.boundingSphere===null&&Mt.computeBoundingSphere(),ue.copy(Mt.boundingSphere.center)),ue.applyMatrix4(y.matrixWorld).applyMatrix4(zt)),Array.isArray(mt)){let Tt=Mt.groups;for(let Rt=0,Vt=Tt.length;Rt<Vt;Rt++){let qt=Tt[Rt],At=mt[qt.materialIndex];At&&At.visible&&b.push(y,Mt,At,X,ue.z,qt,P)}}else mt.visible&&b.push(y,Mt,mt,X,ue.z,null,P)}}let gt=y.children;for(let Mt=0,mt=gt.length;Mt<mt;Mt++)eo(gt[Mt],P,X,B)}function kl(y,P,X,B){let{opaque:z,transmissive:gt,transparent:Mt}=y;E.setupLightsView(X),Zt===!0&&xt.setGlobalState(D.clippingPlanes,X),B&&m.viewport(it.copy(B)),z.length>0&&Gs(z,P,X),gt.length>0&&Gs(gt,P,X),Mt.length>0&&Gs(Mt,P,X),m.buffers.depth.setTest(!0),m.buffers.depth.setMask(!0),m.buffers.color.setMask(!0),m.setPolygonOffset(!1)}function Vl(y,P,X,B){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;if(E.state.transmissionRenderTarget[B.id]===void 0){let At=Xt.has("EXT_color_buffer_half_float")||Xt.has("EXT_color_buffer_float");E.state.transmissionRenderTarget[B.id]=new ze(1,1,{generateMipmaps:!0,type:At?hn:Ge,minFilter:$n,samples:Math.max(4,S.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:Yt.workingColorSpace})}let gt=E.state.transmissionRenderTarget[B.id],Mt=B.viewport||it;gt.setSize(Mt.z*D.transmissionResolutionScale,Mt.w*D.transmissionResolutionScale);let mt=D.getRenderTarget(),Tt=D.getActiveCubeFace(),Rt=D.getActiveMipmapLevel();D.setRenderTarget(gt),D.getClearColor(ee),Lt=D.getClearAlpha(),Lt<1&&D.setClearColor(16777215,.5),D.clear(),re&&Pt.render(X);let Vt=D.toneMapping;D.toneMapping=on;let qt=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),E.setupLightsView(B),Zt===!0&&xt.setGlobalState(D.clippingPlanes,B),Gs(y,X,B),J.updateMultisampleRenderTarget(gt),J.updateRenderTargetMipmap(gt),Xt.has("WEBGL_multisampled_render_to_texture")===!1){let At=!1;for(let jt=0,_e=P.length;jt<_e;jt++){let oe=P[jt],{object:se,geometry:Ce,material:vt,group:De}=oe;if(vt.side===mn&&se.layers.test(B.layers)){let Jt=vt.side;vt.side=Fe,vt.needsUpdate=!0,Gl(se,X,B,Ce,vt,De),vt.side=Jt,vt.needsUpdate=!0,At=!0}}At===!0&&(J.updateMultisampleRenderTarget(gt),J.updateRenderTargetMipmap(gt))}D.setRenderTarget(mt,Tt,Rt),D.setClearColor(ee,Lt),qt!==void 0&&(B.viewport=qt),D.toneMapping=Vt}function Gs(y,P,X){let B=P.isScene===!0?P.overrideMaterial:null;for(let z=0,gt=y.length;z<gt;z++){let Mt=y[z],{object:mt,geometry:Tt,group:Rt}=Mt,Vt=Mt.material;Vt.allowOverride===!0&&B!==null&&(Vt=B),mt.layers.test(X.layers)&&Gl(mt,P,X,Tt,Vt,Rt)}}function Gl(y,P,X,B,z,gt){V!==null&&z.isNodeMaterial&&V.setObject(y,z),y.onBeforeRender(D,P,X,B,z,gt),y.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),z.onBeforeRender(D,P,X,B,y,gt),z.transparent===!0&&z.side===mn&&z.forceSinglePass===!1?(z.side=Fe,z.needsUpdate=!0,D.renderBufferDirect(X,P,B,z,y,gt),z.side=Zn,z.needsUpdate=!0,D.renderBufferDirect(X,P,B,z,y,gt),z.side=mn):D.renderBufferDirect(X,P,B,z,y,gt),y.onAfterRender(D,P,X,B,z,gt)}function Hs(y,P,X){P.isScene!==!0&&(P=me);let B=G.get(y),z=E.state.lights,gt=E.state.shadowsArray,Mt=z.state.version,mt=nt.getParameters(y,z.state,gt,P,X,E.state.lightProbeGridArray),Tt=nt.getProgramCacheKey(mt),Rt=B.programs;B.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?P.environment:null,B.fog=P.fog;let Vt=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;B.envMap=lt.get(y.envMap||B.environment,Vt),B.envMapRotation=B.environment!==null&&y.envMap===null?P.environmentRotation:y.envMapRotation,Rt===void 0&&(y.addEventListener("dispose",We),Rt=new Map,B.programs=Rt);let qt=Rt.get(Tt);if(qt!==void 0){if(B.currentProgram===qt&&B.lightsStateVersion===Mt)return Wl(y,mt),qt}else mt.uniforms=nt.getUniforms(y),V!==null&&y.isNodeMaterial&&V.build(y,X,mt),y.onBeforeCompile(mt,D),qt=nt.acquireProgram(mt,Tt),Rt.set(Tt,qt),B.uniforms=mt.uniforms;let At=B.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(At.clippingPlanes=xt.uniform),Wl(y,mt),B.needsLights=hu(y),B.lightsStateVersion=Mt,B.needsLights&&(At.ambientLightColor.value=z.state.ambient,At.lightProbe.value=z.state.probe,At.sunLights.value=z.state.sun,At.sunLightShadows.value=z.state.sunShadow,At.directionalLights.value=z.state.directional,At.directionalLightShadows.value=z.state.directionalShadow,At.spotLights.value=z.state.spot,At.spotLightShadows.value=z.state.spotShadow,At.rectAreaLights.value=z.state.rectArea,At.ltc_1.value=z.state.rectAreaLTC1,At.ltc_2.value=z.state.rectAreaLTC2,At.pointLights.value=z.state.point,At.pointLightShadows.value=z.state.pointShadow,At.hemisphereLights.value=z.state.hemi,At.sunShadowMatrix.value=z.state.sunShadowMatrix,At.sunShadowCascade.value=z.state.sunShadowCascade,At.directionalShadowMatrix.value=z.state.directionalShadowMatrix,At.spotLightMatrix.value=z.state.spotLightMatrix,At.spotLightMap.value=z.state.spotLightMap,At.pointShadowMatrix.value=z.state.pointShadowMatrix),B.lightProbeGrid=E.state.lightProbeGridArray.length>0,B.currentProgram=qt,B.uniformsList=null,qt}function Hl(y){if(y.uniformsList===null){let P=y.currentProgram.getUniforms();y.uniformsList=Ji.seqWithValue(P.seq,y.uniforms)}return y.uniformsList}function Wl(y,P){let X=G.get(y);X.outputColorSpace=P.outputColorSpace,X.batching=P.batching,X.batchingColor=P.batchingColor,X.instancing=P.instancing,X.instancingColor=P.instancingColor,X.instancingMorph=P.instancingMorph,X.skinning=P.skinning,X.morphTargets=P.morphTargets,X.morphNormals=P.morphNormals,X.morphColors=P.morphColors,X.morphTargetsCount=P.morphTargetsCount,X.numClippingPlanes=P.numClippingPlanes,X.numIntersection=P.numClipIntersection,X.vertexAlphas=P.vertexAlphas,X.vertexTangents=P.vertexTangents,X.toneMapping=P.toneMapping}function ou(y,P){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;M.setFromMatrixPosition(P.matrixWorld);for(let X=0,B=y.length;X<B;X++){let z=y[X];if(z.texture!==null&&z.boundingBox.containsPoint(M))return z}return null}function lu(y,P,X,B,z){P.isScene!==!0&&(P=me),J.resetTextureUnits();let gt=P.fog,Mt=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?P.environment:null,mt=st===null?D.outputColorSpace:st.isXRRenderTarget===!0?st.texture.colorSpace:Yt.workingColorSpace,Tt=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Rt=lt.get(B.envMap||Mt,Tt),Vt=B.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,qt=!!X.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),At=!!X.morphAttributes.position,jt=!!X.morphAttributes.normal,_e=!!X.morphAttributes.color,oe=on;B.toneMapped&&(st===null||st.isXRRenderTarget===!0)&&(oe=D.toneMapping);let se=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Ce=se!==void 0?se.length:0,vt=G.get(B),De=E.state.lights;if(Zt===!0&&($t===!0||y!==et)){let ae=y===et&&B.id===Y;xt.setState(B,y,ae)}let Jt=!1;B.version===vt.__version?(vt.needsLights&&vt.lightsStateVersion!==De.state.version||vt.outputColorSpace!==mt||z.isBatchedMesh&&vt.batching===!1||!z.isBatchedMesh&&vt.batching===!0||z.isBatchedMesh&&vt.batchingColor===!0&&z._colorsTexture===null||z.isBatchedMesh&&vt.batchingColor===!1&&z._colorsTexture!==null||z.isInstancedMesh&&vt.instancing===!1||!z.isInstancedMesh&&vt.instancing===!0||z.isSkinnedMesh&&vt.skinning===!1||!z.isSkinnedMesh&&vt.skinning===!0||z.isInstancedMesh&&vt.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&vt.instancingColor===!1&&z.instanceColor!==null||z.isInstancedMesh&&vt.instancingMorph===!0&&z.morphTexture===null||z.isInstancedMesh&&vt.instancingMorph===!1&&z.morphTexture!==null||vt.envMap!==Rt||B.fog===!0&&vt.fog!==gt||vt.numClippingPlanes!==void 0&&(vt.numClippingPlanes!==xt.numPlanes||vt.numIntersection!==xt.numIntersection)||vt.vertexAlphas!==Vt||vt.vertexTangents!==qt||vt.morphTargets!==At||vt.morphNormals!==jt||vt.morphColors!==_e||vt.toneMapping!==oe||vt.morphTargetsCount!==Ce||!!vt.lightProbeGrid!=E.state.lightProbeGridArray.length>0)&&(Jt=!0):(Jt=!0,vt.__version=B.version);let je=vt.currentProgram;Jt===!0&&(je=Hs(B,P,z),V&&B.isNodeMaterial&&V.onUpdateProgram(B,je,vt));let un=!1,Ln=!1,fi=!1,ne=je.getUniforms(),ge=vt.uniforms;if(m.useProgram(je.program)&&(un=!0,Ln=!0,fi=!0),B.id!==Y&&(Y=B.id,Ln=!0),vt.needsLights){let ae=ou(E.state.lightProbeGridArray,z);vt.lightProbeGrid!==ae&&(vt.lightProbeGrid=ae,Ln=!0)}if(un||et!==y){m.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),ne.setValue(I,"projectionMatrix",y.projectionMatrix),ne.setValue(I,"viewMatrix",y.matrixWorldInverse);let Nn=ne.map.cameraPosition;Nn!==void 0&&Nn.setValue(I,ie.setFromMatrixPosition(y.matrixWorld)),S.logarithmicDepthBuffer&&ne.setValue(I,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&ne.setValue(I,"isOrthographic",y.isOrthographicCamera===!0),et!==y&&(et=y,Ln=!0,fi=!0)}if(vt.needsLights&&(De.state.sunShadowMap.length>0&&ne.setValue(I,"sunShadowMap",De.state.sunShadowMap,J),De.state.directionalShadowMap.length>0&&ne.setValue(I,"directionalShadowMap",De.state.directionalShadowMap,J),De.state.spotShadowMap.length>0&&ne.setValue(I,"spotShadowMap",De.state.spotShadowMap,J),De.state.pointShadowMap.length>0&&ne.setValue(I,"pointShadowMap",De.state.pointShadowMap,J)),z.isSkinnedMesh){ne.setOptional(I,z,"bindMatrix"),ne.setOptional(I,z,"bindMatrixInverse");let ae=z.skeleton;ae&&(ae.boneTexture===null&&ae.computeBoneTexture(),ne.setValue(I,"boneTexture",ae.boneTexture,J))}z.isBatchedMesh&&(ne.setOptional(I,z,"batchingTexture"),ne.setValue(I,"batchingTexture",z._matricesTexture,J),ne.setOptional(I,z,"batchingIdTexture"),ne.setValue(I,"batchingIdTexture",z._indirectTexture,J),ne.setOptional(I,z,"batchingColorTexture"),z._colorsTexture!==null&&ne.setValue(I,"batchingColorTexture",z._colorsTexture,J));let Dn=X.morphAttributes;if((Dn.position!==void 0||Dn.normal!==void 0||Dn.color!==void 0)&&C.update(z,X,je),(Ln||vt.receiveShadow!==z.receiveShadow)&&(vt.receiveShadow=z.receiveShadow,ne.setValue(I,"receiveShadow",z.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&P.environment!==null&&(ge.envMapIntensity.value=P.environmentIntensity),ge.dfgLUT!==void 0&&(ge.dfgLUT.value=Kg()),Ln){if(ne.setValue(I,"toneMappingExposure",D.toneMappingExposure),vt.needsLights&&cu(ge,fi),gt&&B.fog===!0&&ht.refreshFogUniforms(ge,gt),ht.refreshMaterialUniforms(ge,B,Q,j,E.state.transmissionRenderTarget[y.id]),vt.needsLights&&vt.lightProbeGrid){let ae=vt.lightProbeGrid;ge.probesSH.value=ae.texture,ge.probesMin.value.copy(ae.boundingBox.min),ge.probesMax.value.copy(ae.boundingBox.max),ge.probesResolution.value.copy(ae.resolution)}Ji.upload(I,Hl(vt),ge,J)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Ji.upload(I,Hl(vt),ge,J),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&ne.setValue(I,"center",z.center),ne.setValue(I,"modelViewMatrix",z.modelViewMatrix),ne.setValue(I,"normalMatrix",z.normalMatrix),ne.setValue(I,"modelMatrix",z.matrixWorld),B.uniformsGroups!==void 0){let ae=B.uniformsGroups;for(let Nn=0,pi=ae.length;Nn<pi;Nn++){let ql=ae[Nn];tt.update(ql,je),tt.bind(ql,je)}}return je}function cu(y,P){y.ambientLightColor.needsUpdate=P,y.lightProbe.needsUpdate=P,y.sunLights.needsUpdate=P,y.sunLightShadows.needsUpdate=P,y.directionalLights.needsUpdate=P,y.directionalLightShadows.needsUpdate=P,y.pointLights.needsUpdate=P,y.pointLightShadows.needsUpdate=P,y.spotLights.needsUpdate=P,y.spotLightShadows.needsUpdate=P,y.rectAreaLights.needsUpdate=P,y.hemisphereLights.needsUpdate=P}function hu(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return $},this.getActiveMipmapLevel=function(){return K},this.getRenderTarget=function(){return st},this.setRenderTargetTextures=function(y,P,X){let B=G.get(y);B.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),G.get(y.texture).__webglTexture=P,G.get(y.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:X,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,P){let X=G.get(y);X.__webglFramebuffer=P,X.__useDefaultFramebuffer=P===void 0},this.setRenderTarget=function(y,P=0,X=0){st=y,$=P,K=X;let B=null,z=!1,gt=!1;if(y){let mt=G.get(y);if(mt.__useDefaultFramebuffer!==void 0){m.bindFramebuffer(I.FRAMEBUFFER,mt.__webglFramebuffer),it.copy(y.viewport),Ct.copy(y.scissor),Et=y.scissorTest,m.viewport(it),m.scissor(Ct),m.setScissorTest(Et),Y=-1;return}else if(mt.__webglFramebuffer===void 0)J.setupRenderTarget(y);else if(mt.__hasExternalTextures)J.rebindTextures(y,G.get(y.texture).__webglTexture,G.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){let Vt=y.depthTexture;if(mt.__boundDepthTexture!==Vt){if(Vt!==null&&G.has(Vt)&&(y.width!==Vt.image.width||y.height!==Vt.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");J.setupDepthRenderbuffer(y)}}let Tt=y.texture;(Tt.isData3DTexture||Tt.isDataArrayTexture||Tt.isCompressedArrayTexture)&&(gt=!0);let Rt=G.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Rt[P])?B=Rt[P][X]:B=Rt[P],z=!0):y.samples>0&&J.useMultisampledRTT(y)===!1?B=G.get(y).__webglMultisampledFramebuffer:Array.isArray(Rt)?B=Rt[X]:B=Rt,it.copy(y.viewport),Ct.copy(y.scissor),Et=y.scissorTest}else it.copy(pt).multiplyScalar(Q).floor(),Ct.copy(Ot).multiplyScalar(Q).floor(),Et=pe;if(X!==0&&(B=H),m.bindFramebuffer(I.FRAMEBUFFER,B)&&m.drawBuffers(y,B),m.viewport(it),m.scissor(Ct),m.setScissorTest(Et),z){let mt=G.get(y.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+P,mt.__webglTexture,X)}else if(gt){let mt=P;for(let Tt=0;Tt<y.textures.length;Tt++){let Rt=G.get(y.textures[Tt]);I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0+Tt,Rt.__webglTexture,X,mt)}}else if(y!==null&&X!==0){let mt=G.get(y.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,mt.__webglTexture,X)}Y=-1};function Xl(y){let P=G.get(y);return(P.__readFormat!==y.format||P.__readType!==y.type)&&(P.__readFormat=y.format,P.__readType=y.type,P.__formatReadable=S.textureFormatReadable(y.format),P.__typeReadable=S.textureTypeReadable(y.type)),P}this.readRenderTargetPixels=function(y,P,X,B,z,gt,Mt,mt=0){if(!(y&&y.isWebGLRenderTarget)){Dt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Tt=G.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&Mt!==void 0&&(Tt=Tt[Mt]),Tt){m.bindFramebuffer(I.FRAMEBUFFER,Tt);try{let Rt=y.textures[mt],Vt=Rt.format,qt=Rt.type;y.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+mt);let At=Xl(Rt);if(At.__formatReadable===!1){Dt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(At.__typeReadable===!1){Dt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}P>=0&&P<=y.width-B&&X>=0&&X<=y.height-z&&I.readPixels(P,X,B,z,ct.convert(Vt),ct.convert(qt),gt)}finally{let Rt=st!==null?G.get(st).__webglFramebuffer:null;m.bindFramebuffer(I.FRAMEBUFFER,Rt)}}},this.readRenderTargetPixelsAsync=async function(y,P,X,B,z,gt,Mt,mt=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Tt=G.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&Mt!==void 0&&(Tt=Tt[Mt]),Tt)if(P>=0&&P<=y.width-B&&X>=0&&X<=y.height-z){m.bindFramebuffer(I.FRAMEBUFFER,Tt);let Rt=y.textures[mt],Vt=Rt.format,qt=Rt.type;y.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+mt);let At=Xl(Rt);if(At.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(At.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let jt=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,jt),I.bufferData(I.PIXEL_PACK_BUFFER,gt.byteLength,I.STREAM_READ),I.readPixels(P,X,B,z,ct.convert(Vt),ct.convert(qt),0),I.bindBuffer(I.PIXEL_PACK_BUFFER,null);let _e=st!==null?G.get(st).__webglFramebuffer:null;m.bindFramebuffer(I.FRAMEBUFFER,_e);let oe=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await eh(I,oe,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,jt),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,gt),I.bindBuffer(I.PIXEL_PACK_BUFFER,null),I.deleteBuffer(jt),I.deleteSync(oe),gt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,P=null,X=0){let B=Math.pow(2,-X),z=Math.floor(y.image.width*B),gt=Math.floor(y.image.height*B),Mt=P!==null?P.x:0,mt=P!==null?P.y:0;J.setTexture2D(y,0),I.copyTexSubImage2D(I.TEXTURE_2D,X,0,0,Mt,mt,z,gt),m.unbindTexture()},this.copyTextureToTexture=function(y,P,X=null,B=null,z=0,gt=0){let Mt,mt,Tt,Rt,Vt,qt,At,jt,_e,oe=y.isCompressedTexture?y.mipmaps[gt]:y.image;if(X!==null)Mt=X.max.x-X.min.x,mt=X.max.y-X.min.y,Tt=X.isBox3?X.max.z-X.min.z:1,Rt=X.min.x,Vt=X.min.y,qt=X.isBox3?X.min.z:0;else{let ge=Math.pow(2,-z);Mt=Math.floor(oe.width*ge),mt=Math.floor(oe.height*ge),y.isDataArrayTexture?Tt=oe.depth:y.isData3DTexture?Tt=Math.floor(oe.depth*ge):Tt=1,Rt=0,Vt=0,qt=0}B!==null?(At=B.x,jt=B.y,_e=B.z):(At=0,jt=0,_e=0);let se=ct.convert(P.format),Ce=ct.convert(P.type),vt;P.isData3DTexture?(J.setTexture3D(P,0),vt=I.TEXTURE_3D):P.isDataArrayTexture||P.isCompressedArrayTexture?(J.setTexture2DArray(P,0),vt=I.TEXTURE_2D_ARRAY):(J.setTexture2D(P,0),vt=I.TEXTURE_2D),m.activeTexture(I.TEXTURE0),m.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,P.flipY),m.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),m.pixelStorei(I.UNPACK_ALIGNMENT,P.unpackAlignment);let De=m.getParameter(I.UNPACK_ROW_LENGTH),Jt=m.getParameter(I.UNPACK_IMAGE_HEIGHT),je=m.getParameter(I.UNPACK_SKIP_PIXELS),un=m.getParameter(I.UNPACK_SKIP_ROWS),Ln=m.getParameter(I.UNPACK_SKIP_IMAGES);m.pixelStorei(I.UNPACK_ROW_LENGTH,oe.width),m.pixelStorei(I.UNPACK_IMAGE_HEIGHT,oe.height),m.pixelStorei(I.UNPACK_SKIP_PIXELS,Rt),m.pixelStorei(I.UNPACK_SKIP_ROWS,Vt),m.pixelStorei(I.UNPACK_SKIP_IMAGES,qt);let fi=y.isDataArrayTexture||y.isData3DTexture,ne=P.isDataArrayTexture||P.isData3DTexture;if(y.isDepthTexture){let ge=G.get(y),Dn=G.get(P),ae=G.get(ge.__renderTarget),Nn=G.get(Dn.__renderTarget);m.bindFramebuffer(I.READ_FRAMEBUFFER,ae.__webglFramebuffer),m.bindFramebuffer(I.DRAW_FRAMEBUFFER,Nn.__webglFramebuffer);for(let pi=0;pi<Tt;pi++)fi&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,G.get(y).__webglTexture,z,qt+pi),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,G.get(P).__webglTexture,gt,_e+pi)),I.blitFramebuffer(Rt,Vt,Mt,mt,At,jt,Mt,mt,I.DEPTH_BUFFER_BIT,I.NEAREST);m.bindFramebuffer(I.READ_FRAMEBUFFER,null),m.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(z!==0||y.isRenderTargetTexture||G.has(y)){let ge=G.get(y),Dn=G.get(P);m.bindFramebuffer(I.READ_FRAMEBUFFER,R),m.bindFramebuffer(I.DRAW_FRAMEBUFFER,W);for(let ae=0;ae<Tt;ae++)fi?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,ge.__webglTexture,z,qt+ae):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,ge.__webglTexture,z),ne?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Dn.__webglTexture,gt,_e+ae):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Dn.__webglTexture,gt),z!==0?I.blitFramebuffer(Rt,Vt,Mt,mt,At,jt,Mt,mt,I.COLOR_BUFFER_BIT,I.NEAREST):ne?I.copyTexSubImage3D(vt,gt,At,jt,_e+ae,Rt,Vt,Mt,mt):I.copyTexSubImage2D(vt,gt,At,jt,Rt,Vt,Mt,mt);m.bindFramebuffer(I.READ_FRAMEBUFFER,null),m.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else ne?y.isDataTexture||y.isData3DTexture?I.texSubImage3D(vt,gt,At,jt,_e,Mt,mt,Tt,se,Ce,oe.data):P.isCompressedArrayTexture?I.compressedTexSubImage3D(vt,gt,At,jt,_e,Mt,mt,Tt,se,oe.data):I.texSubImage3D(vt,gt,At,jt,_e,Mt,mt,Tt,se,Ce,oe):y.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,gt,At,jt,Mt,mt,se,Ce,oe.data):y.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,gt,At,jt,oe.width,oe.height,se,oe.data):I.texSubImage2D(I.TEXTURE_2D,gt,At,jt,Mt,mt,se,Ce,oe);m.pixelStorei(I.UNPACK_ROW_LENGTH,De),m.pixelStorei(I.UNPACK_IMAGE_HEIGHT,Jt),m.pixelStorei(I.UNPACK_SKIP_PIXELS,je),m.pixelStorei(I.UNPACK_SKIP_ROWS,un),m.pixelStorei(I.UNPACK_SKIP_IMAGES,Ln),gt===0&&P.generateMipmaps&&I.generateMipmap(vt),m.unbindTexture()},this.initRenderTarget=function(y){G.get(y).__webglFramebuffer===void 0&&J.setupRenderTarget(y)},this.initTexture=function(y){y.isCubeTexture?J.setTextureCube(y,0):y.isData3DTexture?J.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?J.setTexture2DArray(y,0):J.setTexture2D(y,0),m.unbindTexture()},this.resetState=function(){$=0,K=0,st=null,m.reset(),dt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return rn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=Yt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Yt._getUnpackColorSpace()}};var Uh={type:"change"},Cl={type:"start"},Oh={type:"end"},Ya=new oi,Fh=new Ze,jg=Math.cos(70*nl.DEG2RAD),Me=new U,He=2*Math.PI,te={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Al=1e-6,Za=class extends bs{constructor(t,e=null){super(t,e),this.state=te.NONE,this.target=new U,this.cursor=new U,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:qn.ROTATE,MIDDLE:qn.DOLLY,RIGHT:qn.PAN},this.touches={ONE:Yn.ROTATE,TWO:Yn.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 U,this._lastQuaternion=new Je,this._lastTargetPosition=new U,this._quat=new Je().setFromUnitVectors(t.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Vi,this._sphericalDelta=new Vi,this._scale=1,this._panOffset=new U,this._rotateStart=new Nt,this._rotateEnd=new Nt,this._rotateDelta=new Nt,this._panStart=new Nt,this._panEnd=new Nt,this._panDelta=new Nt,this._dollyStart=new Nt,this._dollyEnd=new Nt,this._dollyDelta=new Nt,this._dollyDirection=new U,this._mouse=new Nt,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=t_.bind(this),this._onPointerDown=Qg.bind(this),this._onPointerUp=e_.bind(this),this._onContextMenu=l_.bind(this),this._onMouseWheel=s_.bind(this),this._onKeyDown=r_.bind(this),this._onTouchStart=a_.bind(this),this._onTouchMove=o_.bind(this),this._onMouseDown=n_.bind(this),this._onMouseMove=i_.bind(this),this._interceptControlDown=c_.bind(this),this._interceptControlUp=h_.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(t){this._cursorStyle=t,t==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(t){super.connect(t),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.state=te.NONE,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();let t=this.domElement.getRootNode();t.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),t.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}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(Uh),this.update(),this.state=te.NONE}pan(t,e){this._pan(t,e),this.update()}dollyIn(t){this._dollyIn(t),this.update()}dollyOut(t){this._dollyOut(t),this.update()}rotateLeft(t){this._rotateLeft(t),this.update()}rotateUp(t){this._rotateUp(t),this.update()}update(t=null){let e=this.object.position;Me.copy(e).sub(this.target),Me.applyQuaternion(this._quat),this._spherical.setFromVector3(Me),this.autoRotate&&this.state===te.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),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,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=He:n>Math.PI&&(n-=He),s<-Math.PI?s+=He:s>Math.PI&&(s-=He),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,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{let a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Me.setFromSpherical(this._spherical),Me.applyQuaternion(this._quatInverse),e.copy(this.target).add(Me),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 a=null;if(this.object.isPerspectiveCamera){let o=Me.length();a=this._clampDistance(o*this._scale);let c=o-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),r=!!c}else if(this.object.isOrthographicCamera){let o=new U(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let 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;let l=new U(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(o),this.object.updateMatrixWorld(),a=Me.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).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))<jg?this.object.lookAt(this.target):(Fh.setFromNormalAndCoplanarPoint(this.object.up,this.target),Ya.intersectPlane(Fh,this.target))))}else if(this.object.isOrthographicCamera){let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Al||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Al||this._lastTargetPosition.distanceToSquared(this.target)>Al?(this.dispatchEvent(Uh),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?He/60*this.autoRotateSpeed*t:He/60/60*this.autoRotateSpeed}_getZoomScale(t){let e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){Me.setFromMatrixColumn(e,0),Me.multiplyScalar(-t),this._panOffset.add(Me)}_panUp(t,e){this.screenSpacePanning===!0?Me.setFromMatrixColumn(e,1):(Me.setFromMatrixColumn(e,0),Me.crossVectors(this.object.up,Me)),Me.multiplyScalar(t),this._panOffset.add(Me)}_pan(t,e){let n=this.domElement;if(this.object.isPerspectiveCamera){let s=this.object.position;Me.copy(s).sub(this.target);let r=Me.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/n.clientHeight,this.object.matrix),this._panUp(2*e*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(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(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),s=t-n.left,r=e-n.top,a=n.width,o=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let e=this.domElement;this._rotateLeft(He*this._rotateDelta.x/e.clientHeight),this._rotateUp(He*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.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(t){this._panEnd.set(t.clientX,t.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(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(He*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-He*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(He*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-He*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panStart.set(n,s)}}_handleTouchStartDolly(t){let e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{let n=this._getSecondPointerPosition(t),s=.5*(t.pageX+n.x),r=.5*(t.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let e=this.domElement;this._rotateLeft(He*this._rotateDelta.x/e.clientHeight),this._rotateUp(He*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){let e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);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);let a=(t.pageX+e.x)*.5,o=(t.pageY+e.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new Nt,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){let e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){let e=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function Qg(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function t_(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function e_(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Oh),this.state=te.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:let t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function n_(i){let t;switch(i.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case qn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=te.DOLLY;break;case qn.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=te.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=te.ROTATE}break;case qn.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=te.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=te.PAN}break;default:this.state=te.NONE}this.state!==te.NONE&&this.dispatchEvent(Cl)}function i_(i){switch(this.state){case te.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case te.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case te.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function s_(i){this.enabled===!1||this.enableZoom===!1||this.state!==te.NONE||(i.preventDefault(),this.dispatchEvent(Cl),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(Oh))}function r_(i){this.enabled!==!1&&this._handleKeyDown(i)}function a_(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case Yn.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=te.TOUCH_ROTATE;break;case Yn.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=te.TOUCH_PAN;break;default:this.state=te.NONE}break;case 2:switch(this.touches.TWO){case Yn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=te.TOUCH_DOLLY_PAN;break;case Yn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=te.TOUCH_DOLLY_ROTATE;break;default:this.state=te.NONE}break;default:this.state=te.NONE}this.state!==te.NONE&&this.dispatchEvent(Cl)}function o_(i){switch(this._trackPointer(i),this.state){case te.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case te.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case te.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case te.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=te.NONE}}function l_(i){this.enabled!==!1&&i.preventDefault()}function c_(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function h_(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}var Se={drawn:.4,svgIn:.5,rise:.55,svgOut:.62,tilted:.78,wallsUp:.84,done:.96};var Bh=i=>i<0?0:i>1?1:i,di=i=>{let t=Bh(i);return t*t*(3-2*t)};function Os(i,t){let e=Bh(t),n=e<Se.drawn?0:e<Se.svgIn?di((e-Se.drawn)/(Se.svgIn-Se.drawn)):e<Se.rise?1:1-di((e-Se.rise)/(Se.svgOut-Se.rise)),s=new Map;for(let h of i){let d=!h.hidden&&e>=h.appear,u=h.riseTo<=h.riseFrom?e>=h.riseFrom?1:0:di((e-h.riseFrom)/(h.riseTo-h.riseFrom));s.set(h.key,{visible:d,rise:u})}let r=[],a=[];for(let h of i)h.storey===void 0||h.hidden||(r[h.storey]=Math.max(r[h.storey]??0,h.riseTo),a[h.storey]=Math.min(a[h.storey]??1,h.appear));let o=r[0]??1,c=0;for(let h=1;h<r.length;h++){let d=r[h-1],u=a[h];e>d&&(c=h-1+(u>d?di((e-d)/(u-d)):1))}let l=0;if(r.length>1){let h=u_(r);l=h<1?di((e-h)/(1-h)):e>=1?1:0,l>0&&(c=r.length-1+l)}return{tilt:di((e-Se.rise)/(Math.min(Se.tilted,o)-Se.rise)),dolly:di((e-Se.rise)/(o-Se.rise)),stop:c,settle:l,svg:n,nodes:s}}var u_=i=>Math.max(Se.done,...i);var zh=.88,Qn=i=>i*Math.PI/180;function Pl(i){let t=Qn(i.elevation),e=Qn(i.azimuth);return[Math.cos(t)*Math.sin(e),Math.sin(t),Math.cos(t)*Math.cos(e)]}function Il(i,t,e){let n=Pl(e);return[i[0]+t*n[0],i[1]+t*n[1],i[2]+t*n[2]]}function Gh(i){let t=i[2],e=-i[0],n=Math.hypot(t,e),s=[t/n,0,e/n],r=[i[1]*s[2]-i[2]*s[1],i[2]*s[0]-i[0]*s[2],i[0]*s[1]-i[1]*s[0]];return{right:s,up:r}}function Hh(i){let t=[];for(let e of[i.lo[0],i.hi[0]])for(let n of[i.lo[1],i.hi[1]])for(let s of[i.lo[2],i.hi[2]])t.push([e,n,s]);return t}function d_(i,t,e){let n=Pl(e),{right:s,up:r}=Gh(n),a=Math.tan(Qn(e.fov)/2),o=1/0,c=-1/0,l=1/0,h=-1/0;for(let d of Hh(i)){let u=[d[0]-t.target[0],d[1]-t.target[1],d[2]-t.target[2]],p=t.dist-(u[0]*n[0]+u[1]*n[1]+u[2]*n[2]),_=(u[0]*s[0]+u[2]*s[2])/(p*a*e.aspect),v=(u[0]*r[0]+u[1]*r[1]+u[2]*r[2])/(p*a);o=Math.min(o,_),c=Math.max(c,_),l=Math.min(l,v),h=Math.max(h,v)}return{x:[o,c],y:[l,h]}}function Rl(i,t){let e=Pl(t),{right:n,up:s}=Gh(e),r=Math.tan(Qn(t.fov)/2),a=[(i.lo[0]+i.hi[0])/2,(i.lo[1]+i.hi[1])/2,(i.lo[2]+i.hi[2])/2],o=1e3;for(let c=0;c<4;c++){o=0;for(let u of Hh(i)){let p=[u[0]-a[0],u[1]-a[1],u[2]-a[2]],_=p[0]*e[0]+p[1]*e[1]+p[2]*e[2],v=Math.abs(p[0]*n[0]+p[2]*n[2]),g=Math.abs(p[0]*s[0]+p[1]*s[1]+p[2]*s[2]);o=Math.max(o,_+v/(zh*r*t.aspect),_+g/(zh*r))}if(c===3)break;let l=d_(i,{target:a,dist:o},t),h=(l.x[0]+l.x[1])/2*o*r*t.aspect,d=(l.y[0]+l.y[1])/2*o*r;a=[a[0]+h*n[0]+d*s[0],a[1]+h*n[1]+d*s[1],a[2]+h*n[2]+d*s[2]]}return{target:a,dist:o}}var yn=30,Ll=-32;function Bs(i,t={}){let e=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],s=t.ghosts?i:i.filter(r=>r.part!=="demolish");for(let r of s.length>0?s:i){let a=t.settle===void 0?r.lift??0:Dl(r.lift,t.settle);for(let o=0;o<r.positions.length;o+=3){let c=[r.positions[o]/1e3,r.positions[o+1]/1e3+a,r.positions[o+2]/1e3];for(let l=0;l<3;l++)e[l]=Math.min(e[l],c[l]),n[l]=Math.max(n[l],c[l])}}return{lo:e,hi:n}}var Dl=(i,t)=>(i??0)*(1-t),$a=i=>Math.max(1,...i.map(t=>(t.storey??0)+1)),Ja=1.5;function Wh(i,t,e){let n=new Map(t.map(a=>[a.key,a.storey??0])),s=$a(t),r=[];for(let a=0;a<s;a++)r.push(Rl(Bs(i.filter(o=>(n.get(o.key)??0)<=a)),e));return s>1&&r.push(Rl(Bs(i,{settle:1}),e)),r}function f_(i,t){let e=Math.min(i.length-1,Math.floor(t)),n=i[e],s=i[Math.min(i.length-1,e+1)],r=t-e;return r<=0||n===s?n:{target:[0,1,2].map(a=>n.target[a]*(1-r)+s.target[a]*r),dist:n.dist*(1-r)+s.dist*r}}function Ka(i,t,e){let n=h=>h*Math.PI/180,s=f_(t,i.stop),r=2*s.dist*Math.tan(n(yn)/2),a=Ja+(yn-Ja)*i.dolly,c=(e.oh+(r-e.oh)*i.dolly)/(2*Math.tan(n(a)/2));return{target:[e.cx+(s.target[0]-e.cx)*i.dolly,s.target[1]*i.tilt,e.cz+(s.target[2]-e.cz)*i.dolly],dist:c,fov:a,elevation:90-(90-e.elevation)*i.tilt,azimuth:Ll*i.tilt}}function Nl(i,t){let[e,n,s,r]=i,a=Math.max(s,r*t);return{cx:e+s/2,cz:n+r/2,ow:a,oh:a/t}}var kh={north:180,east:90,south:0,west:-90},zs={min:0,max:90};function Xh(i,t,e){if(t[1]>=e||i[1]<=e)return t;let n=(i[1]-e)/(i[1]-t[1]);return[i[0]+(t[0]-i[0])*n,e,i[2]+(t[2]-i[2])*n]}function qh(i,t){if(i==="iso")return Ka(Os(t.events,1),t.fits,t.frame);let e=i==="top"?{elevation:zs.max,azimuth:kh.south}:{elevation:zs.min,azimuth:kh[i]},n=Rl(t.box,{...e,fov:yn,aspect:t.aspect});return{target:n.target,dist:n.dist,fov:yn,...e}}function Yh(i){return i.fov===yn?i:{...i,fov:yn,dist:i.dist*Math.tan(Qn(i.fov)/2)/Math.tan(Qn(yn)/2)}}var Vh={in:8,out:3};function Zh(i,t){let e=i[i.length-1].dist,n=Math.tan(Qn(yn)/2)/Math.tan(Qn(t)/2);return{min:e*n/Vh.in,max:e*n*Vh.out}}function Jh(i){let t=[i.hi[0]-i.lo[0],i.hi[1]-i.lo[1],i.hi[2]-i.lo[2]];return{centre:[(i.lo[0]+i.hi[0])/2,(i.lo[1]+i.hi[1])/2,(i.lo[2]+i.hi[2])/2],radius:Math.hypot(t[0],t[1],t[2])/2}}var Kt=(i,t,e=0,n=1)=>({srgb:i,alpha:n,metallic:e,roughness:t}),ja={wood:Kt("#c6a785",.75),wood_dark:Kt("#7b5b44",.7),fabric:Kt("#968f85",.95),cushion:Kt("#bfb7ab",.95),linen:Kt("#f3efe7",.9),wool:Kt("#a7ac98",1),ceramic:Kt("#f6f4f0",.25),stone:Kt("#d8d4cc",.45),metal:Kt("#aeb2b4",.35,1),glass:Kt("#c9dee6",.05,0,.35),appliance:Kt("#dcdcd8",.35),screen:Kt("#2e3033",.2),paint:Kt("#a9b1a2",.6),rubber:Kt("#3b3b3b",.9),foliage:Kt("#8c9b78",.9),bark:Kt("#6f5b49",.9),soil:Kt("#5f4b3b",1),water:Kt("#a3c6d0",.1,0,.7)},p_="wood",Ul={slab:Kt("#bdb6ab",.9),column:Kt("#e6e1d8",.85),wall:Kt("#f2f0eb",.9),door:Kt("#c2a27e",.7),"window:frame":Kt("#55534f",.5),"window:glass":Kt("#bcd6e0",.05,0,.4),opening:Kt("#e6e1d8",.85),furniture:Kt("#d6cec1",.9),roof:Kt("#9c958a",.9),"wall:demolish":Kt("#c8553d",.9,0,.3),stair:ja[p_]},$h="#8f877d";var m_={timber:Kt("#cdb596",.6),tile:Kt("#e3e1db",.35),neutral:Kt("#e8e2d7",.9)};function Kh(i,t,e){let n=ja[i].srgb;if(t==="light")return n;let s=r=>{let a=Number.parseInt(n.slice(r,r+2),16),o=Number.parseInt(e.slice(r,r+2),16);return Math.round(a*.4+o*.6).toString(16).padStart(2,"0")};return`#${s(1)}${s(3)}${s(5)}`}function jh(i,t,e){let n=m_[i].srgb;if(t==="light")return n;let s=r=>{let a=Number.parseInt(n.slice(r,r+2),16),o=Number.parseInt(e.slice(r,r+2),16);return Math.round(a*.4+o*.6).toString(16).padStart(2,"0")};return`#${s(1)}${s(3)}${s(5)}`}var ks=(i,t,e)=>`${i} ${i===1?t:e}`,Qh=i=>`${Number(i.toFixed(2))} m\xB2`;function Fl(i,t,e){let n;for(let s of i)s.stage===t&&!s.hidden&&(n===void 0||s.appear<n)&&(n=s.appear);return n??e}function tu(i,t,e){let n=Fl(t,"rooms",Se.drawn),s=Fl(t,"openings",Se.drawn),r=[],a=(o,c)=>{e>=o&&r.push(c)};return i.storeys!==void 0&&a(Fl(t,"brief",0),{id:"storeys",text:ks(i.storeys,"storey","storeys")}),a(n,{id:"rooms",text:ks(i.rooms,"room","rooms")}),i.areaNet!==void 0&&a(n,{id:"area-net",text:`floor area ${Qh(i.areaNet)} (net)`}),a(n,{id:"area-centre",text:`floor area ${Qh(i.areaCentre)} (to wall centre lines)`}),a(s,{id:"doors",text:ks(i.doors,"door","doors")}),a(s,{id:"windows",text:ks(i.windows,"window","windows")}),a(Se.svgIn,{id:"warnings",text:i.warnings===0?"no warnings":ks(i.warnings,"warning","warnings")}),r}function eu(i,t){let e=t.map(s=>`${s.id}=${s.text}`).join("|");if(i.dataset.stripKey===e)return;i.dataset.stripKey=e,i.hidden=t.length===0;let n=[];for(let s of t){let r=i.ownerDocument.createElement("span");r.dataset.fact=s.id,r.textContent=s.text,n.length>0&&n.push(i.ownerDocument.createTextNode(" ")),n.push(r)}i.replaceChildren(...n)}var g_=5,Qa=.9,nu={light:{background:"#f7f5f0",edge:"#8f877c",cap:$h,colors:Object.fromEntries(Object.entries(Ul).map(([i,t])=>[i,t.srgb]))},dark:{background:"#0f2235",edge:"#cfe3f5",cap:"#cfe3f5",colors:{slab:"#20384f",floor:"#1b3248",column:"#3b5b78",wall:"#2e4d6a",roof:"#14283c",door:"#7aa6c9","window:frame":"#5d86a8","window:glass":"#86c5ee","wall:demolish":"#e07a5f",furniture:"#3f6a8f",stair:"#5d86a8"}}},In={sky:16317439,ground:14275271,hemi:2.4,keyColour:16775922,key:2.7,keyFrom:[-1,1.25,.3],fillColour:15002869,fill:.5,fillFrom:[.7,.5,-.6]},__=12;function iu(i,t,e,n={}){let s=nu[t.theme],r=s.colors.furniture,a=t.width,o=t.height,c=document.createElement("canvas");c.width=a,c.height=o,i.width=a,i.height=o;let l=i.getContext("2d",{willReadFrequently:!0}),h=new Wa({canvas:c,antialias:!1,preserveDrawingBuffer:!0});h.setPixelRatio(1),h.setSize(a,o,!1),h.toneMapping=ws;let d=new cs;d.background=new Ft(s.background),d.add(new Ms(In.sky,In.ground,In.hemi));let u=new ki(In.keyColour,In.key);u.position.set(...In.keyFrom),d.add(u);let p=new ki(In.fillColour,In.fill);p.position.set(...In.fillFrom),d.add(p);let _=new Map,v=[];for(let N of t.nodes){let k=new Float32Array(N.positions.length),q=1/0,nt=-1/0;for(let ut=1;ut<N.positions.length;ut+=3)q=Math.min(q,N.positions[ut]/1e3),nt=Math.max(nt,N.positions[ut]/1e3);for(let ut=0;ut<N.positions.length;ut+=3){let Pt=N.positions[ut]/1e3,C=N.positions[ut+1]/1e3,rt=N.positions[ut+2]/1e3;k[ut]=Pt,k[ut+1]=C-q,k[ut+2]=rt}let ht=N.part?`${N.kind}:${N.part}`:N.kind,at=new Tn;at.position.y=q+(N.lift??0);let ot=(ut,Pt,C,rt,Z,ct,dt=!0)=>{let tt=new ke;tt.setAttribute("position",ut),tt.setIndex(Pt),ct&&tt.computeVertexNormals();let wt=ht==="wall:demolish",bt=N.kind==="floor"||N.kind==="slab",yt=new xs({color:new Ft(C),transparent:rt||wt,opacity:rt?Z:wt?.3:1,depthWrite:!wt,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:bt?4:1});if(v.push(tt,yt),at.add(new Ve(tt,yt)),N.kind!=="slab"&&!rt&&dt){let kt=new gs(tt,30),we=new Bi({color:new Ft(s.edge)});v.push(kt,we),at.add(new fs(kt,we))}},xt=new Oe(k,3);if(N.groups){let ut=0;for(let{slot:Pt,count:C}of N.groups){let rt=N.indices.slice(ut,ut+C);if(ut+=C,Pt==="body")ot(xt,rt,s.colors[ht]??r,!1,1,!1);else{let{alpha:Z}=ja[Pt];ot(xt,rt,Kh(Pt,t.theme,r),Z<1,Z,!1)}}}else if(N.finish)ot(xt,N.indices,jh(N.finish,t.theme,nu.dark.colors.floor),!1,1,!0);else if(ht==="wall"){let ut=rt=>N.positions[rt*3+1]/1e3===nt,Pt=[],C=[];for(let rt=0;rt<N.indices.length;rt+=3){let Z=N.indices.slice(rt,rt+3);(Z.every(ut)?Pt:C).push(...Z)}ot(xt,C,s.colors.wall??r,!1,1,!0),Pt.length&&ot(xt,Pt,s.cap,!1,1,!0,!1)}else{let ut=ht==="window:glass";ot(xt,N.indices,s.colors[ht]??r,ut,ut?Ul["window:glass"].alpha:1,!0)}at.visible=!1,d.add(at),_.set(N.key,{g:at,flat:Math.min(1,__/Math.max(1e-6,nt-q)),base:q,lift:N.lift??0})}let[g,f,T,L]=t.viewBox,M=a/o,{cx:b,cz:E,ow:A,oh:x}=Nl(t.viewBox,M),w=Bs(t.nodes,{ghosts:!0}),D=new U(...w.lo),O=new U(...w.hi),V=O.y+1e3,H=new Xn(-A/2,A/2,x/2,-x/2,1,V+1e5);H.up.set(0,0,-1),H.position.set(b,V+5e4,E),H.lookAt(b,0,E);let R=new Ie(Ja,M,10,1e9),W=N=>Wh(t.nodes,t.events,{elevation:t.elevation,azimuth:Ll,fov:yn,aspect:N}),$=W(M),K=O.clone().sub(D),st=D.clone().add(O).multiplyScalar(.5),Y=N=>{let k=Math.max(...N.map(q=>st.distanceTo(new U(...q.target))));return Math.max(K.length()*.75+k+Math.hypot(st.x-(g+T/2),st.z-(f+L/2)),1e3)},et=Y($.slice(0,$a(t.events))),it=Y($),Ct=N=>N*Math.PI/180,Et=new Image,ee=new Promise(N=>{Et.onload=()=>N(),Et.onerror=()=>N()});Et.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(t.svg)))}`;let Lt=!1,Wt={cx:b,cz:E,oh:x,elevation:t.elevation},j=new Map(t.events.map(N=>[N.key,N.storey??0])),Q=Math.max(1,...t.events.filter(N=>!N.hidden).map(N=>(N.storey??0)+1)),_t=Q,St="replay",pt=0,Ot=!1,pe=K.length()/2,Bt=N=>Math.max(it,st.distanceTo(N)+pe);function Zt(N,k){let{fov:q,dist:nt,elevation:ht,azimuth:at}=N,ot=new U(...N.target),xt=Ct(ht);R.fov=q,R.near=Math.max(10,nt-k),R.far=nt+k,R.updateProjectionMatrix(),R.up.set(0,0,-1),xt<Ct(89.99)&&R.up.set(0,1,0),R.position.set(...Il([ot.x,ot.y,ot.z],nt,{elevation:ht,azimuth:at})),R.lookAt(ot)}let $t={events:t.events,fits:$,frame:Wt,box:Bs(t.nodes,{settle:1}),aspect:M},zt=new Map,ie=N=>{let k=zt.get(N);if(k)return k;let q=qh(N,$t);return zt.set(N,q),q},ue,me=()=>{},re=()=>{},de=()=>{},I=new Set,fe=()=>{for(let N of I)N()};function Xt(N){pt=N,Ot=!0,e&&t.facts&&eu(e,tu(t.facts,t.events,Math.min(1,Math.max(0,N))));let k=Os(t.events,N);for(let[nt,{g:ht,flat:at,base:ot,lift:xt}]of _){let ut=k.nodes.get(nt);ht.visible=ut?.visible===!0&&(j.get(nt)??0)<_t,ht.scale.y=Math.max(at,ut?.rise??0),xt!==0&&(ht.position.y=ot+Dl(xt,k.settle))}let q=H;if(St==="free"&&ue){let nt=R.position.distanceTo(ue.target),ht=Bt(ue.target);R.near=Math.max(10,nt-ht),R.far=nt+ht,R.updateProjectionMatrix(),q=R}else if(St!=="replay"&&St!=="free"){let nt=ie(St);Zt(nt,Bt(new U(...nt.target))),q=R}else(k.tilt>0||k.dolly>0)&&(Zt(Ka(k,$,Wt),k.settle>0?it:et),q=R);if(h.render(d,q),l.globalAlpha=1,l.drawImage(c,0,0),St==="replay"&&k.svg>0&&Et.complete&&Et.naturalWidth>0){let nt=Math.min(a/T,o/L),ht=T*nt,at=L*nt;l.globalAlpha=k.svg,l.drawImage(Et,(a-ht)/2,(o-at)/2,ht,at),l.globalAlpha=1}}function S(N){Lt||(St!=="replay"&&(me(),St="replay",fe()),Xt(N),de())}async function m(){let N=l.getImageData(0,0,a,o).data,k=await crypto.subtle.digest("SHA-256",N);return[...new Uint8Array(k)].map(q=>q.toString(16).padStart(2,"0")).join("")}let F=n.interactive?G():void 0;function G(){let N=new Za(R,i);ue=N,N.enableDamping=!1,N.screenSpacePanning=!1,N.minPolarAngle=Ct(90-zs.max),N.maxPolarAngle=Ct(90-zs.min);let k=Jh(w);N.cursor.set(...k.centre);let q=i.getAttribute("tabindex");i.tabIndex=0;let nt=0,ht=!1,at=!1,ot=()=>window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,xt=()=>{nt=0,!(Lt||St!=="free")&&(N.update()||ht)&&(nt=requestAnimationFrame(xt))},ut=()=>{N.enableDamping&&!nt&&(nt=requestAnimationFrame(xt))};me=()=>{nt&&cancelAnimationFrame(nt),nt=0,ht=!1,N.enableDamping&&(at=!0,N.enableDamping=!1,N.update(),at=!1)};let Pt=(yt,kt,we)=>{R.fov=we,R.up.set(0,1,0),R.position.set(...yt),N.target.set(...Xh(yt,kt,$t.box.lo[1])),R.lookAt(N.target);let We=R.position.distanceTo(N.target),Vs=Zh($,we);N.minDistance=Math.min(Vs.min,We),N.maxDistance=Math.max(Vs.max,We),N.maxTargetRadius=Math.max(k.radius,N.target.distanceTo(N.cursor)),N.enableDamping=!ot()},C=()=>{if(St==="free")return;let yt=St==="replay"?Yh(Ka(Os(t.events,pt),$,Wt)):ie(St);Pt(Il(yt.target,yt.dist,yt),yt.target,yt.fov)},rt=()=>{St!=="free"&&(St="free",n.onTake?.(),fe(),ut())},Z=!1;de=()=>{Z&&C()},N.addEventListener("start",()=>{C(),Z=!0,ht=!0}),N.addEventListener("end",()=>{Z=!1,ht=!1}),N.addEventListener("change",()=>{at||Lt||(Z=!1,rt(),Xt(pt))});let ct=Ct(g_),dt=new Map([["ArrowLeft",()=>N.rotateLeft(ct)],["ArrowRight",()=>N.rotateLeft(-ct)],["ArrowUp",()=>N.rotateUp(ct)],["ArrowDown",()=>N.rotateUp(-ct)],["+",()=>N.dollyIn(Qa)],["=",()=>N.dollyIn(Qa)],["-",()=>N.dollyOut(Qa)],["_",()=>N.dollyOut(Qa)]]),tt=yt=>{let kt=dt.get(yt.key);!kt||Lt||yt.ctrlKey||yt.metaKey||yt.altKey||(yt.preventDefault(),C(),kt(),ut())};i.addEventListener("keydown",tt),re=()=>{i.removeEventListener("keydown",tt),N.dispose(),q===null?i.removeAttribute("tabindex"):i.setAttribute("tabindex",q),I.clear()};let wt=yt=>Math.min(Q,Math.max(1,Math.round(yt))),bt=()=>_t===Q?"all":_t;return{at:yt=>{Lt||Xt(yt)},preset:yt=>{Lt||(me(),St=yt,n.onTake?.(),fe(),Xt(pt))},reset:()=>{Lt||(me(),St="replay",_t=Q,fe(),Xt(pt))},storeys:Q,showStoreys:yt=>{Lt||(_t=wt(yt),fe(),Xt(pt))},onChange:yt=>(I.add(yt),()=>I.delete(yt)),spin:yt=>{if(Lt||ht||!Number.isFinite(yt)||yt===0)return;C();let kt=N.enableDamping;N.enableDamping=!1,N.rotateLeft(Ct(yt)),N.update(),N.enableDamping=kt},get shown(){return _t},get camera(){return St},state:()=>St==="free"?{camera:"free",position:R.position.toArray(),target:N.target.toArray(),fov:R.fov,storeys:bt()}:{camera:St,storeys:bt()},restore:yt=>{Lt||(me(),_t=yt.storeys==="all"?Q:wt(yt.storeys),yt.camera==="free"&&Pt(yt.position,yt.target,yt.fov),St=yt.camera,St!=="replay"&&n.onTake?.(),fe())}}}function J(N,k){if(Lt)return;let q=Math.max(1,Math.round(N)),nt=Math.max(1,Math.round(k));q===a&&nt===o||(a=q,o=nt,c.width=a,c.height=o,i.width=a,i.height=o,h.setSize(a,o,!1),M=a/o,{cx:b,cz:E,ow:A,oh:x}=Nl(t.viewBox,M),H.left=-A/2,H.right=A/2,H.top=x/2,H.bottom=-x/2,H.position.set(b,V+5e4,E),H.lookAt(b,0,E),H.updateProjectionMatrix(),R.aspect=M,R.updateProjectionMatrix(),$=W(M),et=Y($.slice(0,$a(t.events))),it=Y($),Wt={cx:b,cz:E,oh:x,elevation:t.elevation},$t={...$t,fits:$,frame:Wt,aspect:M},zt.clear(),Ot&&Xt(pt))}function lt(){if(!Lt){me(),Lt=!0,re();for(let N of v)N.dispose();h.dispose(),h.forceContextLoss()}}return{seek:S,frameHash:m,ready:ee,dispose:lt,resize:J,...F?{view:F}:{}}}var x_=[["iso","Iso","Iso view: the replay's end view"],["top","Top","Top view, the plan's top edge up"],["north","N","View from north: level, from the plan's top edge"],["east","E","View from east: level, from the plan's right edge"],["south","S","View from south: level, from the plan's bottom edge"],["west","W","View from west: level, from the plan's left edge"]],y_="Drag to turn, right-drag to pan, scroll to zoom; on the focused view, arrow keys turn and + / \u2212 zoom.";function su(i,t={}){let e=document.createElement("div");e.className="archlang-views",e.setAttribute("role","toolbar"),e.setAttribute("aria-label","3D view");let n=(h,d,u)=>{let p=document.createElement("button");return p.type="button",t.buttonClass&&(p.className=t.buttonClass),p.textContent=h,p.setAttribute("aria-label",d),p.addEventListener("click",u),p},s=[],r=[],a=()=>{for(let[h,d]of s)d.setAttribute("aria-pressed",String(i.camera===h));for(let[h,d]of r.entries())d.setAttribute("aria-pressed",String(h+1===i.shown))},o=h=>{};for(let[h,d,u]of x_){let p=n(d,u,()=>{i.preset(h),o(!0)});p.dataset.preset=h,s.push([h,p])}let c="Reset the view: the replay's own camera, every storey shown";if(t.compact){e.classList.add("archlang-views-compact"),e.append(n("\u27F2 Reset",c,()=>i.reset()));let h=document.createElement("span");h.className="archlang-views-menu";let d=document.createElement("span");d.className="archlang-views-presets",d.id=`${t.hintId??"archlang-views"}-presets`,d.setAttribute("role","group"),d.setAttribute("aria-label","Preset views"),d.hidden=!0,d.append(...s.map(([,v])=>v));let u=n("View \u25BE","View presets: iso, top, and from north, east, south and west",()=>d.hidden?_():o(!1));u.setAttribute("aria-expanded","false"),u.setAttribute("aria-controls",d.id);let p=v=>{h.contains(v.target)||o(!1)},_=()=>{d.hidden=!1,u.setAttribute("aria-expanded","true"),document.addEventListener("pointerdown",p,!0),(s.find(([v])=>i.camera===v)?.[1]??s[0]?.[1])?.focus()};o=v=>{d.hidden||(d.hidden=!0,u.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",p,!0),v&&u.focus())},h.addEventListener("keydown",v=>{v.key!=="Escape"||d.hidden||(v.preventDefault(),v.stopPropagation(),o(!0))}),h.addEventListener("focusout",v=>{h.contains(v.relatedTarget)||o(!1)}),h.append(u,d),e.append(h)}else e.append(...s.map(([,h])=>h)),e.append(n("Reset",c,()=>i.reset()));if(i.storeys>1&&t.storeys!==!1){let h=document.createElement("span");h.className="archlang-views-storeys",h.setAttribute("role","group"),h.setAttribute("aria-label","Storeys shown"),h.append("Storeys ");for(let d=1;d<=i.storeys;d++){let u=d===i.storeys,p=n(u?"All":d===1?"1":`1\u2013${d}`,u?"Show every storey":`Show storeys 1 to ${d}, hide the ones above`,()=>i.showStoreys(d));p.dataset.storeys=String(d),r.push(p),h.append(p)}e.append(h)}i.onChange(a),a();let l=document.createElement("span");return l.className="archlang-views-hint",t.hintId&&(l.id=t.hintId),l.textContent=y_,e.append(l),e}function v_(){let i=document.getElementById("archlang-replay-payload");return JSON.parse(i?.textContent??"{}")}function M_(){let i=v_(),t=document.getElementById("archlang-replay"),e=document.getElementById("archlang-replay-strip")??void 0,n=0,s=()=>{n&&cancelAnimationFrame(n),n=0},{seek:r,frameHash:a,ready:o,view:c}=iu(t,i,e,{interactive:!0,onTake:s});window.__seek=r,window.__frameHash=a,window.__ready=o.then(()=>r(0));let l=document.getElementById("archlang-replay-views");c&&l&&(l.replaceWith(su(c,{hintId:"archlang-replay-hint"})),t.setAttribute("aria-describedby","archlang-replay-hint"));let h=document.getElementById("archlang-replay-t"),d=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;window.__ready.then(()=>{if(window.__replayAutoplay===!1)return;if(d){r(1),h&&(h.value="1");return}let u,p=_=>{u??(u=_);let v=Math.min(1,(_-u)/(i.seconds*1e3));r(v),h&&(h.value=String(v)),n=v<1?requestAnimationFrame(p):0};n=requestAnimationFrame(p)}),h?.addEventListener("input",()=>{s(),r(Number(h.value))})}M_();})();
|
|
4225
|
+
}`,Nl=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Rs(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){let t=e.cameras[0].viewport,n=new Mn({vertexShader:l_,fragmentShader:c_,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new en(new Ps(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Ul=class extends dn{constructor(e,t){super();let n=this,s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,d=null,u=null,m=null,_=null,y=typeof XRWebGLBinding<"u",p=new Nl,f={},S=t.getContextAttributes(),A=null,b=null,T=[],w=[],g=new Fe,M=null,U=null,I=new Bt;I.viewport=new dt;let D=new Bt;D.viewport=new dt;let F=[I,D],H=new ca,C=null,Y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(j){let pe=T[j];return pe===void 0&&(pe=new Yi,T[j]=pe),pe.getTargetRaySpace()},this.getControllerGrip=function(j){let pe=T[j];return pe===void 0&&(pe=new Yi,T[j]=pe),pe.getGripSpace()},this.getHand=function(j){let pe=T[j];return pe===void 0&&(pe=new Yi,T[j]=pe),pe.getHandSpace()};function J(j){let pe=w.indexOf(j.inputSource);if(pe===-1)return;let ye=T[pe];ye!==void 0&&(ye.update(j.inputSource,j.frame,l||a),ye.dispatchEvent({type:j.type,data:j.inputSource}))}function z(){s.removeEventListener("select",J),s.removeEventListener("selectstart",J),s.removeEventListener("selectend",J),s.removeEventListener("squeeze",J),s.removeEventListener("squeezestart",J),s.removeEventListener("squeezeend",J),s.removeEventListener("end",z),s.removeEventListener("inputsourceschange",te);for(let j=0;j<T.length;j++){let pe=w[j];pe!==null&&(w[j]=null,T[j].disconnect(pe))}C=null,Y=null,p.reset();for(let j in f)delete f[j];if(e.setRenderTarget(A),m=null,u=null,d=null,s=null,b=null,De.stop(),n.isPresenting=!1,e.setPixelRatio(M),e.setSize(g.width,g.height,!1),U!==null){let j=U.camera;j.fov=U.fov,j.zoom=U.zoom,j.updateProjectionMatrix(),U=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){r=j,n.isPresenting===!0&&Ie("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){o=j,n.isPresenting===!0&&Ie("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(j){l=j},this.getBaseLayer=function(){return u!==null?u:m},this.getBinding=function(){return d===null&&y&&(d=new XRWebGLBinding(s,t)),d},this.getFrame=function(){return _},this.getSession=function(){return s},this.setSession=async function(j){if(s=j,s!==null){if(A=e.getRenderTarget(),s.addEventListener("select",J),s.addEventListener("selectstart",J),s.addEventListener("selectend",J),s.addEventListener("squeeze",J),s.addEventListener("squeezestart",J),s.addEventListener("squeezeend",J),s.addEventListener("end",z),s.addEventListener("inputsourceschange",te),S.xrCompatible!==!0&&await t.makeXRCompatible(),M=e.getPixelRatio(),e.getSize(g),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let ye=null,Re=null,fe=null;S.depth&&(fe=S.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ye=S.stencil?Hn:Bn,Re=S.stencil?Si:fn);let Le={colorFormat:t.RGBA8,depthFormat:fe,scaleFactor:r};d=this.getBinding(),u=d.createProjectionLayer(Le),s.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),b=new Qt(u.textureWidth,u.textureHeight,{format:gn,type:Xt,depthTexture:new Vn(u.textureWidth,u.textureHeight,Re,void 0,void 0,void 0,void 0,void 0,void 0,ye),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1,storeMultisampledDepthBuffer:u.ignoreDepthValues===!1,storeMultisampledStencilBuffer:u.ignoreDepthValues===!1})}else{let ye={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:r};m=new XRWebGLLayer(s,t,ye),s.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),b=new Qt(m.framebufferWidth,m.framebufferHeight,{format:gn,type:Xt,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1,storeMultisampledDepthBuffer:m.ignoreDepthValues===!1,storeMultisampledStencilBuffer:m.ignoreDepthValues===!1})}b.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await s.requestReferenceSpace(o),De.setContext(s),De.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return p.getDepthTexture()};function te(j){for(let pe=0;pe<j.removed.length;pe++){let ye=j.removed[pe],Re=w.indexOf(ye);Re>=0&&(w[Re]=null,T[Re].disconnect(ye))}for(let pe=0;pe<j.added.length;pe++){let ye=j.added[pe],Re=w.indexOf(ye);if(Re===-1){for(let Le=0;Le<T.length;Le++)if(Le>=w.length){w.push(ye),Re=Le;break}else if(w[Le]===null){w[Le]=ye,Re=Le;break}if(Re===-1)break}let fe=T[Re];fe&&fe.connect(ye)}}function W(j,pe){pe===null?j.matrixWorld.copy(j.matrix):j.matrixWorld.multiplyMatrices(pe.matrixWorld,j.matrix),j.matrixWorldInverse.copy(j.matrixWorld).invert()}this.updateCamera=function(j){if(s===null)return;let pe=j.near,ye=j.far;p.texture!==null&&(p.depthNear>0&&(pe=p.depthNear),p.depthFar>0&&(ye=p.depthFar)),H.near=D.near=I.near=pe,H.far=D.far=I.far=ye,(C!==H.near||Y!==H.far)&&(s.updateRenderState({depthNear:H.near,depthFar:H.far}),C=H.near,Y=H.far),H.layers.mask=j.layers.mask|6,I.layers.mask=H.layers.mask&-5,D.layers.mask=H.layers.mask&-3;let Re=j.parent,fe=H.cameras;W(H,Re);for(let Le=0;Le<fe.length;Le++)W(fe[Le],Re);H.projectionMatrix.copy(I.projectionMatrix),H.projectionMatrixInverse.copy(I.projectionMatrixInverse),U===null&&j.isPerspectiveCamera&&(U={camera:j,fov:j.fov,zoom:j.zoom}),$(j,H,Re)};function $(j,pe,ye){ye===null?j.matrix.copy(pe.matrixWorld):(j.matrix.copy(ye.matrixWorld),j.matrix.invert(),j.matrix.multiply(pe.matrixWorld)),j.matrix.decompose(j.position,j.quaternion,j.scale),j.updateMatrixWorld(!0),j.projectionMatrix.copy(pe.projectionMatrix),j.projectionMatrixInverse.copy(pe.projectionMatrixInverse),j.isPerspectiveCamera&&(j.fov=Xi*2*Math.atan(1/j.projectionMatrix.elements[5]),j.zoom=1)}this.getCamera=function(){return H},this.getFoveation=function(){if(!(u===null&&m===null))return c},this.setFoveation=function(j){c=j,u!==null&&(u.fixedFoveation=j),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=j)},this.hasDepthSensing=function(){return p.texture!==null},this.getDepthSensingMesh=function(){return p.getMesh(H)},this.getCameraTexture=function(j){return f[j]};let ae=null;function _e(j,pe){if(h=pe.getViewerPose(l||a),_=pe,h!==null){let ye=h.views;m!==null&&(e.setRenderTargetFramebuffer(b,m.framebuffer),e.setRenderTarget(b));let Re=!1;ye.length!==H.cameras.length&&(H.cameras.length=0,Re=!0);for(let be=0;be<ye.length;be++){let $e=ye[be],it=null;if(m!==null)it=m.getViewport($e);else{let lt=d.getViewSubImage(u,$e);it=lt.viewport,be===0&&(e.setRenderTargetTextures(b,lt.colorTexture,lt.depthStencilTexture),e.setRenderTarget(b))}let ke=F[be];ke===void 0&&(ke=new Bt,ke.layers.enable(be),ke.viewport=new dt,F[be]=ke),ke.matrix.fromArray($e.transform.matrix),ke.matrix.decompose(ke.position,ke.quaternion,ke.scale),ke.projectionMatrix.fromArray($e.projectionMatrix),ke.projectionMatrixInverse.copy(ke.projectionMatrix).invert(),ke.viewport.set(it.x,it.y,it.width,it.height),be===0&&(H.matrix.copy(ke.matrix),H.matrix.decompose(H.position,H.quaternion,H.scale)),Re===!0&&H.cameras.push(ke)}let fe=s.enabledFeatures;if(fe&&fe.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&y){d=n.getBinding();let be=d.getDepthInformation(ye[0]);be&&be.isValid&&be.texture&&p.init(be,s.renderState)}if(fe&&fe.includes("camera-access")&&y){e.state.unbindTexture(),d=n.getBinding();for(let be=0;be<ye.length;be++){let $e=ye[be].camera;if($e){let it=f[$e];it||(it=new Rs,f[$e]=it);let ke=d.getCameraImage($e);it.sourceTexture=ke}}}}for(let ye=0;ye<T.length;ye++){let Re=w[ye],fe=T[ye];Re!==null&&fe!==void 0&&fe.update(Re,pe,l||a)}ae&&ae(j,pe),pe.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:pe}),_=null}let De=new kh;De.setAnimationLoop(_e),this.setAnimationLoop=function(j){ae=j},this.dispose=function(){}}},h_=new ht,Jh=new Oe;Jh.set(-1,0,0,0,1,0,0,0,1);function u_(i,e){function t(p,f){p.matrixAutoUpdate===!0&&p.updateMatrix(),f.value.copy(p.matrix)}function n(p,f){f.color.getRGB(p.fogColor.value,_l(i)),f.isFog?(p.fogNear.value=f.near,p.fogFar.value=f.far):f.isFogExp2&&(p.fogDensity.value=f.density)}function s(p,f,S,A,b){f.isNodeMaterial?f.uniformsNeedUpdate=!1:f.isMeshBasicMaterial?r(p,f):f.isMeshLambertMaterial?(r(p,f),f.envMap&&(p.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(r(p,f),d(p,f)):f.isMeshPhongMaterial?(r(p,f),h(p,f),f.envMap&&(p.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(r(p,f),u(p,f),f.isMeshPhysicalMaterial&&m(p,f,b)):f.isMeshMatcapMaterial?(r(p,f),_(p,f)):f.isMeshDepthMaterial?r(p,f):f.isMeshDistanceMaterial?(r(p,f),y(p,f)):f.isMeshNormalMaterial?r(p,f):f.isLineBasicMaterial?(a(p,f),f.isLineDashedMaterial&&o(p,f)):f.isPointsMaterial?c(p,f,S,A):f.isSpriteMaterial?l(p,f):f.isShadowMaterial?(p.color.value.copy(f.color),p.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function r(p,f){p.opacity.value=f.opacity,f.color&&p.diffuse.value.copy(f.color),f.emissive&&p.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(p.map.value=f.map,t(f.map,p.mapTransform)),f.alphaMap&&(p.alphaMap.value=f.alphaMap,t(f.alphaMap,p.alphaMapTransform)),f.bumpMap&&(p.bumpMap.value=f.bumpMap,t(f.bumpMap,p.bumpMapTransform),p.bumpScale.value=f.bumpScale,f.side===Vt&&(p.bumpScale.value*=-1)),f.normalMap&&(p.normalMap.value=f.normalMap,t(f.normalMap,p.normalMapTransform),p.normalScale.value.copy(f.normalScale),f.side===Vt&&p.normalScale.value.negate()),f.displacementMap&&(p.displacementMap.value=f.displacementMap,t(f.displacementMap,p.displacementMapTransform),p.displacementScale.value=f.displacementScale,p.displacementBias.value=f.displacementBias),f.emissiveMap&&(p.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,p.emissiveMapTransform)),f.specularMap&&(p.specularMap.value=f.specularMap,t(f.specularMap,p.specularMapTransform)),f.alphaTest>0&&(p.alphaTest.value=f.alphaTest);let S=e.get(f),A=S.envMap,b=S.envMapRotation;A&&(p.envMap.value=A,p.envMapRotation.value.setFromMatrix4(h_.makeRotationFromEuler(b)).transpose(),A.isCubeTexture&&A.isRenderTargetTexture===!1&&p.envMapRotation.value.premultiply(Jh),p.reflectivity.value=f.reflectivity,p.ior.value=f.ior,p.refractionRatio.value=f.refractionRatio),f.lightMap&&(p.lightMap.value=f.lightMap,p.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,p.lightMapTransform)),f.aoMap&&(p.aoMap.value=f.aoMap,p.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,p.aoMapTransform))}function a(p,f){p.diffuse.value.copy(f.color),p.opacity.value=f.opacity,f.map&&(p.map.value=f.map,t(f.map,p.mapTransform))}function o(p,f){p.dashSize.value=f.dashSize,p.totalSize.value=f.dashSize+f.gapSize,p.scale.value=f.scale}function c(p,f,S,A){p.diffuse.value.copy(f.color),p.opacity.value=f.opacity,p.size.value=f.size*S,p.scale.value=A*.5,f.map&&(p.map.value=f.map,t(f.map,p.uvTransform)),f.alphaMap&&(p.alphaMap.value=f.alphaMap,t(f.alphaMap,p.alphaMapTransform)),f.alphaTest>0&&(p.alphaTest.value=f.alphaTest)}function l(p,f){p.diffuse.value.copy(f.color),p.opacity.value=f.opacity,p.rotation.value=f.rotation,f.map&&(p.map.value=f.map,t(f.map,p.mapTransform)),f.alphaMap&&(p.alphaMap.value=f.alphaMap,t(f.alphaMap,p.alphaMapTransform)),f.alphaTest>0&&(p.alphaTest.value=f.alphaTest)}function h(p,f){p.specular.value.copy(f.specular),p.shininess.value=Math.max(f.shininess,1e-4)}function d(p,f){f.gradientMap&&(p.gradientMap.value=f.gradientMap)}function u(p,f){p.metalness.value=f.metalness,f.metalnessMap&&(p.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,p.metalnessMapTransform)),p.roughness.value=f.roughness,f.roughnessMap&&(p.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,p.roughnessMapTransform)),f.envMap&&(p.envMapIntensity.value=f.envMapIntensity)}function m(p,f,S){p.ior.value=f.ior,f.diffuseRoughness>0&&(p.diffuseRoughness.value=f.diffuseRoughness,f.diffuseRoughnessMap&&(p.diffuseRoughnessMap.value=f.diffuseRoughnessMap,t(f.diffuseRoughnessMap,p.diffuseRoughnessMapTransform))),f.sheen>0&&(p.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),p.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(p.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,p.sheenColorMapTransform)),f.sheenRoughnessMap&&(p.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,p.sheenRoughnessMapTransform))),f.clearcoat>0&&(p.clearcoat.value=f.clearcoat,p.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(p.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,p.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(p.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Vt&&p.clearcoatNormalScale.value.negate())),f.dispersion>0&&(p.dispersion.value=f.dispersion),f.retroreflectivity>0&&(p.retroreflectivity.value=f.retroreflectivity),f.iridescence>0&&(p.iridescence.value=f.iridescence,p.iridescenceIOR.value=f.iridescenceIOR,p.iridescenceThicknessMinimum.value=f.iridescenceThicknessMinimum,p.iridescenceThicknessMaximum.value=f.iridescenceThicknessMaximum,f.iridescenceMap&&(p.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,p.iridescenceMapTransform)),f.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),f.transmission>0&&(p.transmission.value=f.transmission,p.transmissionSamplerMap.value=S.texture,p.transmissionSamplerSize.value.set(S.width,S.height),f.transmissionMap&&(p.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,p.transmissionMapTransform)),p.thickness.value=f.thickness,f.thicknessMap&&(p.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=f.attenuationDistance,p.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(p.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(p.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=f.specularIntensity,p.specularColor.value.copy(f.specularColor),f.specularColorMap&&(p.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,p.specularColorMapTransform)),f.specularIntensityMap&&(p.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,p.specularIntensityMapTransform))}function _(p,f){f.matcap&&(p.matcap.value=f.matcap)}function y(p,f){let S=e.get(f).light;p.referencePosition.value.setFromMatrixPosition(S.matrixWorld),p.nearDistance.value=S.shadow.camera.near,p.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function d_(i,e,t,n){let s={},r={};function a(S,A){let b=A.program;n.uniformBlockBinding(S,b,s[S.id])}function o(S,A){let b=s[S.id];b===void 0&&(_(S),b=c(S),s[S.id]=b,S.addEventListener("dispose",p));let T=A.program;n.updateUBOMapping(S,T);let w=e.render.frame;r[S.id]!==w&&(l(S),r[S.id]=w)}function c(S){let A=i.createBuffer(),b=S.__size,T=S.usage;return i.bindBuffer(i.UNIFORM_BUFFER,A),i.bufferData(i.UNIFORM_BUFFER,b,T),i.bindBuffer(i.UNIFORM_BUFFER,null),A}function l(S){let A=s[S.id],b=S.uniforms,T=S.__cache;i.bindBuffer(i.UNIFORM_BUFFER,A);for(let w=0,g=b.length;w<g;w++){let M=b[w];if(Array.isArray(M))for(let U=0,I=M.length;U<I;U++)h(M[U],w,U,T);else h(M,w,0,T)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function h(S,A,b,T){if(u(S,A,b,T)===!0){let w=S.__offset,g=S.value;if(Array.isArray(g)){let M=0;for(let U=0;U<g.length;U++){let I=g[U],D=y(I,!0);d(I,S.__data,M),M+=D.storage/Float32Array.BYTES_PER_ELEMENT}}else d(g,S.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,w,S.__data)}}function d(S,A,b){typeof S=="number"||typeof S=="boolean"?A[b]=S:S.isMatrix3?(A[b]=S.elements[0],A[b+1]=S.elements[1],A[b+2]=S.elements[2],A[b+3]=0,A[b+4]=S.elements[3],A[b+5]=S.elements[4],A[b+6]=S.elements[5],A[b+7]=0,A[b+8]=S.elements[6],A[b+9]=S.elements[7],A[b+10]=S.elements[8],A[b+11]=0):ArrayBuffer.isView(S)?A.set(S.subarray(0,A.length-b),b):S.toArray(A,b)}function u(S,A,b,T){let w=S.value,g=A+"_"+b;if(Array.isArray(w)){T[g]===void 0&&(T[g]=[]);let M=T[g],U=!1;for(let I=0;I<w.length;I++)m(w[I],M,I)===!0&&(U=!0);return U}return m(w,T,g)}function m(S,A,b){if(A[b]===void 0)return typeof S=="number"||typeof S=="boolean"?A[b]=S:ArrayBuffer.isView(S)?A[b]=S.slice():A[b]=S.clone(),!0;{let T=A[b];if(typeof S=="number"||typeof S=="boolean"){if(T!==S)return A[b]=S,!0}else{if(ArrayBuffer.isView(S))return!0;if(T.equals(S)===!1)return T.copy(S),!0}}return!1}function _(S){let A=S.uniforms,b=0,T=16;for(let g=0,M=A.length;g<M;g++){let U=Array.isArray(A[g])?A[g]:[A[g]];for(let I=0,D=U.length;I<D;I++){let F=U[I],H=Array.isArray(F.value)?F.value:[F.value],C=Array.isArray(A[g])||Array.isArray(F.value),Y=b;for(let z=0,te=H.length;z<te;z++){let W=H[z],$=y(W,C),ae=b%T,_e=ae%$.boundary,De=ae+_e;b+=_e,De!==0&&T-De<$.storage&&(b+=T-De),z===0&&(Y=b),b+=$.storage}let J=F.type==="int"?Int32Array:F.type==="uint"?Uint32Array:Float32Array;F.__data=new J((b-Y)/Float32Array.BYTES_PER_ELEMENT),F.__offset=Y}}let w=b%T;return w>0&&(b+=T-w),S.__size=b,S.__cache={},this}function y(S,A){let b={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(b.boundary=4,b.storage=4):S.isVector2?(b.boundary=8,b.storage=8):S.isVector3||S.isColor?(b.boundary=16,b.storage=12):S.isVector4?(b.boundary=16,b.storage=16):S.isMatrix3?(b.boundary=16,b.storage=48):S.isMatrix4?(b.boundary=16,b.storage=64):S.isTexture?Ie("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(S)?(b.boundary=16,b.storage=S.byteLength):Ie("WebGLRenderer: Unsupported uniform value type.",S),A===!0&&(b.boundary=16,b.storage=Math.ceil(b.storage/16)*16),b}function p(S){let A=S.target;A.removeEventListener("dispose",p),i.deleteBuffer(s[A.id]),delete s[A.id],delete r[A.id]}function f(){for(let S in s)i.deleteBuffer(s[S]);s={},r={}}return{bind:a,update:o,dispose:f}}var f_=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]),wn=null;function p_(){return wn===null&&(wn=new Wr(f_,16,16,ai,mn),wn.name="DFG_LUT",wn.minFilter=kt,wn.magFilter=kt,wn.wrapS=vn,wn.wrapT=vn,wn.generateMipmaps=!1,wn.needsUpdate=!0),wn}var to=class{constructor(e={}){let{canvas:t=ch(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:m=Xt}=e;this.isWebGLRenderer=!0;let _;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");_=n.getContextAttributes().alpha}else _=a;let y=m,p=new Set([va,ya,xa]),f=new Set([Xt,fn,is,Si,ga,_a]),S=new Uint32Array(4),A=new Int32Array(4),b={textures:[],min:[],max:[],resolution:[]},T=null,w=null,g=[],M=[],U=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Sn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let I=this,D=!1,F=null,H=null,C=null,Y=null;this._outputColorSpace=Jt;let J=0,z=0,te=null,W=-1,$=null,ae=new dt,_e=new dt,De=null,j=new ze(0),pe=0,ye=t.width,Re=t.height,fe=1,Le=null,pt=null,be=new dt(0,0,ye,Re),$e=new dt(0,0,ye,Re),it=!1,ke=new Qn,lt=new Xr,Ge=!1,mt=!1,at=new ht,nn=new B,gt=new dt,Ft={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Tt=!1;function Pt(){return te===null?fe:1}let N=n;function At(v,L){return t.getContext(v,L)}let Qe,st,ue,ut,Te,Ce,E,x,k,oe,ee,le,ce,K,P,Q,R,X,O,q,ne,se,xe;try{let v={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"187"}`),t.addEventListener("webglcontextlost",ve,!1),t.addEventListener("webglcontextrestored",Ae,!1),t.addEventListener("webglcontextcreationerror",ie,!1),N===null){let L="webgl2";if(N=At(L,v),N===null)throw At(L)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Pe()}catch(v){throw t.removeEventListener("webglcontextlost",ve,!1),t.removeEventListener("webglcontextrestored",Ae,!1),t.removeEventListener("webglcontextcreationerror",ie,!1),Ue("WebGLRenderer: "+v.message),v}function Pe(){Qe=new Em(N),Qe.init(),ne=new o_(N,Qe),st=new pm(N,Qe,e,ne),ue=new r_(N,Qe),st.reversedDepthBuffer&&u&&ue.buffers.depth.setReversed(!0),H=N.createFramebuffer(),C=N.createFramebuffer(),Y=N.createFramebuffer(),ut=new Rm(N),Te=new Xg,Ce=new a_(N,Qe,ue,Te,st,ne,ut),E=new wm(I),x=new Cd(N),se=new dm(N,x),k=new Tm(N,x,ut,se),oe=new Pm(N,k,x,se,ut),X=new Cm(N,st,Ce),P=new mm(Te),ee=new Wg(I,E,Qe,st,se,P),le=new u_(I,Te),ce=new Yg,K=new Qg(Qe),R=new um(I,E,ue,oe,_,c),Q=new s_(I,oe,st),xe=new d_(N,ut,st,ue),O=new fm(N,Qe,ut),q=new Am(N,Qe,ut),ut.programs=ee.programs,I.capabilities=st,I.extensions=Qe,I.properties=Te,I.renderLists=ce,I.shadowMap=Q,I.state=ue,I.info=ut}y!==Xt&&(U=new Lm(y,t.width,t.height,o,s,r));let re=new Ul(I,N);this.xr=re,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let v=Qe.get("WEBGL_lose_context");v&&v.loseContext()},this.forceContextRestore=function(){let v=Qe.get("WEBGL_lose_context");v&&v.restoreContext()},this.getPixelRatio=function(){return fe},this.setPixelRatio=function(v){v!==void 0&&(fe=v,this.setSize(ye,Re,!1))},this.getSize=function(v){return v.set(ye,Re)},this.setSize=function(v,L,Z=!0){if(re.isPresenting){Ie("WebGLRenderer: Can't change size while VR device is presenting.");return}ye=v,Re=L,t.width=Math.floor(v*fe),t.height=Math.floor(L*fe),Z===!0&&(t.style.width=v+"px",t.style.height=L+"px"),U!==null&&U.setSize(t.width,t.height),this.setViewport(0,0,v,L)},this.getDrawingBufferSize=function(v){return v.set(ye*fe,Re*fe).floor()},this.setDrawingBufferSize=function(v,L,Z){ye=v,Re=L,fe=Z,t.width=Math.floor(v*Z),t.height=Math.floor(L*Z),this.setViewport(0,0,v,L)},this.setEffects=function(v){if(y===Xt){Ue("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(v){for(let L=0;L<v.length;L++)if(v[L].isOutputPass===!0){Ie("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}U.setEffects(v||[])},this.getCurrentViewport=function(v){return v.copy(ae)},this.getViewport=function(v){return v.copy(be)},this.setViewport=function(v,L,Z,V){v.isVector4?be.set(v.x,v.y,v.z,v.w):be.set(v,L,Z,V),ue.viewport(ae.copy(be).multiplyScalar(Pt()).round())},this.getScissor=function(v){return v.copy($e)},this.setScissor=function(v,L,Z,V){v.isVector4?$e.set(v.x,v.y,v.z,v.w):$e.set(v,L,Z,V),ue.scissor(_e.copy($e).multiplyScalar(Pt()).round())},this.getScissorTest=function(){return it},this.setScissorTest=function(v){ue.setScissorTest(it=v)},this.setOpaqueSort=function(v){Le=v},this.setTransparentSort=function(v){pt=v},this.getClearColor=function(v){return v.copy(R.getClearColor())},this.setClearColor=function(){R.setClearColor(...arguments)},this.getClearAlpha=function(){return R.getClearAlpha()},this.setClearAlpha=function(){R.setClearAlpha(...arguments)},this.clear=function(v=!0,L=!0,Z=!0){let V=0;if(v){let G=!1;if(te!==null){let de=te.texture.format;G=p.has(de)}if(G){let de=te.texture.type,Me=f.has(de),he=R.getClearColor(),ge=R.getClearAlpha(),Ee=he.r,Be=he.g,qe=he.b;Me?(S[0]=Ee,S[1]=Be,S[2]=qe,S[3]=ge,N.clearBufferuiv(N.COLOR,0,S)):(A[0]=Ee,A[1]=Be,A[2]=qe,A[3]=ge,N.clearBufferiv(N.COLOR,0,A))}else V|=N.COLOR_BUFFER_BIT}L&&(V|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Z&&(V|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),V!==0&&N.clear(V)},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.setNodesHandler=function(v){v.setRenderer(this),F=v},this.dispose=function(){t.removeEventListener("webglcontextlost",ve,!1),t.removeEventListener("webglcontextrestored",Ae,!1),t.removeEventListener("webglcontextcreationerror",ie,!1),R.dispose(),ce.dispose(),K.dispose(),Ce.dispose(),Te.dispose(),E.dispose(),oe.dispose(),k.dispose(),se.dispose(),xe.dispose(),ee.dispose(),re.dispose(),re.removeEventListener("sessionstart",sn),re.removeEventListener("sessionend",Rn),rn.stop()};function ve(v){v.preventDefault(),dl("WebGLRenderer: Context Lost."),D=!0}function Ae(){dl("WebGLRenderer: Context Restored."),D=!1;let v=ut.autoReset,L=Q.enabled,Z=Q.autoUpdate,V=Q.needsUpdate,G=Q.type;Pe(),ut.autoReset=v,Q.enabled=L,Q.autoUpdate=Z,Q.needsUpdate=V,Q.type=G}function ie(v){Ue("WebGLRenderer: A WebGL context could not be created. Reason: ",v.statusMessage)}function Ne(v){let L=v.target;L.removeEventListener("dispose",Ne),Je(L)}function Je(v){Xe(v),Te.remove(v)}function Xe(v){let L=Te.get(v).programs;L!==void 0&&(L.forEach(function(Z){ee.releaseProgram(Z)}),v.isShaderMaterial&&ee.releaseShaderCache(v))}this.renderBufferDirect=function(v,L,Z,V,G,de){L===null&&(L=Ft);let Me=G.isMesh&&G.matrixWorld.determinantAffine()<0,he=Pu(v,L,Z,V,G);ue.setMaterial(V,Me);let ge=Z.index,Ee=1;if(V.wireframe===!0){if(ge=k.getWireframeAttribute(Z),ge===void 0)return;Ee=2}let Be=Z.drawRange,qe=Z.attributes.position,Se=Be.start*Ee,Ye=(Be.start+Be.count)*Ee;de!==null&&(Se=Math.max(Se,de.start*Ee),Ye=Math.min(Ye,(de.start+de.count)*Ee)),ge!==null?(Se=Math.max(Se,0),Ye=Math.min(Ye,ge.count)):qe!=null&&(Se=Math.max(Se,0),Ye=Math.min(Ye,qe.count));let _t=Ye-Se;if(_t<0||_t===1/0)return;se.setup(G,V,he,Z,ge);let ot,rt=O;if(ge!==null&&(ot=x.get(ge),rt=q,rt.setIndex(ot)),G.isMesh)V.wireframe===!0?(ue.setLineWidth(V.wireframeLinewidth*Pt()),rt.setMode(N.LINES)):rt.setMode(N.TRIANGLES);else if(G.isLine){let It=V.linewidth;It===void 0&&(It=1),ue.setLineWidth(It*Pt()),G.isLineSegments?rt.setMode(N.LINES):G.isLineLoop?rt.setMode(N.LINE_LOOP):rt.setMode(N.LINE_STRIP)}else G.isPoints?rt.setMode(N.POINTS):G.isSprite&&rt.setMode(N.TRIANGLES);if(G.isBatchedMesh)if(Qe.get("WEBGL_multi_draw"))rt.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{let It=G._multiDrawStarts,we=G._multiDrawCounts,Ot=G._multiDrawCount,et=ge?x.get(ge).bytesPerElement:1,hi=Te.get(V).currentProgram.getUniforms();for(let Lt=0;Lt<Ot;Lt++)hi.setValue(N,"_gl_DrawID",Lt),rt.render(It[Lt]/et,we[Lt])}else if(G.isInstancedMesh)rt.renderInstances(Se,_t,G.count);else if(Z.isInstancedBufferGeometry){let It=Z._maxInstanceCount!==void 0?Z._maxInstanceCount:1/0,we=Math.min(Z.instanceCount,It);rt.renderInstances(Se,_t,we)}else rt.render(Se,_t)};function Yt(v,L,Z,V){F!==null&&v.isNodeMaterial&&F.setObject(V,v),Ge===!0&&P.setState(v,Z,!1),v.transparent===!0&&v.side===bn&&v.forceSinglePass===!1?(v.side=Vt,v.needsUpdate=!0,cs(v,L,V),v.side=ri,v.needsUpdate=!0,cs(v,L,V),v.side=bn):cs(v,L,V)}this.compile=function(v,L,Z=null){Z===null&&(Z=v),F!==null&&F.renderStart(v,L,Z),w=K.get(Z),w.init(L),M.push(w),Z.traverseVisible(function(G){G.isLight&&G.layers.test(L.layers)&&(w.pushLight(G),G.castShadow&&w.pushShadow(G))}),v!==Z&&v.traverseVisible(function(G){G.isLight&&G.layers.test(L.layers)&&(w.pushLight(G),G.castShadow&&w.pushShadow(G))}),w.setupLights(),F!==null&&F.updateLights(w.state.lightsArray),mt=this.localClippingEnabled,Ge=P.init(this.clippingPlanes,mt),Ge===!0&&P.setGlobalState(this.clippingPlanes,L),F!==null&&Q.render(w.state.shadowsArray,Z,L);let V=new Set;return v.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;let de=G.material;if(de)if(Array.isArray(de))for(let Me=0;Me<de.length;Me++){let he=de[Me];Yt(he,Z,L,G),V.add(he)}else Yt(de,Z,L,G),V.add(de)}),w=M.pop(),F!==null&&F.renderEnd(),V},this.compileAsync=function(v,L,Z=null){let V=this.compile(v,L,Z);return new Promise(G=>{function de(){if(V.forEach(function(Me){let ge=Te.get(Me).currentProgram;(ge===void 0||ge.isReady())&&V.delete(Me)}),V.size===0){G(v);return}setTimeout(de,10)}Qe.get("KHR_parallel_shader_compile")!==null?de():setTimeout(de,10)})};let Ve=null;function xn(v){Ve&&Ve(v)}function sn(){rn.stop()}function Rn(){rn.start()}let rn=new kh;rn.setAnimationLoop(xn),typeof self<"u"&&rn.setContext(self),this.setAnimationLoop=function(v){Ve=v,re.setAnimationLoop(v),v===null?rn.stop():rn.start()},re.addEventListener("sessionstart",sn),re.addEventListener("sessionend",Rn),this.render=function(v,L){if(L!==void 0&&L.isCamera!==!0){Ue("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;F!==null&&F.renderStart(v,L);let Z=re.enabled===!0&&re.isPresenting===!0,V=U!==null&&(te===null||Z)&&U.begin(I,te);if(v.matrixWorldAutoUpdate===!0&&v.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),re.enabled===!0&&re.isPresenting===!0&&(U===null||U.isCompositing()===!1)&&(re.cameraAutoUpdate===!0&&re.updateCamera(L),L=re.getCamera()),v.isScene===!0&&v.onBeforeRender(I,v,L,te),w=K.get(v,M.length),w.init(L),w.state.textureUnits=Ce.getTextureUnits(),M.push(w),at.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),L.isArrayCamera?lt.setFromArrayCamera(L):ke.setFromProjectionMatrix(at,on,L.reversedDepth),mt=this.localClippingEnabled,Ge=P.init(this.clippingPlanes,mt),T=ce.get(v,g.length),T.init(),g.push(T),this.info.render.frame++,re.enabled===!0&&re.isPresenting===!0){let Me=I.xr.getDepthSensingMesh();Me!==null&&Ti(Me,L,-1/0,I.sortObjects)}Ti(v,L,0,I.sortObjects),T.finish(),F!==null&&F.updateLights(w.state.lightsArray),I.sortObjects===!0&&T.sort(Le,pt),Tt=re.enabled===!1||re.isPresenting===!1||re.hasDepthSensing()===!1,Tt&&R.addToRenderList(T,v),this.info.autoReset===!0&&this.info.reset(),Ge===!0&&P.beginShadows();let G=w.state.shadowsArray;if(Q.render(G,v,L),Ge===!0&&P.endShadows(),(V&&U.hasRenderPass())===!1){let Me=T.opaque,he=T.transmissive;if(w.setupLights(),L.isArrayCamera){let ge=L.cameras;if(he.length>0)for(let Ee=0,Be=ge.length;Ee<Be;Ee++){let qe=ge[Ee];ls(Me,he,v,qe)}Tt&&R.render(v);for(let Ee=0,Be=ge.length;Ee<Be;Ee++){let qe=ge[Ee];os(T,v,qe,qe.viewport)}}else he.length>0&&ls(Me,he,v,L),Tt&&R.render(v),os(T,v,L)}te!==null&&z===0&&(Ce.updateMultisampleRenderTarget(te),Ce.updateRenderTargetMipmap(te)),V&&U.end(I),v.isScene===!0&&v.onAfterRender(I,v,L),se.resetDefaultState(),W=-1,$=null,M.pop(),M.length>0?(w=M[M.length-1],Ce.setTextureUnits(w.state.textureUnits),Ge===!0&&P.setGlobalState(I.clippingPlanes,w.state.camera)):w=null,g.pop(),g.length>0?T=g[g.length-1]:T=null,F!==null&&F.renderEnd()};function Ti(v,L,Z,V){if(v.visible===!1)return;if(v.layers.test(L.layers)){if(v.isGroup)Z=v.renderOrder;else if(v.isLOD)v.autoUpdate===!0&&v.update(L);else if(v.isLight)w.pushLight(v),v.castShadow&&w.pushShadow(v);else if(v.isSprite){let Me=L.isArrayCamera?lt:ke;if(!v.frustumCulled||v.intersectsFrustum(Me)){V&>.setFromMatrixPosition(v.matrixWorld).applyMatrix4(at);let he=oe.update(v),ge=v.material;ge.visible&&T.push(v,he,ge,Z,gt.z,null,L)}}else if(v.isMesh||v.isLine||v.isPoints){let Me=L.isArrayCamera?lt:ke;if(!v.frustumCulled||v.intersectsFrustum(Me)){let he=oe.update(v),ge=v.material;if(V&&(v.boundingSphere!==void 0?(v.boundingSphere===null&&v.computeBoundingSphere(),gt.copy(v.boundingSphere.center)):(he.boundingSphere===null&&he.computeBoundingSphere(),gt.copy(he.boundingSphere.center)),gt.applyMatrix4(v.matrixWorld).applyMatrix4(at)),Array.isArray(ge)){let Ee=he.groups;for(let Be=0,qe=Ee.length;Be<qe;Be++){let Se=Ee[Be],Ye=ge[Se.materialIndex];Ye&&Ye.visible&&T.push(v,he,Ye,Z,gt.z,Se,L)}}else ge.visible&&T.push(v,he,ge,Z,gt.z,null,L)}}}let de=v.children;for(let Me=0,he=de.length;Me<he;Me++)Ti(de[Me],L,Z,V)}function os(v,L,Z,V){let{opaque:G,transmissive:de,transparent:Me}=v;w.setupLightsView(Z),Ge===!0&&P.setGlobalState(I.clippingPlanes,Z),V&&ue.viewport(ae.copy(V)),G.length>0&&ci(G,L,Z),de.length>0&&ci(de,L,Z),Me.length>0&&ci(Me,L,Z),ue.buffers.depth.setTest(!0),ue.buffers.depth.setMask(!0),ue.buffers.color.setMask(!0),ue.setPolygonOffset(!1)}function ls(v,L,Z,V){if((Z.isScene===!0?Z.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[V.id]===void 0){let Se=Qe.has("EXT_color_buffer_half_float")||Qe.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[V.id]=new Qt(1,1,{generateMipmaps:!0,type:Se?mn:Xt,minFilter:Gn,samples:Math.max(4,st.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:Ze.workingColorSpace})}let de=w.state.transmissionRenderTarget[V.id],Me=V.viewport||ae;de.setSize(Me.z*I.transmissionResolutionScale,Me.w*I.transmissionResolutionScale);let he=I.getRenderTarget(),ge=I.getActiveCubeFace(),Ee=I.getActiveMipmapLevel();I.setRenderTarget(de),I.getClearColor(j),pe=I.getClearAlpha(),pe<1&&I.setClearColor(16777215,.5),I.clear(),Tt&&R.render(Z);let Be=I.toneMapping;I.toneMapping=Sn;let qe=V.viewport;if(V.viewport!==void 0&&(V.viewport=void 0),w.setupLightsView(V),Ge===!0&&P.setGlobalState(I.clippingPlanes,V),ci(v,Z,V),Ce.updateMultisampleRenderTarget(de),Ce.updateRenderTargetMipmap(de),Qe.has("WEBGL_multisampled_render_to_texture")===!1){let Se=!1;for(let Ye=0,_t=L.length;Ye<_t;Ye++){let ot=L[Ye],{object:rt,geometry:It,material:we,group:Ot}=ot;if(we.side===bn&&rt.layers.test(V.layers)){let et=we.side;we.side=Vt,we.needsUpdate=!0,Jl(rt,Z,V,It,we,Ot),we.side=et,we.needsUpdate=!0,Se=!0}}Se===!0&&(Ce.updateMultisampleRenderTarget(de),Ce.updateRenderTargetMipmap(de))}I.setRenderTarget(he,ge,Ee),I.setClearColor(j,pe),qe!==void 0&&(V.viewport=qe),I.toneMapping=Be}function ci(v,L,Z){let V=L.isScene===!0?L.overrideMaterial:null;for(let G=0,de=v.length;G<de;G++){let Me=v[G],{object:he,geometry:ge,group:Ee}=Me,Be=Me.material;Be.allowOverride===!0&&V!==null&&(Be=V),he.layers.test(Z.layers)&&Jl(he,L,Z,ge,Be,Ee)}}function Jl(v,L,Z,V,G,de){F!==null&&G.isNodeMaterial&&F.setObject(v,G),v.onBeforeRender(I,L,Z,V,G,de),v.modelViewMatrix.multiplyMatrices(Z.matrixWorldInverse,v.matrixWorld),v.normalMatrix.getNormalMatrix(v.modelViewMatrix),G.onBeforeRender(I,L,Z,V,v,de),G.transparent===!0&&G.side===bn&&G.forceSinglePass===!1?(G.side=Vt,G.needsUpdate=!0,I.renderBufferDirect(Z,L,V,G,v,de),G.side=ri,G.needsUpdate=!0,I.renderBufferDirect(Z,L,V,G,v,de),G.side=bn):I.renderBufferDirect(Z,L,V,G,v,de),v.onAfterRender(I,L,Z,V,G,de)}function Kl(v){let L=0;for(let Z of v)Z.texture!==null&&L++;return L}function cs(v,L,Z){L.isScene!==!0&&(L=Ft);let V=Te.get(v),G=w.state.lights,de=w.state.shadowsArray,Me=G.state.version,he=ee.getParameters(v,G.state,de,L,Z,w.state.lightProbeGridArray),ge=ee.getProgramCacheKey(he),Ee=V.programs;V.environment=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,V.fog=L.fog;let Be=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap;V.envMap=E.get(v.envMap||V.environment,Be),V.envMapRotation=V.environment!==null&&v.envMap===null?L.environmentRotation:v.envMapRotation,Ee===void 0&&(v.addEventListener("dispose",Ne),Ee=new Map,V.programs=Ee,V.programVariants=new Map);let qe=Ee.get(ge);if(qe!==void 0){if(V.currentProgram===qe&&V.lightsStateVersion===Me)return Ql(v,he),qe}else he.uniforms=ee.getUniforms(v),F!==null&&v.isNodeMaterial&&F.build(v,Z,he),v.onBeforeCompile(he,I),qe=ee.acquireProgram(he,ge),Ee.set(ge,qe),V.uniforms=he.uniforms;let Se=V.uniforms;return(!v.isShaderMaterial&&!v.isRawShaderMaterial||v.clipping===!0)&&(Se.clippingPlanes=P.uniform),Ql(v,he),V.needsLights=Lu(v),V.lightsStateVersion=Me,V.needsLights&&(Se.ambientLightColor.value=G.state.ambient,Se.lightProbe.value=G.state.probe,Se.sunLights.value=G.state.sun,Se.sunLightShadows.value=G.state.sunShadow,Se.directionalLights.value=G.state.directional,Se.directionalLightShadows.value=G.state.directionalShadow,Se.spotLights.value=G.state.spot,Se.spotLightShadows.value=G.state.spotShadow,Se.rectAreaLights.value=G.state.rectArea,Se.ltc_1.value=G.state.rectAreaLTC1,Se.ltc_2.value=G.state.rectAreaLTC2,Se.pointLights.value=G.state.point,Se.pointLightShadows.value=G.state.pointShadow,Se.hemisphereLights.value=G.state.hemi,Se.sunShadowMatrix.value=G.state.sunShadowMatrix,Se.sunShadowCascade.value=G.state.sunShadowCascade,Se.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Se.spotLightMatrix.value=G.state.spotLightMatrix,Se.spotLightMap.value=G.state.spotLightMap,Se.pointShadowMatrix.value=G.state.pointShadowMatrix),V.numLightProbeGrids=Kl(w.state.lightProbeGridArray),V.currentProgram=qe,V.uniformsList=null,qe}function Cu(v,L,Z,V,G){let de=Te.get(v),Me=de.currentProgram.id+","+V+","+G,he=de.programVariants.get(Me);return he===void 0?(he=cs(v,L,Z),de.programVariants.set(Me,he)):(de.currentProgram=he,de.uniformsList=null,de.outputColorSpace=V,de.toneMapping=G),he}function jl(v){if(v.uniformsList===null){let L=v.currentProgram.getUniforms();v.uniformsList=rs.seqWithValue(L.seq,v.uniforms)}return v.uniformsList}function Ql(v,L){let Z=Te.get(v);Z.outputColorSpace=L.outputColorSpace,Z.batching=L.batching,Z.batchingColor=L.batchingColor,Z.instancing=L.instancing,Z.instancingColor=L.instancingColor,Z.instancingMorph=L.instancingMorph,Z.skinning=L.skinning,Z.morphTargets=L.morphTargets,Z.morphNormals=L.morphNormals,Z.morphColors=L.morphColors,Z.morphTargetsCount=L.morphTargetsCount,Z.numClippingPlanes=L.numClippingPlanes,Z.numIntersection=L.numClipIntersection,Z.vertexAlphas=L.vertexAlphas,Z.vertexTangents=L.vertexTangents,Z.toneMapping=L.toneMapping}function Pu(v,L,Z,V,G){L.isScene!==!0&&(L=Ft),Ce.resetTextureUnits();let de=L.fog,Me=V.isMeshStandardMaterial||V.isMeshLambertMaterial||V.isMeshPhongMaterial?L.environment:null,he=te===null?I.outputColorSpace:te.isXRRenderTarget===!0?te.texture.colorSpace:Ze.workingColorSpace,ge=V.isMeshStandardMaterial||V.isMeshLambertMaterial&&!V.envMap||V.isMeshPhongMaterial&&!V.envMap,Ee=E.get(V.envMap||Me,ge),Be=V.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,qe=!!Z.attributes.tangent&&(!!V.normalMap||V.anisotropy>0),Se=!!Z.morphAttributes.position,Ye=!!Z.morphAttributes.normal,_t=!!Z.morphAttributes.color,ot=Sn;V.toneMapped&&(te===null||te.isXRRenderTarget===!0)&&(ot=I.toneMapping);let rt=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,It=rt!==void 0?rt.length:0,we=Te.get(V),Ot=w.state.lights;if(Ge===!0&&(mt===!0||v!==$)){let ft=v===$&&V.id===W;P.setState(V,v,ft)}let et=!1,hi=!1;V.version===we.__version?we.needsLights&&we.lightsStateVersion!==Ot.state.version||G.isBatchedMesh&&we.batching===!1||!G.isBatchedMesh&&we.batching===!0||G.isBatchedMesh&&we.batchingColor===!0&&G._colorsTexture===null||G.isBatchedMesh&&we.batchingColor===!1&&G._colorsTexture!==null||G.isInstancedMesh&&we.instancing===!1||!G.isInstancedMesh&&we.instancing===!0||G.isSkinnedMesh&&we.skinning===!1||!G.isSkinnedMesh&&we.skinning===!0||G.isInstancedMesh&&we.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&we.instancingColor===!1&&G.instanceColor!==null||G.isInstancedMesh&&we.instancingMorph===!0&&G.morphTexture===null||G.isInstancedMesh&&we.instancingMorph===!1&&G.morphTexture!==null||we.envMap!==Ee||V.fog===!0&&we.fog!==de||we.numClippingPlanes!==void 0&&(we.numClippingPlanes!==P.numPlanes||we.numIntersection!==P.numIntersection)||we.vertexAlphas!==Be||we.vertexTangents!==qe||we.morphTargets!==Se||we.morphNormals!==Ye||we.morphColors!==_t||we.morphTargetsCount!==It||we.numLightProbeGrids!==Kl(w.state.lightProbeGridArray)?et=!0:(we.outputColorSpace!==he||we.toneMapping!==ot)&&(hi=!0):(et=!0,we.__version=V.version);let Lt=we.currentProgram;(et===!0||hi===!0)&&(Lt=hi===!0?Cu(V,L,G,he,ot):cs(V,L,G),F&&V.isNodeMaterial&&F.onUpdateProgram(V,Lt,we));let nr=!1,qn=!1,ui=!1,je=Lt.getUniforms(),Rt=we.uniforms;if(ue.useProgram(Lt.program)&&(nr=!0,qn=!0,ui=!0),V.id!==W&&(W=V.id,qn=!0),nr||$!==v){ue.buffers.depth.getReversed()&&v.reversedDepth!==!0&&(v._reversedDepth=!0,v.updateProjectionMatrix()),je.setValue(N,"projectionMatrix",v.projectionMatrix),je.setValue(N,"viewMatrix",v.matrixWorldInverse);let St=je.map.cameraPosition;St!==void 0&&St.setValue(N,nn.setFromMatrixPosition(v.matrixWorld)),st.logarithmicDepthBuffer&&je.setValue(N,"logDepthBufFC",2/(Math.log(v.far+1)/Math.LN2)),(V.isMeshPhongMaterial||V.isMeshToonMaterial||V.isMeshLambertMaterial||V.isMeshBasicMaterial||V.isMeshStandardMaterial||V.isShaderMaterial)&&je.setValue(N,"isOrthographic",v.isOrthographicCamera===!0),$!==v&&($=v,qn=!0,ui=!0)}if(we.needsLights&&(Ot.state.sunShadowMap.length>0&&je.setValue(N,"sunShadowMap",Ot.state.sunShadowMap,Ce),Ot.state.directionalShadowMap.length>0&&je.setValue(N,"directionalShadowMap",Ot.state.directionalShadowMap,Ce),Ot.state.spotShadowMap.length>0&&je.setValue(N,"spotShadowMap",Ot.state.spotShadowMap,Ce),Ot.state.pointShadowMap.length>0&&je.setValue(N,"pointShadowMap",Ot.state.pointShadowMap,Ce)),G.isSkinnedMesh){je.setOptional(N,G,"bindMatrix"),je.setOptional(N,G,"bindMatrixInverse");let ft=G.skeleton;ft&&(ft.boneTexture===null&&ft.computeBoneTexture(),je.setValue(N,"boneTexture",ft.boneTexture,Ce))}G.isBatchedMesh&&(je.setOptional(N,G,"batchingTexture"),je.setValue(N,"batchingTexture",G._matricesTexture,Ce),je.setOptional(N,G,"batchingIdTexture"),je.setValue(N,"batchingIdTexture",G._indirectTexture,Ce),je.setOptional(N,G,"batchingColorTexture"),G._colorsTexture!==null&&je.setValue(N,"batchingColorTexture",G._colorsTexture,Ce));let ln=Z.morphAttributes;if((ln.position!==void 0||ln.normal!==void 0||ln.color!==void 0)&&X.update(G,Z,Lt),(qn||we.receiveShadow!==G.receiveShadow)&&(we.receiveShadow=G.receiveShadow,je.setValue(N,"receiveShadow",G.receiveShadow)),(V.isMeshStandardMaterial||V.isMeshLambertMaterial||V.isMeshPhongMaterial)&&V.envMap===null&&L.environment!==null&&(Rt.envMapIntensity.value=L.environmentIntensity),Rt.dfgLUT!==void 0&&(Rt.dfgLUT.value=p_()),qn){if(je.setValue(N,"toneMappingExposure",I.toneMappingExposure),we.needsLights&&Iu(Rt,ui),de&&V.fog===!0&&le.refreshFogUniforms(Rt,de),le.refreshMaterialUniforms(Rt,V,fe,Re,w.state.transmissionRenderTarget[v.id]),we.needsLights&&we.numLightProbeGrids>0){let ft=b,St=0;for(let Cn of w.state.lightProbeGridArray)Cn.texture!==null&&(ft.textures[St]=Cn.texture,ft.min[St]=Cn.boundingBox.min,ft.max[St]=Cn.boundingBox.max,ft.resolution[St]=Cn.resolution,St++);for(let Cn in ft)ft[Cn].length=St;Rt.probesSH.value=ft.textures,Rt.probesMin.value=ft.min,Rt.probesMax.value=ft.max,Rt.probesResolution.value=ft.resolution}rs.upload(N,jl(we),Rt,Ce)}if(V.isShaderMaterial&&V.uniformsNeedUpdate===!0&&(rs.upload(N,jl(we),Rt,Ce),V.uniformsNeedUpdate=!1),V.isSpriteMaterial&&je.setValue(N,"center",G.center),je.setValue(N,"modelViewMatrix",G.modelViewMatrix),je.setValue(N,"normalMatrix",G.normalMatrix),je.setValue(N,"modelMatrix",G.matrixWorld),V.uniformsGroups!==void 0){let ft=V.uniformsGroups;for(let St=0,Cn=ft.length;St<Cn;St++){let tc=ft[St];xe.update(tc,Lt),xe.bind(tc,Lt)}}return Lt}function Iu(v,L){v.ambientLightColor.needsUpdate=L,v.lightProbe.needsUpdate=L,v.sunLights.needsUpdate=L,v.sunLightShadows.needsUpdate=L,v.directionalLights.needsUpdate=L,v.directionalLightShadows.needsUpdate=L,v.pointLights.needsUpdate=L,v.pointLightShadows.needsUpdate=L,v.spotLights.needsUpdate=L,v.spotLightShadows.needsUpdate=L,v.rectAreaLights.needsUpdate=L,v.hemisphereLights.needsUpdate=L}function Lu(v){return v.isMeshLambertMaterial||v.isMeshToonMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isShadowMaterial||v.isShaderMaterial&&v.lights===!0}this.getActiveCubeFace=function(){return J},this.getActiveMipmapLevel=function(){return z},this.getRenderTarget=function(){return te},this.setRenderTargetTextures=function(v,L,Z){let V=Te.get(v);V.__autoAllocateDepthBuffer=v.resolveDepthBuffer===!1,V.__autoAllocateDepthBuffer===!1&&(V.__useRenderToTexture=!1),Te.get(v.texture).__webglTexture=L,Te.get(v.depthTexture).__webglTexture=V.__autoAllocateDepthBuffer?void 0:Z,V.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(v,L){let Z=Te.get(v);Z.__webglFramebuffer=L,Z.__useDefaultFramebuffer=L===void 0},this.setRenderTarget=function(v,L=0,Z=0){te=v,J=L,z=Z;let V=null,G=!1,de=!1;if(v){let he=Te.get(v);if(he.__useDefaultFramebuffer!==void 0){ue.bindFramebuffer(N.FRAMEBUFFER,he.__webglFramebuffer),ae.copy(v.viewport),_e.copy(v.scissor),De=v.scissorTest,ue.viewport(ae),ue.scissor(_e),ue.setScissorTest(De),W=-1;return}else if(he.__webglFramebuffer===void 0)Ce.setupRenderTarget(v);else if(he.__hasExternalTextures)Ce.rebindTextures(v,Te.get(v.texture).__webglTexture,Te.get(v.depthTexture).__webglTexture);else if(v.depthBuffer){let Be=v.depthTexture;if(he.__boundDepthTexture!==Be){if(Be!==null&&Te.has(Be)&&(v.width!==Be.image.width||v.height!==Be.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Ce.setupDepthRenderbuffer(v)}}let ge=v.texture;(ge.isData3DTexture||ge.isDataArrayTexture||ge.isCompressedArrayTexture)&&(de=!0);let Ee=Te.get(v).__webglFramebuffer;v.isWebGLCubeRenderTarget?(Array.isArray(Ee[L])?V=Ee[L][Z]:V=Ee[L],G=!0):v.samples>0&&Ce.useMultisampledRTT(v)===!1?V=Te.get(v).__webglMultisampledFramebuffer:Array.isArray(Ee)?V=Ee[Z]:V=Ee,ae.copy(v.viewport),_e.copy(v.scissor),De=v.scissorTest}else ae.copy(be).multiplyScalar(fe).floor(),_e.copy($e).multiplyScalar(fe).floor(),De=it;if(Z!==0&&(V=H),ue.bindFramebuffer(N.FRAMEBUFFER,V)&&ue.drawBuffers(v,V),ue.viewport(ae),ue.scissor(_e),ue.setScissorTest(De),G){let he=Te.get(v.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+L,he.__webglTexture,Z)}else if(de){let he=L;for(let ge=0;ge<v.textures.length;ge++){let Ee=Te.get(v.textures[ge]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+ge,Ee.__webglTexture,Z,he)}}else if(v!==null&&Z!==0){let he=Te.get(v.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,he.__webglTexture,Z)}W=-1};function ec(v){let L=Te.get(v);return(L.__readFormat!==v.format||L.__readType!==v.type)&&(L.__readFormat=v.format,L.__readType=v.type,L.__formatReadable=st.textureFormatReadable(v.format),L.__typeReadable=st.textureTypeReadable(v.type)),L}this.readRenderTargetPixels=function(v,L,Z,V,G,de,Me,he=0){if(!(v&&v.isWebGLRenderTarget)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ge=Te.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&Me!==void 0&&(ge=ge[Me],Array.isArray(ge)&&(ge=ge[0])),ge){ue.bindFramebuffer(N.FRAMEBUFFER,ge);try{let Ee=v.textures[he],Be=Ee.format,qe=Ee.type;v.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+he);let Se=ec(Ee);if(Se.__formatReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Se.__typeReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=v.width-V&&Z>=0&&Z<=v.height-G&&N.readPixels(L,Z,V,G,ne.convert(Be),ne.convert(qe),de)}finally{let Ee=te!==null?Te.get(te).__webglFramebuffer:null;ue.bindFramebuffer(N.FRAMEBUFFER,Ee)}}},this.readRenderTargetPixelsAsync=async function(v,L,Z,V,G,de,Me,he=0){if(!(v&&v.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ge=Te.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&Me!==void 0&&(ge=ge[Me],Array.isArray(ge)&&(ge=ge[0])),ge)if(L>=0&&L<=v.width-V&&Z>=0&&Z<=v.height-G){ue.bindFramebuffer(N.FRAMEBUFFER,ge);let Ee=v.textures[he],Be=Ee.format,qe=Ee.type;v.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+he);let Se=ec(Ee);if(Se.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Se.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Ye=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Ye),N.bufferData(N.PIXEL_PACK_BUFFER,de.byteLength,N.STREAM_READ),N.readPixels(L,Z,V,G,ne.convert(Be),ne.convert(qe),0),N.bindBuffer(N.PIXEL_PACK_BUFFER,null);let _t=te!==null?Te.get(te).__webglFramebuffer:null;ue.bindFramebuffer(N.FRAMEBUFFER,_t);let ot=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await uh(N,ot,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Ye),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,de),N.bindBuffer(N.PIXEL_PACK_BUFFER,null),N.deleteBuffer(Ye),N.deleteSync(ot),de}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(v,L=null,Z=0){let V=Math.pow(2,-Z),G=Math.floor(v.image.width*V),de=Math.floor(v.image.height*V),Me=L!==null?L.x:0,he=L!==null?L.y:0;Ce.setTexture2D(v,0),N.copyTexSubImage2D(N.TEXTURE_2D,Z,0,0,Me,he,G,de),ue.unbindTexture()},this.copyTextureToTexture=function(v,L,Z=null,V=null,G=0,de=0){let Me,he,ge,Ee,Be,qe,Se,Ye,_t,ot=v.isCompressedTexture?v.mipmaps[de]:v.image;if(Z!==null)Me=Z.max.x-Z.min.x,he=Z.max.y-Z.min.y,ge=Z.isBox3?Z.max.z-Z.min.z:1,Ee=Z.min.x,Be=Z.min.y,qe=Z.isBox3?Z.min.z:0;else{let je=Math.pow(2,-G);Me=Math.floor(ot.width*je),he=Math.floor(ot.height*je),v.isDataArrayTexture?ge=ot.depth:v.isData3DTexture?ge=Math.floor(ot.depth*je):ge=1,Ee=0,Be=0,qe=0}V!==null?(Se=V.x,Ye=V.y,_t=V.z):(Se=0,Ye=0,_t=0);let rt=ne.convert(L.format),It=ne.convert(L.type),we;L.isData3DTexture?(Ce.setTexture3D(L,0),we=N.TEXTURE_3D):L.isDataArrayTexture||L.isCompressedArrayTexture?(Ce.setTexture2DArray(L,0),we=N.TEXTURE_2D_ARRAY):(Ce.setTexture2D(L,0),we=N.TEXTURE_2D),ue.activeTexture(N.TEXTURE0),ue.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,L.flipY),ue.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),ue.pixelStorei(N.UNPACK_ALIGNMENT,L.unpackAlignment);let Ot=ue.getParameter(N.UNPACK_ROW_LENGTH),et=ue.getParameter(N.UNPACK_IMAGE_HEIGHT),hi=ue.getParameter(N.UNPACK_SKIP_PIXELS),Lt=ue.getParameter(N.UNPACK_SKIP_ROWS),nr=ue.getParameter(N.UNPACK_SKIP_IMAGES);ue.pixelStorei(N.UNPACK_ROW_LENGTH,ot.width),ue.pixelStorei(N.UNPACK_IMAGE_HEIGHT,ot.height),ue.pixelStorei(N.UNPACK_SKIP_PIXELS,Ee),ue.pixelStorei(N.UNPACK_SKIP_ROWS,Be),ue.pixelStorei(N.UNPACK_SKIP_IMAGES,qe);let qn=v.isDataArrayTexture||v.isData3DTexture,ui=L.isDataArrayTexture||L.isData3DTexture;if(v.isDepthTexture){let je=Te.get(v),Rt=Te.get(L),ln=Te.get(je.__renderTarget),ft=Te.get(Rt.__renderTarget);ue.bindFramebuffer(N.READ_FRAMEBUFFER,ln.__webglFramebuffer),ue.bindFramebuffer(N.DRAW_FRAMEBUFFER,ft.__webglFramebuffer);for(let St=0;St<ge;St++)qn&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Te.get(v).__webglTexture,G,qe+St),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Te.get(L).__webglTexture,de,_t+St)),N.blitFramebuffer(Ee,Be,Ee+Me,Be+he,Se,Ye,Se+Me,Ye+he,N.DEPTH_BUFFER_BIT,N.NEAREST);ue.bindFramebuffer(N.READ_FRAMEBUFFER,null),ue.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(G!==0||v.isRenderTargetTexture||Te.has(v)){let je=Te.get(v),Rt=Te.get(L);ue.bindFramebuffer(N.READ_FRAMEBUFFER,C),ue.bindFramebuffer(N.DRAW_FRAMEBUFFER,Y);for(let ln=0;ln<ge;ln++)qn?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,je.__webglTexture,G,qe+ln):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,je.__webglTexture,G),ui?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Rt.__webglTexture,de,_t+ln):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Rt.__webglTexture,de),G!==0?N.blitFramebuffer(Ee,Be,Ee+Me,Be+he,Se,Ye,Se+Me,Ye+he,N.COLOR_BUFFER_BIT,N.NEAREST):ui?N.copyTexSubImage3D(we,de,Se,Ye,_t+ln,Ee,Be,Me,he):N.copyTexSubImage2D(we,de,Se,Ye,Ee,Be,Me,he);ue.bindFramebuffer(N.READ_FRAMEBUFFER,null),ue.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else ui?v.isDataTexture||v.isData3DTexture?N.texSubImage3D(we,de,Se,Ye,_t,Me,he,ge,rt,It,ot.data):L.isCompressedArrayTexture?N.compressedTexSubImage3D(we,de,Se,Ye,_t,Me,he,ge,rt,ot.data):N.texSubImage3D(we,de,Se,Ye,_t,Me,he,ge,rt,It,ot):v.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,de,Se,Ye,Me,he,rt,It,ot.data):v.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,de,Se,Ye,ot.width,ot.height,rt,ot.data):N.texSubImage2D(N.TEXTURE_2D,de,Se,Ye,Me,he,rt,It,ot);ue.pixelStorei(N.UNPACK_ROW_LENGTH,Ot),ue.pixelStorei(N.UNPACK_IMAGE_HEIGHT,et),ue.pixelStorei(N.UNPACK_SKIP_PIXELS,hi),ue.pixelStorei(N.UNPACK_SKIP_ROWS,Lt),ue.pixelStorei(N.UNPACK_SKIP_IMAGES,nr),de===0&&L.generateMipmaps===!0&&L.mipmapsAutoUpdate===!0&&N.generateMipmap(we),ue.unbindTexture()},this.initRenderTarget=function(v){Te.get(v).__webglFramebuffer===void 0&&Ce.setupRenderTarget(v)},this.initTexture=function(v){v.isCubeTexture?Ce.setTextureCube(v,0):v.isData3DTexture?Ce.setTexture3D(v,0):v.isDataArrayTexture||v.isCompressedArrayTexture?Ce.setTexture2DArray(v,0):Ce.setTexture2D(v,0),ue.unbindTexture()},this.resetState=function(){J=0,z=0,te=null,ue.reset(),se.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return on}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Ze._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ze._getUnpackColorSpace()}};var Kh={type:"change"},Ol={type:"start"},Qh={type:"end"},so=new _i,jh=new Kt,m_=Math.cos(70*gl.DEG2RAD),bt=new B,qt=2*Math.PI,tt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Fl=1e-6,ro=class extends Us{constructor(e,t=null){super(e,t),this.state=tt.NONE,this.target=new B,this.cursor=new B,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:ii.ROTATE,MIDDLE:ii.DOLLY,RIGHT:ii.PAN},this.touches={ONE:si.ROTATE,TWO:si.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 B,this._lastQuaternion=new jt,this._lastTargetPosition=new B,this._quat=new jt().setFromUnitVectors(e.up,new B(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Qi,this._sphericalDelta=new Qi,this._scale=1,this._panOffset=new B,this._rotateStart=new Fe,this._rotateEnd=new Fe,this._rotateDelta=new Fe,this._panStart=new Fe,this._panEnd=new Fe,this._panDelta=new Fe,this._dollyStart=new Fe,this._dollyEnd=new Fe,this._dollyDelta=new Fe,this._dollyDirection=new B,this._mouse=new Fe,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=__.bind(this),this._onPointerDown=g_.bind(this),this._onPointerUp=x_.bind(this),this._onContextMenu=E_.bind(this),this._onMouseWheel=M_.bind(this),this._onKeyDown=b_.bind(this),this._onTouchStart=S_.bind(this),this._onTouchMove=w_.bind(this),this._onMouseDown=y_.bind(this),this._onMouseMove=v_.bind(this),this._interceptControlDown=T_.bind(this),this._interceptControlUp=A_.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.ownerDocument.addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=tt.NONE,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.ownerDocument.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.ownerDocument.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="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(Kh),this.update(),this.state=tt.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){let t=this.object.position;bt.copy(t).sub(this.target),bt.applyQuaternion(this._quat),this._spherical.setFromVector3(bt),this.autoRotate&&this.state===tt.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,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=qt:n>Math.PI&&(n-=qt),s<-Math.PI?s+=qt:s>Math.PI&&(s-=qt),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,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{let a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(bt.setFromSpherical(this._spherical),bt.applyQuaternion(this._quatInverse),t.copy(this.target).add(bt),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 a=null;if(this.object.isPerspectiveCamera){let o=bt.length();a=this._clampDistance(o*this._scale);let c=o-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),r=!!c}else if(this.object.isOrthographicCamera){let o=new B(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let 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;let l=new B(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(o),this.object.updateMatrixWorld(),a=bt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(so.origin.copy(this.object.position),so.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(so.direction))<m_?this.object.lookAt(this.target):(jh.setFromNormalAndCoplanarPoint(this.object.up,this.target),so.intersectPlane(jh,this.target))))}else if(this.object.isOrthographicCamera){let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Fl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Fl||this._lastTargetPosition.distanceToSquared(this.target)>Fl?(this.dispatchEvent(Kh),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?qt/60*this.autoRotateSpeed*e:qt/60/60*this.autoRotateSpeed}_getZoomScale(e){let 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){bt.setFromMatrixColumn(t,0),bt.multiplyScalar(-e),this._panOffset.add(bt)}_panUp(e,t){this.screenSpacePanning===!0?bt.setFromMatrixColumn(t,1):(bt.setFromMatrixColumn(t,0),bt.crossVectors(this.object.up,bt)),bt.multiplyScalar(e),this._panOffset.add(bt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let s=this.object.position;bt.copy(s).sub(this.target);let r=bt.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;let n=this.domElement.getBoundingClientRect(),s=e-n.left,r=t-n.top,a=n.width,o=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*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.clientY),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);let t=this.domElement;this._rotateLeft(qt*this._rotateDelta.x/t.clientHeight),this._rotateUp(qt*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.zoomToCursor&&(this._performCursorZoom=!0,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()),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(qt*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(-qt*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(qt*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(-qt*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{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);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{let n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(qt*this._rotateDelta.x/t.clientHeight),this._rotateUp(qt*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{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}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){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);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);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_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 Fe,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let 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 g_(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function __(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function x_(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Qh),this.state=tt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:let e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function y_(i){let e;switch(i.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 ii.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=tt.DOLLY;break;case ii.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=tt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=tt.ROTATE}break;case ii.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=tt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=tt.PAN}break;default:this.state=tt.NONE}this.state!==tt.NONE&&this.dispatchEvent(Ol)}function v_(i){switch(this.state){case tt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case tt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case tt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function M_(i){this.enabled===!1||this.enableZoom===!1||this.state!==tt.NONE||(i.preventDefault(),this.dispatchEvent(Ol),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(Qh))}function b_(i){this.enabled!==!1&&this._handleKeyDown(i)}function S_(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case si.ROTATE:if(this.enableRotate===!1){this.state=tt.NONE;break}this._handleTouchStartRotate(i),this.state=tt.TOUCH_ROTATE;break;case si.PAN:if(this.enablePan===!1){this.state=tt.NONE;break}this._handleTouchStartPan(i),this.state=tt.TOUCH_PAN;break;default:this.state=tt.NONE}break;case 2:switch(this.touches.TWO){case si.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=tt.TOUCH_DOLLY_PAN;break;case si.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=tt.TOUCH_DOLLY_ROTATE;break;default:this.state=tt.NONE}break;default:this.state=tt.NONE}this.state!==tt.NONE&&this.dispatchEvent(Ol)}function w_(i){switch(this._trackPointer(i),this.state){case tt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case tt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case tt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case tt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=tt.NONE}}function E_(i){this.enabled!==!1&&i.preventDefault()}function T_(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.ownerDocument.addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function A_(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.ownerDocument.removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}var yt={drawn:.4,svgIn:.5,rise:.55,svgOut:.62,tilted:.78,wallsUp:.84,done:.96};var eu=i=>i<0?0:i>1?1:i,Ei=i=>{let e=eu(i);return e*e*(3-2*e)};function $s(i,e){let t=eu(e),n=t<yt.drawn?0:t<yt.svgIn?Ei((t-yt.drawn)/(yt.svgIn-yt.drawn)):t<yt.rise?1:1-Ei((t-yt.rise)/(yt.svgOut-yt.rise)),s=new Map;for(let h of i){let d=!h.hidden&&t>=h.appear,u=h.riseTo<=h.riseFrom?t>=h.riseFrom?1:0:Ei((t-h.riseFrom)/(h.riseTo-h.riseFrom));s.set(h.key,{visible:d,rise:u})}let r=[],a=[];for(let h of i)h.storey===void 0||h.hidden||(r[h.storey]=Math.max(r[h.storey]??0,h.riseTo),a[h.storey]=Math.min(a[h.storey]??1,h.appear));let o=r[0]??1,c=0;for(let h=1;h<r.length;h++){let d=r[h-1],u=a[h];t>d&&(c=h-1+(u>d?Ei((t-d)/(u-d)):1))}let l=0;if(r.length>1){let h=R_(r);l=h<1?Ei((t-h)/(1-h)):t>=1?1:0,l>0&&(c=r.length-1+l)}return{tilt:Ei((t-yt.rise)/(Math.min(yt.tilted,o)-yt.rise)),dolly:Ei((t-yt.rise)/(o-yt.rise)),stop:c,settle:l,svg:n,ground:t>=yt.rise?1-n:0,nodes:s}}var R_=i=>Math.max(yt.done,...i);var tu=.88,oi=i=>i*Math.PI/180;function zl(i){let e=oi(i.elevation),t=oi(i.azimuth);return[Math.cos(e)*Math.sin(t),Math.sin(e),Math.cos(e)*Math.cos(t)]}function kl(i,e,t){let n=zl(t);return[i[0]+e*n[0],i[1]+e*n[1],i[2]+e*n[2]]}function su(i){let e=i[2],t=-i[0],n=Math.hypot(e,t),s=[e/n,0,t/n],r=[i[1]*s[2]-i[2]*s[1],i[2]*s[0]-i[0]*s[2],i[0]*s[1]-i[1]*s[0]];return{right:s,up:r}}function ru(i){let e=[];for(let t of[i.lo[0],i.hi[0]])for(let n of[i.lo[1],i.hi[1]])for(let s of[i.lo[2],i.hi[2]])e.push([t,n,s]);return e}function C_(i,e,t){let n=zl(t),{right:s,up:r}=su(n),a=Math.tan(oi(t.fov)/2),o=1/0,c=-1/0,l=1/0,h=-1/0;for(let d of ru(i)){let u=[d[0]-e.target[0],d[1]-e.target[1],d[2]-e.target[2]],m=e.dist-(u[0]*n[0]+u[1]*n[1]+u[2]*n[2]),_=(u[0]*s[0]+u[2]*s[2])/(m*a*t.aspect),y=(u[0]*r[0]+u[1]*r[1]+u[2]*r[2])/(m*a);o=Math.min(o,_),c=Math.max(c,_),l=Math.min(l,y),h=Math.max(h,y)}return{x:[o,c],y:[l,h]}}function Bl(i,e){let t=zl(e),{right:n,up:s}=su(t),r=Math.tan(oi(e.fov)/2),a=[(i.lo[0]+i.hi[0])/2,(i.lo[1]+i.hi[1])/2,(i.lo[2]+i.hi[2])/2],o=1e3;for(let c=0;c<4;c++){o=0;for(let u of ru(i)){let m=[u[0]-a[0],u[1]-a[1],u[2]-a[2]],_=m[0]*t[0]+m[1]*t[1]+m[2]*t[2],y=Math.abs(m[0]*n[0]+m[2]*n[2]),p=Math.abs(m[0]*s[0]+m[1]*s[1]+m[2]*s[2]);o=Math.max(o,_+y/(tu*r*e.aspect),_+p/(tu*r))}if(c===3)break;let l=C_(i,{target:a,dist:o},e),h=(l.x[0]+l.x[1])/2*o*r*e.aspect,d=(l.y[0]+l.y[1])/2*o*r;a=[a[0]+h*n[0]+d*s[0],a[1]+h*n[1]+d*s[1],a[2]+h*n[2]+d*s[2]]}return{target:a,dist:o}}var Tn=30,Vl=-32;function Js(i,e={}){let t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],s=e.ghosts?i:i.filter(r=>r.part!=="demolish");for(let r of s.length>0?s:i){let a=e.settle===void 0?r.lift??0:Gl(r.lift,e.settle);for(let o=0;o<r.positions.length;o+=3){let c=[r.positions[o]/1e3,r.positions[o+1]/1e3+a,r.positions[o+2]/1e3];for(let l=0;l<3;l++)t[l]=Math.min(t[l],c[l]),n[l]=Math.max(n[l],c[l])}}return{lo:t,hi:n}}var Gl=(i,e)=>(i??0)*(1-e),oo=i=>Math.max(1,...i.map(e=>(e.storey??0)+1)),ao=1.5;function au(i,e,t){let n=new Map(e.map(a=>[a.key,a.storey??0])),s=oo(e),r=[];for(let a=0;a<s;a++)r.push(Bl(Js(i.filter(o=>(n.get(o.key)??0)<=a)),t));return s>1&&r.push(Bl(Js(i,{settle:1}),t)),r}function P_(i,e){let t=Math.min(i.length-1,Math.floor(e)),n=i[t],s=i[Math.min(i.length-1,t+1)],r=e-t;return r<=0||n===s?n:{target:[0,1,2].map(a=>n.target[a]*(1-r)+s.target[a]*r),dist:n.dist*(1-r)+s.dist*r}}function lo(i,e,t){let n=h=>h*Math.PI/180,s=P_(e,i.stop),r=2*s.dist*Math.tan(n(Tn)/2),a=ao+(Tn-ao)*i.dolly,c=(t.oh+(r-t.oh)*i.dolly)/(2*Math.tan(n(a)/2));return{target:[t.cx+(s.target[0]-t.cx)*i.dolly,s.target[1]*i.tilt,t.cz+(s.target[2]-t.cz)*i.dolly],dist:c,fov:a,elevation:90-(90-t.elevation)*i.tilt,azimuth:Vl*i.tilt}}function Hl(i,e){let[t,n,s,r]=i,a=Math.max(s,r*e);return{cx:t+s/2,cz:n+r/2,ow:a,oh:a/e}}var nu={north:180,east:90,south:0,west:-90},Ks={min:0,max:90};function ou(i,e,t){if(e[1]>=t||i[1]<=t)return e;let n=(i[1]-t)/(i[1]-e[1]);return[i[0]+(e[0]-i[0])*n,t,i[2]+(e[2]-i[2])*n]}function lu(i,e){if(i==="iso")return lo($s(e.events,1),e.fits,e.frame);let t=i==="top"?{elevation:Ks.max,azimuth:nu.south}:{elevation:Ks.min,azimuth:nu[i]},n=Bl(e.box,{...t,fov:Tn,aspect:e.aspect});return{target:n.target,dist:n.dist,fov:Tn,...t}}function cu(i){return i.fov===Tn?i:{...i,fov:Tn,dist:i.dist*Math.tan(oi(i.fov)/2)/Math.tan(oi(Tn)/2)}}var iu={in:8,out:3};function hu(i,e){let t=i[i.length-1].dist,n=Math.tan(oi(Tn)/2)/Math.tan(oi(e)/2);return{min:t*n/iu.in,max:t*n*iu.out}}function uu(i){let e=[i.hi[0]-i.lo[0],i.hi[1]-i.lo[1],i.hi[2]-i.lo[2]];return{centre:[(i.lo[0]+i.hi[0])/2,(i.lo[1]+i.hi[1])/2,(i.lo[2]+i.hi[2])/2],radius:Math.hypot(e[0],e[1],e[2])/2}}var Ke=(i,e,t=0,n=1)=>({srgb:i,alpha:n,metallic:t,roughness:e}),_n={wood:Ke("#c6a785",.75),wood_dark:Ke("#7b5b44",.7),fabric:Ke("#968f85",.95),cushion:Ke("#bfb7ab",.95),linen:Ke("#f3efe7",.9),wool:Ke("#a7ac98",1),ceramic:Ke("#f6f4f0",.25),stone:Ke("#d8d4cc",.45),metal:Ke("#aeb2b4",.35,1),glass:Ke("#c9dee6",.05,0,.35),appliance:Ke("#dcdcd8",.35),screen:Ke("#2e3033",.2),paint:Ke("#a9b1a2",.6),rubber:Ke("#3b3b3b",.9),foliage:Ke("#8c9b78",.9),bark:Ke("#6f5b49",.9),soil:Ke("#5f4b3b",1),water:Ke("#a3c6d0",.1,0,.7)},I_="wood",L_="wood_dark",Wl=Ke("#c2a27e",.7),du=Ke("#55534f",.5),An={slab:Ke("#bdb6ab",.9),column:Ke("#e6e1d8",.85),wall:Ke("#f2f0eb",.9),door:Wl,"window:frame":du,"window:glass":Ke("#bcd6e0",.05,0,.4),"window:reveal":du,"window:sill":_n.stone,"window:board":_n.wood,"opening:lining":Wl,"opening:casing":Wl,opening:Ke("#e6e1d8",.85),furniture:Ke("#d6cec1",.9),roof:Ke("#9c958a",.9),"wall:demolish":Ke("#c8553d",.9,0,.3),stair:_n[I_],"stair:rail":_n[L_]},Iv={"door:lining":{material:"door",srgb:An.door.srgb},"door:casing":{material:"door",srgb:An.door.srgb},"opening:lining":{material:"opening:lining",srgb:An["opening:lining"].srgb},"opening:casing":{material:"opening:casing",srgb:An["opening:casing"].srgb},"window:reveal":{material:"window:reveal",srgb:An["window:reveal"].srgb},"window:sill":{material:"window:sill",srgb:An["window:sill"].srgb},"window:board":{material:"window:board",srgb:An["window:board"].srgb}},pu="#8f877d";var D_={timber:Ke("#cdb596",.6),tile:Ke("#e3e1db",.35),neutral:Ke("#e8e2d7",.9)};var fu={gravel:Ke("#cbc3b4",.95),tarmac:Ke("#8c8984",.85)},Lv={planting:_n.foliage,deck:_n.wood,gravel:fu.gravel,driveway:fu.tarmac};var Dv={picket:Ke("#eeebe4",.8),panel:_n.wood,post:_n.wood_dark},co={light:"#e2ddd3",dark:"#16293d",marginMm:6e3};function mu(i,e,t){if(e==="light")return i;let n=s=>{let r=Number.parseInt(i.slice(s,s+2),16),a=Number.parseInt(t.slice(s,s+2),16);return Math.round(r*.4+a*.6).toString(16).padStart(2,"0")};return`#${n(1)}${n(3)}${n(5)}`}function gu(i,e,t){let n=_n[i].srgb;if(e==="light")return n;let s=r=>{let a=Number.parseInt(n.slice(r,r+2),16),o=Number.parseInt(t.slice(r,r+2),16);return Math.round(a*.4+o*.6).toString(16).padStart(2,"0")};return`#${s(1)}${s(3)}${s(5)}`}function _u(i,e,t){let n=D_[i].srgb;if(e==="light")return n;let s=r=>{let a=Number.parseInt(n.slice(r,r+2),16),o=Number.parseInt(t.slice(r,r+2),16);return Math.round(a*.4+o*.6).toString(16).padStart(2,"0")};return`#${s(1)}${s(3)}${s(5)}`}var js=(i,e,t)=>`${i} ${i===1?e:t}`,xu=i=>`${Number(i.toFixed(2))} m\xB2`;function Xl(i,e,t){let n;for(let s of i)s.stage===e&&!s.hidden&&(n===void 0||s.appear<n)&&(n=s.appear);return n??t}function yu(i,e,t){let n=Xl(e,"rooms",yt.drawn),s=Xl(e,"openings",yt.drawn),r=[],a=(o,c)=>{t>=o&&r.push(c)};return i.storeys!==void 0&&a(Xl(e,"brief",0),{id:"storeys",text:js(i.storeys,"storey","storeys")}),a(n,{id:"rooms",text:js(i.rooms,"room","rooms")}),i.areaNet!==void 0&&a(n,{id:"area-net",text:`floor area ${xu(i.areaNet)} (net)`}),a(n,{id:"area-centre",text:`floor area ${xu(i.areaCentre)} (to wall centre lines)`}),a(s,{id:"doors",text:js(i.doors,"door","doors")}),a(s,{id:"windows",text:js(i.windows,"window","windows")}),a(yt.svgIn,{id:"warnings",text:i.warnings===0?"no warnings":js(i.warnings,"warning","warnings")}),r}function vu(i,e){let t=e.map(s=>`${s.id}=${s.text}`).join("|");if(i.dataset.stripKey===t)return;i.dataset.stripKey=t,i.hidden=e.length===0;let n=[];for(let s of e){let r=i.ownerDocument.createElement("span");r.dataset.fact=s.id,r.textContent=s.text,n.length>0&&n.push(i.ownerDocument.createTextNode(" ")),n.push(r)}i.replaceChildren(...n)}function ho(i){return i.kind==="wall"&&i.part===void 0||i.kind==="column"}var li=2**26;function Qs(i,e,t,n){if(Math.abs(i)<li&&Math.abs(e)<li&&Math.abs(t)<li&&Math.abs(n)<li)return i*n-e*t;let s=BigInt(i)*BigInt(n)-BigInt(e)*BigInt(t);return s>0n?1:s<0n?-1:0}function N_(i,e,t,n){return Math.abs(i)<li&&Math.abs(e)<li&&Math.abs(t)<li&&Math.abs(n)<li?String(i*n-e*t):(BigInt(i)*BigInt(n)-BigInt(e)*BigInt(t)).toString()}function U_(i,e){let t=Math.abs(i),n=Math.abs(e);for(;n!==0;)[t,n]=[n,t%n];return t}function F_(i,e,t,n){let s=BigInt(i[0])*BigInt(e[0])+BigInt(i[1])*BigInt(e[1]),r=BigInt(i[0])*BigInt(e[1])-BigInt(i[1])*BigInt(e[0]),a=t*n>0?s:-s;return a>0n&&a*a>3n*r*r}function ql(i,e,t,n){let s=t-i,r=n-e,a=U_(s,r);return s/=a,r/=a,(s<0||s===0&&r<0)&&(s=0-s,r=0-r),{dx:s,dz:r,key:`${s},${r},${N_(s,r,i,e)}`}}var Yl=(i,e)=>{for(let t=0;t<i.length;t++){let n=i[t]-e[t];if(n!==0)return n}return 0},er=i=>[...i.keys()].sort((e,t)=>e<t?-1:e>t?1:0),tr=i=>{let e=[...i].sort((n,s)=>n-s),t=0;for(let n=0;n<e.length;n++)(n===0||e[n]!==e[t-1])&&(e[t++]=e[n]);return e.length=t,e};function Mu(i){let e=1/0,t=-1/0;for(let n of i)n<e&&(e=n),n>t&&(t=n);return[e,t]}function bu(i,e){let t=-1;for(let n of i)if(t<0)t=n;else{let s=e?.[n]??0,r=e?.[t]??0;(s>r||s===r&&n<t)&&(t=n)}return t}function wu(i){let e=new Map;return i.forEach((t,n)=>{if(!ho(t))return;let s=/^L(-?\d+)\//.exec(t.key)?.[1]??"",r=e.get(s);r?r.push(n):e.set(s,[n])}),er(e).map(t=>e.get(t)??[])}function Eu(i,e){let t=z_(i),n=i.map((s,r)=>ho(s)?{...s,...k_(s,t[r])}:s);return{faces:t,lines:O_(n,e)}}function O_(i,e){let t=i.map(s=>ho(s)?[]:void 0),n=i.map(()=>[]);for(let s of wu(i))B_(i,s,n,e);return n.forEach((s,r)=>{if(!t[r])return;let a=s.map(o=>Yl(o.slice(0,3),o.slice(3))<=0?o:[o[3],o[4],o[5],o[0],o[1],o[2]]).sort(Yl);t[r]=a.flat()}),t}function Su(i,e){let t=i.map((a,o)=>[a,o]).sort((a,o)=>a[0].t0-o[0].t0||a[1]-o[1]),n=tr(i.flatMap(a=>[a.t0,a.t1])),s=0,r=[];for(let a=0;a+1<n.length;a++){let o=n[a],c=n[a+1];for(r.some(l=>l.t1<=o)&&(r=r.filter(l=>l.t1>o));s<t.length&&t[s]?.[0].t0<=o;)r.push(t[s++]?.[0]);r.length>0&&e(o,c,r)}}function B_(i,e,t,n){let s=new Map,r=new Map,a=new Map,o=new Map,c=(_,y,p)=>{let f=`${_}|${y}`,S=s.get(f);S?S.edges.push(p):s.set(f,{line:y,plane:_,edges:[p]})},l=(_,y,p,f)=>{let S=Yl(y,p)<0,[A,b]=S?[y,p]:[p,y],T=`${_}|${A[0]},${A[1]},${A[2]}|${b[0]},${b[1]},${b[2]}`,w=o.get(T);w?(w.net+=S?1:-1,w.nodes.push(f)):o.set(T,{a:A,b,net:S?1:-1,nodes:[f]})},h=(_,y,p,f)=>{let S=`h${_}:${y.key}`,A=r.get(S);if(A||(A={kind:"horizontal",y:_,alongX:y.dx!==0,other:new Map},r.set(S,A)),A.kind==="horizontal")for(let b of[p,f]){let[T,,w]=b;A.alongX?A.other.set(T,w):A.other.set(w,T)}return S},d=(_,y)=>_.dx!==0?y[0]:y[2],u=(_,y,p,f)=>_<y?{t0:_,t1:y,k:1,node:p,f}:{t0:y,t1:_,k:-1,node:p,f};for(let _ of e){let y=i[_],p=f=>[Math.round(y.positions[f*3]),Math.round(y.positions[f*3+1]),Math.round(y.positions[f*3+2])];for(let f=0;f+2<y.indices.length;f+=3){let S=[p(y.indices[f]),p(y.indices[f+1]),p(y.indices[f+2])],[A,b,T]=S,w=A[0],g=A[1],M=A[2],U=[[A,b],[b,T],[T,A]];if(g===b[1]&&g===T[1]){if(Qs(b[0]-w,b[2]-M,T[0]-w,T[2]-M)===0)continue;let z=`H${g}`;for(let[te,W]of U){if(te[0]===W[0]&&te[2]===W[2])continue;let $=ql(te[0],te[2],W[0],W[2]);c(z,h(g,$,te,W),u(d($,te),d($,W),_,0))}continue}if(!(Qs(b[0]-w,b[2]-M,T[0]-w,T[2]-M)===0)){for(let[z,te]of U)t[_].push([...z,...te]);continue}let D=A[0]!==b[0]||A[2]!==b[2]?b:T;if(D[0]===w&&D[2]===M)continue;let F=ql(w,M,D[0],D[2]),H=`V${F.key}`;a.has(H)||a.set(H,[F.dx,F.dz]);let C=z=>d(F,z),Y=Qs(C(b)-C(A),b[1]-g,C(T)-C(A),T[1]-g);if(Y===0)continue;let J=Y>0?1:-1;for(let[z,te]of U)if(z[0]===te[0]&&z[2]===te[2]){if(z[1]===te[1])continue;let W=`v${z[0]},${z[2]}`;r.has(W)||r.set(W,{kind:"vertical",x:z[0],z:z[2]}),c(H,W,u(z[1],te[1],_,J))}else z[1]===te[1]?c(H,h(z[1],F,z,te),u(d(F,z),d(F,te),_,J)):l(H,z,te,_)}}let m=new Map;for(let _ of er(s)){let{line:y,plane:p,edges:f}=s.get(_),[S,A]=f;f.length===2&&A&&S.t0===A.t0&&S.t1===A.t1&&S.k!==A.k||Su(f,(b,T,w)=>{let g=0;for(let H of w)g+=H.k;if(g===0)return;let M=new Map;for(let H of w)M.set(H.node,(M.get(H.node)??0)+H.k);let U=tr(w.filter(H=>M.get(H.node)!==0).map(H=>H.node)),I=tr(w.filter(H=>H.k===Math.sign(g)).map(H=>H.f)),D={t0:b,t1:T,nodes:U,plane:p,f:I.length===1?I[0]:0},F=m.get(y);F?F.push(D):m.set(y,[D])})}for(let _ of er(m)){let y=m.get(_),p=r.get(_),f=[];Su(y,(S,A,b)=>{if(p.kind==="vertical"&&b.length===2){let[g,M]=b,U=a.get(g.plane),I=a.get(M.plane);if(U&&I&&g.f!==0&&M.f!==0&&F_(U,I,g.f,M.f))return}let T=bu(b.flatMap(g=>g.nodes),n),w=f[f.length-1];w&&w.t1===S&&w.node===T?w.t1=A:f.push({t0:S,t1:A,node:T})});for(let S of f){let A=b=>{if(p.kind==="vertical")return[p.x,b,p.z];let T=p.other.get(b);return p.alongX?[b,p.y,T]:[T,p.y,b]};t[S.node].push([...A(S.t0),...A(S.t1)])}}for(let _ of er(o)){let{a:y,b:p,net:f,nodes:S}=o.get(_);f!==0&&t[bu(S,n)].push([...y,...p])}}function Tu(i,e){let t=new Map;i.forEach((s,r)=>{s&&s.group>=0&&t.set(s.group,(t.get(s.group)??!0)&&e(r))});let n=new Set;for(let[s,r]of t)r&&n.add(s);return n}function z_(i){let e=i.map(a=>ho(a)?{hide:[],add:[],alone:[],joined:[],group:-1}:void 0),t=i.map((a,o)=>o),n=a=>{let o=a;for(;t[o]!==o;)o=t[o];for(;t[a]!==o;)[a,t[a]]=[t[a],o];return o},s=(a,o)=>{let c=n(a),l=n(o);c<l?t[l]=c:l<c&&(t[c]=l)},r=new Set;for(let a of wu(i))G_(i,a,e,s,r);return e.forEach((a,o)=>{a&&(a.hide.sort((c,l)=>c-l),r.has(o)&&(a.group=n(o)))}),e}function Zl(i,e){if(!e)return{positions:i.positions,base:[...i.indices],alone:[],joined:[]};let t=new Set(e.hide),n=[];for(let c=0;c+2<i.indices.length;c+=3)t.has(c/3)||n.push(i.indices[c],i.indices[c+1],i.indices[c+2]);let s=i.positions.length/3,r=(c,l=[])=>{for(let h=0;h<c.length/3;h++)l.push(s++);return l};r(e.add,n);let a=r(e.alone),o=r(e.joined);return{positions:i.positions.concat(e.add,e.alone,e.joined),base:n,alone:a,joined:o}}function k_(i,e,t="joined"){if(!e)return{positions:i.positions,indices:i.indices};let n=Zl(i,e);return{positions:n.positions,indices:n.base.concat(t==="joined"?n.joined:n.alone)}}function V_(i){let e=i.map(s=>{let[r,a]=Mu(s.s),[o,c]=Mu(s.p.map(l=>l[1]));return{s0:r,s1:a,y0:o,y1:c,f:s.f}});e.sort((s,r)=>s.s0-r.s0);let t=[],n=[];for(let s of e){if(t.some(a=>a.s1<=s.s0)&&(t=t.filter(a=>a.s1>s.s0)),n.some(a=>a.s1<=s.s0)&&(n=n.filter(a=>a.s1>s.s0)),(s.f>0?n:t).some(a=>Math.min(a.y1,s.y1)>Math.max(a.y0,s.y0)))return!0;(s.f>0?t:n).push(s)}return!1}function G_(i,e,t,n,s){let r=new Map;for(let a of e){let o=i[a],c=l=>[Math.round(o.positions[l*3]),Math.round(o.positions[l*3+1]),Math.round(o.positions[l*3+2])];for(let l=0;l+2<o.indices.length;l+=3){let h=c(o.indices[l]),d=c(o.indices[l+1]),u=c(o.indices[l+2]),m=h[0],_=h[1],y=h[2];if(_===d[1]&&_===u[1]||Qs(d[0]-m,d[2]-y,u[0]-m,u[2]-y)!==0)continue;let p=h[0]!==d[0]||h[2]!==d[2]?d:u;if(p[0]===m&&p[2]===y)continue;let f=ql(m,y,p[0],p[2]),S=M=>f.dx!==0?M[0]:M[2],A=[S(h),S(d),S(u)],b=Qs(A[1]-A[0],d[1]-_,A[2]-A[0],u[1]-_);if(b===0)continue;let T=`V${f.key}`,w={node:a,tri:l/3,p:[h,d,u],f:b>0?1:-1,s:A},g=r.get(T);g?g.tris.push(w):r.set(T,{pl:f,tris:[w]})}}for(let a of er(r)){let{tris:o}=r.get(a);if(!V_(o))continue;let c=tr(o.flatMap(b=>b.s)),l=tr(o.flatMap(b=>b.p.map(T=>T[1]))),h=new Map;for(let b of o)for(let T=0;T<3;T++)h.set(b.s[T],b.p[T]);let d=new Map(c.map((b,T)=>[b,T])),u=new Map(l.map((b,T)=>[b,T])),m=l.length-1,_=c.map(()=>[]);for(let b of o)for(let T=0;T<3;T++){let w=b.p[T],g=b.p[(T+1)%3];if(w[0]!==g[0]||w[2]!==g[2]||w[1]===g[1])continue;let M=d.get(b.s[T]),U=Math.min(w[1],g[1]),I=Math.max(w[1],g[1]);_[M].push([b.node,u.get(U),u.get(I),g[1]>w[1]?1:-1])}let y=new Map,p=new Map,f=[],S=new Int32Array(m),A=(b,T,w,g,M)=>{let U=l[g],I=l[g+1],D=(J,z)=>{let te=h.get(J);return[te[0],z,te[2]]},[F,H,C,Y]=[D(T,U),D(w,U),D(w,I),D(T,I)];M>0?b.push(...F,...H,...C,...F,...C,...Y):b.push(...F,...C,...H,...F,...Y,...C)};for(let b=0;b+1<c.length;b++){let T=_[b];for(let[M,U,I,D]of T){let F=y.get(M);F||(F=new Int32Array(m),y.set(M,F));let H=p.get(M)??0;for(let C=U;C<I;C++){let Y=F[C],J=Y-D;F[C]=J,S[C]=S[C]-D,Y===0?H++:J===0&&H--}p.set(M,H)}if(T.length>0){for(let M of[...y.keys()])p.get(M)===0&&(y.delete(M),p.delete(M));f=[...y.keys()].sort((M,U)=>M-U)}let w=c[b],g=c[b+1];for(let M=0;M<m;M++){let U=f.filter(F=>y.get(F)[M]!==0);if(U.length===0)continue;if(U.length===1){let F=U[0];A(t[F].add,w,g,M,y.get(F)[M]);continue}for(let F of U)A(t[F].alone,w,g,M,y.get(F)[M]),s.add(F),n(F,U[0]);let I=S[M];if(I===0)continue;let D=U.find(F=>Math.sign(y.get(F)[M])===Math.sign(I));A(t[D].joined,w,g,M,I)}}for(let b of o)t[b.node].hide.push(b.tri)}}var H_=5,uo=.9,$l={light:{background:"#f7f5f0",edge:"#8f877c",cap:pu,colors:Object.fromEntries(Object.entries(An).map(([i,e])=>[i,e.srgb]))},dark:{background:"#0f2235",edge:"#cfe3f5",cap:"#cfe3f5",colors:{slab:"#20384f",floor:"#1b3248",column:"#3b5b78",wall:"#2e4d6a",roof:"#14283c",door:"#7aa6c9","window:frame":"#5d86a8","window:glass":"#86c5ee","window:reveal":"#5d86a8","window:sill":"#7aa6c9","window:board":"#7aa6c9","opening:lining":"#7aa6c9","opening:casing":"#7aa6c9","stair:rail":"#3b5b78","wall:demolish":"#e07a5f",furniture:"#3f6a8f",stair:"#5d86a8"}}},Xn={sky:16317439,ground:14275271,hemi:2.4,keyColour:16775922,key:2.7,keyFrom:[-1,1.25,.3],fillColour:15002869,fill:.5,fillFrom:[.7,.5,-.6]},W_=12;function Au(i,e,t,n={}){let s=$l[e.theme],r=s.colors.furniture,a=e.width,o=e.height,c=document.createElement("canvas");c.width=a,c.height=o,i.width=a,i.height=o;let l=i.getContext("2d",{willReadFrequently:!0}),h=new to({canvas:c,antialias:!1,preserveDrawingBuffer:!0});h.setPixelRatio(1),h.setSize(a,o,!1),h.toneMapping=Os;let d=new Ss;d.background=new ze(s.background),d.add(new Ds(Xn.sky,Xn.ground,Xn.hemi));let u=new Ki(Xn.keyColour,Xn.key);u.position.set(...Xn.keyFrom),d.add(u);let m=new Ki(Xn.fillColour,Xn.fill);m.position.set(...Xn.fillFrom),d.add(m);let _=new Map,y=[],p=new Map(e.events.map(P=>[P.key,P.rank])),{faces:f,lines:S}=Eu(e.nodes,e.nodes.map(P=>p.get(P.key)??0)),A=[];for(let[P,Q]of e.nodes.entries()){let R=S[P],X=f[P],O=Zl(Q,X),q={...Q,positions:O.positions,indices:O.base},ne=new Float32Array(q.positions.length),se=1/0,xe=-1/0;for(let ie=1;ie<q.positions.length;ie+=3)se=Math.min(se,q.positions[ie]/1e3),xe=Math.max(xe,q.positions[ie]/1e3);for(let ie=0;ie<q.positions.length;ie+=3){let Ne=q.positions[ie]/1e3,Je=q.positions[ie+1]/1e3,Xe=q.positions[ie+2]/1e3;ne[ie]=Ne,ne[ie+1]=Je-se,ne[ie+2]=Xe}let Pe=q.part?`${q.kind}:${q.part}`:q.kind,re=new Fn;re.position.y=se+(q.lift??0);let ve=(ie,Ne,Je,Xe,Yt,Ve,xn=!0)=>{let sn=new Wt;sn.setAttribute("position",ie),sn.setIndex(Ne),Ve&&sn.computeVertexNormals();let Rn=Pe==="wall:demolish",rn=q.kind==="floor"||q.kind==="slab",Ti=new Ji({color:new ze(Je),transparent:Xe||Rn,opacity:Xe?Yt:Rn?.3:1,depthWrite:!Rn,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:q.kind==="outdoor"?8:rn?4:1});y.push(sn,Ti);let os=new en(sn,Ti);if(re.add(os),q.kind!=="slab"&&!Xe&&xn){let ls=new Cs(sn,30),ci=new xi({color:new ze(s.edge)});y.push(ls,ci),re.add(new Zi(ls,ci))}return os},Ae=new Gt(ne,3);if(q.groups){let ie=0;for(let{slot:Ne,count:Je}of q.groups){let Xe=q.indices.slice(ie,ie+Je);if(ie+=Je,Ne==="body")ve(Ae,Xe,s.colors[Pe]??s.colors[q.kind]??r,!1,1,!1);else{let{alpha:Yt}=_n[Ne];ve(Ae,Xe,gu(Ne,e.theme,r),Yt<1,Yt,!1)}}}else if(q.colour)ve(Ae,q.indices,mu(q.colour,e.theme,$l.dark.colors.floor),!1,1,!0,q.kind!=="fence");else if(q.finish)ve(Ae,q.indices,_u(q.finish,e.theme,$l.dark.colors.floor),!1,1,!0);else if(Pe==="wall"){let ie=Xe=>q.positions[Xe*3+1]/1e3===xe,Ne=[],Je=[];for(let Xe=0;Xe<q.indices.length;Xe+=3){let Yt=q.indices.slice(Xe,Xe+3);(Yt.every(ie)?Ne:Je).push(...Yt)}ve(Ae,Je,s.colors.wall??r,!1,1,!0,R===void 0),Ne.length&&ve(Ae,Ne,s.cap,!1,1,!0,!1)}else{let ie=Pe==="window:glass";ve(Ae,q.indices,s.colors[Pe]??s.colors[q.kind]??r,ie,ie?An["window:glass"].alpha:1,!0,R===void 0)}if(X&&X.group>=0){let ie=s.colors[Pe]??s.colors[q.kind]??r;A.push({key:q.key,...O.alone.length>0?{alone:ve(Ae,O.alone,ie,!1,1,!0,!1)}:{},...O.joined.length>0?{joined:ve(Ae,O.joined,ie,!1,1,!0,!1)}:{},group:X.group})}if(R&&R.length>0){let ie=new Float32Array(R.length);for(let Xe=0;Xe<R.length;Xe+=3)ie[Xe]=R[Xe]/1e3,ie[Xe+1]=R[Xe+1]/1e3-se,ie[Xe+2]=R[Xe+2]/1e3;let Ne=new Wt;Ne.setAttribute("position",new Gt(ie,3));let Je=new xi({color:new ze(s.edge)});y.push(Ne,Je),re.add(new Zi(Ne,Je))}re.visible=!1,d.add(re),_.set(q.key,{g:re,flat:Math.min(1,W_/Math.max(1e-6,xe-se)),base:se,lift:q.lift??0})}let[b,T,w,g]=e.viewBox,M=a/o,{cx:U,cz:I,ow:D,oh:F}=Hl(e.viewBox,M),H=Js(e.nodes,{ghosts:!0}),C=new B(...H.lo),Y=new B(...H.hi),J=Y.y+1e3,z,te;if(e.ground){let P=e.ground.y/1e3,Q=co.marginMm,[R,X,O,q]=[C.x-Q,C.z-Q,Y.x+Q,Y.z+Q],ne=new Wt;ne.setAttribute("position",new Gt(new Float32Array([R,P,X,R,P,q,O,P,q,O,P,X]),3)),ne.setIndex([0,1,2,0,2,3]);let se=new Ji({color:new ze(e.theme==="light"?co.light:co.dark),transparent:!0,opacity:0,depthWrite:!0,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:2,polygonOffsetUnits:16});y.push(ne,se),z=new en(ne,se),te=se,z.renderOrder=-1,z.visible=!1,d.add(z)}let W=new yi(-D/2,D/2,F/2,-F/2,1,J+1e5);W.up.set(0,0,-1),W.position.set(U,J+5e4,I),W.lookAt(U,0,I);let $=new Bt(ao,M,10,1e9),ae=P=>au(e.nodes,e.events,{elevation:e.elevation,azimuth:Vl,fov:Tn,aspect:P}),_e=ae(M),De=Y.clone().sub(C),j=C.clone().add(Y).multiplyScalar(.5),pe=P=>{let Q=Math.max(...P.map(R=>j.distanceTo(new B(...R.target))));return Math.max(De.length()*.75+Q+Math.hypot(j.x-(b+w/2),j.z-(T+g/2)),1e3)},ye=pe(_e.slice(0,oo(e.events))),Re=pe(_e),fe=P=>P*Math.PI/180,Le=new Image,pt=new Promise(P=>{Le.onload=()=>P(),Le.onerror=()=>P()});Le.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(e.svg)))}`;let be=!1,$e={cx:U,cz:I,oh:F,elevation:e.elevation},it=new Map(e.events.map(P=>[P.key,P.storey??0])),ke=Math.max(1,...e.events.filter(P=>!P.hidden).map(P=>(P.storey??0)+1)),lt=ke,Ge="replay",mt=0,at=!1,nn=De.length()/2,gt=P=>Math.max(Re,j.distanceTo(P)+nn);function Ft(P,Q){let{fov:R,dist:X,elevation:O,azimuth:q}=P,ne=new B(...P.target),se=fe(O);$.fov=R,$.near=Math.max(10,X-Q),$.far=X+Q,$.updateProjectionMatrix(),$.up.set(0,0,-1),se<fe(89.99)&&$.up.set(0,1,0),$.position.set(...kl([ne.x,ne.y,ne.z],X,{elevation:O,azimuth:q})),$.lookAt(ne)}let Tt={events:e.events,fits:_e,frame:$e,box:Js(e.nodes,{settle:1}),aspect:M},Pt=new Map,N=P=>{let Q=Pt.get(P);if(Q)return Q;let R=lu(P,Tt);return Pt.set(P,R),R},At,Qe=()=>{},st=()=>{},ue=()=>{},ut=new Set,Te=()=>{for(let P of ut)P()},Ce=Math.max(1,Math.min(4,Math.floor(e.supersample??1)));function E(P){let Q=Ce*Ce,R=new Uint32Array(a*o*4);l.globalAlpha=1;for(let O=0;O<Ce;O++)for(let q=0;q<Ce;q++){P.setViewOffset(a,o,(q+.5)/Ce-.5,(O+.5)/Ce-.5,a,o),h.render(d,P),l.drawImage(c,0,0);let ne=l.getImageData(0,0,a,o).data;for(let se=0;se<ne.length;se++)R[se]=R[se]+ne[se]}P.clearViewOffset();let X=l.createImageData(a,o);for(let O=0;O<R.length;O++)X.data[O]=Math.floor((R[O]+(Q>>1))/Q);l.putImageData(X,0,0)}function x(P){mt=P,at=!0,t&&e.facts&&vu(t,yu(e.facts,e.events,Math.min(1,Math.max(0,P))));let Q=$s(e.events,P);z&&te&&(z.visible=Q.ground>0,te.opacity=Q.ground);for(let[O,{g:q,flat:ne,base:se,lift:xe}]of _){let Pe=Q.nodes.get(O);q.visible=Pe?.visible===!0&&(it.get(O)??0)<lt,q.scale.y=Math.max(ne,Pe?.rise??0),xe!==0&&(q.position.y=se+Gl(xe,Q.settle))}let R=Tu(f,O=>{let q=e.nodes[O]?.key??"";return _.get(q)?.g.visible===!0&&(Q.nodes.get(q)?.rise??0)>=1});for(let{group:O,alone:q,joined:ne}of A){let se=R.has(O);q&&(q.visible=!se),ne&&(ne.visible=se)}let X=W;if(Ge==="free"&&At){let O=$.position.distanceTo(At.target),q=gt(At.target);$.near=Math.max(10,O-q),$.far=O+q,$.updateProjectionMatrix(),X=$}else if(Ge!=="replay"&&Ge!=="free"){let O=N(Ge);Ft(O,gt(new B(...O.target))),X=$}else(Q.tilt>0||Q.dolly>0)&&(Ft(lo(Q,_e,$e),Q.settle>0?Re:ye),X=$);if(Ce===1?(h.render(d,X),l.globalAlpha=1,l.drawImage(c,0,0)):E(X),Ge==="replay"&&Q.svg>0&&Le.complete&&Le.naturalWidth>0){let O=Math.min(a/w,o/g),q=w*O,ne=g*O;l.globalAlpha=Q.svg,l.drawImage(Le,(a-q)/2,(o-ne)/2,q,ne),l.globalAlpha=1}}function k(P){be||(Ge!=="replay"&&(Qe(),Ge="replay",Te()),x(P),ue())}async function oe(){let P=l.getImageData(0,0,a,o).data,Q=await crypto.subtle.digest("SHA-256",P);return[...new Uint8Array(Q)].map(R=>R.toString(16).padStart(2,"0")).join("")}let ee=n.interactive?le():void 0;function le(){let P=new ro($,i);At=P,P.enableDamping=!1,P.screenSpacePanning=!1,P.minPolarAngle=fe(90-Ks.max),P.maxPolarAngle=fe(90-Ks.min);let Q=uu(H);P.cursor.set(...Q.centre);let R=i.getAttribute("tabindex");i.tabIndex=0;let X=0,O=!1,q=!1,ne=()=>window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,se=()=>{X=0,!(be||Ge!=="free")&&(P.update()||O)&&(X=requestAnimationFrame(se))},xe=()=>{P.enableDamping&&!X&&(X=requestAnimationFrame(se))};Qe=()=>{X&&cancelAnimationFrame(X),X=0,O=!1,P.enableDamping&&(q=!0,P.enableDamping=!1,P.update(),q=!1)};let Pe=(Ve,xn,sn)=>{$.fov=sn,$.up.set(0,1,0),$.position.set(...Ve),P.target.set(...ou(Ve,xn,Tt.box.lo[1])),$.lookAt(P.target);let Rn=$.position.distanceTo(P.target),rn=hu(_e,sn);P.minDistance=Math.min(rn.min,Rn),P.maxDistance=Math.max(rn.max,Rn),P.maxTargetRadius=Math.max(Q.radius,P.target.distanceTo(P.cursor)),P.enableDamping=!ne()},re=()=>{if(Ge==="free")return;let Ve=Ge==="replay"?cu(lo($s(e.events,mt),_e,$e)):N(Ge);Pe(kl(Ve.target,Ve.dist,Ve),Ve.target,Ve.fov)},ve=()=>{Ge!=="free"&&(Ge="free",n.onTake?.(),Te(),xe())},Ae=!1;ue=()=>{Ae&&re()},P.addEventListener("start",()=>{re(),Ae=!0,O=!0}),P.addEventListener("end",()=>{Ae=!1,O=!1}),P.addEventListener("change",()=>{q||be||(Ae=!1,ve(),x(mt))});let ie=fe(H_),Ne=new Map([["ArrowLeft",()=>P.rotateLeft(ie)],["ArrowRight",()=>P.rotateLeft(-ie)],["ArrowUp",()=>P.rotateUp(ie)],["ArrowDown",()=>P.rotateUp(-ie)],["+",()=>P.dollyIn(uo)],["=",()=>P.dollyIn(uo)],["-",()=>P.dollyOut(uo)],["_",()=>P.dollyOut(uo)]]),Je=Ve=>{let xn=Ne.get(Ve.key);!xn||be||Ve.ctrlKey||Ve.metaKey||Ve.altKey||(Ve.preventDefault(),re(),xn(),xe())};i.addEventListener("keydown",Je),st=()=>{i.removeEventListener("keydown",Je),P.dispose(),R===null?i.removeAttribute("tabindex"):i.setAttribute("tabindex",R),ut.clear()};let Xe=Ve=>Math.min(ke,Math.max(1,Math.round(Ve))),Yt=()=>lt===ke?"all":lt;return{at:Ve=>{be||x(Ve)},preset:Ve=>{be||(Qe(),Ge=Ve,n.onTake?.(),Te(),x(mt))},reset:()=>{be||(Qe(),Ge="replay",lt=ke,Te(),x(mt))},storeys:ke,showStoreys:Ve=>{be||(lt=Xe(Ve),Te(),x(mt))},onChange:Ve=>(ut.add(Ve),()=>ut.delete(Ve)),spin:Ve=>{if(be||O||!Number.isFinite(Ve)||Ve===0)return;re();let xn=P.enableDamping;P.enableDamping=!1,P.rotateLeft(fe(Ve)),P.update(),P.enableDamping=xn},get shown(){return lt},get camera(){return Ge},state:()=>Ge==="free"?{camera:"free",position:$.position.toArray(),target:P.target.toArray(),fov:$.fov,storeys:Yt()}:{camera:Ge,storeys:Yt()},restore:Ve=>{be||(Qe(),lt=Ve.storeys==="all"?ke:Xe(Ve.storeys),Ve.camera==="free"&&Pe(Ve.position,Ve.target,Ve.fov),Ge=Ve.camera,Ge!=="replay"&&n.onTake?.(),Te())}}}function ce(P,Q){if(be)return;let R=Math.max(1,Math.round(P)),X=Math.max(1,Math.round(Q));R===a&&X===o||(a=R,o=X,c.width=a,c.height=o,i.width=a,i.height=o,h.setSize(a,o,!1),M=a/o,{cx:U,cz:I,ow:D,oh:F}=Hl(e.viewBox,M),W.left=-D/2,W.right=D/2,W.top=F/2,W.bottom=-F/2,W.position.set(U,J+5e4,I),W.lookAt(U,0,I),W.updateProjectionMatrix(),$.aspect=M,$.updateProjectionMatrix(),_e=ae(M),ye=pe(_e.slice(0,oo(e.events))),Re=pe(_e),$e={cx:U,cz:I,oh:F,elevation:e.elevation},Tt={...Tt,fits:_e,frame:$e,aspect:M},Pt.clear(),at&&x(mt))}function K(){if(!be){Qe(),be=!0,st();for(let P of y)P.dispose();h.dispose(),h.forceContextLoss()}}return{seek:k,frameHash:oe,ready:pt,dispose:K,resize:ce,...ee?{view:ee}:{}}}var X_=[["iso","Iso","Iso view: the replay's end view"],["top","Top","Top view, the plan's top edge up"],["north","N","View from north: level, from the plan's top edge"],["east","E","View from east: level, from the plan's right edge"],["south","S","View from south: level, from the plan's bottom edge"],["west","W","View from west: level, from the plan's left edge"]],q_="Drag to turn, right-drag to pan, scroll to zoom; on the focused view, arrow keys turn and + / \u2212 zoom.";function Ru(i,e={}){let t=document.createElement("div");t.className="archlang-views",t.setAttribute("role","toolbar"),t.setAttribute("aria-label","3D view");let n=(h,d,u)=>{let m=document.createElement("button");return m.type="button",e.buttonClass&&(m.className=e.buttonClass),m.textContent=h,m.setAttribute("aria-label",d),m.addEventListener("click",u),m},s=[],r=[],a=()=>{for(let[h,d]of s)d.setAttribute("aria-pressed",String(i.camera===h));for(let[h,d]of r.entries())d.setAttribute("aria-pressed",String(h+1===i.shown))},o=h=>{};for(let[h,d,u]of X_){let m=n(d,u,()=>{i.preset(h),o(!0)});m.dataset.preset=h,s.push([h,m])}let c="Reset the view: the replay's own camera, every storey shown";if(e.compact){t.classList.add("archlang-views-compact"),t.append(n("\u27F2 Reset",c,()=>i.reset()));let h=document.createElement("span");h.className="archlang-views-menu";let d=document.createElement("span");d.className="archlang-views-presets",d.id=`${e.hintId??"archlang-views"}-presets`,d.setAttribute("role","group"),d.setAttribute("aria-label","Preset views"),d.hidden=!0,d.append(...s.map(([,y])=>y));let u=n("View \u25BE","View presets: iso, top, and from north, east, south and west",()=>d.hidden?_():o(!1));u.setAttribute("aria-expanded","false"),u.setAttribute("aria-controls",d.id);let m=y=>{h.contains(y.target)||o(!1)},_=()=>{d.hidden=!1,u.setAttribute("aria-expanded","true"),document.addEventListener("pointerdown",m,!0),(s.find(([y])=>i.camera===y)?.[1]??s[0]?.[1])?.focus()};o=y=>{d.hidden||(d.hidden=!0,u.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",m,!0),y&&u.focus())},h.addEventListener("keydown",y=>{y.key!=="Escape"||d.hidden||(y.preventDefault(),y.stopPropagation(),o(!0))}),h.addEventListener("focusout",y=>{h.contains(y.relatedTarget)||o(!1)}),h.append(u,d),t.append(h)}else t.append(...s.map(([,h])=>h)),t.append(n("Reset",c,()=>i.reset()));if(i.storeys>1&&e.storeys!==!1){let h=document.createElement("span");h.className="archlang-views-storeys",h.setAttribute("role","group"),h.setAttribute("aria-label","Storeys shown"),h.append("Storeys ");for(let d=1;d<=i.storeys;d++){let u=d===i.storeys,m=n(u?"All":d===1?"1":`1\u2013${d}`,u?"Show every storey":`Show storeys 1 to ${d}, hide the ones above`,()=>i.showStoreys(d));m.dataset.storeys=String(d),r.push(m),h.append(m)}t.append(h)}i.onChange(a),a();let l=document.createElement("span");return l.className="archlang-views-hint",e.hintId&&(l.id=e.hintId),l.textContent=q_,t.append(l),t}function Y_(){let i=document.getElementById("archlang-replay-payload");return JSON.parse(i?.textContent??"{}")}function Z_(){let i=Y_(),e=document.getElementById("archlang-replay"),t=document.getElementById("archlang-replay-strip")??void 0,n=0,s=()=>{n&&cancelAnimationFrame(n),n=0},{seek:r,frameHash:a,ready:o,view:c}=Au(e,i,t,{interactive:!0,onTake:s});window.__seek=r,window.__frameHash=a,window.__ready=o.then(()=>r(0));let l=document.getElementById("archlang-replay-views");c&&l&&(l.replaceWith(Ru(c,{hintId:"archlang-replay-hint"})),e.setAttribute("aria-describedby","archlang-replay-hint"));let h=document.getElementById("archlang-replay-t"),d=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;window.__ready.then(()=>{if(window.__replayAutoplay===!1)return;if(d){r(1),h&&(h.value="1");return}let u,m=_=>{u??(u=_);let y=Math.min(1,(_-u)/(i.seconds*1e3));r(y),h&&(h.value=String(y)),n=y<1?requestAnimationFrame(m):0};n=requestAnimationFrame(m)}),h?.addEventListener("input",()=>{s(),r(Number(h.value))})}Z_();})();
|