@chanmeng666/archlang-3d 0.7.0 → 0.8.1
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 +91 -0
- package/README.md +4 -4
- package/dist/browser.d.ts +3 -5
- package/dist/browser.js +87 -472
- package/dist/{camera-CGIIudHj.d.ts → camera-BAsRq_eC.d.ts} +1 -1
- package/dist/{chunk-GXWLZ2KC.js → chunk-33J3YGNF.js} +392 -29
- package/dist/{chunk-QN4LQTVG.js → chunk-CYSES7C3.js} +128 -44
- package/dist/chunk-JQTG6BDR.js +1127 -0
- package/dist/{chunk-TI4RYEOL.js → chunk-LNIVDMPG.js} +75 -5
- package/dist/{chunk-FHBR2U5Z.js → chunk-VMVKI2WQ.js} +65 -3
- package/dist/{chunk-FVD3DZU2.js → chunk-WOEJKIXN.js} +15 -6
- package/dist/cli.js +12 -6
- package/dist/{facts-3wb9egIT.d.ts → facts-CsO0xtFw.d.ts} +1 -1
- package/dist/index.d.ts +104 -35
- package/dist/index.js +19 -5
- package/dist/node.d.ts +23 -7
- package/dist/node.js +4 -4
- package/dist/{strip-Sdsm54Qw.d.ts → payload-DwiB2P7x.d.ts} +232 -12
- package/dist/replay.d.ts +1 -115
- package/dist/scene3d.schema.json +12 -0
- package/dist/viewer.iife.js +180 -180
- package/package.json +3 -3
package/dist/viewer.iife.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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() {
|
|
1
|
+
"use strict";(()=>{var td=Object.defineProperty;var nd=(i,e,t)=>e in i?td(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var pn=(i,e,t)=>nd(i,typeof e!="symbol"?e+"":e,t);var pi={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},mi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Zc=0,il=1,$c=2;var Zs=1,Jc=2,us=3,gi=0,Jt=1,_n=2,Ii=0,ds=1,sl=2,rl=3,ol=4,Kc=5;var Li=100,jc=101,Qc=102,eh=103,th=104,nh=200,ih=201,sh=202,rh=203,al=204,ll=205,oh=206,ah=207,lh=208,ch=209,hh=210,uh=211,dh=212,fh=213,ph=214,Hr=0,Wr=1,Xr=2,ji=3,qr=4,Yr=5,Zr=6,$r=7,wo=0,mh=1,gh=2,Ln=0,cl=1,hl=2,ul=3,dl=4,fl=5,pl=6,$s=7;var ml=300,Di=301,fs=302,Eo=303,To=304,Jr=1e3,Cn=1001,Kr=1002,Pt=1003,_h=1004;var Js=1005;var Zt=1006,Ao=1007;var Kn=1008;var en=1009,gl=1010,_l=1011,ps=1012,Ro=1013,wn=1014,En=1015,Tn=1016,Co=1017,Po=1018,Ni=1020,xl=35902,yl=35899,vl=1021,bl=1022,An=1023,Yn=1026,jn=1027,Ml=1028,Io=1029,_i=1030,Lo=1031;var Do=1033,Ks=33776,js=33777,Qs=33778,er=33779,No=35840,Uo=35841,Fo=35842,Oo=35843,Bo=36196,zo=37492,ko=37496,Vo=37488,Go=37489,tr=37490,Ho=37491,Wo=37808,Xo=37809,qo=37810,Yo=37811,Zo=37812,$o=37813,Jo=37814,Ko=37815,jo=37816,Qo=37817,ea=37818,ta=37819,na=37820,ia=37821,sa=36492,ra=36494,oa=36495,aa=36283,la=36284,nr=36285,ca=36286;var Cs=2300,jr=2301,Vr=2302,Ja=2303,Ka=2400,ja=2401,Qa=2402;var xh=3200;var ha=0,yh=1,Qn="",on="srgb",Ps="srgb-linear",Is="linear",ct="srgb";var Gr=7680;var vh=519,bh=512,Mh=513,Sh=514,Sl=515,wh=516,Eh=517,wl=518,El=519,Th=35044;var Tl="300 es",gn=2e3,Qi=2001;function id(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function sd(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Ls(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Ah(){let i=Ls("canvas");return i.style.display="block",i}var vc={},es=null;function Al(...i){let e="THREE."+i.shift();es?es("log",e,...i):console.log(e,...i)}function Rh(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 Fe(...i){i=Rh(i);let e="THREE."+i.shift();if(es)es("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function ke(...i){i=Rh(i);let e="THREE."+i.shift();if(es)es("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function As(...i){let e=i.join(" ");e in vc||(vc[e]=!0,Fe(...i))}function Ch(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 Ph={[Hr]:Hr,[Xr]:Zr,[qr]:qr,[ji]:Yr,[Wr]:Wr,[Zr]:Xr,[$r]:$r,[Yr]:ji},Sn=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,o=s.length;r<o;r++)s[r].call(this,e);e.target=null}}},zt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],bc=1234567,Ji=Math.PI/180,ts=180/Math.PI;function ms(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(zt[i&255]+zt[i>>8&255]+zt[i>>16&255]+zt[i>>24&255]+"-"+zt[e&255]+zt[e>>8&255]+"-"+zt[e>>16&15|64]+zt[e>>24&255]+"-"+zt[t&63|128]+zt[t>>8&255]+"-"+zt[t>>16&255]+zt[t>>24&255]+zt[n&255]+zt[n>>8&255]+zt[n>>16&255]+zt[n>>24&255]).toLowerCase()}function Je(i,e,t){return Math.max(e,Math.min(t,i))}function Rl(i,e){return(i%e+e)%e}function rd(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function od(i,e,t){return i!==e?(t-i)/(e-i):0}function Rs(i,e,t){return(1-t)*i+t*e}function ad(i,e,t,n){return Rs(i,e,1-Math.exp(-t*n))}function ld(i,e=1){return e-Math.abs(Rl(i,e*2)-e)}function cd(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function hd(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function ud(i,e){return i+Math.floor(Math.random()*(e-i+1))}function dd(i,e){return i+Math.random()*(e-i)}function fd(i){return i*(.5-Math.random())}function pd(i){i!==void 0&&(bc=i);let e=bc+=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 md(i){return i*Ji}function gd(i){return i*ts}function _d(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function xd(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Cl(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function yd(i,e,t,n,s){let r=Math.cos,o=Math.sin,a=r(t/2),c=o(t/2),l=r((e+n)/2),h=o((e+n)/2),u=r((e-n)/2),d=o((e-n)/2),f=r((n-e)/2),_=o((n-e)/2);switch(s){case"XYX":i.set(a*h,c*u,c*d,a*l);break;case"YZY":i.set(c*d,a*h,c*u,a*l);break;case"ZXZ":i.set(c*u,c*d,a*h,a*l);break;case"XZX":i.set(a*h,c*_,c*f,a*l);break;case"YXY":i.set(c*f,a*h,c*_,a*l);break;case"ZYZ":i.set(c*_,c*f,a*h,a*l);break;default:Fe("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Pl(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 Ih(i,e){if(e.constructor===Float32Array)return i;let t=Pl(e);if(t===void 0)throw new Error("THREE.MathUtils: Invalid component type.");return Math.max(i/t,-1)}function Lh(i,e){if(e.constructor===Float32Array)return i;let t=Pl(e);if(t===void 0)throw new Error("THREE.MathUtils: Invalid component type.");return Math.round(i*t)}var Il={DEG2RAD:Ji,RAD2DEG:ts,generateUUID:ms,clamp:Je,euclideanModulo:Rl,mapLinear:rd,inverseLerp:od,lerp:Rs,damp:ad,pingpong:ld,smoothstep:cd,smootherstep:hd,randInt:ud,randFloat:dd,randFloatSpread:fd,seededRandom:pd,degToRad:md,radToDeg:gd,isPowerOfTwo:_d,ceilPowerOfTwo:xd,floorPowerOfTwo:Cl,setQuaternionFromProperEuler:yd,normalize:Lh,denormalize:Ih},Fl=class Fl{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=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(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(Je(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,o=this.y-e.y;return this.x=r*n-o*s+e.x,this.y=r*s+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Fl.prototype.isVector2=!0;var Ve=Fl,ln=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,o,a){let c=n[s+0],l=n[s+1],h=n[s+2],u=n[s+3],d=r[o+0],f=r[o+1],_=r[o+2],x=r[o+3];if(u!==x||c!==d||l!==f||h!==_){let m=c*d+l*f+h*_+u*x;m<0&&(d=-d,f=-f,_=-_,x=-x,m=-m);let p=1-a;if(m<.9995){let w=Math.acos(m),T=Math.sin(w);p=Math.sin(p*w)/T,a=Math.sin(a*w)/T,c=c*p+d*a,l=l*p+f*a,h=h*p+_*a,u=u*p+x*a}else{c=c*p+d*a,l=l*p+f*a,h=h*p+_*a,u=u*p+x*a;let w=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=w,l*=w,h*=w,u*=w}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,s,r,o){let a=n[s],c=n[s+1],l=n[s+2],h=n[s+3],u=r[o],d=r[o+1],f=r[o+2],_=r[o+3];return e[t]=a*_+h*u+c*f-l*d,e[t+1]=c*_+h*d+l*u-a*f,e[t+2]=l*_+h*f+a*d-c*u,e[t+3]=h*_-a*u-c*d-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,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,o=e._order,a=Math.cos,c=Math.sin,l=a(n/2),h=a(s/2),u=a(r/2),d=c(n/2),f=c(s/2),_=c(r/2);switch(o){case"XYZ":this._x=d*h*u+l*f*_,this._y=l*f*u-d*h*_,this._z=l*h*_+d*f*u,this._w=l*h*u-d*f*_;break;case"YXZ":this._x=d*h*u+l*f*_,this._y=l*f*u-d*h*_,this._z=l*h*_-d*f*u,this._w=l*h*u+d*f*_;break;case"ZXY":this._x=d*h*u-l*f*_,this._y=l*f*u+d*h*_,this._z=l*h*_+d*f*u,this._w=l*h*u-d*f*_;break;case"ZYX":this._x=d*h*u-l*f*_,this._y=l*f*u+d*h*_,this._z=l*h*_-d*f*u,this._w=l*h*u+d*f*_;break;case"YZX":this._x=d*h*u+l*f*_,this._y=l*f*u+d*h*_,this._z=l*h*_-d*f*u,this._w=l*h*u-d*f*_;break;case"XZY":this._x=d*h*u-l*f*_,this._y=l*f*u-d*h*_,this._z=l*h*_+d*f*u,this._w=l*h*u+d*f*_;break;default:Fe("Quaternion: .setFromEuler() encountered an unknown order: "+o)}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],o=t[1],a=t[5],c=t[9],l=t[2],h=t[6],u=t[10],d=n+a+u;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(r-l)*f,this._z=(o-s)*f}else if(n>a&&n>u){let f=2*Math.sqrt(1+n-a-u);this._w=(h-c)/f,this._x=.25*f,this._y=(s+o)/f,this._z=(r+l)/f}else if(a>u){let f=2*Math.sqrt(1+a-n-u);this._w=(r-l)/f,this._x=(s+o)/f,this._y=.25*f,this._z=(c+h)/f}else{let f=2*Math.sqrt(1+u-n-a);this._w=(o-s)/f,this._x=(r+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Je(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,o=e._w,a=t._x,c=t._y,l=t._z,h=t._w;return this._x=n*h+o*a+s*l-r*c,this._y=s*h+o*c+r*a-n*l,this._z=r*h+o*l+n*c-s*a,this._w=o*h-n*a-s*c-r*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,o=e._w,a=this.dot(e);a<0&&(n=-n,s=-s,r=-r,o=-o,a=-a);let c=1-t;if(a<.9995){let l=Math.acos(a),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+o*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+o*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}},Ol=class Ol{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(Mc.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Mc.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,o=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])*o,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,s=this.z,r=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*s-a*n),h=2*(a*t-r*s),u=2*(r*n-o*t);return this.x=t+c*l+o*u-a*h,this.y=n+c*h+a*l-r*u,this.z=s+c*u+r*h-o*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){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=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(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,o=t.x,a=t.y,c=t.z;return this.x=s*c-r*a,this.y=r*o-n*c,this.z=n*a-s*o,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 Ra.copy(this).projectOnVector(e),this.sub(Ra)}reflect(e){return this.sub(Ra.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(Je(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}};Ol.prototype.isVector3=!0;var k=Ol,Ra=new k,Mc=new ln,Bl=class Bl{constructor(e,t,n,s,r,o,a,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,o,a,c,l)}set(e,t,n,s,r,o,a,c,l){let h=this.elements;return h[0]=e,h[1]=s,h[2]=a,h[3]=t,h[4]=r,h[5]=c,h[6]=n,h[7]=o,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,o=n[0],a=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],f=n[5],_=n[8],x=s[0],m=s[3],p=s[6],w=s[1],T=s[4],S=s[7],E=s[2],M=s[5],g=s[8];return r[0]=o*x+a*w+c*E,r[3]=o*m+a*T+c*M,r[6]=o*p+a*S+c*g,r[1]=l*x+h*w+u*E,r[4]=l*m+h*T+u*M,r[7]=l*p+h*S+u*g,r[2]=d*x+f*w+_*E,r[5]=d*m+f*T+_*M,r[8]=d*p+f*S+_*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],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8];return t*o*h-t*a*l-n*r*h+n*a*c+s*r*l-s*o*c}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=h*o-a*l,d=a*c-h*r,f=l*r-o*c,_=t*u+n*d+s*f;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/_;return e[0]=u*x,e[1]=(s*l-h*n)*x,e[2]=(a*n-s*o)*x,e[3]=d*x,e[4]=(h*t-s*c)*x,e[5]=(s*r-a*t)*x,e[6]=f*x,e[7]=(n*c-l*t)*x,e[8]=(o*t-n*r)*x,this}transpose(){let e,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,o,a){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*o+l*a)+o+e,-s*l,s*c,-s*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return As("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Ca.makeScale(e,t)),this}rotate(e){return As("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Ca.makeRotation(-e)),this}translate(e,t){return As("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Ca.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)}};Bl.prototype.isMatrix3=!0;var Ge=Bl,Ca=new Ge,Sc=new Ge().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),wc=new Ge().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function vd(){let i={enabled:!0,workingColorSpace:Ps,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===ct&&(s.r=qn(s.r),s.g=qn(s.g),s.b=qn(s.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===ct&&(s.r=Ki(s.r),s.g=Ki(s.g),s.b=Ki(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===Qn?Is: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,o){return s.copy(this.spaces[o].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({[Ps]:{primaries:e,whitePoint:n,transfer:Is,toXYZ:Sc,fromXYZ:wc,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:on},outputColorSpaceConfig:{drawingBufferColorSpace:on}},[on]:{primaries:e,whitePoint:n,transfer:ct,toXYZ:Sc,fromXYZ:wc,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:on}}}),i}var et=vd();function qn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Ki(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Oi,Qr=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{Oi===void 0&&(Oi=Ls("canvas")),Oi.width=e.width,Oi.height=e.height;let s=Oi.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=Oi}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=Ls("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 o=0;o<r.length;o++)r[o]=qn(r[o]/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(qn(t[n]/255)*255):t[n]=qn(t[n]);return{data:t,width:e.width,height:e.height}}else return Fe("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},bd=0,ns=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:bd++}),this.uuid=ms(),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 o=0,a=s.length;o<a;o++)s[o].isDataTexture?r.push(Pa(s[o].image)):r.push(Pa(s[o]))}else r=Pa(s);n.url=r}return t||(e.images[this.uuid]=n),n}};function Pa(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Qr.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Fe("Texture: Unable to serialize Texture."),{})}var Md=0,Ia=new k,jt=class i extends Sn{constructor(e=i.DEFAULT_IMAGE,t=i.DEFAULT_MAPPING,n=Cn,s=Cn,r=Zt,o=Kn,a=An,c=en,l=i.DEFAULT_ANISOTROPY,h=Qn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Md++}),this.uuid=ms(),this.name="",this.source=new ns(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new Ve(0,0),this.repeat=new Ve(1,1),this.center=new Ve(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ge,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(Ia).x}get height(){return this.source.getSize(Ia).y}get depth(){return this.source.getSize(Ia).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){Fe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Fe(`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!==ml)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Jr:e.x=e.x-Math.floor(e.x);break;case Cn:e.x=e.x<0?0:1;break;case Kr: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 Jr:e.y=e.y-Math.floor(e.y);break;case Cn:e.y=e.y<0?0:1;break;case Kr: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++}};jt.DEFAULT_IMAGE=null;jt.DEFAULT_MAPPING=ml;jt.DEFAULT_ANISOTROPY=1;var zl=class zl{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,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*s+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*s+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*s+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*s+o[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);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],u=c[8],d=c[1],f=c[5],_=c[9],x=c[2],m=c[6],p=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-x)<.01&&Math.abs(_-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+x)<.1&&Math.abs(_+m)<.1&&Math.abs(l+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let T=(l+1)/2,S=(f+1)/2,E=(p+1)/2,M=(h+d)/4,g=(u+x)/4,v=(_+m)/4;return T>S&&T>E?T<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(T),s=M/n,r=g/n):S>E?S<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(S),n=M/s,r=v/s):E<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(E),n=g/r,s=v/r),this.set(n,s,r,t),this}let w=Math.sqrt((m-_)*(m-_)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(w)<.001&&(w=1),this.x=(m-_)/w,this.y=(u-x)/w,this.z=(d-h)/w,this.w=Math.acos((l+f+p-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=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this.w=Je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this.w=Je(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(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}};zl.prototype.isVector4=!0;var _t=zl,eo=class extends Sn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Zt,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 _t(0,0,e,t),this.scissorTest=!1,this.viewport=new _t(0,0,e,t),this.textures=[];let s=n.count;for(let r=0;r<s;r++)this.textures[r]=new jt({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:Zt,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 ns(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"})}},cn=class extends eo{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Ds=class extends jt{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=Pt,this.minFilter=Pt,this.wrapR=Cn,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 to=class extends jt{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=Pt,this.minFilter=Pt,this.wrapR=Cn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}};var So=class So{constructor(e,t,n,s,r,o,a,c,l,h,u,d,f,_,x,m){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,o,a,c,l,h,u,d,f,_,x,m)}set(e,t,n,s,r,o,a,c,l,h,u,d,f,_,x,m){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=s,p[1]=r,p[5]=o,p[9]=a,p[13]=c,p[2]=l,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=_,p[11]=x,p[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new So().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/Bi.setFromMatrixColumn(e,0).length(),r=1/Bi.setFromMatrixColumn(e,1).length(),o=1/Bi.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]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,s=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let d=o*h,f=o*u,_=a*h,x=a*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=f+_*l,t[5]=d-x*l,t[9]=-a*c,t[2]=x-d*l,t[6]=_+f*l,t[10]=o*c}else if(e.order==="YXZ"){let d=c*h,f=c*u,_=l*h,x=l*u;t[0]=d+x*a,t[4]=_*a-f,t[8]=o*l,t[1]=o*u,t[5]=o*h,t[9]=-a,t[2]=f*a-_,t[6]=x+d*a,t[10]=o*c}else if(e.order==="ZXY"){let d=c*h,f=c*u,_=l*h,x=l*u;t[0]=d-x*a,t[4]=-o*u,t[8]=_+f*a,t[1]=f+_*a,t[5]=o*h,t[9]=x-d*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){let d=o*h,f=o*u,_=a*h,x=a*u;t[0]=c*h,t[4]=_*l-f,t[8]=d*l+x,t[1]=c*u,t[5]=x*l+d,t[9]=f*l-_,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){let d=o*c,f=o*l,_=a*c,x=a*l;t[0]=c*h,t[4]=x-d*u,t[8]=_*u+f,t[1]=u,t[5]=o*h,t[9]=-a*h,t[2]=-l*h,t[6]=f*u+_,t[10]=d-x*u}else if(e.order==="XZY"){let d=o*c,f=o*l,_=a*c,x=a*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=d*u+x,t[5]=o*h,t[9]=f*u-_,t[2]=_*u-f,t[6]=a*h,t[10]=x*u+d}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(Sd,e,wd)}lookAt(e,t,n){let s=this.elements;return sn.subVectors(e,t),sn.lengthSq()===0&&(sn.z=1),sn.normalize(),si.crossVectors(n,sn),si.lengthSq()===0&&(Math.abs(n.z)===1?sn.x+=1e-4:sn.z+=1e-4,sn.normalize(),si.crossVectors(n,sn)),si.normalize(),gr.crossVectors(sn,si),s[0]=si.x,s[4]=gr.x,s[8]=sn.x,s[1]=si.y,s[5]=gr.y,s[9]=sn.y,s[2]=si.z,s[6]=gr.z,s[10]=sn.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,o=n[0],a=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],f=n[13],_=n[2],x=n[6],m=n[10],p=n[14],w=n[3],T=n[7],S=n[11],E=n[15],M=s[0],g=s[4],v=s[8],L=s[12],R=s[1],D=s[5],N=s[9],B=s[13],C=s[2],W=s[6],Z=s[10],z=s[14],ee=s[3],q=s[7],J=s[11],O=s[15];return r[0]=o*M+a*R+c*C+l*ee,r[4]=o*g+a*D+c*W+l*q,r[8]=o*v+a*N+c*Z+l*J,r[12]=o*L+a*B+c*z+l*O,r[1]=h*M+u*R+d*C+f*ee,r[5]=h*g+u*D+d*W+f*q,r[9]=h*v+u*N+d*Z+f*J,r[13]=h*L+u*B+d*z+f*O,r[2]=_*M+x*R+m*C+p*ee,r[6]=_*g+x*D+m*W+p*q,r[10]=_*v+x*N+m*Z+p*J,r[14]=_*L+x*B+m*z+p*O,r[3]=w*M+T*R+S*C+E*ee,r[7]=w*g+T*D+S*W+E*q,r[11]=w*v+T*N+S*Z+E*J,r[15]=w*L+T*B+S*z+E*O,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],o=e[1],a=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],f=e[14],_=e[3],x=e[7],m=e[11],p=e[15],w=c*f-l*d,T=a*f-l*u,S=a*d-c*u,E=o*f-l*h,M=o*d-c*h,g=o*u-a*h;return t*(x*w-m*T+p*S)-n*(_*w-m*E+p*M)+s*(_*T-x*E+p*g)-r*(_*S-x*M+m*g)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[1],o=e[5],a=e[9],c=e[2],l=e[6],h=e[10];return t*(o*h-a*l)-n*(r*h-a*c)+s*(r*l-o*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],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],f=e[11],_=e[12],x=e[13],m=e[14],p=e[15],w=t*a-n*o,T=t*c-s*o,S=t*l-r*o,E=n*c-s*a,M=n*l-r*a,g=s*l-r*c,v=h*x-u*_,L=h*m-d*_,R=h*p-f*_,D=u*m-d*x,N=u*p-f*x,B=d*p-f*m,C=w*B-T*N+S*D+E*R-M*L+g*v;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let W=1/C;return e[0]=(a*B-c*N+l*D)*W,e[1]=(s*N-n*B-r*D)*W,e[2]=(x*g-m*M+p*E)*W,e[3]=(d*M-u*g-f*E)*W,e[4]=(c*R-o*B-l*L)*W,e[5]=(t*B-s*R+r*L)*W,e[6]=(m*S-_*g-p*T)*W,e[7]=(h*g-d*S+f*T)*W,e[8]=(o*N-a*R+l*v)*W,e[9]=(n*R-t*N-r*v)*W,e[10]=(_*M-x*S+p*w)*W,e[11]=(u*S-h*M-f*w)*W,e[12]=(a*L-o*D-c*v)*W,e[13]=(t*D-n*L+s*v)*W,e[14]=(x*T-_*E-m*w)*W,e[15]=(h*E-u*T+d*w)*W,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,o=e.x,a=e.y,c=e.z,l=r*o,h=r*a;return this.set(l*o+n,l*a-s*c,l*c+s*a,0,l*a+s*c,h*a+n,h*c-s*o,0,l*c-s*a,h*c+s*o,r*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,r,o){return this.set(1,n,r,0,e,1,o,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){let s=this.elements,r=t._x,o=t._y,a=t._z,c=t._w,l=r+r,h=o+o,u=a+a,d=r*l,f=r*h,_=r*u,x=o*h,m=o*u,p=a*u,w=c*l,T=c*h,S=c*u,E=n.x,M=n.y,g=n.z;return s[0]=(1-(x+p))*E,s[1]=(f+S)*E,s[2]=(_-T)*E,s[3]=0,s[4]=(f-S)*M,s[5]=(1-(d+p))*M,s[6]=(m+w)*M,s[7]=0,s[8]=(_+T)*g,s[9]=(m-w)*g,s[10]=(1-(d+x))*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 o=Bi.set(s[0],s[1],s[2]).length(),a=Bi.set(s[4],s[5],s[6]).length(),c=Bi.set(s[8],s[9],s[10]).length();r<0&&(o=-o),vn.copy(this);let l=1/o,h=1/a,u=1/c;return vn.elements[0]*=l,vn.elements[1]*=l,vn.elements[2]*=l,vn.elements[4]*=h,vn.elements[5]*=h,vn.elements[6]*=h,vn.elements[8]*=u,vn.elements[9]*=u,vn.elements[10]*=u,t.setFromRotationMatrix(vn),n.x=o,n.y=a,n.z=c,this}makePerspective(e,t,n,s,r,o,a=gn,c=!1){let l=this.elements,h=2*r/(t-e),u=2*r/(n-s),d=(t+e)/(t-e),f=(n+s)/(n-s),_,x;if(c)_=r/(o-r),x=o*r/(o-r);else if(a===gn)_=-(o+r)/(o-r),x=-2*o*r/(o-r);else if(a===Qi)_=-o/(o-r),x=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=_,l[14]=x,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,s,r,o,a=gn,c=!1){let l=this.elements,h=2/(t-e),u=2/(n-s),d=-(t+e)/(t-e),f=-(n+s)/(n-s),_,x;if(c)_=1/(o-r),x=o/(o-r);else if(a===gn)_=-2/(o-r),x=-(o+r)/(o-r);else if(a===Qi)_=-1/(o-r),x=-r/(o-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=_,l[14]=x,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}};So.prototype.isMatrix4=!0;var mt=So,Bi=new k,vn=new mt,Sd=new k(0,0,0),wd=new k(1,1,1),si=new k,gr=new k,sn=new k,Ec=new mt,Tc=new ln,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],o=s[4],a=s[8],c=s[1],l=s[5],h=s[9],u=s[2],d=s[6],f=s[10];switch(t){case"XYZ":this._y=Math.asin(Je(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Je(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Je(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Je(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Je(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-Je(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Fe("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ec.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ec,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Tc.setFromEuler(this),this.setFromQuaternion(Tc,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 Ns=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}},Ed=0,Ac=new k,zi=new ln,kn=new mt,_r=new k,Ms=new k,Td=new k,Ad=new ln,Rc=new k(1,0,0),Cc=new k(0,1,0),Pc=new k(0,0,1),Ic={type:"added"},Rd={type:"removed"},ki={type:"childadded",child:null},La={type:"childremoved",child:null},Ut=class i extends Sn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ed++}),this.uuid=ms(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let e=new k,t=new Zn,n=new ln,s=new k(1,1,1);function r(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new mt},normalMatrix:{value:new Ge}}),this.matrix=new mt,this.matrixWorld=new mt,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ns,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 zi.setFromAxisAngle(e,t),this.quaternion.multiply(zi),this}rotateOnWorldAxis(e,t){return zi.setFromAxisAngle(e,t),this.quaternion.premultiply(zi),this}rotateX(e){return this.rotateOnAxis(Rc,e)}rotateY(e){return this.rotateOnAxis(Cc,e)}rotateZ(e){return this.rotateOnAxis(Pc,e)}translateOnAxis(e,t){return Ac.copy(e).applyQuaternion(this.quaternion),this.position.add(Ac.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Rc,e)}translateY(e){return this.translateOnAxis(Cc,e)}translateZ(e){return this.translateOnAxis(Pc,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(kn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?_r.copy(e):_r.set(e,t,n);let s=this.parent;this.updateWorldMatrix(!0,!1),Ms.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?kn.lookAt(Ms,_r,this.up):kn.lookAt(_r,Ms,this.up),this.quaternion.setFromRotationMatrix(kn),s&&(kn.extractRotation(s.matrixWorld),zi.setFromRotationMatrix(kn),this.quaternion.premultiply(zi.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(ke("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(Ic),ki.child=e,this.dispatchEvent(ki),ki.child=null):ke("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(Rd),La.child=e,this.dispatchEvent(La),La.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),kn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),kn.multiply(e.parent.matrixWorld)),e.applyMatrix4(kn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ic),ki.child=e,this.dispatchEvent(ki),ki.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 o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let s=this.children;for(let r=0,o=s.length;r<o;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(Ms,e,Td),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ms,Ad,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 o=0,a=r.length;o<a;o++)r[o].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(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(a=>({...a})),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(a,c){return a[c.uuid]===void 0&&(a[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 a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let c=a.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){let u=c[l];r(e.shapes,u)}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 a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(r(e.materials,this.material[c]));s.material=a}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let a=0;a<this.children.length;a++)s.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let a=0;a<this.animations.length;a++){let c=this.animations[a];s.animations.push(r(e.animations,c))}}if(t){let a=o(e.geometries),c=o(e.materials),l=o(e.textures),h=o(e.images),u=o(e.shapes),d=o(e.skeletons),f=o(e.animations),_=o(e.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),_.length>0&&(n.nodes=_)}return n.object=s,n;function o(a){let c=[];for(let l in a){let h=a[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"})}};Ut.DEFAULT_UP=new k(0,1,0);Ut.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Pn=class extends Ut{constructor(){super(),this.isGroup=!0,this.type="Group"}},Cd={type:"move"},is=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Pn,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 Pn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new k,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new k),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Pn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new k,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new k,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,o=null,a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(let x of e.hand.values()){let m=t.getJointPose(x,n),p=this._getHandJoint(l,x);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.quaternion,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}let h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,_=.005;l.inputState.pinching&&d>f+_?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=f-_&&(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})));a!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Cd)))}return a!==null&&(a.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Pn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Dh={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},ri={h:0,s:0,l:0},xr={h:0,s:0,l:0};function Da(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 Ye=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=on){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,et.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=et.workingColorSpace){return this.r=e,this.g=t,this.b=n,et.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=et.workingColorSpace){if(e=Rl(e,1),t=Je(t,0,1),n=Je(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=Da(o,r,e+1/3),this.g=Da(o,r,e),this.b=Da(o,r,e-1/3)}return et.colorSpaceToWorking(this,s),this}setStyle(e,t=on){function n(r){r!==void 0&&parseFloat(r)<1&&Fe("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,o=s[1],a=s[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))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(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Fe("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);Fe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=on){let n=Dh[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Fe("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=qn(e.r),this.g=qn(e.g),this.b=qn(e.b),this}copyLinearToSRGB(e){return this.r=Ki(e.r),this.g=Ki(e.g),this.b=Ki(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=on){return et.workingToColorSpace(kt.copy(this),e),Math.round(Je(kt.r*255,0,255))*65536+Math.round(Je(kt.g*255,0,255))*256+Math.round(Je(kt.b*255,0,255))}getHexString(e=on){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=et.workingColorSpace){et.workingToColorSpace(kt.copy(this),t);let n=kt.r,s=kt.g,r=kt.b,o=Math.max(n,s,r),a=Math.min(n,s,r),c,l,h=(a+o)/2;if(a===o)c=0,l=0;else{let u=o-a;switch(l=h<=.5?u/(o+a):u/(2-o-a),o){case n:c=(s-r)/u+(s<r?6:0);break;case s:c=(r-n)/u+2;break;case r:c=(n-s)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=et.workingColorSpace){return et.workingToColorSpace(kt.copy(this),t),e.r=kt.r,e.g=kt.g,e.b=kt.b,e}getStyle(e=on){et.workingToColorSpace(kt.copy(this),e);let t=kt.r,n=kt.g,s=kt.b;return e!==on?`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(ri),this.setHSL(ri.h+e,ri.s+t,ri.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(ri),e.getHSL(xr);let n=Rs(ri.h,xr.h,t),s=Rs(ri.s,xr.s,t),r=Rs(ri.l,xr.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}},kt=new Ye;Ye.NAMES=Dh;var Us=class extends Ut{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}},bn=new k,Vn=new k,Na=new k,Gn=new k,Vi=new k,Gi=new k,Lc=new k,Ua=new k,Fa=new k,Oa=new k,Ba=new _t,za=new _t,ka=new _t,Xn=class i{constructor(e=new k,t=new k,n=new k){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),bn.subVectors(e,t),s.cross(bn);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){bn.subVectors(s,t),Vn.subVectors(n,t),Na.subVectors(e,t);let o=bn.dot(bn),a=bn.dot(Vn),c=bn.dot(Na),l=Vn.dot(Vn),h=Vn.dot(Na),u=o*l-a*a;if(u===0)return r.set(0,0,0),null;let d=1/u,f=(l*c-a*h)*d,_=(o*h-a*c)*d;return r.set(1-f-_,_,f)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Gn)===null?!1:Gn.x>=0&&Gn.y>=0&&Gn.x+Gn.y<=1}static getInterpolation(e,t,n,s,r,o,a,c){return this.getBarycoord(e,t,n,s,Gn)===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,Gn.x),c.addScaledVector(o,Gn.y),c.addScaledVector(a,Gn.z),c)}static getInterpolatedAttribute(e,t,n,s,r,o){return Ba.setScalar(0),za.setScalar(0),ka.setScalar(0),Ba.fromBufferAttribute(e,t),za.fromBufferAttribute(e,n),ka.fromBufferAttribute(e,s),o.setScalar(0),o.addScaledVector(Ba,r.x),o.addScaledVector(za,r.y),o.addScaledVector(ka,r.z),o}static isFrontFacing(e,t,n,s){return bn.subVectors(n,t),Vn.subVectors(e,t),bn.cross(Vn).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 bn.subVectors(this.c,this.b),Vn.subVectors(this.a,this.b),bn.cross(Vn).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,o,a;Vi.subVectors(s,n),Gi.subVectors(r,n),Ua.subVectors(e,n);let c=Vi.dot(Ua),l=Gi.dot(Ua);if(c<=0&&l<=0)return t.copy(n);Fa.subVectors(e,s);let h=Vi.dot(Fa),u=Gi.dot(Fa);if(h>=0&&u<=h)return t.copy(s);let d=c*u-h*l;if(d<=0&&c>=0&&h<=0&&c-h>0)return o=c/(c-h),t.copy(n).addScaledVector(Vi,o);Oa.subVectors(e,r);let f=Vi.dot(Oa),_=Gi.dot(Oa);if(_>=0&&f<=_)return t.copy(r);let x=f*l-c*_;if(x<=0&&l>=0&&_<=0)return a=l/(l-_),t.copy(n).addScaledVector(Gi,a);let m=h*_-f*u;if(m<=0&&u-h>=0&&f-_>=0)return Lc.subVectors(r,s),a=(u-h)/(u-h+(f-_)),t.copy(s).addScaledVector(Lc,a);let p=1/(m+x+d);return o=x*p,a=d*p,t.copy(n).addScaledVector(Vi,o).addScaledVector(Gi,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},ci=class{constructor(e=new k(1/0,1/0,1/0),t=new k(-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(Mn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Mn.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=Mn.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 o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,Mn):Mn.fromBufferAttribute(r,o),Mn.applyMatrix4(e.matrixWorld),this.expandByPoint(Mn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),yr.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),yr.copy(n.boundingBox)),yr.applyMatrix4(e.matrixWorld),this.union(yr)}let s=e.children;for(let r=0,o=s.length;r<o;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,Mn),Mn.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(Ss),vr.subVectors(this.max,Ss),Hi.subVectors(e.a,Ss),Wi.subVectors(e.b,Ss),Xi.subVectors(e.c,Ss),oi.subVectors(Wi,Hi),ai.subVectors(Xi,Wi),Si.subVectors(Hi,Xi);let t=[0,-oi.z,oi.y,0,-ai.z,ai.y,0,-Si.z,Si.y,oi.z,0,-oi.x,ai.z,0,-ai.x,Si.z,0,-Si.x,-oi.y,oi.x,0,-ai.y,ai.x,0,-Si.y,Si.x,0];return!Va(t,Hi,Wi,Xi,vr)||(t=[1,0,0,0,1,0,0,0,1],!Va(t,Hi,Wi,Xi,vr))?!1:(br.crossVectors(oi,ai),t=[br.x,br.y,br.z],Va(t,Hi,Wi,Xi,vr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Mn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Mn).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:(Hn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Hn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Hn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Hn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Hn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Hn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Hn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Hn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Hn),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}},Hn=[new k,new k,new k,new k,new k,new k,new k,new k],Mn=new k,yr=new ci,Hi=new k,Wi=new k,Xi=new k,oi=new k,ai=new k,Si=new k,Ss=new k,vr=new k,br=new k,wi=new k;function Va(i,e,t,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){wi.fromArray(i,r);let a=s.x*Math.abs(wi.x)+s.y*Math.abs(wi.y)+s.z*Math.abs(wi.z),c=e.dot(wi),l=t.dot(wi),h=n.dot(wi);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>a)return!1}return!0}var St=new k,Mr=new Ve,Pd=0,Vt=class extends Sn{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:Pd++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Th,this.updateRanges=[],this.gpuType=En,this.version=0,this._normalizationScale=e!==void 0?Pl(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++)Mr.fromBufferAttribute(this,t),Mr.applyMatrix3(e),this.setXY(t,Mr.x,Mr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)St.fromBufferAttribute(this,t),St.applyMatrix3(e),this.setXYZ(t,St.x,St.y,St.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)St.fromBufferAttribute(this,t),St.applyMatrix4(e),this.setXYZ(t,St.x,St.y,St.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)St.fromBufferAttribute(this,t),St.applyNormalMatrix(e),this.setXYZ(t,St.x,St.y,St.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)St.fromBufferAttribute(this,t),St.transformDirection(e),this.setXYZ(t,St.x,St.y,St.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):Ih(e,this.array)}_normalize(e){let t=this._normalizationScale;return t!==void 0?Math.round(e*t):Lh(e,this.array)}};var Fs=class extends Vt{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var Os=class extends Vt{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var Yt=class extends Vt{constructor(e,t,n){super(new Float32Array(e),t,n)}},Id=new ci,ws=new k,Ga=new k,Ai=class{constructor(e=new k,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):Id.setFromPoints(e).getCenter(n);let s=0;for(let r=0,o=e.length;r<o;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;ws.subVectors(e,this.center);let t=ws.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(ws,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):(Ga.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ws.copy(e.center).add(Ga)),this.expandByPoint(ws.copy(e.center).sub(Ga))),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,mn=new mt,Ha=new Ut,qi=new k,rn=new ci,Es=new ci,Ct=new k,$t=class i extends Sn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ld++}),this.uuid=ms(),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(id(e)?Os:Fs)(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 Ge().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 mn.makeRotationFromQuaternion(e),this.applyMatrix4(mn),this}rotateX(e){return mn.makeRotationX(e),this.applyMatrix4(mn),this}rotateY(e){return mn.makeRotationY(e),this.applyMatrix4(mn),this}rotateZ(e){return mn.makeRotationZ(e),this.applyMatrix4(mn),this}translate(e,t,n){return mn.makeTranslation(e,t,n),this.applyMatrix4(mn),this}scale(e,t,n){return mn.makeScale(e,t,n),this.applyMatrix4(mn),this}lookAt(e){return Ha.lookAt(e),Ha.updateMatrix(),this.applyMatrix4(Ha.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(qi).negate(),this.translate(qi.x,qi.y,qi.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 o=e[s];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Yt(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&&Fe("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 ci);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new k(-1/0,-1/0,-1/0),new k(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];rn.setFromBufferAttribute(r),this.morphTargetsRelative?(Ct.addVectors(this.boundingBox.min,rn.min),this.boundingBox.expandByPoint(Ct),Ct.addVectors(this.boundingBox.max,rn.max),this.boundingBox.expandByPoint(Ct)):(this.boundingBox.expandByPoint(rn.min),this.boundingBox.expandByPoint(rn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ke('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 e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new k,1/0);return}if(e){let n=this.boundingSphere.center;if(rn.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){let a=t[r];Es.setFromBufferAttribute(a),this.morphTargetsRelative?(Ct.addVectors(rn.min,Es.min),rn.expandByPoint(Ct),Ct.addVectors(rn.max,Es.max),rn.expandByPoint(Ct)):(rn.expandByPoint(Es.min),rn.expandByPoint(Es.max))}rn.getCenter(n);let s=0;for(let r=0,o=e.count;r<o;r++)Ct.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(Ct));if(t)for(let r=0,o=t.length;r<o;r++){let a=t[r],c=this.morphTargetsRelative;for(let l=0,h=a.count;l<h;l++)Ct.fromBufferAttribute(a,l),c&&(qi.fromBufferAttribute(e,l),Ct.add(qi)),s=Math.max(s,n.distanceToSquared(Ct))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&ke('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){ke("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,s=t.normal,r=t.uv,o=this.getAttribute("tangent");(o===void 0||o.count!==n.count)&&(o=new Vt(new Float32Array(4*n.count),4),this.setAttribute("tangent",o));let a=[],c=[],l=new Uint8Array(n.count);for(let L=0;L<n.count;L++)a[L]=new k,c[L]=new k;let h=new k,u=new k,d=new k,f=new Ve,_=new Ve,x=new Ve,m=new k,p=new k;function w(L,R,D){l[L]=l[R]=l[D]=1,h.fromBufferAttribute(n,L),u.fromBufferAttribute(n,R),d.fromBufferAttribute(n,D),f.fromBufferAttribute(r,L),_.fromBufferAttribute(r,R),x.fromBufferAttribute(r,D),u.sub(h),d.sub(h),_.sub(f),x.sub(f);let N=1/(_.x*x.y-x.x*_.y);isFinite(N)&&(m.copy(u).multiplyScalar(x.y).addScaledVector(d,-_.y).multiplyScalar(N),p.copy(d).multiplyScalar(_.x).addScaledVector(u,-x.x).multiplyScalar(N),a[L].add(m),a[R].add(m),a[D].add(m),c[L].add(p),c[R].add(p),c[D].add(p))}let T=this.groups;T.length===0&&(T=[{start:0,count:e.count}]);for(let L=0,R=T.length;L<R;++L){let D=T[L],N=D.start,B=D.count;for(let C=N,W=N+B;C<W;C+=3)w(e.getX(C+0),e.getX(C+1),e.getX(C+2))}let S=new k,E=new k,M=new k,g=new k;function v(L){M.fromBufferAttribute(s,L),g.copy(M);let R=a[L];S.copy(R),S.sub(M.multiplyScalar(M.dot(R))).normalize(),E.crossVectors(g,R);let N=E.dot(c[L])<0?-1:1;o.setXYZW(L,S.x,S.y,S.z,N)}for(let L=0,R=n.count;L<R;++L)l[L]&&v(L);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 Vt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);let s=new k,r=new k,o=new k,a=new k,c=new k,l=new k,h=new k,u=new k;if(e)for(let d=0,f=e.count;d<f;d+=3){let _=e.getX(d+0),x=e.getX(d+1),m=e.getX(d+2);s.fromBufferAttribute(t,_),r.fromBufferAttribute(t,x),o.fromBufferAttribute(t,m),h.subVectors(o,r),u.subVectors(s,r),h.cross(u),a.fromBufferAttribute(n,_),c.fromBufferAttribute(n,x),l.fromBufferAttribute(n,m),a.add(h),c.add(h),l.add(h),n.setXYZ(_,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,f=t.count;d<f;d+=3)s.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),h.subVectors(o,r),u.subVectors(s,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+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++)Ct.fromBufferAttribute(e,t),Ct.normalize(),e.setXYZ(t,Ct.x,Ct.y,Ct.z)}toNonIndexed(){function e(a,c){let l=a.array,h=a.itemSize,u=a.normalized,d=new l.constructor(c.length*h),f=0,_=0;for(let x=0,m=c.length;x<m;x++){a.isInterleavedBufferAttribute?f=c[x]*a.data.stride+a.offset:f=c[x]*h;for(let p=0;p<h;p++)d[_++]=l[f++]}return new Vt(d,h,u)}if(this.index===null)return Fe("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new i,n=this.index.array,s=this.attributes;for(let a in s){let c=s[a],l=e(c,n);t.setAttribute(a,l)}let r=this.morphAttributes;for(let a in r){let c=[],l=r[a];for(let h=0,u=l.length;h<u;h++){let d=l[h],f=e(d,n);c.push(f)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,c=o.length;a<c;a++){let l=o[a];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 u=0,d=l.length;u<d;u++){let f=l[u];h.push(f.toJSON(e.data))}h.length>0&&(s[c]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;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=[],u=r[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let l=0,h=o.length;l<h;l++){let u=o[l];this.addGroup(u.start,u.count,u.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.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 Wa=new k,Dd=new k,Nd=new Ge,an=class{constructor(e=new k(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=Wa.subVectors(n,t).cross(Dd.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(Wa),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let o=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(o<0||o>1)?null:t.copy(e.start).addScaledVector(s,o)}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||Nd.getNormalMatrix(e),s=this.coplanarPoint(Wa).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,$n=class extends Sn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ud++}),this.uuid=ms(),this.name="",this.type="Material",this.blending=ds,this.side=gi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=al,this.blendDst=ll,this.blendEquation=Li,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ye(0,0,0),this.blendAlpha=0,this.depthFunc=ji,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=vh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Gr,this.stencilZFail=Gr,this.stencilZPass=Gr,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){Fe(`Material: parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Fe(`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 o=[];for(let a in r){let c=r[a];delete c.metadata,o.push(c)}return o}if(t){let r=s(e.textures),o=s(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}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 Ye().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 an().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 Ve().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 Ve().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 Wn=new k,Xa=new k,Sr=new k,wr=new k,Ri=class{constructor(e=new k,t=new k(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,Wn)),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=Wn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Wn.copy(this.origin).addScaledVector(this.direction,t),Wn.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Xa.copy(e).add(t).multiplyScalar(.5),Sr.copy(t).sub(e).normalize(),wr.copy(this.origin).sub(Xa);let r=e.distanceTo(t)*.5,o=-this.direction.dot(Sr),a=wr.dot(this.direction),c=-wr.dot(Sr),l=wr.lengthSq(),h=Math.abs(1-o*o),u,d,f,_;if(h>0)if(u=o*c-a,d=o*a-c,_=r*h,u>=0)if(d>=-_)if(d<=_){let x=1/h;u*=x,d*=x,f=u*(u+o*d+2*a)+d*(o*u+d+2*c)+l}else d=r,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*c)+l;else d<=-_?(u=Math.max(0,-(-o*r+a)),d=u>0?-r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l):d<=_?(u=0,d=Math.min(Math.max(-r,-c),r),f=d*(d+2*c)+l):(u=Math.max(0,-(o*r+a)),d=u>0?r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l);else d=o>0?-r:r,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(Xa).addScaledVector(Sr,d),f}intersectSphere(e,t){if(e.radius<0)return null;Wn.subVectors(e.center,this.origin);let n=Wn.dot(this.direction),s=Wn.dot(Wn)-n*n,r=e.radius*e.radius;if(s>r)return null;let o=Math.sqrt(r-s),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){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,o,a,c,l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,s=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,s=(e.min.x-d.x)*l),h>=0?(r=(e.min.y-d.y)*h,o=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,o=(e.min.y-d.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o<s||isNaN(s))&&(s=o),u>=0?(a=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(a=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),n>c||a>s)||((a>n||n!==n)&&(n=a),(c<s||s!==s)&&(s=c),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Wn)!==null}intersectTriangle(e,t,n,s,r){let o=this.origin,a=this.direction,c=a.x,l=a.y,h=a.z,u=e.x-o.x,d=e.y-o.y,f=e.z-o.z,_=t.x-o.x,x=t.y-o.y,m=t.z-o.z,p=n.x-o.x,w=n.y-o.y,T=n.z-o.z,S=Math.abs(c),E=Math.abs(l),M=Math.abs(h),g,v,L,R,D,N,B,C,W,Z,z,ee;if(S>=E&&S>=M?(L=c,N=u,W=_,ee=p,c>=0?(g=l,v=h,R=d,D=f,B=x,C=m,Z=w,z=T):(g=h,v=l,R=f,D=d,B=m,C=x,Z=T,z=w)):E>=M?(L=l,N=d,W=x,ee=w,l>=0?(g=h,v=c,R=f,D=u,B=m,C=_,Z=T,z=p):(g=c,v=h,R=u,D=f,B=_,C=m,Z=p,z=T)):(L=h,N=f,W=m,ee=T,h>=0?(g=c,v=l,R=u,D=d,B=_,C=x,Z=p,z=w):(g=l,v=c,R=d,D=u,B=x,C=_,Z=w,z=p)),L===0)return null;let q=g/L,J=v/L,O=1/L,ae=R-q*N,xe=D-J*N,H=B-q*W,ue=C-J*W,de=Z-q*ee,we=z-J*ee,fe=de*ue-we*H,Te=ae*we-xe*de,He=H*xe-ue*ae;if(s){if(fe<0||Te<0||He<0)return null}else if((fe<0||Te<0||He<0)&&(fe>0||Te>0||He>0))return null;let me=fe+Te+He;if(me===0)return null;let Ie=O*(fe*N+Te*W+He*ee);return(me>0?Ie<0:Ie>0)?null:this.at(Ie/me,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)}},ss=class extends $n{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ye(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=wo,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}},Dc=new mt,Ei=new Ri,Er=new Ai,Nc=new k,Tr=new k,Ar=new k,Rr=new k,qa=new k,Cr=new k,Uc=new k,Pr=new k,Qt=class extends Ut{constructor(e=new $t,t=new ss){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,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(s,e);let a=this.morphTargetInfluences;if(r&&a){Cr.set(0,0,0);for(let c=0,l=r.length;c<l;c++){let h=a[c],u=r[c];h!==0&&(qa.fromBufferAttribute(u,e),o?Cr.addScaledVector(qa,h):Cr.addScaledVector(qa.sub(t),h))}t.add(Cr)}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(),Er.copy(n.boundingSphere),Er.applyMatrix4(r),Ei.copy(e.ray).recast(e.near),!(Er.containsPoint(Ei.origin)===!1&&(Ei.intersectSphere(Er,Nc)===null||Ei.origin.distanceToSquared(Nc)>(e.far-e.near)**2))&&(Dc.copy(r).invert(),Ei.copy(e.ray).applyMatrix4(Dc),!(n.boundingBox!==null&&Ei.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Ei)))}_computeIntersections(e,t,n){let s,r=this.geometry,o=this.material,a=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let _=0,x=d.length;_<x;_++){let m=d[_],p=o[m.materialIndex],w=Math.max(m.start,f.start),T=Math.min(a.count,Math.min(m.start+m.count,f.start+f.count));for(let S=w,E=T;S<E;S+=3){let M=a.getX(S),g=a.getX(S+1),v=a.getX(S+2);s=Ir(this,p,e,n,l,h,u,M,g,v),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{let _=Math.max(0,f.start),x=Math.min(a.count,f.start+f.count);for(let m=_,p=x;m<p;m+=3){let w=a.getX(m),T=a.getX(m+1),S=a.getX(m+2);s=Ir(this,o,e,n,l,h,u,w,T,S),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}else if(c!==void 0)if(Array.isArray(o))for(let _=0,x=d.length;_<x;_++){let m=d[_],p=o[m.materialIndex],w=Math.max(m.start,f.start),T=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let S=w,E=T;S<E;S+=3){let M=S,g=S+1,v=S+2;s=Ir(this,p,e,n,l,h,u,M,g,v),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{let _=Math.max(0,f.start),x=Math.min(c.count,f.start+f.count);for(let m=_,p=x;m<p;m+=3){let w=m,T=m+1,S=m+2;s=Ir(this,o,e,n,l,h,u,w,T,S),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}};function Fd(i,e,t,n,s,r,o,a){let c;if(e.side===Jt?c=n.intersectTriangle(o,r,s,!0,a):c=n.intersectTriangle(s,r,o,e.side===gi,a),c===null)return null;Pr.copy(a),Pr.applyMatrix4(i.matrixWorld);let l=t.ray.origin.distanceTo(Pr);return l<t.near||l>t.far?null:{distance:l,point:Pr.clone(),object:i}}function Ir(i,e,t,n,s,r,o,a,c,l){i.getVertexPosition(a,Tr),i.getVertexPosition(c,Ar),i.getVertexPosition(l,Rr);let h=Fd(i,e,t,n,Tr,Ar,Rr,Uc);if(h){let u=new k;Xn.getBarycoord(Uc,Tr,Ar,Rr,u),s&&(h.uv=Xn.getInterpolatedAttribute(s,a,c,l,u,new Ve)),r&&(h.uv1=Xn.getInterpolatedAttribute(r,a,c,l,u,new Ve)),o&&(h.normal=Xn.getInterpolatedAttribute(o,a,c,l,u,new k),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let d={a,b:c,c:l,normal:new k,materialIndex:0};Xn.getNormal(Tr,Ar,Rr,d.normal),h.face=d,h.barycoord=u}return h}var no=class extends jt{constructor(e=null,t=1,n=1,s,r,o,a,c,l=Pt,h=Pt,u,d){super(null,o,a,c,l,h,s,r,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Ti=new Ai,Od=new Ve(.5,.5),Lr=new k,hi=class{constructor(e=new an,t=new an,n=new an,s=new an,r=new an,o=new an){this.planes=[e,t,n,s,r,o]}set(e,t,n,s,r,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(s),a[4].copy(r),a[5].copy(o),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=gn,n=!1){let s=this.planes,r=e.elements,o=r[0],a=r[1],c=r[2],l=r[3],h=r[4],u=r[5],d=r[6],f=r[7],_=r[8],x=r[9],m=r[10],p=r[11],w=r[12],T=r[13],S=r[14],E=r[15];if(s[0].setComponents(l-o,f-h,p-_,E-w).normalize(),s[1].setComponents(l+o,f+h,p+_,E+w).normalize(),s[2].setComponents(l+a,f+u,p+x,E+T).normalize(),s[3].setComponents(l-a,f-u,p-x,E-T).normalize(),n)s[4].setComponents(c,d,m,S).normalize(),s[5].setComponents(l-c,f-d,p-m,E-S).normalize();else if(s[4].setComponents(l-c,f-d,p-m,E-S).normalize(),t===gn)s[5].setComponents(l+c,f+d,p+m,E+S).normalize();else if(t===Qi)s[5].setComponents(c,d,m,S).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(),Ti.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ti.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ti)}intersectsSprite(e){Ti.center.set(0,0,0);let t=Od.distanceTo(e.center);return Ti.radius=.7071067811865476+t,Ti.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ti)}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(Lr.x=s.normal.x>0?e.max.x:e.min.x,Lr.y=s.normal.y>0?e.max.y:e.min.y,Lr.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Lr)<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)}},Fc=new mt,io=class i{constructor(){this.coordinateSystem=gn,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];Fc.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),n[s]===void 0&&(n[s]=new hi),n[s].setFromProjectionMatrix(Fc,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 hi),t[s].copy(n[s]);return this._count=e._count,this}clone(){return new i().copy(this)}};var Ci=class extends $n{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ye(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}},so=new k,ro=new k,Oc=new mt,Ts=new Ri,Dr=new Ai,Ya=new k,Bc=new k,oo=class extends Ut{constructor(e=new $t,t=new Ci){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++)so.fromBufferAttribute(t,s-1),ro.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=so.distanceTo(ro);e.setAttribute("lineDistance",new Yt(n,1))}else Fe("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,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Dr.copy(n.boundingSphere),Dr.applyMatrix4(s),Dr.radius+=r,e.ray.intersectsSphere(Dr)===!1)return;Oc.copy(s).invert(),Ts.copy(e.ray).applyMatrix4(Oc);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){let f=Math.max(0,o.start),_=Math.min(h.count,o.start+o.count);for(let x=f,m=_-1;x<m;x+=l){let p=h.getX(x),w=h.getX(x+1),T=Nr(this,e,Ts,c,p,w,x);T&&t.push(T)}if(this.isLineLoop){let x=h.getX(_-1),m=h.getX(f),p=Nr(this,e,Ts,c,x,m,_-1);p&&t.push(p)}}else{let f=Math.max(0,o.start),_=Math.min(d.count,o.start+o.count);for(let x=f,m=_-1;x<m;x+=l){let p=Nr(this,e,Ts,c,x,x+1,x);p&&t.push(p)}if(this.isLineLoop){let x=Nr(this,e,Ts,c,_-1,f,_-1);x&&t.push(x)}}}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,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function Nr(i,e,t,n,s,r,o){let a=i.geometry.attributes.position;if(so.fromBufferAttribute(a,s),ro.fromBufferAttribute(a,r),t.distanceSqToSegment(so,ro,Ya,Bc)>n)return;Ya.applyMatrix4(i.matrixWorld);let l=e.ray.origin.distanceTo(Ya);if(!(l<e.near||l>e.far))return{distance:l,point:Bc.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var zc=new k,kc=new k,rs=class extends oo{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)zc.fromBufferAttribute(t,s),kc.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+zc.distanceTo(kc);e.setAttribute("lineDistance",new Yt(n,1))}else Fe("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Bs=class extends jt{constructor(e=[],t=Di,n,s,r,o,a,c,l,h){super(e,t,n,s,r,o,a,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};var Jn=class extends jt{constructor(e,t,n=wn,s,r,o,a=Pt,c=Pt,l,h=Yn,u=1){if(h!==Yn&&h!==jn)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:u};super(d,s,r,o,a,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 ns(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},zs=class extends Jn{constructor(e,t=wn,n=Di,s,r,o=Pt,a=Pt,c,l=Yn){let h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,n,s,r,o,a,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},ks=class extends jt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},os=class i extends $t{constructor(e=1,t=1,n=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:o};let a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);let c=[],l=[],h=[],u=[],d=0,f=0;_("z","y","x",-1,-1,n,t,e,o,r,0),_("z","y","x",1,-1,n,t,-e,o,r,1),_("x","z","y",1,1,e,n,t,s,o,2),_("x","z","y",1,-1,e,n,-t,s,o,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 Yt(l,3)),this.setAttribute("normal",new Yt(h,3)),this.setAttribute("uv",new Yt(u,2));function _(x,m,p,w,T,S,E,M,g,v,L){let R=S/g,D=E/v,N=S/2,B=E/2,C=M/2,W=g+1,Z=v+1,z=0,ee=0,q=new k;for(let J=0;J<Z;J++){let O=J*D-B;for(let ae=0;ae<W;ae++){let xe=ae*R-N;q[x]=xe*w,q[m]=O*T,q[p]=C,l.push(q.x,q.y,q.z),q[x]=0,q[m]=0,q[p]=M>0?1:-1,h.push(q.x,q.y,q.z),u.push(ae/g),u.push(1-J/v),z+=1}}for(let J=0;J<v;J++)for(let O=0;O<g;O++){let ae=d+O+W*J,xe=d+O+W*(J+1),H=d+(O+1)+W*(J+1),ue=d+(O+1)+W*J;c.push(ae,xe,ue),c.push(xe,H,ue),ee+=6}a.addGroup(f,ee,L),f+=ee,d+=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 Ur=new k,Fr=new k,Za=new k,Or=new Xn,Vs=class extends $t{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(Ji*t),o=e.getIndex(),a=e.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],h=["a","b","c"],u=new Array(3),d=new Map,f=[];for(let _=0;_<c;_+=3){o?(l[0]=o.getX(_),l[1]=o.getX(_+1),l[2]=o.getX(_+2)):(l[0]=_,l[1]=_+1,l[2]=_+2);let{a:x,b:m,c:p}=Or;if(x.fromBufferAttribute(a,l[0]),m.fromBufferAttribute(a,l[1]),p.fromBufferAttribute(a,l[2]),Or.getNormal(Za),u[0]=`${Math.round(x.x*s)},${Math.round(x.y*s)},${Math.round(x.z*s)}`,u[1]=`${Math.round(m.x*s)},${Math.round(m.y*s)},${Math.round(m.z*s)}`,u[2]=`${Math.round(p.x*s)},${Math.round(p.y*s)},${Math.round(p.z*s)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let w=0;w<3;w++){let T=(w+1)%3,S=u[w],E=u[T],M=Or[h[w]],g=Or[h[T]],v=`${S}_${E}`,L=`${E}_${S}`,R=d.get(L);R?(Za.dot(R.normal)<=r&&(f.push(M.x,M.y,M.z),f.push(g.x,g.y,g.z)),d.set(L,null)):d.has(v)||d.set(v,{index0:l[w],index1:l[T],normal:Za.clone()})}}for(let _ of d.values())if(_){let{index0:x,index1:m}=_;Ur.fromBufferAttribute(a,x),Fr.fromBufferAttribute(a,m),f.push(Ur.x,Ur.y,Ur.z),f.push(Fr.x,Fr.y,Fr.z)}this.setAttribute("position",new Yt(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};var Gs=class i extends $t{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,o=t/2,a=Math.floor(n),c=Math.floor(s),l=a+1,h=c+1,u=e/a,d=t/c,f=[],_=[],x=[],m=[];for(let p=0;p<h;p++){let w=p*d-o;for(let T=0;T<l;T++){let S=T*u-r;_.push(S,-w,0),x.push(0,0,1),m.push(T/a),m.push(1-p/c)}}for(let p=0;p<c;p++)for(let w=0;w<a;w++){let T=w+l*p,S=w+l*(p+1),E=w+1+l*(p+1),M=w+1+l*p;f.push(T,S,M),f.push(S,E,M)}this.setIndex(f),this.setAttribute("position",new Yt(_,3)),this.setAttribute("normal",new Yt(x,3)),this.setAttribute("uv",new Yt(m,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 Ui(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let s=i[t][n];if(Vc(s))s.isRenderTargetTexture?(Fe("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(Vc(s[0])){let r=[];for(let o=0,a=s.length;o<a;o++)r[o]=s[o].clone();e[t][n]=r}else e[t][n]=s.slice();else e[t][n]=s}}return e}function Gt(i){let e={};for(let t=0;t<i.length;t++){let n=Ui(i[t]);for(let s in n)e[s]=n[s]}return e}function Vc(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function Bd(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Ll(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:et.workingColorSpace}var Nh={clone:Ui,merge:Gt},zd=`void main() {
|
|
2
2
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
|
-
}`,
|
|
3
|
+
}`,kd=`void main() {
|
|
4
4
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
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
|
|
5
|
+
}`,In=class extends $n{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=zd,this.fragmentShader=kd,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=Ui(e.uniforms),this.uniformsGroups=Bd(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 o=this.uniforms[s].value;o&&o.isTexture?t.uniforms[s]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[s]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[s]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[s]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[s]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[s]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[s]={type:"m4",value:o.toArray()}:t.uniforms[s]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;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 Ye().setHex(s.value);break;case"v2":this.uniforms[n].value=new Ve().fromArray(s.value);break;case"v3":this.uniforms[n].value=new k().fromArray(s.value);break;case"v4":this.uniforms[n].value=new _t().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Ge().fromArray(s.value);break;case"m4":this.uniforms[n].value=new mt().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}},ao=class extends In{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var as=class extends $n{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ye(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ha,this.normalScale=new Ve(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=wo,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}},lo=class extends $n{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=xh,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}},co=class extends $n{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 Yi(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function Br(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}var ui=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 o;t:{i:if(!(e<s)){for(let a=n+2;;){if(s===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=s,s=t[++n],e<s)break e}o=t.length;break t}if(!(e>=r)){let a=t[1];e<a&&(n=2,r=a);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(s=r,r=t[--n-1],e>=r)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+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 o=0;o!==s;++o)t[o]=n[r+o];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}},ho=class extends ui{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:Ka,endingEnd:Ka}}intervalChanged_(e,t,n){let s=this.parameterPositions,r=e-2,o=e+1,a=s[r],c=s[o];if(a===void 0)switch(this.getSettings_().endingStart){case ja:r=e,a=2*t-n;break;case Qa:r=s.length-2,a=t+s[r]-s[r+1];break;default:r=e,a=n}if(c===void 0)switch(this.getSettings_().endingEnd){case ja:o=e,c=2*n-t;break;case Qa:o=1,c=n+s[1]-s[0];break;default:o=e-1,c=t}let l=(n-t)*.5,h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=o*h}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,_=(n-t)/(s-t),x=_*_,m=x*_,p=-d*m+2*d*x-d*_,w=(1+d)*m+(-1.5-2*d)*x+(-.5+d)*_+1,T=(-1-f)*m+(1.5+f)*x+.5*_,S=f*m-f*x;for(let E=0;E!==a;++E)r[E]=p*o[h+E]+w*o[l+E]+T*o[c+E]+S*o[u+E];return r}},uo=class extends ui{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=(n-t)/(s-t),u=1-h;for(let d=0;d!==a;++d)r[d]=o[l+d]*u+o[c+d]*h;return r}},fo=class extends ui{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}},po=class extends ui{interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=this.inTangents,u=this.outTangents;if(!h||!u){let _=(n-t)/(s-t),x=1-_;for(let m=0;m!==a;++m)r[m]=o[l+m]*x+o[c+m]*_;return r}let d=a*2,f=e-1;for(let _=0;_!==a;++_){let x=o[l+_],m=o[c+_],p=f*d+_*2,w=u[p],T=u[p+1],S=e*d+_*2,E=h[S],M=h[S+1],g=Gd(n,t,w,E,s);r[_]=Uh(g,x,T,M,m)}return r}};function Uh(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 Vd(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 Gd(i,e,t,n,s){let r=(i-e)/(s-e);for(let o=0;o<8;o++){let a=Uh(r,e,t,n,s)-i;if(Math.abs(a)<1e-10)break;let c=Vd(r,e,t,n,s);if(Math.abs(c)<1e-10)break;r=Math.max(0,Math.min(1,r-a/c))}return r}var hn=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=Yi(t,this.TimeBufferType),this.values=Yi(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:Yi(e.times,Array),values:Yi(e.values,Array)};let s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s),Br(e.settings)&&(n.settings={inTangents:Yi(e.settings.inTangents,Array),outTangents:Yi(e.settings.outTangents,Array)})}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new fo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new uo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ho(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new po(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 Cs:t=this.InterpolantFactoryMethodDiscrete;break;case jr:t=this.InterpolantFactoryMethodLinear;break;case Vr:t=this.InterpolantFactoryMethodSmooth;break;case Ja: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 Fe("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Cs;case this.InterpolantFactoryMethodLinear:return jr;case this.InterpolantFactoryMethodSmooth:return Vr;case this.InterpolantFactoryMethodBezier:return Ja}}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;Br(this.settings)&&(Gc(this.settings.inTangents,e),Gc(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;Br(this.settings)&&(Hc(this.settings.inTangents,e),Hc(this.settings.outTangents,e))}return this}trim(e,t){let n=this.times,s=n.length,r=0,o=s-1;for(;r!==s&&n[r]<e;)++r;for(;o!==-1&&n[o]>t;)--o;if(++o,r!==0||o!==s){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(ke("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(ke("KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){let c=n[a];if(typeof c=="number"&&isNaN(c)){ke("KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){ke("KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(s!==void 0&&sd(s))for(let a=0,c=s.length;a!==c;++a){let l=s[a];if(isNaN(l)){ke("KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===Vr,r=e.length-1,o=1;for(let a=1;a<r;++a){let c=!1,l=e[a],h=e[a+1];if(l!==h&&(a!==1||l!==e[0]))if(s)c=!0;else{let u=a*n,d=u-n,f=u+n;for(let _=0;_!==n;++_){let x=t[u+_];if(x!==t[d+_]||x!==t[f+_]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];let u=a*n,d=o*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++o}}if(r>0){e[o]=e[r];for(let a=r*n,c=o*n,l=0;l!==n;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,Br(this.settings)&&(s.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),s}};function Gc(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]+=e}function Hc(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]*=e}hn.prototype.ValueTypeName="";hn.prototype.TimeBufferType=Float32Array;hn.prototype.ValueBufferType=Float32Array;hn.prototype.DefaultInterpolation=jr;var di=class extends hn{constructor(e,t,n){super(e,t,n)}};di.prototype.ValueTypeName="bool";di.prototype.ValueBufferType=Array;di.prototype.DefaultInterpolation=Cs;di.prototype.InterpolantFactoryMethodLinear=void 0;di.prototype.InterpolantFactoryMethodSmooth=void 0;var mo=class extends hn{constructor(e,t,n,s){super(e,t,n,s)}};mo.prototype.ValueTypeName="color";var go=class extends hn{constructor(e,t,n,s){super(e,t,n,s)}};go.prototype.ValueTypeName="number";var _o=class extends ui{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(n-t)/(s-t),l=e*a;for(let h=l+a;l!==h;l+=4)ln.slerpFlat(r,0,o,l-a,o,l,c);return r}},Hs=class extends hn{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new _o(this.times,this.values,this.getValueSize(),e)}};Hs.prototype.ValueTypeName="quaternion";Hs.prototype.InterpolantFactoryMethodSmooth=void 0;var fi=class extends hn{constructor(e,t,n){super(e,t,n)}};fi.prototype.ValueTypeName="string";fi.prototype.ValueBufferType=Array;fi.prototype.DefaultInterpolation=Cs;fi.prototype.InterpolantFactoryMethodLinear=void 0;fi.prototype.InterpolantFactoryMethodSmooth=void 0;var xo=class extends hn{constructor(e,t,n,s){super(e,t,n,s)}};xo.prototype.ValueTypeName="vector";var yo=class{constructor(e,t,n){let s=this,r=!1,o=0,a=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){a++,r===!1&&s.onStart!==void 0&&s.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,s.onProgress!==void 0&&s.onProgress(h,o,a),o===a&&(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,u){return l.push(h,u),this},this.removeHandler=function(h){let u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){let f=l[u],_=l[u+1];if(f.global&&(f.lastIndex=0),f.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}},Fh=new yo,vo=class{constructor(e){this.manager=e!==void 0?e:Fh,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}};vo.DEFAULT_MATERIAL_NAME="__DEFAULT";var Ws=class extends Ut{static registerNode(e){this.prototype._lightNode=e}constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ye(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}},Xs=class extends Ws{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ut.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ye(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}},$a=new mt,Wc=new k,Xc=new k,bo=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 Ve(512,512),this.mapType=en,this.map=null,this.mapPass=null,this.matrix=new mt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new hi,this._frameExtents=new Ve(1,1),this._viewportCount=1,this._viewports=[new _t(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;Wc.setFromMatrixPosition(e.matrixWorld),t.position.copy(Wc),Xc.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Xc),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,s){$a.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix($a,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,o=s?s.z/r.x:1,a=s?s.w/r.y:1,c=s?s.x/r.x:0,l=s?s.y/r.y:0;e.coordinateSystem===Qi||e.reversedDepth?t.set(.5*o,0,0,.5*o+c,0,.5*a,0,.5*a+l,0,0,1,0,0,0,0,1):t.set(.5*o,0,0,.5*o+c,0,.5*a,0,.5*a+l,0,0,.5,.5,0,0,0,1),t.multiply($a)}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}},zr=new k,kr=new ln,Rn=new k,qs=class extends Ut{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new mt,this.projectionMatrix=new mt,this.projectionMatrixInverse=new mt,this.coordinateSystem=gn,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(zr,kr,Rn),Rn.x===1&&Rn.y===1&&Rn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(zr,kr,Rn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(zr,kr,Rn),Rn.x===1&&Rn.y===1&&Rn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(zr,kr,Rn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},li=new k,qc=new Ve,Yc=new Ve,qt=class extends qs{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=ts*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Ji*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ts*2*Math.atan(Math.tan(Ji*.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){li.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(li.x,li.y).multiplyScalar(-e/li.z),li.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(li.x,li.y).multiplyScalar(-e/li.z)}getViewSize(e,t){return this.getViewBounds(e,qc,Yc),t.subVectors(Yc,qc)}setViewOffset(e,t,n,s,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Ji*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s,o=this.view;if(this.view!==null&&this.view.enabled){let c=o.fullWidth,l=o.fullHeight;r+=o.offsetX*s/c,t-=o.offsetY*n/l,s*=o.width/c,n*=o.height/l}let a=this.filmOffset;a!==0&&(r+=e*a/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 Pi=class extends qs{constructor(e=-1,t=1,n=1,s=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=o,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,o=n+e,a=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,o=r+l*this.view.width,a-=h*this.view.offsetY,c=a-h*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){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}},el=class extends bo{constructor(){super(new Pi(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},ls=class extends Ws{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ut.DEFAULT_UP),this.updateMatrix(),this.target=new Ut,this.shadow=new el}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 Zi=-90,$i=1,cs=class extends Ut{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new qt(Zi,$i,e,t);s.layers=this.layers,this.add(s);let r=new qt(Zi,$i,e,t);r.layers=this.layers,this.add(r);let o=new qt(Zi,$i,e,t);o.layers=this.layers,this.add(o);let a=new qt(Zi,$i,e,t);a.layers=this.layers,this.add(a);let c=new qt(Zi,$i,e,t);c.layers=this.layers,this.add(c);let l=new qt(Zi,$i,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,s,r,o,a,c]=t;for(let l of t)this.remove(l);if(e===gn)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),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Qi)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),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(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,o,a,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;let x=n.texture.mipmapsAutoUpdate;n.texture.mipmapsAutoUpdate=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.mipmapsAutoUpdate=x,e.setRenderTarget(n,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(u,d,f),e.xr.enabled=_,n.texture.needsPMREMUpdate=!0}},Mo=class extends qt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e,this.perCameraFrustumCulled=!1}};var Dl="\\[\\]\\.:\\/",Hd=new RegExp("["+Dl+"]","g"),Nl="[^"+Dl+"]",Wd="[^"+Dl.replace("\\.","")+"]",Xd=/((?:WC+[\/:])*)/.source.replace("WC",Nl),qd=/(WCOD+)?/.source.replace("WCOD",Wd),Yd=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Nl),Zd=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Nl),$d=new RegExp("^"+Xd+qd+Yd+Zd+"$"),Jd=["material","materials","bones","map"],tl=class{constructor(e,t,n){let s=n||pt.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()}},pt=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(Hd,"")}static parseTrackName(e){let t=$d.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);Jd.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 o=0;o<r.length;o++){let a=r[o];if(a.name===t||a.uuid===t)return a;let c=n(a.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){Fe("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ke("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){ke("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){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ke("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){ke("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){ke("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let o=e[s];if(o===void 0){let l=t.nodeName;ke("PropertyBinding: Trying to update property for track: "+l+"."+s+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?a=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!e.geometry){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=s;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};pt.Composite=tl;pt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};pt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};pt.prototype.GetterByBindingType=[pt.prototype._getValue_direct,pt.prototype._getValue_array,pt.prototype._getValue_arrayElement,pt.prototype._getValue_toArray];pt.prototype.SetterByBindingTypeAndVersioning=[[pt.prototype._setValue_direct,pt.prototype._setValue_direct_setNeedsUpdate,pt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_array,pt.prototype._setValue_array_setNeedsUpdate,pt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_arrayElement,pt.prototype._setValue_arrayElement_setNeedsUpdate,pt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_fromArray,pt.prototype._setValue_fromArray_setNeedsUpdate,pt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var T_=new Float32Array(1);var hs=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=Je(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(Je(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var kl=class kl{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}};kl.prototype.isMatrix2=!0;var nl=kl;var Ys=class extends Sn{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 Ul(i,e,t,n){let s=Kd(n);switch(t){case vl:return i*e;case Ml:return i*e/s.components*s.byteLength;case Io:return i*e/s.components*s.byteLength;case _i:return i*e*2/s.components*s.byteLength;case Lo:return i*e*2/s.components*s.byteLength;case bl:return i*e*3/s.components*s.byteLength;case An:return i*e*4/s.components*s.byteLength;case Do:return i*e*4/s.components*s.byteLength;case Ks:case js:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Qs:case er:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Uo:case Oo:return Math.max(i,16)*Math.max(e,8)/4;case No:case Fo:return Math.max(i,8)*Math.max(e,8)/2;case Bo:case zo:case Vo:case Go:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ko:case tr:case Ho:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Wo:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Xo:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case qo:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Yo:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Zo:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case $o:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Jo:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Ko:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case jo:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Qo:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case ea:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case ta:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case na:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case ia:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case sa:case ra:case oa:return Math.ceil(i/4)*Math.ceil(e/4)*16;case aa:case la:return Math.ceil(i/4)*Math.ceil(e/4)*8;case nr:case ca:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Kd(i){switch(i){case en:case gl:return{byteLength:1,components:1};case ps:case _l:case Tn:return{byteLength:2,components:1};case Co:case Po:return{byteLength:2,components:4};case wn:case Ro:case En:return{byteLength:4,components:1};case xl:case yl: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__?Fe("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="187");function su(){let i=null,e=!1,t=null,n=null;function s(r,o){n=i.requestAnimationFrame(s),t(r,o)}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 Qd(i){let e=new WeakMap;function t(a,c){let l=a.array,h=a.usage,u=l.byteLength,d=i.createBuffer();i.bindBuffer(c,d),i.bufferData(c,l,h),a.onUploadCallback();let f;if(l instanceof Float32Array)f=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)f=i.HALF_FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=i.SHORT;else if(l instanceof Uint32Array)f=i.UNSIGNED_INT;else if(l instanceof Int32Array)f=i.INT;else if(l instanceof Int8Array)f=i.BYTE;else if(l instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:u}}function n(a,c,l){let h=c.array,u=c.updateRanges;if(i.bindBuffer(l,a),u.length===0)i.bufferSubData(l,0,h);else{u.sort((f,_)=>f.start-_.start);let d=0;for(let f=1;f<u.length;f++){let _=u[d],x=u[f];x.start<=_.start+_.count+1?_.count=Math.max(_.count,x.start+x.count-_.start):(++d,u[d]=x)}u.length=d+1;for(let f=0,_=u.length;f<_;f++){let x=u[f];i.bufferSubData(l,x.start*h.BYTES_PER_ELEMENT,h,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function s(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);let c=e.get(a);c&&(i.deleteBuffer(c.buffer),e.delete(a))}function o(a,c){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){let h=e.get(a);(!h||h.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=e.get(a);if(l===void 0)e.set(a,t(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,a,c),l.version=a.version}}return{get:s,remove:r,update:o}}var ef=`#ifdef USE_ALPHAHASH
|
|
6
6
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
7
|
-
#endif`,
|
|
7
|
+
#endif`,tf=`#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`,nf=`#ifdef USE_ALPHAMAP
|
|
43
43
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
44
|
-
#endif`,
|
|
44
|
+
#endif`,sf=`#ifdef USE_ALPHAMAP
|
|
45
45
|
uniform sampler2D alphaMap;
|
|
46
|
-
#endif`,
|
|
46
|
+
#endif`,rf=`#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`,of=`#ifdef USE_ALPHATEST
|
|
54
54
|
uniform float alphaTest;
|
|
55
|
-
#endif`,
|
|
55
|
+
#endif`,af=`#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`,lf=`#ifdef USE_AOMAP
|
|
69
69
|
uniform sampler2D aoMap;
|
|
70
70
|
uniform float aoMapIntensity;
|
|
71
|
-
#endif`,
|
|
71
|
+
#endif`,cf=`#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`,hf=`#ifdef USE_BATCHING
|
|
106
106
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
107
|
-
#endif`,
|
|
107
|
+
#endif`,uf=`vec3 transformed = vec3( position );
|
|
108
108
|
#ifdef USE_ALPHAHASH
|
|
109
109
|
vPosition = vec3( position );
|
|
110
|
-
#endif`,
|
|
110
|
+
#endif`,df=`vec3 objectNormal = vec3( normal );
|
|
111
111
|
#ifdef USE_TANGENT
|
|
112
112
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
113
|
-
#endif`,
|
|
113
|
+
#endif`,ff=`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`,pf=`#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`,mf=`#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`,gf=`#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`,_f=`#if NUM_CLIPPING_PLANES > 0
|
|
258
258
|
varying vec3 vClipPosition;
|
|
259
259
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
260
|
-
#endif`,
|
|
260
|
+
#endif`,xf=`#if NUM_CLIPPING_PLANES > 0
|
|
261
261
|
varying vec3 vClipPosition;
|
|
262
|
-
#endif`,
|
|
262
|
+
#endif`,yf=`#if NUM_CLIPPING_PLANES > 0
|
|
263
263
|
vClipPosition = - mvPosition.xyz;
|
|
264
|
-
#endif
|
|
264
|
+
#endif`,vf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
265
265
|
diffuseColor *= vColor;
|
|
266
|
-
#endif`,
|
|
266
|
+
#endif`,bf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
267
267
|
varying vec4 vColor;
|
|
268
|
-
#endif`,
|
|
268
|
+
#endif`,Mf=`#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`,Sf=`#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`,wf=`#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,7 +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`,
|
|
354
|
+
} // validated`,Ef=`vec3 transformedNormal = objectNormal;
|
|
355
355
|
#ifdef USE_TANGENT
|
|
356
356
|
vec3 transformedTangent = objectTangent;
|
|
357
357
|
#endif
|
|
@@ -377,21 +377,21 @@ transformedNormal = normalMatrix * transformedNormal;
|
|
|
377
377
|
#endif
|
|
378
378
|
#ifdef USE_TANGENT
|
|
379
379
|
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
380
|
-
#endif`,
|
|
380
|
+
#endif`,Tf=`#ifdef USE_DISPLACEMENTMAP
|
|
381
381
|
uniform sampler2D displacementMap;
|
|
382
382
|
uniform float displacementScale;
|
|
383
383
|
uniform float displacementBias;
|
|
384
|
-
#endif`,
|
|
384
|
+
#endif`,Af=`#ifdef USE_DISPLACEMENTMAP
|
|
385
385
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
386
|
-
#endif`,
|
|
386
|
+
#endif`,Rf=`#ifdef USE_EMISSIVEMAP
|
|
387
387
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
388
388
|
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
389
389
|
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
390
390
|
#endif
|
|
391
391
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
392
|
-
#endif`,
|
|
392
|
+
#endif`,Cf=`#ifdef USE_EMISSIVEMAP
|
|
393
393
|
uniform sampler2D emissiveMap;
|
|
394
|
-
#endif`,
|
|
394
|
+
#endif`,Pf="gl_FragColor = linearToOutputTexel( gl_FragColor );",If=`vec4 LinearTransferOETF( in vec4 value ) {
|
|
395
395
|
return value;
|
|
396
396
|
}
|
|
397
397
|
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
@@ -399,7 +399,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
|
399
399
|
}
|
|
400
400
|
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
401
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 );
|
|
402
|
-
}`,
|
|
402
|
+
}`,Lf=`#ifdef USE_ENVMAP
|
|
403
403
|
#ifdef ENV_WORLDPOS
|
|
404
404
|
vec3 cameraToFrag;
|
|
405
405
|
if ( isOrthographic ) {
|
|
@@ -426,7 +426,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
426
426
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
427
427
|
#endif
|
|
428
428
|
#endif
|
|
429
|
-
#endif`,
|
|
429
|
+
#endif`,Df=`#ifdef USE_ENVMAP
|
|
430
430
|
uniform float envMapIntensity;
|
|
431
431
|
uniform mat3 envMapRotation;
|
|
432
432
|
uniform samplerCube envMap;
|
|
@@ -436,7 +436,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
436
436
|
return ENVMAP_MAX_LOD * r * ( 2.0 - r );
|
|
437
437
|
}
|
|
438
438
|
#endif
|
|
439
|
-
#endif`,
|
|
439
|
+
#endif`,Nf=`#ifdef USE_ENVMAP
|
|
440
440
|
uniform float reflectivity;
|
|
441
441
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
442
442
|
#define ENV_WORLDPOS
|
|
@@ -447,7 +447,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
447
447
|
#else
|
|
448
448
|
varying vec3 vReflect;
|
|
449
449
|
#endif
|
|
450
|
-
#endif`,
|
|
450
|
+
#endif`,Uf=`#ifdef USE_ENVMAP
|
|
451
451
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
452
452
|
#define ENV_WORLDPOS
|
|
453
453
|
#endif
|
|
@@ -458,7 +458,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
458
458
|
varying vec3 vReflect;
|
|
459
459
|
uniform float refractionRatio;
|
|
460
460
|
#endif
|
|
461
|
-
#endif`,
|
|
461
|
+
#endif`,Ff=`#ifdef USE_ENVMAP
|
|
462
462
|
#ifdef ENV_WORLDPOS
|
|
463
463
|
vWorldPosition = worldPosition.xyz;
|
|
464
464
|
#else
|
|
@@ -475,18 +475,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
475
475
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
476
476
|
#endif
|
|
477
477
|
#endif
|
|
478
|
-
#endif`,
|
|
478
|
+
#endif`,Of=`#ifdef USE_FOG
|
|
479
479
|
vFogDepth = - mvPosition.z;
|
|
480
|
-
#endif`,
|
|
480
|
+
#endif`,Bf=`#ifdef USE_FOG
|
|
481
481
|
varying float vFogDepth;
|
|
482
|
-
#endif`,
|
|
482
|
+
#endif`,zf=`#ifdef USE_FOG
|
|
483
483
|
#ifdef FOG_EXP2
|
|
484
484
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
485
485
|
#else
|
|
486
486
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
487
487
|
#endif
|
|
488
488
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
489
|
-
#endif`,
|
|
489
|
+
#endif`,kf=`#ifdef USE_FOG
|
|
490
490
|
uniform vec3 fogColor;
|
|
491
491
|
varying float vFogDepth;
|
|
492
492
|
#ifdef FOG_EXP2
|
|
@@ -495,7 +495,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
495
495
|
uniform float fogNear;
|
|
496
496
|
uniform float fogFar;
|
|
497
497
|
#endif
|
|
498
|
-
#endif`,
|
|
498
|
+
#endif`,Vf=`#ifdef USE_GRADIENTMAP
|
|
499
499
|
uniform sampler2D gradientMap;
|
|
500
500
|
#endif
|
|
501
501
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
@@ -507,12 +507,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
|
507
507
|
vec2 fw = fwidth( coord ) * 0.5;
|
|
508
508
|
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
509
509
|
#endif
|
|
510
|
-
}`,
|
|
510
|
+
}`,Gf=`#ifdef USE_LIGHTMAP
|
|
511
511
|
uniform sampler2D lightMap;
|
|
512
512
|
uniform float lightMapIntensity;
|
|
513
|
-
#endif`,
|
|
513
|
+
#endif`,Hf=`LambertMaterial material;
|
|
514
514
|
material.diffuseColor = diffuseColor.rgb;
|
|
515
|
-
material.specularStrength = specularStrength;`,
|
|
515
|
+
material.specularStrength = specularStrength;`,Wf=`varying vec3 vViewPosition;
|
|
516
516
|
struct LambertMaterial {
|
|
517
517
|
vec3 diffuseColor;
|
|
518
518
|
float specularStrength;
|
|
@@ -526,7 +526,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
|
|
|
526
526
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
527
527
|
}
|
|
528
528
|
#define RE_Direct RE_Direct_Lambert
|
|
529
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,
|
|
529
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Xf=`uniform bool receiveShadow;
|
|
530
530
|
uniform vec3 ambientLightColor;
|
|
531
531
|
#if defined( USE_LIGHT_PROBES )
|
|
532
532
|
uniform vec3 lightProbe[ 9 ];
|
|
@@ -655,7 +655,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
655
655
|
return irradiance;
|
|
656
656
|
}
|
|
657
657
|
#endif
|
|
658
|
-
#include <lightprobes_pars_fragment>`,
|
|
658
|
+
#include <lightprobes_pars_fragment>`,qf=`#ifdef USE_ENVMAP
|
|
659
659
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
660
660
|
#ifdef ENVMAP_TYPE_PMREM
|
|
661
661
|
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
|
|
@@ -712,8 +712,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
712
712
|
}
|
|
713
713
|
#endif
|
|
714
714
|
#endif
|
|
715
|
-
#endif`,
|
|
716
|
-
material.diffuseColor = diffuseColor.rgb;`,
|
|
715
|
+
#endif`,Yf=`ToonMaterial material;
|
|
716
|
+
material.diffuseColor = diffuseColor.rgb;`,Zf=`varying vec3 vViewPosition;
|
|
717
717
|
struct ToonMaterial {
|
|
718
718
|
vec3 diffuseColor;
|
|
719
719
|
};
|
|
@@ -725,11 +725,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
|
|
|
725
725
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
726
726
|
}
|
|
727
727
|
#define RE_Direct RE_Direct_Toon
|
|
728
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
|
|
728
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,$f=`BlinnPhongMaterial material;
|
|
729
729
|
material.diffuseColor = diffuseColor.rgb;
|
|
730
730
|
material.specularColor = specular;
|
|
731
731
|
material.specularShininess = shininess;
|
|
732
|
-
material.specularStrength = specularStrength;`,
|
|
732
|
+
material.specularStrength = specularStrength;`,Jf=`varying vec3 vViewPosition;
|
|
733
733
|
struct BlinnPhongMaterial {
|
|
734
734
|
vec3 diffuseColor;
|
|
735
735
|
vec3 specularColor;
|
|
@@ -746,7 +746,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
|
|
|
746
746
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
747
747
|
}
|
|
748
748
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
749
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,
|
|
749
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Kf=`PhysicalMaterial material;
|
|
750
750
|
material.diffuseColor = diffuseColor.rgb;
|
|
751
751
|
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
752
752
|
material.metalness = metalnessFactor;
|
|
@@ -847,7 +847,7 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
847
847
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
848
848
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
849
849
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
850
|
-
#endif`,
|
|
850
|
+
#endif`,jf=`uniform sampler2D dfgLUT;
|
|
851
851
|
struct PhysicalMaterial {
|
|
852
852
|
vec3 diffuseColor;
|
|
853
853
|
vec3 diffuseContribution;
|
|
@@ -1270,7 +1270,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
1270
1270
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
1271
1271
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
1272
1272
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
1273
|
-
}`,
|
|
1273
|
+
}`,Qf=`
|
|
1274
1274
|
vec3 geometryPosition = - vViewPosition;
|
|
1275
1275
|
vec3 geometryNormal = normal;
|
|
1276
1276
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
@@ -1428,7 +1428,7 @@ IncidentLight directLight;
|
|
|
1428
1428
|
#if defined( RE_IndirectSpecular )
|
|
1429
1429
|
vec3 radiance = vec3( 0.0 );
|
|
1430
1430
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
1431
|
-
#endif`,
|
|
1431
|
+
#endif`,ep=`#if defined( RE_IndirectDiffuse )
|
|
1432
1432
|
#ifdef USE_LIGHTMAP
|
|
1433
1433
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
1434
1434
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
@@ -1458,7 +1458,7 @@ IncidentLight directLight;
|
|
|
1458
1458
|
#ifdef USE_CLEARCOAT
|
|
1459
1459
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
1460
1460
|
#endif
|
|
1461
|
-
#endif`,
|
|
1461
|
+
#endif`,tp=`#if defined( RE_IndirectDiffuse )
|
|
1462
1462
|
#if defined( LAMBERT ) || defined( PHONG )
|
|
1463
1463
|
irradiance += iblIrradiance;
|
|
1464
1464
|
#endif
|
|
@@ -1466,7 +1466,7 @@ IncidentLight directLight;
|
|
|
1466
1466
|
#endif
|
|
1467
1467
|
#if defined( RE_IndirectSpecular )
|
|
1468
1468
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1469
|
-
#endif`,
|
|
1469
|
+
#endif`,np=`#if NUM_LIGHT_PROBE_GRIDS > 0
|
|
1470
1470
|
uniform highp sampler3D probesSH[ NUM_LIGHT_PROBE_GRIDS ];
|
|
1471
1471
|
uniform vec3 probesMin[ NUM_LIGHT_PROBE_GRIDS ];
|
|
1472
1472
|
uniform vec3 probesMax[ NUM_LIGHT_PROBE_GRIDS ];
|
|
@@ -1515,27 +1515,27 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3
|
|
|
1515
1515
|
result += c8 * 0.429043 * ( x * x - y * y );
|
|
1516
1516
|
return max( result, vec3( 0.0 ) );
|
|
1517
1517
|
}
|
|
1518
|
-
#endif`,
|
|
1518
|
+
#endif`,ip=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1519
1519
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
1520
|
-
#endif`,
|
|
1520
|
+
#endif`,sp=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1521
1521
|
uniform float logDepthBufFC;
|
|
1522
1522
|
varying float vFragDepth;
|
|
1523
1523
|
varying float vIsPerspective;
|
|
1524
|
-
#endif`,
|
|
1524
|
+
#endif`,rp=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1525
1525
|
varying float vFragDepth;
|
|
1526
1526
|
varying float vIsPerspective;
|
|
1527
|
-
#endif`,
|
|
1527
|
+
#endif`,op=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1528
1528
|
vFragDepth = 1.0 + gl_Position.w;
|
|
1529
1529
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1530
|
-
#endif`,
|
|
1530
|
+
#endif`,ap=`#ifdef USE_MAP
|
|
1531
1531
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
1532
1532
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
1533
1533
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
1534
1534
|
#endif
|
|
1535
1535
|
diffuseColor *= sampledDiffuseColor;
|
|
1536
|
-
#endif`,
|
|
1536
|
+
#endif`,lp=`#ifdef USE_MAP
|
|
1537
1537
|
uniform sampler2D map;
|
|
1538
|
-
#endif`,
|
|
1538
|
+
#endif`,cp=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1539
1539
|
#if defined( USE_POINTS_UV )
|
|
1540
1540
|
vec2 uv = vUv;
|
|
1541
1541
|
#else
|
|
@@ -1547,7 +1547,7 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3
|
|
|
1547
1547
|
#endif
|
|
1548
1548
|
#ifdef USE_ALPHAMAP
|
|
1549
1549
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
1550
|
-
#endif`,
|
|
1550
|
+
#endif`,hp=`#if defined( USE_POINTS_UV )
|
|
1551
1551
|
varying vec2 vUv;
|
|
1552
1552
|
#else
|
|
1553
1553
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
@@ -1559,19 +1559,19 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3
|
|
|
1559
1559
|
#endif
|
|
1560
1560
|
#ifdef USE_ALPHAMAP
|
|
1561
1561
|
uniform sampler2D alphaMap;
|
|
1562
|
-
#endif`,
|
|
1562
|
+
#endif`,up=`float metalnessFactor = metalness;
|
|
1563
1563
|
#ifdef USE_METALNESSMAP
|
|
1564
1564
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
1565
1565
|
metalnessFactor *= texelMetalness.b;
|
|
1566
|
-
#endif`,
|
|
1566
|
+
#endif`,dp=`#ifdef USE_METALNESSMAP
|
|
1567
1567
|
uniform sampler2D metalnessMap;
|
|
1568
|
-
#endif`,
|
|
1568
|
+
#endif`,fp=`#ifdef USE_INSTANCING_MORPH
|
|
1569
1569
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
1570
1570
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
1571
1571
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1572
1572
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
1573
1573
|
}
|
|
1574
|
-
#endif`,
|
|
1574
|
+
#endif`,pp=`#if defined( USE_MORPHCOLORS )
|
|
1575
1575
|
#if defined( USE_COLOR_ALPHA )
|
|
1576
1576
|
vColor *= morphTargetBaseInfluence;
|
|
1577
1577
|
#elif defined( USE_COLOR )
|
|
@@ -1584,12 +1584,12 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3
|
|
|
1584
1584
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor.rgb += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
1585
1585
|
#endif
|
|
1586
1586
|
}
|
|
1587
|
-
#endif`,
|
|
1587
|
+
#endif`,mp=`#ifdef USE_MORPHNORMALS
|
|
1588
1588
|
objectNormal *= morphTargetBaseInfluence;
|
|
1589
1589
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1590
1590
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
1591
1591
|
}
|
|
1592
|
-
#endif`,
|
|
1592
|
+
#endif`,gp=`#ifdef USE_MORPHTARGETS
|
|
1593
1593
|
#ifndef USE_INSTANCING_MORPH
|
|
1594
1594
|
uniform float morphTargetBaseInfluence;
|
|
1595
1595
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
@@ -1603,12 +1603,12 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3
|
|
|
1603
1603
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
1604
1604
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
1605
1605
|
}
|
|
1606
|
-
#endif`,
|
|
1606
|
+
#endif`,_p=`#ifdef USE_MORPHTARGETS
|
|
1607
1607
|
transformed *= morphTargetBaseInfluence;
|
|
1608
1608
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1609
1609
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
1610
1610
|
}
|
|
1611
|
-
#endif`,
|
|
1611
|
+
#endif`,xp=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
1612
1612
|
#ifdef FLAT_SHADED
|
|
1613
1613
|
vec3 fdx = dFdx( vViewPosition );
|
|
1614
1614
|
vec3 fdy = dFdy( vViewPosition );
|
|
@@ -1649,7 +1649,7 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3
|
|
|
1649
1649
|
tbn2[1] *= faceDirection;
|
|
1650
1650
|
#endif
|
|
1651
1651
|
#endif
|
|
1652
|
-
vec3 nonPerturbedNormal = normal
|
|
1652
|
+
vec3 nonPerturbedNormal = normal;`,yp=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
1653
1653
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1654
1654
|
#ifdef FLIP_SIDED
|
|
1655
1655
|
normal = - normal;
|
|
@@ -1667,19 +1667,19 @@ vec3 nonPerturbedNormal = normal;`,$f=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1667
1667
|
normal = normalize( tbn * mapN );
|
|
1668
1668
|
#elif defined( USE_BUMPMAP )
|
|
1669
1669
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
1670
|
-
#endif`,
|
|
1670
|
+
#endif`,vp=`#ifndef FLAT_SHADED
|
|
1671
1671
|
varying vec3 vNormal;
|
|
1672
1672
|
#ifdef USE_TANGENT
|
|
1673
1673
|
varying vec3 vTangent;
|
|
1674
1674
|
varying vec3 vBitangent;
|
|
1675
1675
|
#endif
|
|
1676
|
-
#endif`,
|
|
1676
|
+
#endif`,bp=`#ifndef FLAT_SHADED
|
|
1677
1677
|
varying vec3 vNormal;
|
|
1678
1678
|
#ifdef USE_TANGENT
|
|
1679
1679
|
varying vec3 vTangent;
|
|
1680
1680
|
varying vec3 vBitangent;
|
|
1681
1681
|
#endif
|
|
1682
|
-
#endif`,
|
|
1682
|
+
#endif`,Mp=`#ifndef FLAT_SHADED
|
|
1683
1683
|
vNormal = normalize( transformedNormal );
|
|
1684
1684
|
#ifdef USE_TANGENT
|
|
1685
1685
|
vTangent = normalize( transformedTangent );
|
|
@@ -1688,7 +1688,7 @@ vec3 nonPerturbedNormal = normal;`,$f=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1688
1688
|
vBitangent = - vBitangent;
|
|
1689
1689
|
#endif
|
|
1690
1690
|
#endif
|
|
1691
|
-
#endif`,
|
|
1691
|
+
#endif`,Sp=`#ifdef USE_NORMALMAP
|
|
1692
1692
|
uniform sampler2D normalMap;
|
|
1693
1693
|
uniform vec2 normalScale;
|
|
1694
1694
|
#endif
|
|
@@ -1710,13 +1710,13 @@ vec3 nonPerturbedNormal = normal;`,$f=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1710
1710
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
1711
1711
|
return mat3( T * scale, B * scale, N );
|
|
1712
1712
|
}
|
|
1713
|
-
#endif`,
|
|
1713
|
+
#endif`,wp=`#ifdef USE_CLEARCOAT
|
|
1714
1714
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
1715
|
-
#endif`,
|
|
1715
|
+
#endif`,Ep=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1716
1716
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1717
1717
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
1718
1718
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
1719
|
-
#endif`,
|
|
1719
|
+
#endif`,Tp=`#ifdef USE_CLEARCOATMAP
|
|
1720
1720
|
uniform sampler2D clearcoatMap;
|
|
1721
1721
|
#endif
|
|
1722
1722
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
@@ -1725,18 +1725,18 @@ vec3 nonPerturbedNormal = normal;`,$f=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1725
1725
|
#endif
|
|
1726
1726
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
1727
1727
|
uniform sampler2D clearcoatRoughnessMap;
|
|
1728
|
-
#endif`,
|
|
1728
|
+
#endif`,Ap=`#ifdef USE_IRIDESCENCEMAP
|
|
1729
1729
|
uniform sampler2D iridescenceMap;
|
|
1730
1730
|
#endif
|
|
1731
1731
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
1732
1732
|
uniform sampler2D iridescenceThicknessMap;
|
|
1733
|
-
#endif`,
|
|
1733
|
+
#endif`,Rp=`#ifdef OPAQUE
|
|
1734
1734
|
diffuseColor.a = 1.0;
|
|
1735
1735
|
#endif
|
|
1736
1736
|
#ifdef USE_TRANSMISSION
|
|
1737
1737
|
diffuseColor.a *= material.transmissionAlpha;
|
|
1738
1738
|
#endif
|
|
1739
|
-
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,
|
|
1739
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Cp=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
1740
1740
|
return normalize( normal ) * 0.5 + 0.5;
|
|
1741
1741
|
}
|
|
1742
1742
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
@@ -1815,9 +1815,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
1815
1815
|
#else
|
|
1816
1816
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
1817
1817
|
#endif
|
|
1818
|
-
}`,
|
|
1818
|
+
}`,Pp=`#ifdef PREMULTIPLIED_ALPHA
|
|
1819
1819
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
1820
|
-
#endif`,
|
|
1820
|
+
#endif`,Ip=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
1821
1821
|
#ifdef USE_BATCHING
|
|
1822
1822
|
mvPosition = batchingMatrix * mvPosition;
|
|
1823
1823
|
#endif
|
|
@@ -1825,22 +1825,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
1825
1825
|
mvPosition = instanceMatrix * mvPosition;
|
|
1826
1826
|
#endif
|
|
1827
1827
|
mvPosition = modelViewMatrix * mvPosition;
|
|
1828
|
-
gl_Position = projectionMatrix * mvPosition;`,
|
|
1828
|
+
gl_Position = projectionMatrix * mvPosition;`,Lp=`#ifdef DITHERING
|
|
1829
1829
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
1830
|
-
#endif`,
|
|
1830
|
+
#endif`,Dp=`#ifdef DITHERING
|
|
1831
1831
|
vec3 dithering( vec3 color ) {
|
|
1832
1832
|
float grid_position = rand( gl_FragCoord.xy );
|
|
1833
1833
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
1834
1834
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
1835
1835
|
return color + dither_shift_RGB;
|
|
1836
1836
|
}
|
|
1837
|
-
#endif`,
|
|
1837
|
+
#endif`,Np=`float roughnessFactor = roughness;
|
|
1838
1838
|
#ifdef USE_ROUGHNESSMAP
|
|
1839
1839
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
1840
1840
|
roughnessFactor *= texelRoughness.g;
|
|
1841
|
-
#endif`,
|
|
1841
|
+
#endif`,Up=`#ifdef USE_ROUGHNESSMAP
|
|
1842
1842
|
uniform sampler2D roughnessMap;
|
|
1843
|
-
#endif`,
|
|
1843
|
+
#endif`,Fp=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1844
1844
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1845
1845
|
#endif
|
|
1846
1846
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
@@ -2094,7 +2094,7 @@ gl_Position = projectionMatrix * mvPosition;`,lp=`#ifdef DITHERING
|
|
|
2094
2094
|
}
|
|
2095
2095
|
#endif
|
|
2096
2096
|
#endif
|
|
2097
|
-
#endif`,
|
|
2097
|
+
#endif`,Op=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
2098
2098
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
2099
2099
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
2100
2100
|
#endif
|
|
@@ -2139,7 +2139,7 @@ gl_Position = projectionMatrix * mvPosition;`,lp=`#ifdef DITHERING
|
|
|
2139
2139
|
};
|
|
2140
2140
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
2141
2141
|
#endif
|
|
2142
|
-
#endif`,
|
|
2142
|
+
#endif`,Bp=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
2143
2143
|
#ifdef HAS_NORMAL
|
|
2144
2144
|
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
|
|
2145
2145
|
#else
|
|
@@ -2179,7 +2179,7 @@ gl_Position = projectionMatrix * mvPosition;`,lp=`#ifdef DITHERING
|
|
|
2179
2179
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
2180
2180
|
}
|
|
2181
2181
|
#pragma unroll_loop_end
|
|
2182
|
-
#endif`,
|
|
2182
|
+
#endif`,zp=`float getShadowMask() {
|
|
2183
2183
|
float shadow = 1.0;
|
|
2184
2184
|
#ifdef USE_SHADOWMAP
|
|
2185
2185
|
#if NUM_SUN_LIGHT_SHADOWS > 0
|
|
@@ -2220,12 +2220,12 @@ gl_Position = projectionMatrix * mvPosition;`,lp=`#ifdef DITHERING
|
|
|
2220
2220
|
#endif
|
|
2221
2221
|
#endif
|
|
2222
2222
|
return shadow;
|
|
2223
|
-
}`,
|
|
2223
|
+
}`,kp=`#ifdef USE_SKINNING
|
|
2224
2224
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
2225
2225
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
2226
2226
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
2227
2227
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
2228
|
-
#endif`,
|
|
2228
|
+
#endif`,Vp=`#ifdef USE_SKINNING
|
|
2229
2229
|
uniform mat4 bindMatrix;
|
|
2230
2230
|
uniform mat4 bindMatrixInverse;
|
|
2231
2231
|
uniform highp sampler2D boneTexture;
|
|
@@ -2240,7 +2240,7 @@ gl_Position = projectionMatrix * mvPosition;`,lp=`#ifdef DITHERING
|
|
|
2240
2240
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
2241
2241
|
return mat4( v1, v2, v3, v4 );
|
|
2242
2242
|
}
|
|
2243
|
-
#endif`,
|
|
2243
|
+
#endif`,Gp=`#ifdef USE_SKINNING
|
|
2244
2244
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
2245
2245
|
vec4 skinned = vec4( 0.0 );
|
|
2246
2246
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
@@ -2248,7 +2248,7 @@ gl_Position = projectionMatrix * mvPosition;`,lp=`#ifdef DITHERING
|
|
|
2248
2248
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2249
2249
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2250
2250
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2251
|
-
#endif`,
|
|
2251
|
+
#endif`,Hp=`#ifdef USE_SKINNING
|
|
2252
2252
|
mat4 skinMatrix = mat4( 0.0 );
|
|
2253
2253
|
skinMatrix += skinWeight.x * boneMatX;
|
|
2254
2254
|
skinMatrix += skinWeight.y * boneMatY;
|
|
@@ -2259,17 +2259,17 @@ gl_Position = projectionMatrix * mvPosition;`,lp=`#ifdef DITHERING
|
|
|
2259
2259
|
#ifdef USE_TANGENT
|
|
2260
2260
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2261
2261
|
#endif
|
|
2262
|
-
#endif`,
|
|
2262
|
+
#endif`,Wp=`float specularStrength;
|
|
2263
2263
|
#ifdef USE_SPECULARMAP
|
|
2264
2264
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
2265
2265
|
specularStrength = texelSpecular.r;
|
|
2266
2266
|
#else
|
|
2267
2267
|
specularStrength = 1.0;
|
|
2268
|
-
#endif`,
|
|
2268
|
+
#endif`,Xp=`#ifdef USE_SPECULARMAP
|
|
2269
2269
|
uniform sampler2D specularMap;
|
|
2270
|
-
#endif`,
|
|
2270
|
+
#endif`,qp=`#if defined( TONE_MAPPING )
|
|
2271
2271
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2272
|
-
#endif`,
|
|
2272
|
+
#endif`,Yp=`#ifndef saturate
|
|
2273
2273
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
2274
2274
|
#endif
|
|
2275
2275
|
uniform float toneMappingExposure;
|
|
@@ -2366,7 +2366,7 @@ vec3 NeutralToneMapping( vec3 color ) {
|
|
|
2366
2366
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
2367
2367
|
return mix( color, vec3( newPeak ), g );
|
|
2368
2368
|
}
|
|
2369
|
-
vec3 CustomToneMapping( vec3 color ) { return color; }`,
|
|
2369
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,Zp=`#ifdef USE_TRANSMISSION
|
|
2370
2370
|
material.transmission = transmission;
|
|
2371
2371
|
material.transmissionAlpha = 1.0;
|
|
2372
2372
|
material.thickness = thickness;
|
|
@@ -2387,7 +2387,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,wp=`#ifdef USE_TRANSMISS
|
|
|
2387
2387
|
material.attenuationColor, material.attenuationDistance );
|
|
2388
2388
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
2389
2389
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
2390
|
-
#endif
|
|
2390
|
+
#endif`,$p=`#ifdef USE_TRANSMISSION
|
|
2391
2391
|
uniform float transmission;
|
|
2392
2392
|
uniform float thickness;
|
|
2393
2393
|
uniform float attenuationDistance;
|
|
@@ -2513,7 +2513,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,wp=`#ifdef USE_TRANSMISS
|
|
|
2513
2513
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
2514
2514
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
2515
2515
|
}
|
|
2516
|
-
#endif`,
|
|
2516
|
+
#endif`,Jp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2517
2517
|
varying vec2 vUv;
|
|
2518
2518
|
#endif
|
|
2519
2519
|
#ifdef USE_MAP
|
|
@@ -2586,7 +2586,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,wp=`#ifdef USE_TRANSMISS
|
|
|
2586
2586
|
#ifdef USE_THICKNESSMAP
|
|
2587
2587
|
uniform mat3 thicknessMapTransform;
|
|
2588
2588
|
varying vec2 vThicknessMapUv;
|
|
2589
|
-
#endif`,
|
|
2589
|
+
#endif`,Kp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2590
2590
|
varying vec2 vUv;
|
|
2591
2591
|
#endif
|
|
2592
2592
|
#ifdef USE_MAP
|
|
@@ -2684,7 +2684,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,wp=`#ifdef USE_TRANSMISS
|
|
|
2684
2684
|
#ifdef USE_THICKNESSMAP
|
|
2685
2685
|
uniform mat3 thicknessMapTransform;
|
|
2686
2686
|
varying vec2 vThicknessMapUv;
|
|
2687
|
-
#endif`,
|
|
2687
|
+
#endif`,jp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2688
2688
|
vUv = vec3( uv, 1 ).xy;
|
|
2689
2689
|
#endif
|
|
2690
2690
|
#ifdef USE_MAP
|
|
@@ -2758,7 +2758,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,wp=`#ifdef USE_TRANSMISS
|
|
|
2758
2758
|
#endif
|
|
2759
2759
|
#ifdef USE_THICKNESSMAP
|
|
2760
2760
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
2761
|
-
#endif`,
|
|
2761
|
+
#endif`,Qp=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
2762
2762
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
2763
2763
|
#ifdef USE_BATCHING
|
|
2764
2764
|
worldPosition = batchingMatrix * worldPosition;
|
|
@@ -2767,12 +2767,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,wp=`#ifdef USE_TRANSMISS
|
|
|
2767
2767
|
worldPosition = instanceMatrix * worldPosition;
|
|
2768
2768
|
#endif
|
|
2769
2769
|
worldPosition = modelMatrix * worldPosition;
|
|
2770
|
-
#endif`,
|
|
2770
|
+
#endif`,em=`varying vec2 vUv;
|
|
2771
2771
|
uniform mat3 uvTransform;
|
|
2772
2772
|
void main() {
|
|
2773
2773
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
2774
2774
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
2775
|
-
}`,
|
|
2775
|
+
}`,tm=`uniform sampler2D t2D;
|
|
2776
2776
|
uniform float backgroundIntensity;
|
|
2777
2777
|
varying vec2 vUv;
|
|
2778
2778
|
void main() {
|
|
@@ -2784,14 +2784,14 @@ void main() {
|
|
|
2784
2784
|
gl_FragColor = texColor;
|
|
2785
2785
|
#include <tonemapping_fragment>
|
|
2786
2786
|
#include <colorspace_fragment>
|
|
2787
|
-
}`,
|
|
2787
|
+
}`,nm=`varying vec3 vWorldDirection;
|
|
2788
2788
|
#include <common>
|
|
2789
2789
|
void main() {
|
|
2790
2790
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2791
2791
|
#include <begin_vertex>
|
|
2792
2792
|
#include <project_vertex>
|
|
2793
2793
|
gl_Position.z = gl_Position.w;
|
|
2794
|
-
}`,
|
|
2794
|
+
}`,im=`uniform float backgroundBlurriness;
|
|
2795
2795
|
uniform float backgroundIntensity;
|
|
2796
2796
|
uniform mat3 backgroundRotation;
|
|
2797
2797
|
varying vec3 vWorldDirection;
|
|
@@ -2806,14 +2806,14 @@ void main() {
|
|
|
2806
2806
|
gl_FragColor = texColor;
|
|
2807
2807
|
#include <tonemapping_fragment>
|
|
2808
2808
|
#include <colorspace_fragment>
|
|
2809
|
-
}`,
|
|
2809
|
+
}`,sm=`varying vec3 vWorldDirection;
|
|
2810
2810
|
#include <common>
|
|
2811
2811
|
void main() {
|
|
2812
2812
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2813
2813
|
#include <begin_vertex>
|
|
2814
2814
|
#include <project_vertex>
|
|
2815
2815
|
gl_Position.z = gl_Position.w;
|
|
2816
|
-
}`,
|
|
2816
|
+
}`,rm=`uniform samplerCube tCube;
|
|
2817
2817
|
uniform float tFlip;
|
|
2818
2818
|
uniform float opacity;
|
|
2819
2819
|
varying vec3 vWorldDirection;
|
|
@@ -2823,7 +2823,7 @@ void main() {
|
|
|
2823
2823
|
gl_FragColor.a *= opacity;
|
|
2824
2824
|
#include <tonemapping_fragment>
|
|
2825
2825
|
#include <colorspace_fragment>
|
|
2826
|
-
}`,
|
|
2826
|
+
}`,om=`#include <common>
|
|
2827
2827
|
#include <batching_pars_vertex>
|
|
2828
2828
|
#include <uv_pars_vertex>
|
|
2829
2829
|
#include <displacementmap_pars_vertex>
|
|
@@ -2850,7 +2850,7 @@ void main() {
|
|
|
2850
2850
|
#include <logdepthbuf_vertex>
|
|
2851
2851
|
#include <clipping_planes_vertex>
|
|
2852
2852
|
vHighPrecisionZW = gl_Position.zw;
|
|
2853
|
-
}`,
|
|
2853
|
+
}`,am=`#if DEPTH_PACKING == 3200
|
|
2854
2854
|
uniform float opacity;
|
|
2855
2855
|
#endif
|
|
2856
2856
|
#include <common>
|
|
@@ -2888,7 +2888,7 @@ void main() {
|
|
|
2888
2888
|
#elif DEPTH_PACKING == 3203
|
|
2889
2889
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
2890
2890
|
#endif
|
|
2891
|
-
}`,
|
|
2891
|
+
}`,lm=`#define DISTANCE
|
|
2892
2892
|
varying vec3 vWorldPosition;
|
|
2893
2893
|
#include <common>
|
|
2894
2894
|
#include <batching_pars_vertex>
|
|
@@ -2915,7 +2915,7 @@ void main() {
|
|
|
2915
2915
|
#include <worldpos_vertex>
|
|
2916
2916
|
#include <clipping_planes_vertex>
|
|
2917
2917
|
vWorldPosition = worldPosition.xyz;
|
|
2918
|
-
}`,
|
|
2918
|
+
}`,cm=`#define DISTANCE
|
|
2919
2919
|
uniform vec3 referencePosition;
|
|
2920
2920
|
uniform float nearDistance;
|
|
2921
2921
|
uniform float farDistance;
|
|
@@ -2938,13 +2938,13 @@ void main() {
|
|
|
2938
2938
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
2939
2939
|
dist = saturate( dist );
|
|
2940
2940
|
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
|
|
2941
|
-
}`,
|
|
2941
|
+
}`,hm=`varying vec3 vWorldDirection;
|
|
2942
2942
|
#include <common>
|
|
2943
2943
|
void main() {
|
|
2944
2944
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2945
2945
|
#include <begin_vertex>
|
|
2946
2946
|
#include <project_vertex>
|
|
2947
|
-
}`,
|
|
2947
|
+
}`,um=`uniform sampler2D tEquirect;
|
|
2948
2948
|
varying vec3 vWorldDirection;
|
|
2949
2949
|
#include <common>
|
|
2950
2950
|
void main() {
|
|
@@ -2953,7 +2953,7 @@ void main() {
|
|
|
2953
2953
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
2954
2954
|
#include <tonemapping_fragment>
|
|
2955
2955
|
#include <colorspace_fragment>
|
|
2956
|
-
}`,
|
|
2956
|
+
}`,dm=`uniform float scale;
|
|
2957
2957
|
attribute float lineDistance;
|
|
2958
2958
|
varying float vLineDistance;
|
|
2959
2959
|
#include <common>
|
|
@@ -2975,7 +2975,7 @@ void main() {
|
|
|
2975
2975
|
#include <logdepthbuf_vertex>
|
|
2976
2976
|
#include <clipping_planes_vertex>
|
|
2977
2977
|
#include <fog_vertex>
|
|
2978
|
-
}`,
|
|
2978
|
+
}`,fm=`uniform vec3 diffuse;
|
|
2979
2979
|
uniform float opacity;
|
|
2980
2980
|
uniform float dashSize;
|
|
2981
2981
|
uniform float totalSize;
|
|
@@ -3003,7 +3003,7 @@ void main() {
|
|
|
3003
3003
|
#include <colorspace_fragment>
|
|
3004
3004
|
#include <fog_fragment>
|
|
3005
3005
|
#include <premultiplied_alpha_fragment>
|
|
3006
|
-
}`,
|
|
3006
|
+
}`,pm=`#include <common>
|
|
3007
3007
|
#include <batching_pars_vertex>
|
|
3008
3008
|
#include <uv_pars_vertex>
|
|
3009
3009
|
#include <envmap_pars_vertex>
|
|
@@ -3035,7 +3035,7 @@ void main() {
|
|
|
3035
3035
|
#include <worldpos_vertex>
|
|
3036
3036
|
#include <envmap_vertex>
|
|
3037
3037
|
#include <fog_vertex>
|
|
3038
|
-
}`,
|
|
3038
|
+
}`,mm=`uniform vec3 diffuse;
|
|
3039
3039
|
uniform float opacity;
|
|
3040
3040
|
#ifndef FLAT_SHADED
|
|
3041
3041
|
varying vec3 vNormal;
|
|
@@ -3083,7 +3083,7 @@ void main() {
|
|
|
3083
3083
|
#include <fog_fragment>
|
|
3084
3084
|
#include <premultiplied_alpha_fragment>
|
|
3085
3085
|
#include <dithering_fragment>
|
|
3086
|
-
}`,
|
|
3086
|
+
}`,gm=`#define LAMBERT
|
|
3087
3087
|
varying vec3 vViewPosition;
|
|
3088
3088
|
#include <common>
|
|
3089
3089
|
#include <batching_pars_vertex>
|
|
@@ -3122,7 +3122,7 @@ void main() {
|
|
|
3122
3122
|
#include <envmap_vertex>
|
|
3123
3123
|
#include <shadowmap_vertex>
|
|
3124
3124
|
#include <fog_vertex>
|
|
3125
|
-
}`,
|
|
3125
|
+
}`,_m=`#define LAMBERT
|
|
3126
3126
|
uniform vec3 diffuse;
|
|
3127
3127
|
uniform vec3 emissive;
|
|
3128
3128
|
uniform float opacity;
|
|
@@ -3179,7 +3179,7 @@ void main() {
|
|
|
3179
3179
|
#include <fog_fragment>
|
|
3180
3180
|
#include <premultiplied_alpha_fragment>
|
|
3181
3181
|
#include <dithering_fragment>
|
|
3182
|
-
}`,
|
|
3182
|
+
}`,xm=`#define MATCAP
|
|
3183
3183
|
varying vec3 vViewPosition;
|
|
3184
3184
|
#include <common>
|
|
3185
3185
|
#include <batching_pars_vertex>
|
|
@@ -3213,7 +3213,7 @@ void main() {
|
|
|
3213
3213
|
#include <clipping_planes_vertex>
|
|
3214
3214
|
#include <fog_vertex>
|
|
3215
3215
|
vViewPosition = - mvPosition.xyz;
|
|
3216
|
-
}
|
|
3216
|
+
}`,ym=`#define MATCAP
|
|
3217
3217
|
uniform vec3 diffuse;
|
|
3218
3218
|
uniform float opacity;
|
|
3219
3219
|
uniform sampler2D matcap;
|
|
@@ -3259,7 +3259,7 @@ void main() {
|
|
|
3259
3259
|
#include <fog_fragment>
|
|
3260
3260
|
#include <premultiplied_alpha_fragment>
|
|
3261
3261
|
#include <dithering_fragment>
|
|
3262
|
-
}`,
|
|
3262
|
+
}`,vm=`#define NORMAL
|
|
3263
3263
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3264
3264
|
varying vec3 vViewPosition;
|
|
3265
3265
|
#endif
|
|
@@ -3292,7 +3292,7 @@ void main() {
|
|
|
3292
3292
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3293
3293
|
vViewPosition = - mvPosition.xyz;
|
|
3294
3294
|
#endif
|
|
3295
|
-
}`,
|
|
3295
|
+
}`,bm=`#define NORMAL
|
|
3296
3296
|
uniform float opacity;
|
|
3297
3297
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3298
3298
|
varying vec3 vViewPosition;
|
|
@@ -3313,7 +3313,7 @@ void main() {
|
|
|
3313
3313
|
#ifdef OPAQUE
|
|
3314
3314
|
gl_FragColor.a = 1.0;
|
|
3315
3315
|
#endif
|
|
3316
|
-
}`,
|
|
3316
|
+
}`,Mm=`#define PHONG
|
|
3317
3317
|
varying vec3 vViewPosition;
|
|
3318
3318
|
#include <common>
|
|
3319
3319
|
#include <batching_pars_vertex>
|
|
@@ -3352,7 +3352,7 @@ void main() {
|
|
|
3352
3352
|
#include <envmap_vertex>
|
|
3353
3353
|
#include <shadowmap_vertex>
|
|
3354
3354
|
#include <fog_vertex>
|
|
3355
|
-
}`,
|
|
3355
|
+
}`,Sm=`#define PHONG
|
|
3356
3356
|
uniform vec3 diffuse;
|
|
3357
3357
|
uniform vec3 emissive;
|
|
3358
3358
|
uniform vec3 specular;
|
|
@@ -3411,7 +3411,7 @@ void main() {
|
|
|
3411
3411
|
#include <fog_fragment>
|
|
3412
3412
|
#include <premultiplied_alpha_fragment>
|
|
3413
3413
|
#include <dithering_fragment>
|
|
3414
|
-
}`,
|
|
3414
|
+
}`,wm=`#define STANDARD
|
|
3415
3415
|
varying vec3 vViewPosition;
|
|
3416
3416
|
#ifdef USE_TRANSMISSION
|
|
3417
3417
|
varying vec3 vWorldPosition;
|
|
@@ -3454,7 +3454,7 @@ void main() {
|
|
|
3454
3454
|
#ifdef USE_TRANSMISSION
|
|
3455
3455
|
vWorldPosition = worldPosition.xyz;
|
|
3456
3456
|
#endif
|
|
3457
|
-
}`,
|
|
3457
|
+
}`,Em=`#define STANDARD
|
|
3458
3458
|
#ifdef PHYSICAL
|
|
3459
3459
|
#define IOR
|
|
3460
3460
|
#define USE_SPECULAR
|
|
@@ -3587,7 +3587,7 @@ void main() {
|
|
|
3587
3587
|
#include <fog_fragment>
|
|
3588
3588
|
#include <premultiplied_alpha_fragment>
|
|
3589
3589
|
#include <dithering_fragment>
|
|
3590
|
-
}`,
|
|
3590
|
+
}`,Tm=`#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
|
+
}`,Am=`#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
|
+
}`,Rm=`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
|
+
}`,Cm=`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
|
+
}`,Pm=`#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
|
+
}`,Im=`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
|
+
}`,Dm=`uniform vec3 diffuse;
|
|
3799
3799
|
uniform float opacity;
|
|
3800
3800
|
#include <common>
|
|
3801
3801
|
#include <uv_pars_fragment>
|
|
@@ -3820,7 +3820,7 @@ void main() {
|
|
|
3820
3820
|
#include <tonemapping_fragment>
|
|
3821
3821
|
#include <colorspace_fragment>
|
|
3822
3822
|
#include <fog_fragment>
|
|
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:`
|
|
3823
|
+
}`,$e={alphahash_fragment:ef,alphahash_pars_fragment:tf,alphamap_fragment:nf,alphamap_pars_fragment:sf,alphatest_fragment:rf,alphatest_pars_fragment:of,aomap_fragment:af,aomap_pars_fragment:lf,batching_pars_vertex:cf,batching_vertex:hf,begin_vertex:uf,beginnormal_vertex:df,bsdfs:ff,iridescence_fragment:pf,bumpmap_pars_fragment:mf,clipping_planes_fragment:gf,clipping_planes_pars_fragment:_f,clipping_planes_pars_vertex:xf,clipping_planes_vertex:yf,color_fragment:vf,color_pars_fragment:bf,color_pars_vertex:Mf,color_vertex:Sf,common:wf,defaultnormal_vertex:Ef,displacementmap_pars_vertex:Tf,displacementmap_vertex:Af,emissivemap_fragment:Rf,emissivemap_pars_fragment:Cf,colorspace_fragment:Pf,colorspace_pars_fragment:If,envmap_fragment:Lf,envmap_common_pars_fragment:Df,envmap_pars_fragment:Nf,envmap_pars_vertex:Uf,envmap_physical_pars_fragment:qf,envmap_vertex:Ff,fog_vertex:Of,fog_pars_vertex:Bf,fog_fragment:zf,fog_pars_fragment:kf,gradientmap_pars_fragment:Vf,lightmap_pars_fragment:Gf,lights_lambert_fragment:Hf,lights_lambert_pars_fragment:Wf,lights_pars_begin:Xf,lights_toon_fragment:Yf,lights_toon_pars_fragment:Zf,lights_phong_fragment:$f,lights_phong_pars_fragment:Jf,lights_physical_fragment:Kf,lights_physical_pars_fragment:jf,lights_fragment_begin:Qf,lights_fragment_maps:ep,lights_fragment_end:tp,lightprobes_pars_fragment:np,logdepthbuf_fragment:ip,logdepthbuf_pars_fragment:sp,logdepthbuf_pars_vertex:rp,logdepthbuf_vertex:op,map_fragment:ap,map_pars_fragment:lp,map_particle_fragment:cp,map_particle_pars_fragment:hp,metalnessmap_fragment:up,metalnessmap_pars_fragment:dp,morphinstance_vertex:fp,morphcolor_vertex:pp,morphnormal_vertex:mp,morphtarget_pars_vertex:gp,morphtarget_vertex:_p,normal_fragment_begin:xp,normal_fragment_maps:yp,normal_pars_fragment:vp,normal_pars_vertex:bp,normal_vertex:Mp,normalmap_pars_fragment:Sp,clearcoat_normal_fragment_begin:wp,clearcoat_normal_fragment_maps:Ep,clearcoat_pars_fragment:Tp,iridescence_pars_fragment:Ap,opaque_fragment:Rp,packing:Cp,premultiplied_alpha_fragment:Pp,project_vertex:Ip,dithering_fragment:Lp,dithering_pars_fragment:Dp,roughnessmap_fragment:Np,roughnessmap_pars_fragment:Up,shadowmap_pars_fragment:Fp,shadowmap_pars_vertex:Op,shadowmap_vertex:Bp,shadowmask_pars_fragment:zp,skinbase_vertex:kp,skinning_pars_vertex:Vp,skinning_vertex:Gp,skinnormal_vertex:Hp,specularmap_fragment:Wp,specularmap_pars_fragment:Xp,tonemapping_fragment:qp,tonemapping_pars_fragment:Yp,transmission_fragment:Zp,transmission_pars_fragment:$p,uv_pars_fragment:Jp,uv_pars_vertex:Kp,uv_vertex:jp,worldpos_vertex:Qp,background_vert:em,background_frag:tm,backgroundCube_vert:nm,backgroundCube_frag:im,cube_vert:sm,cube_frag:rm,depth_vert:om,depth_frag:am,distance_vert:lm,distance_frag:cm,equirect_vert:hm,equirect_frag:um,linedashed_vert:dm,linedashed_frag:fm,meshbasic_vert:pm,meshbasic_frag:mm,meshlambert_vert:gm,meshlambert_frag:_m,meshmatcap_vert:xm,meshmatcap_frag:ym,meshnormal_vert:vm,meshnormal_frag:bm,meshphong_vert:Mm,meshphong_frag:Sm,meshphysical_vert:wm,meshphysical_frag:Em,meshtoon_vert:Tm,meshtoon_frag:Am,points_vert:Rm,points_frag:Cm,shadow_vert:Pm,shadow_frag:Im,sprite_vert:Lm,sprite_frag:Dm},Me={common:{diffuse:{value:new Ye(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ge},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ge}},envmap:{envMap:{value:null},envMapRotation:{value:new Ge},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ge}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ge}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ge},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ge},normalScale:{value:new Ve(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ge},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ge}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ge}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ge}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ye(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 Ye(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0},uvTransform:{value:new Ge}},sprite:{diffuse:{value:new Ye(16777215)},opacity:{value:1},center:{value:new Ve(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ge},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0}}},Nn={basic:{uniforms:Gt([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:Gt([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 Ye(0)},envMapIntensity:{value:1}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:Gt([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 Ye(0)},specular:{value:new Ye(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:Gt([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 Ye(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:Gt([Me.common,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.gradientmap,Me.fog,Me.lights,{emissive:{value:new Ye(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:Gt([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:Gt([Me.points,Me.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:Gt([Me.common,Me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:Gt([Me.common,Me.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:Gt([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:Gt([Me.sprite,Me.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new Ge},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ge}},vertexShader:$e.backgroundCube_vert,fragmentShader:$e.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distance:{uniforms:Gt([Me.common,Me.displacementmap,{referencePosition:{value:new k},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distance_vert,fragmentShader:$e.distance_frag},shadow:{uniforms:Gt([Me.lights,Me.fog,{color:{value:new Ye(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};Nn.physical={uniforms:Gt([Nn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ge},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ge},clearcoatNormalScale:{value:new Ve(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ge},diffuseRoughness:{value:0},diffuseRoughnessMap:{value:null},diffuseRoughnessMapTransform:{value:new Ge},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ge},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ge},sheen:{value:0},sheenColor:{value:new Ye(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ge},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ge},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ge},transmissionSamplerSize:{value:new Ve},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ge},attenuationDistance:{value:0},attenuationColor:{value:new Ye(0)},specularColor:{value:new Ye(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ge},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ge},anisotropyVector:{value:new Ve},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ge}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};var ua={r:0,b:0,g:0},Nm=new mt,ru=new Ge;ru.set(-1,0,0,0,1,0,0,0,1);function Um(i,e,t,n,s,r){let o=new Ye(0),a=s===!0?0:1,c,l,h=null,u=0,d=null;function f(w){let T=w.isScene===!0?w.background:null;if(T&&T.isTexture){let S=w.backgroundBlurriness>0;T=e.get(T,S)}return T}function _(w){let T=!1,S=f(w);S===null?m(o,a):S&&S.isColor&&(m(S,1),T=!0);let E=i.xr.getEnvironmentBlendMode();E==="additive"?t.buffers.color.setClear(0,0,0,1,r):E==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||T)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function x(w,T){let S=f(T);S&&S.isCubeTexture?(l===void 0&&(l=new Qt(new os(1,1,1),new In({name:"BackgroundCubeMaterial",uniforms:Ui(Nn.backgroundCube.uniforms),vertexShader:Nn.backgroundCube.vertexShader,fragmentShader:Nn.backgroundCube.fragmentShader,side:Jt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(E,M,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=S,l.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Nm.makeRotationFromEuler(T.backgroundRotation)).transpose(),S.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(ru),l.material.toneMapped=et.getTransfer(S.colorSpace)!==ct,(h!==S||u!==S.version||d!==i.toneMapping)&&(l.material.needsUpdate=!0,h=S,u=S.version,d=i.toneMapping),l.layers.enableAll(),w.unshift(l,l.geometry,l.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new Qt(new Gs(2,2),new In({name:"BackgroundMaterial",uniforms:Ui(Nn.background.uniforms),vertexShader:Nn.background.vertexShader,fragmentShader:Nn.background.fragmentShader,side:gi,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=S,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=et.getTransfer(S.colorSpace)!==ct,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(h!==S||u!==S.version||d!==i.toneMapping)&&(c.material.needsUpdate=!0,h=S,u=S.version,d=i.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null))}function m(w,T){w.getRGB(ua,Ll(i)),t.buffers.color.setClear(ua.r,ua.g,ua.b,T,r)}function p(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(w,T=1){o.set(w),a=T,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(w){a=w,m(o,a)},render:_,addToRenderList:x,dispose:p}}function Fm(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null),r=s,o=!1;function a(D,N,B,C,W){let Z=!1,z=u(D,C,B,N);r!==z&&(r=z,l(r.object)),Z=f(D,C,B,W),Z&&_(D,C,B,W),W!==null&&e.update(W,i.ELEMENT_ARRAY_BUFFER),(Z||o)&&(o=!1,S(D,N,B,C),W!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(W).buffer))}function c(){return i.createVertexArray()}function l(D){return i.bindVertexArray(D)}function h(D){return i.deleteVertexArray(D)}function u(D,N,B,C){let W=C.wireframe===!0,Z=n[N.id];Z===void 0&&(Z={},n[N.id]=Z);let z=D.isInstancedMesh===!0?D.id:0,ee=Z[z];ee===void 0&&(ee={},Z[z]=ee);let q=ee[B.id];q===void 0&&(q={},ee[B.id]=q);let J=q[W];return J===void 0&&(J=d(c()),q[W]=J),J}function d(D){let N=[],B=[],C=[];for(let W=0;W<t;W++)N[W]=0,B[W]=0,C[W]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:B,attributeDivisors:C,object:D,attributes:{},index:null}}function f(D,N,B,C){let W=r.attributes,Z=N.attributes,z=0,ee=B.getAttributes();for(let q in ee)if(ee[q].location>=0){let O=W[q],ae=Z[q];if(ae===void 0&&(q==="instanceMatrix"&&D.instanceMatrix&&(ae=D.instanceMatrix),q==="instanceColor"&&D.instanceColor&&(ae=D.instanceColor)),O===void 0||O.attribute!==ae||ae&&O.data!==ae.data)return!0;z++}return r.attributesNum!==z||r.index!==C}function _(D,N,B,C){let W={},Z=N.attributes,z=0,ee=B.getAttributes();for(let q in ee)if(ee[q].location>=0){let O=Z[q];O===void 0&&(q==="instanceMatrix"&&D.instanceMatrix&&(O=D.instanceMatrix),q==="instanceColor"&&D.instanceColor&&(O=D.instanceColor));let ae={};ae.attribute=O,O&&O.data&&(ae.data=O.data),W[q]=ae,z++}r.attributes=W,r.attributesNum=z,r.index=C}function x(){let D=r.newAttributes;for(let N=0,B=D.length;N<B;N++)D[N]=0}function m(D){p(D,0)}function p(D,N){let B=r.newAttributes,C=r.enabledAttributes,W=r.attributeDivisors;B[D]=1,C[D]===0&&(i.enableVertexAttribArray(D),C[D]=1),W[D]!==N&&(i.vertexAttribDivisor(D,N),W[D]=N)}function w(){let D=r.newAttributes,N=r.enabledAttributes;for(let B=0,C=N.length;B<C;B++)N[B]!==D[B]&&(i.disableVertexAttribArray(B),N[B]=0)}function T(D,N,B,C,W,Z,z){z===!0?i.vertexAttribIPointer(D,N,B,W,Z):i.vertexAttribPointer(D,N,B,C,W,Z)}function S(D,N,B,C){x();let W=C.attributes,Z=B.getAttributes(),z=N.defaultAttributeValues;for(let ee in Z){let q=Z[ee];if(q.location>=0){let J=W[ee];if(J===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(J=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(J=D.instanceColor)),J!==void 0){let O=J.normalized,ae=J.itemSize,xe=e.get(J);if(xe===void 0)continue;let H=xe.buffer,ue=xe.type,de=xe.bytesPerElement,we=ue===i.INT||ue===i.UNSIGNED_INT||J.gpuType===Ro;if(J.isInterleavedBufferAttribute){let fe=J.data,Te=fe.isInterleavedBuffer===!0?fe.stride:fe.itemSize,He=J.offset;if(fe.isInstancedInterleavedBuffer||fe.isInstancedBufferAttribute){for(let me=0;me<q.locationSize;me++)p(q.location+me,fe.meshPerAttribute);D.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=fe.meshPerAttribute*fe.count)}else for(let me=0;me<q.locationSize;me++)m(q.location+me);i.bindBuffer(i.ARRAY_BUFFER,H);for(let me=0;me<q.locationSize;me++)T(q.location+me,ae/q.locationSize,ue,O,Te*de,(He+ae/q.locationSize*me)*de,we)}else{if(J.isInstancedBufferAttribute){for(let fe=0;fe<q.locationSize;fe++)p(q.location+fe,J.meshPerAttribute);D.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let fe=0;fe<q.locationSize;fe++)m(q.location+fe);i.bindBuffer(i.ARRAY_BUFFER,H);for(let fe=0;fe<q.locationSize;fe++)T(q.location+fe,ae/q.locationSize,ue,O,ae*de,ae/q.locationSize*fe*de,we)}}else if(z!==void 0){let O=z[ee];if(O!==void 0)switch(O.length){case 2:i.vertexAttrib2fv(q.location,O);break;case 3:i.vertexAttrib3fv(q.location,O);break;case 4:i.vertexAttrib4fv(q.location,O);break;default:i.vertexAttrib1fv(q.location,O)}}}}w()}function E(){L();for(let D in n){let N=n[D];for(let B in N){let C=N[B];for(let W in C){let Z=C[W];for(let z in Z)h(Z[z].object),delete Z[z];delete C[W]}}delete n[D]}}function M(D){if(n[D.id]===void 0)return;let N=n[D.id];for(let B in N){let C=N[B];for(let W in C){let Z=C[W];for(let z in Z)h(Z[z].object),delete Z[z];delete C[W]}}delete n[D.id]}function g(D){for(let N in n){let B=n[N];for(let C in B){let W=B[C];if(W[D.id]===void 0)continue;let Z=W[D.id];for(let z in Z)h(Z[z].object),delete Z[z];delete W[D.id]}}}function v(D){for(let N in n){let B=n[N],C=D.isInstancedMesh===!0?D.id:0,W=B[C];if(W!==void 0){for(let Z in W){let z=W[Z];for(let ee in z)h(z[ee].object),delete z[ee];delete W[Z]}delete B[C],Object.keys(B).length===0&&delete n[N]}}}function L(){R(),o=!0,r!==s&&(r=s,l(r.object))}function R(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:a,reset:L,resetDefaultState:R,dispose:E,releaseStatesOfGeometry:M,releaseStatesOfObject:v,releaseStatesOfProgram:g,initAttributes:x,enableAttribute:m,disableUnusedAttributes:w}}function Om(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 o(c,l,h){h!==0&&(i.drawArraysInstanced(n,c,l,h),t.update(l,n,h))}function a(c,l,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];t.update(d,n,1)}this.setMode=s,this.render=r,this.renderInstances=o,this.renderMultiDraw=a}function Bm(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 o(g){return!(g!==An&&n.convert(g)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(g){let v=g===Tn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(g!==en&&g!==En&&!v&&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&&(Fe("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);let u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),d=t.logarithmicDepthBuffer===!0&&u===!1;t.reversedDepthBuffer===!0&&u===!1&&Fe("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),t.logarithmicDepthBuffer===!0&&u===!0&&Fe("WebGLRenderer: Logarithmic depth buffer is ignored when reversed depth buffer is enabled.");let f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),w=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),T=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),E=i.getParameter(i.MAX_SAMPLES),M=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:f,maxVertexTextures:_,maxTextureSize:x,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:w,maxVaryings:T,maxFragmentUniforms:S,maxSamples:E,samples:M}}function zm(i){let e=this,t=null,n=0,s=!1,r=!1,o=new an,a=new Ge,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){let f=u.length!==0||d||n!==0||s;return s=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,f){let _=u.clippingPlanes,x=u.clipIntersection,m=u.clipShadows,p=i.get(u);if(!s||_===null||_.length===0||r&&!m)r?h(null):l();else{let w=r?0:n,T=w*4,S=p.clippingState||null;c.value=S,S=h(_,d,T,f);for(let E=0;E!==T;++E)S[E]=t[E];p.clippingState=S,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=w}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,f,_){let x=u!==null?u.length:0,m=null;if(x!==0){if(m=c.value,_!==!0||m===null){let p=f+x*4,w=d.matrixWorldInverse;a.getNormalMatrix(w),(m===null||m.length<p)&&(m=new Float32Array(p));for(let T=0,S=f;T!==x;++T,S+=4)o.copy(u[T]).applyMatrix4(w,a),o.normal.toArray(m,S),m[S+3]=o.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,m}}var rr=class extends cn{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 Bs(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
3825
|
varying vec3 vWorldDirection;
|
|
3826
3826
|
|
|
@@ -3855,9 +3855,9 @@ void main() {
|
|
|
3855
3855
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
3856
3856
|
|
|
3857
3857
|
}
|
|
3858
|
-
`},s=new
|
|
3858
|
+
`},s=new os(5,5,5),r=new In({name:"CubemapFromEquirect",uniforms:Ui(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Jt,blending:Ii});r.uniforms.tEquirect.value=t;let o=new Qt(s,r),a=t.minFilter;return t.minFilter===Kn&&(t.minFilter=Zt),new cs(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){let r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,s);e.setRenderTarget(r)}},Oh=256,km=3,Vm=20,ou=256,au=16,Gm=3,Hm=new k,Wm=new Ye,fa=class i{constructor(e){this._renderer=e,this._cubeSize=0,this._sourceTarget=null,this._cubeCamera=new cs(1,10,null),this._boxMesh=new Qt(new os(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:o=256,position:a=Hm}=r,c=this._renderer;this._setSize(o);let l=this._allocateTarget(),h=this._getSourceTarget(!0);t>0&&(h.texture.mipmapsAutoUpdate=!1);let u=c.autoClear,d=c.autoClearColor,f=c.autoClearDepth,_=c.autoClearStencil,x=e.background;c.autoClear=!0,c.autoClearColor=!0,c.autoClearDepth=!0,c.autoClearStencil=!0,x===null&&(e.background=c.getClearColor(Wm));let m=new cs(n,s,h);return m.position.copy(a),m.update(c,e),c.autoClear=u,c.autoClearColor=d,c.autoClearDepth=f,c.autoClearStencil=_,e.background=x,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=kh(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=zh(),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(Oh,Cl(e))}_fromTexture(e,t){e.mapping===Di||e.mapping===fs?this._setSize(e.image.length===0?Oh: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=Bh(e,!1,!1),n=Math.log2(e)-km;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=Bh(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 o=e.width>>t;e.viewport.set(0,0,o,o),r.update(this._renderer,s),e.viewport.set(0,0,e.width,e.height)}_textureToCubemap(e){let t;e.mapping===Di||e.mapping===fs?(this._cubemapMaterial===null&&(this._cubemapMaterial=kh()),t=this._cubemapMaterial,t.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):(this._equirectMaterial===null&&(this._equirectMaterial=zh()),t=this._equirectMaterial),t.uniforms.envMap.value=e,this._renderCube(this._getSourceTarget(),0,t)}_applyPMREM(e){this._ggxMaterial===null&&(this._ggxMaterial=Xm(),this._integrationMaterial=qm());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/au);for(let o=0;o<=n;o++){let a=i.lodToRoughness(o,n);if(o>n-Gm)r.roughness.value=a,this._renderCube(e,o,this._integrationMaterial);else{let c=a>0?Math.log2(t)+.5*Math.log2(6/(ou*Math.pow(a,4)))+.5:0;s.roughness.value=a,s.lodBias.value=c,this._renderCube(e,o,this._ggxMaterial)}}}_blur(e,t){this._blurMaterial===null&&(this._blurMaterial=Ym());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 Bh(i,e,t){return new rr(i,{minFilter:Kn,generateMipmaps:e,type:Tn,colorSpace:Ps,depthBuffer:t})}function or(i,e,t){return new In({name:i,uniforms:e,vertexShader:$e.cube_vert,fragmentShader:t,side:Jt,blending:Ii,depthTest:!1,depthWrite:!1})}function Xm(){return or("PMREMGGXConvolution",{envMap:{value:null},roughness:{value:0},lodBias:{value:0}},`
|
|
3859
3859
|
|
|
3860
|
-
#define GGX_SAMPLES ${
|
|
3860
|
+
#define GGX_SAMPLES ${ou}u
|
|
3861
3861
|
|
|
3862
3862
|
varying vec3 vWorldDirection;
|
|
3863
3863
|
|
|
@@ -3939,7 +3939,7 @@ void main() {
|
|
|
3939
3939
|
gl_FragColor = vec4( prefilteredColor / totalWeight, 1.0 );
|
|
3940
3940
|
|
|
3941
3941
|
}
|
|
3942
|
-
`)}function
|
|
3942
|
+
`)}function qm(){return or("PMREMGGXIntegration",{envMap:{value:null},roughness:{value:0},sourceLod:{value:0},sourceSize:{value:au}},`
|
|
3943
3943
|
|
|
3944
3944
|
varying vec3 vWorldDirection;
|
|
3945
3945
|
|
|
@@ -3992,9 +3992,9 @@ void main() {
|
|
|
3992
3992
|
gl_FragColor = vec4( prefilteredColor / totalWeight, 1.0 );
|
|
3993
3993
|
|
|
3994
3994
|
}
|
|
3995
|
-
`)}function
|
|
3995
|
+
`)}function Ym(){return or("PMREMSphericalGaussianBlur",{envMap:{value:null},sigma:{value:0}},`
|
|
3996
3996
|
|
|
3997
|
-
#define SAMPLES ${
|
|
3997
|
+
#define SAMPLES ${Vm}
|
|
3998
3998
|
#define GOLDEN_ANGLE 2.39996322973
|
|
3999
3999
|
|
|
4000
4000
|
varying vec3 vWorldDirection;
|
|
@@ -4040,7 +4040,7 @@ void main() {
|
|
|
4040
4040
|
gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
|
|
4041
4041
|
|
|
4042
4042
|
}
|
|
4043
|
-
`)}function
|
|
4043
|
+
`)}function zh(){return or("PMREMEquirectangularToCubemap",{envMap:{value:null}},`
|
|
4044
4044
|
|
|
4045
4045
|
varying vec3 vWorldDirection;
|
|
4046
4046
|
|
|
@@ -4062,7 +4062,7 @@ void main() {
|
|
|
4062
4062
|
gl_FragColor = vec4( color * 0.25, 1.0 );
|
|
4063
4063
|
|
|
4064
4064
|
}
|
|
4065
|
-
`)}function
|
|
4065
|
+
`)}function kh(){return or("PMREMCubemapToCubemap",{envMap:{value:null},flipEnvMap:{value:-1}},`
|
|
4066
4066
|
|
|
4067
4067
|
varying vec3 vWorldDirection;
|
|
4068
4068
|
|
|
@@ -4074,7 +4074,7 @@ void main() {
|
|
|
4074
4074
|
gl_FragColor = vec4( textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ).rgb, 1.0 );
|
|
4075
4075
|
|
|
4076
4076
|
}
|
|
4077
|
-
`)}function
|
|
4077
|
+
`)}function Zm(i){let e=new WeakMap,t=new WeakMap,n=null;function s(d,f=!1){return d==null?null:f?o(d):r(d)}function r(d){if(d&&d.isTexture){let f=d.mapping;if(f===Eo||f===To)if(e.has(d)){let _=e.get(d).texture;return a(_,d.mapping)}else{let _=d.image;if(_&&_.height>0){let x=new rr(_.height);return x.fromEquirectangularTexture(i,d),e.set(d,x),d.addEventListener("dispose",l),a(x.texture,d.mapping)}else return null}}return d}function o(d){if(d&&d.isTexture&&d.isPMREMTexture!==!0){let f=d.mapping,_=f===Eo||f===To,x=f===Di||f===fs;if(_||x){let m=t.get(d),p=m!==void 0?m.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==p)return n===null&&(n=new fa(i)),m=_?n.fromEquirectangular(d,m):n.fromCubemap(d,m),m.texture.pmremVersion=d.pmremVersion,t.set(d,m),m.texture;if(m!==void 0)return m.texture;{let w=d.image;return _&&w&&w.height>0||x&&w&&c(w)?(n===null&&(n=new fa(i)),m=_?n.fromEquirectangular(d):n.fromCubemap(d),m.texture.pmremVersion=d.pmremVersion,t.set(d,m),d.addEventListener("dispose",h),m.texture):null}}}return d}function a(d,f){return f===Eo?d.mapping=Di:f===To&&(d.mapping=fs),d}function c(d){let f=0,_=6;for(let x=0;x<_;x++)d[x]!==void 0&&f++;return f===_}function l(d){let f=d.target;f.removeEventListener("dispose",l);let _=e.get(f);_!==void 0&&(e.delete(f),_.dispose())}function h(d){let f=d.target;f.removeEventListener("dispose",h);let _=t.get(f);_!==void 0&&(t.delete(f),_.dispose())}function u(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:u}}function $m(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&&As("WebGLRenderer: "+n+" extension not supported."),s}}}function Jm(i,e,t,n){let s={},r=new WeakMap,o=new FinalizationRegistry(_=>delete s[_]);function a(_){c(_.target)}function c(_){_.index!==null&&e.remove(_.index);for(let m in _.attributes)e.remove(_.attributes[m]);_.removeEventListener("dispose",a),delete s[_.id],o.unregister(_);let x=r.get(_);x&&(e.remove(x),r.delete(_)),n.releaseStatesOfGeometry(_),_.isInstancedBufferGeometry===!0&&delete _._maxInstanceCount,t.memory.geometries--}function l(_,x){return s[x.id]!==void 0||(x.addEventListener("dispose",a),s[x.id]=new WeakRef(x),o.register(x,x.id,x),t.memory.geometries++),x}function h(_){let x=_.attributes;for(let m in x)e.update(x[m],i.ARRAY_BUFFER)}function u(_){let x=_.index,m=_.attributes.position,p=0;if(m===void 0)return;let w=x!==null?x.array.length:m.array.length/3-1,T=m.count>=65535?Os:Fs,S=new T(Math.ceil(w/3)*6,1),E=S.array;if(x!==null){let g=x.array;p=x.version;for(let v=0,L=0;v<w;v+=3){let R=g[v+0],D=g[v+1],N=g[v+2];E[L++]=R,E[L++]=D,E[L++]=D,E[L++]=N,E[L++]=N,E[L++]=R}}else{p=m.version;for(let g=0,v=0;g<w;g+=3){let L=g+0,R=g+1,D=g+2;E[v++]=L,E[v++]=R,E[v++]=R,E[v++]=D,E[v++]=D,E[v++]=L}}S.version=p;let M=r.get(_);M&&e.remove(M),r.set(_,S)}function d(_){let x=r.get(_);if(x){let m=_.index;m!==null&&x.version<m.version&&u(_)}else u(_);return r.get(_)}function f(){for(let _ in s){let x=s[_].deref();x!==void 0&&c(x)}}return{get:l,update:h,getWireframeAttribute:d,dispose:f}}function Km(i,e,t){let n;function s(u){n=u}let r,o;function a(u){r=u.type,o=u.bytesPerElement}function c(u,d){i.drawElements(n,d,r,u*o),t.update(d,n,1)}function l(u,d,f){f!==0&&(i.drawElementsInstanced(n,d,r,u*o,f),t.update(d,n,f))}function h(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,r,u,0,f);let x=0;for(let m=0;m<f;m++)x+=d[m];t.update(x,n,1)}this.setMode=s,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function jm(i){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(t.calls++,o){case i.TRIANGLES:t.triangles+=a*(r/3);break;case i.LINES:t.lines+=a*(r/2);break;case i.LINE_STRIP:t.lines+=a*(r-1);break;case i.LINE_LOOP:t.lines+=a*r;break;case i.POINTS:t.points+=a*r;break;default:ke("WebGLInfo: Unknown draw mode:",o);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 Qm(i,e,t){let n=new WeakMap,s=new _t;function r(o,a,c){let l=o.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,u=h!==void 0?h.length:0,d=n.get(a);if(d===void 0||d.count!==u){let L=function(){g.dispose(),n.delete(a),a.removeEventListener("dispose",L)};d!==void 0&&d.texture.dispose();let f=a.morphAttributes.position!==void 0,_=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],p=a.morphAttributes.normal||[],w=a.morphAttributes.color||[],T=0;f===!0&&(T=1),_===!0&&(T=2),x===!0&&(T=3);let S=a.attributes.position.count*T,E=1;S>e.maxTextureSize&&(E=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);let M=new Float32Array(S*E*4*u),g=new Ds(M,S,E,u);g.type=En,g.needsUpdate=!0;let v=T*4;for(let R=0;R<u;R++){let D=m[R],N=p[R],B=w[R],C=S*E*4*R;for(let W=0;W<D.count;W++){let Z=W*v;f===!0&&(s.fromBufferAttribute(D,W),M[C+Z+0]=s.x,M[C+Z+1]=s.y,M[C+Z+2]=s.z,M[C+Z+3]=0),_===!0&&(s.fromBufferAttribute(N,W),M[C+Z+4]=s.x,M[C+Z+5]=s.y,M[C+Z+6]=s.z,M[C+Z+7]=0),x===!0&&(s.fromBufferAttribute(B,W),M[C+Z+8]=s.x,M[C+Z+9]=s.y,M[C+Z+10]=s.z,M[C+Z+11]=B.itemSize===4?s.w:1)}}d={count:u,texture:g,size:new Ve(S,E)},n.set(a,d),a.addEventListener("dispose",L)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",o.morphTexture,t);else{let f=0;for(let x=0;x<l.length;x++)f+=l[x];let _=a.morphTargetsRelative?1:1-f;c.getUniforms().setValue(i,"morphTargetBaseInfluence",_),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",d.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:r}}function eg(i,e,t,n,s){let r=new WeakMap;function o(l){let h=s.render.frame,u=l.geometry,d=e.get(l,u);if(r.get(d)!==h&&(e.update(d),r.set(d,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 f=l.skeleton;r.get(f)!==h&&(f.update(),r.set(f,h))}return d}function a(){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:o,dispose:a}}var tg={[cl]:"LINEAR_TONE_MAPPING",[hl]:"REINHARD_TONE_MAPPING",[ul]:"CINEON_TONE_MAPPING",[dl]:"ACES_FILMIC_TONE_MAPPING",[pl]:"AGX_TONE_MAPPING",[$s]:"NEUTRAL_TONE_MAPPING",[fl]:"CUSTOM_TONE_MAPPING"};function ng(i,e,t,n,s,r){let o=new cn(e,t,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=null,h=new $t;h.setAttribute("position",new Yt([-1,3,0,-1,-1,0,3,-1,0],3)),h.setAttribute("uv",new Yt([0,2,0,0,2,0],2));let u=new ao({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
4078
4078
|
precision highp float;
|
|
4079
4079
|
|
|
4080
4080
|
uniform mat4 modelViewMatrix;
|
|
@@ -4120,17 +4120,17 @@ void main() {
|
|
|
4120
4120
|
#ifdef SRGB_TRANSFER
|
|
4121
4121
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
4122
4122
|
#endif
|
|
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
|
|
4125
|
-
`)}var
|
|
4123
|
+
}`,depthTest:!1,depthWrite:!1}),d=new Qt(h,u),f=new Pi(-1,1,1,-1,0,1),_=null,x=null,m=!1,p,w=null,T=[],S=!1;this.setSize=function(E,M){o.setSize(E,M),a!==null&&a.setSize(E,M),c!==null&&c.setSize(E,M);for(let g=0;g<T.length;g++){let v=T[g];v.setSize&&v.setSize(E,M)}},this.setEffects=function(E){T=E,S=T.length>0&&T[0].isRenderPass===!0;let M=o.width,g=o.height;T.length>0&&a===null&&(a=new cn(M,g,{type:Tn,depthBuffer:!1,stencilBuffer:!1}),c=new cn(M,g,{type:Tn,depthBuffer:!1,stencilBuffer:!1}));let v=s===!0&&T.some(L=>L.needsDepthTexture===!0);v!==(o.depthTexture!==null)&&(v===!0&&l===null&&(l=new Jn(M,g),r===!0&&(l.format=jn,l.type=Ni)),o.dispose(),o.depthTexture=v?l:null,o.resolveDepthBuffer=v,o.storeMultisampledDepthBuffer=v);for(let L=0;L<T.length;L++){let R=T[L];R.setSize&&R.setSize(M,g),v&&R.needsDepthTexture===!0&&R.setDepthTexture&&R.setDepthTexture(l)}},this.begin=function(E,M){if(m||E.toneMapping===Ln&&T.length===0)return!1;if(w=M,M!==null){let g=M.width,v=M.height;(o.width!==g||o.height!==v)&&this.setSize(g,v)}return S===!1&&E.setRenderTarget(o),p=E.toneMapping,E.toneMapping=Ln,!0},this.hasRenderPass=function(){return S},this.end=function(E,M){E.toneMapping=p,m=!0;let g=o,v=a;for(let L=0;L<T.length;L++){let R=T[L];R.enabled!==!1&&(R.render(E,v,g,M),R.needsSwap!==!1&&(g=v,v=v===a?c:a))}if(_!==E.outputColorSpace||x!==E.toneMapping){_=E.outputColorSpace,x=E.toneMapping,u.defines={},et.getTransfer(_)===ct&&(u.defines.SRGB_TRANSFER="");let L=tg[x];L&&(u.defines[L]=""),u.needsUpdate=!0}u.uniforms.tDiffuse.value=g.texture,E.setRenderTarget(w),E.render(d,f),w=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){o.dispose(),a!==null&&a.dispose(),c!==null&&c.dispose(),h.dispose(),u.dispose()}}var lu=new jt,cu=new Jn(1,1),hu=new zs(1),uu=new Ds,du=new to,fu=new Bs,Vh=[],Gh=[],Hh=new Float32Array(16),Wh=new Float32Array(9),Xh=new Float32Array(4);function _s(i,e,t){let n=i[0];if(n<=0||n>0)return i;let s=e*t,r=Vh[s];if(r===void 0&&(r=new Float32Array(s),Vh[s]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(r,a)}return r}function Et(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 Tt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function ma(i,e){let t=Gh[e];t===void 0&&(t=new Int32Array(e),Gh[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function ig(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function sg(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(Et(t,e))return;i.uniform2fv(this.addr,e),Tt(t,e)}}function rg(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(Et(t,e))return;i.uniform3fv(this.addr,e),Tt(t,e)}}function og(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(Et(t,e))return;i.uniform4fv(this.addr,e),Tt(t,e)}}function ag(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Et(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Tt(t,e)}else{if(Et(t,n))return;Xh.set(n),i.uniformMatrix2fv(this.addr,!1,Xh),Tt(t,n)}}function lg(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Et(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Tt(t,e)}else{if(Et(t,n))return;Wh.set(n),i.uniformMatrix3fv(this.addr,!1,Wh),Tt(t,n)}}function cg(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Et(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Tt(t,e)}else{if(Et(t,n))return;Hh.set(n),i.uniformMatrix4fv(this.addr,!1,Hh),Tt(t,n)}}function hg(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function ug(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(Et(t,e))return;i.uniform2iv(this.addr,e),Tt(t,e)}}function dg(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(Et(t,e))return;i.uniform3iv(this.addr,e),Tt(t,e)}}function fg(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(Et(t,e))return;i.uniform4iv(this.addr,e),Tt(t,e)}}function pg(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function mg(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(Et(t,e))return;i.uniform2uiv(this.addr,e),Tt(t,e)}}function gg(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(Et(t,e))return;i.uniform3uiv(this.addr,e),Tt(t,e)}}function _g(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(Et(t,e))return;i.uniform4uiv(this.addr,e),Tt(t,e)}}function ga(i){return i.version===0&&(i.compareFunction=El,i.needsUpdate=!0),i}function xg(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=ga(cu):r=lu,t.setTexture2D(e||r,s)}function yg(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||du,s)}function vg(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=ga(hu):r=fu,t.setTextureCube(e||r,s)}function bg(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||uu,s)}function Mg(i){switch(i){case 5126:return ig;case 35664:return sg;case 35665:return rg;case 35666:return og;case 35674:return ag;case 35675:return lg;case 35676:return cg;case 5124:case 35670:return hg;case 35667:case 35671:return ug;case 35668:case 35672:return dg;case 35669:case 35673:return fg;case 5125:return pg;case 36294:return mg;case 36295:return gg;case 36296:return _g;case 35678:case 36198:case 36298:case 36306:case 35682:return xg;case 35679:case 36299:case 36307:return yg;case 35680:case 36300:case 36308:case 36293:return vg;case 36289:case 36303:case 36311:case 36292:return bg}}function Sg(i,e){i.uniform1fv(this.addr,e)}function wg(i,e){let t=_s(e,this.size,2);i.uniform2fv(this.addr,t)}function Eg(i,e){let t=_s(e,this.size,3);i.uniform3fv(this.addr,t)}function Tg(i,e){let t=_s(e,this.size,4);i.uniform4fv(this.addr,t)}function Ag(i,e){let t=_s(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function Rg(i,e){let t=_s(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function Cg(i,e){let t=_s(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Pg(i,e){i.uniform1iv(this.addr,e)}function Ig(i,e){i.uniform2iv(this.addr,e)}function Lg(i,e){i.uniform3iv(this.addr,e)}function Dg(i,e){i.uniform4iv(this.addr,e)}function Ng(i,e){i.uniform1uiv(this.addr,e)}function Ug(i,e){i.uniform2uiv(this.addr,e)}function Fg(i,e){i.uniform3uiv(this.addr,e)}function Og(i,e){i.uniform4uiv(this.addr,e)}function Bg(i,e,t){let n=this.cache,s=e.length,r=ma(t,s);Et(n,r)||(i.uniform1iv(this.addr,r),Tt(n,r));let o;this.type===i.SAMPLER_2D_SHADOW?o=ga(cu):o=lu;for(let a=0;a!==s;++a)t.setTexture2D(e[a]||o,r[a])}function zg(i,e,t){let n=this.cache,s=e.length,r=ma(t,s);Et(n,r)||(i.uniform1iv(this.addr,r),Tt(n,r));for(let o=0;o!==s;++o)t.setTexture3D(e[o]||du,r[o])}function kg(i,e,t){let n=this.cache,s=e.length,r=ma(t,s);Et(n,r)||(i.uniform1iv(this.addr,r),Tt(n,r));let o;this.type===i.SAMPLER_CUBE_SHADOW?o=ga(hu):o=fu;for(let a=0;a!==s;++a)t.setTextureCube(e[a]||o,r[a])}function Vg(i,e,t){let n=this.cache,s=e.length,r=ma(t,s);Et(n,r)||(i.uniform1iv(this.addr,r),Tt(n,r));for(let o=0;o!==s;++o)t.setTexture2DArray(e[o]||uu,r[o])}function Gg(i){switch(i){case 5126:return Sg;case 35664:return wg;case 35665:return Eg;case 35666:return Tg;case 35674:return Ag;case 35675:return Rg;case 35676:return Cg;case 5124:case 35670:return Pg;case 35667:case 35671:return Ig;case 35668:case 35672:return Lg;case 35669:case 35673:return Dg;case 5125:return Ng;case 36294:return Ug;case 36295:return Fg;case 36296:return Og;case 35678:case 36198:case 36298:case 36306:case 35682:return Bg;case 35679:case 36299:case 36307:return zg;case 35680:case 36300:case 36308:case 36293:return kg;case 36289:case 36303:case 36311:case 36292:return Vg}}var Hl=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Mg(t.type)}},Wl=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Gg(t.type)}},Xl=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let s=this.seq;for(let r=0,o=s.length;r!==o;++r){let a=s[r];a.setValue(e,t[a.id],n)}}},Vl=/(\w+)(\])?(\[|\.)?/g;function qh(i,e){i.seq.push(e),i.map[e.id]=e}function Hg(i,e,t){let n=i.name,s=n.length;for(Vl.lastIndex=0;;){let r=Vl.exec(n),o=Vl.lastIndex,a=r[1],c=r[2]==="]",l=r[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===s){qh(t,l===void 0?new Hl(a,i,e):new Wl(a,i,e));break}else{let u=t.map[a];u===void 0&&(u=new Xl(a),qh(t,u)),t=u}}}var gs=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let o=0;o<n;++o){let a=e.getActiveUniform(t,o),c=e.getUniformLocation(t,a.name);Hg(a,c,this)}let s=[],r=[];for(let o of this.seq)o.type===e.SAMPLER_2D_SHADOW||o.type===e.SAMPLER_CUBE_SHADOW||o.type===e.SAMPLER_2D_ARRAY_SHADOW?s.push(o):r.push(o);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,o=t.length;r!==o;++r){let a=t[r],c=n[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,s)}}static seqWithValue(e,t){let n=[];for(let s=0,r=e.length;s!==r;++s){let o=e[s];o.id in t&&n.push(o)}return n}};function Yh(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var Wg=37297,Xg=0;function qg(i,e){let t=i.split(`
|
|
4124
|
+
`),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=s;o<r;o++){let a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
|
|
4125
|
+
`)}var Zh=new Ge;function Yg(i){et._getMatrix(Zh,et.workingColorSpace,i);let e=`mat3( ${Zh.elements.map(t=>t.toFixed(4))} )`;switch(et.getTransfer(i)){case Is:return[e,"LinearTransferOETF"];case ct:return[e,"sRGBTransferOETF"];default:return Fe("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function $h(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";let o=/ERROR: 0:(\d+)/.exec(r);if(o){let a=parseInt(o[1]);return t.toUpperCase()+`
|
|
4126
4126
|
|
|
4127
4127
|
`+r+`
|
|
4128
4128
|
|
|
4129
|
-
`+
|
|
4130
|
-
`)}var
|
|
4131
|
-
`)}function
|
|
4132
|
-
`)}function
|
|
4133
|
-
`)}function
|
|
4129
|
+
`+qg(i.getShaderSource(e),a)}else return r}function Zg(i,e){let t=Yg(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( ${t[0]} * value.rgb, value.a ) );`,"}"].join(`
|
|
4130
|
+
`)}var $g={[cl]:"Linear",[hl]:"Reinhard",[ul]:"Cineon",[dl]:"ACESFilmic",[pl]:"AgX",[$s]:"Neutral",[fl]:"Custom"};function Jg(i,e){let t=$g[e];return t===void 0?(Fe("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var da=new k;function Kg(){et.getLuminanceCoefficients(da);let i=da.x.toFixed(4),e=da.y.toFixed(4),t=da.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
4131
|
+
`)}function jg(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(sr).join(`
|
|
4132
|
+
`)}function Qg(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|
4133
|
+
`)}function e0(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let r=i.getActiveAttrib(e,s),o=r.name,a=1;r.type===i.FLOAT_MAT2&&(a=2),r.type===i.FLOAT_MAT3&&(a=3),r.type===i.FLOAT_MAT4&&(a=4),t[o]={type:r.type,location:i.getAttribLocation(e,o),locationSize:a}}return t}function sr(i){return i!==""}function Jh(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 Kh(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var t0=/^[ \t]*#include +<([\w\d./]+)>/gm;function ql(i){return i.replace(t0,n0)}function n0(i,e){let t=$e[e];if(t===void 0)throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">");return ql(t)}var i0=/#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 jh(i){return i.replace(i0,s0)}function s0(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 Qh(i){let e=`precision ${i.precision} float;
|
|
4134
4134
|
precision ${i.precision} int;
|
|
4135
4135
|
precision ${i.precision} sampler2D;
|
|
4136
4136
|
precision ${i.precision} samplerCube;
|
|
@@ -4150,30 +4150,30 @@ void main() {
|
|
|
4150
4150
|
`;return i.precision==="highp"?e+=`
|
|
4151
4151
|
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
|
|
4152
4152
|
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
|
|
4153
|
-
#define LOW_PRECISION`),e}var
|
|
4154
|
-
`:"";t.isRawShaderMaterial?(
|
|
4155
|
-
`),
|
|
4156
|
-
`),
|
|
4157
|
-
`),
|
|
4158
|
-
`)):(
|
|
4159
|
-
`].filter(
|
|
4160
|
-
`),
|
|
4161
|
-
`].filter(
|
|
4162
|
-
`)),
|
|
4163
|
-
`,
|
|
4153
|
+
#define LOW_PRECISION`),e}var r0={[Zs]:"SHADOWMAP_TYPE_PCF",[us]:"SHADOWMAP_TYPE_VSM"};function o0(i){return r0[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var a0={[fs]:"ENVMAP_MODE_REFRACTION"};function l0(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":a0[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}var c0={[wo]:"ENVMAP_BLENDING_MULTIPLY",[mh]:"ENVMAP_BLENDING_MIX",[gh]:"ENVMAP_BLENDING_ADD"};function h0(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":c0[i.combine]||"ENVMAP_BLENDING_NONE"}function u0(i,e,t,n){let s=i.getContext(),r=t.defines,o=t.vertexShader,a=t.fragmentShader,c=o0(t),l=t.envMapPMREM===!0?"ENVMAP_TYPE_PMREM":"ENVMAP_TYPE_CUBE",h=l0(t),u=h0(t),d=jg(t),f=Qg(r),_=s.createProgram(),x,m,p=t.glslVersion?"#version "+t.glslVersion+`
|
|
4154
|
+
`:"";t.isRawShaderMaterial?(x=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,f].filter(sr).join(`
|
|
4155
|
+
`),x.length>0&&(x+=`
|
|
4156
|
+
`),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,f].filter(sr).join(`
|
|
4157
|
+
`),m.length>0&&(m+=`
|
|
4158
|
+
`)):(x=[Qh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,f,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(sr).join(`
|
|
4160
|
+
`),m=[Qh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,f,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 "+u:"",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!==Ln?"#define TONE_MAPPING":"",t.toneMapping!==Ln?$e.tonemapping_pars_fragment:"",t.toneMapping!==Ln?Jg("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",$e.colorspace_pars_fragment,Zg("linearToOutputTexel",t.outputColorSpace),Kg(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
4161
|
+
`].filter(sr).join(`
|
|
4162
|
+
`)),o=ql(o),o=Jh(o,t),o=Kh(o,t),a=ql(a),a=Jh(a,t),a=Kh(a,t),o=jh(o),a=jh(a),t.isRawShaderMaterial!==!0&&(p=`#version 300 es
|
|
4163
|
+
`,x=[d,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
4164
4164
|
`)+`
|
|
4165
|
-
`+
|
|
4165
|
+
`+x,m=["#define varying in",t.glslVersion===Tl?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Tl?"":"#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(`
|
|
4166
4166
|
`)+`
|
|
4167
|
-
`+
|
|
4167
|
+
`+m);let w=p+x+o,T=p+m+a,S=Yh(s,s.VERTEX_SHADER,w),E=Yh(s,s.FRAGMENT_SHADER,T);s.attachShader(_,S),s.attachShader(_,E),t.index0AttributeName!==void 0?s.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function M(R){if(i.debug.checkShaderErrors){let D=s.getProgramInfoLog(_)||"",N=s.getShaderInfoLog(S)||"",B=s.getShaderInfoLog(E)||"",C=D.trim(),W=N.trim(),Z=B.trim(),z=!0,ee=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(z=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,S,E);else{let q=$h(s,S,"vertex"),J=$h(s,E,"fragment");ke("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+`
|
|
4168
4168
|
|
|
4169
|
-
Material Name: `+
|
|
4170
|
-
Material Type: `+
|
|
4169
|
+
Material Name: `+R.name+`
|
|
4170
|
+
Material Type: `+R.type+`
|
|
4171
4171
|
|
|
4172
4172
|
Program Info Log: `+C+`
|
|
4173
|
-
`+
|
|
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() {
|
|
4173
|
+
`+q+`
|
|
4174
|
+
`+J)}else C!==""?Fe("WebGLProgram: Program Info Log:",C):(W===""||Z==="")&&(ee=!1);ee&&(R.diagnostics={runnable:z,programLog:C,vertexShader:{log:W,prefix:x},fragmentShader:{log:Z,prefix:m}})}s.deleteShader(S),s.deleteShader(E),g=new gs(s,_),v=e0(s,_)}let g;this.getUniforms=function(){return g===void 0&&M(this),g};let v;this.getAttributes=function(){return v===void 0&&M(this),v};let L=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return L===!1&&(L=s.getProgramParameter(_,Wg)),L},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Xg++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=S,this.fragmentShader=E,this}var d0=0,Yl=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 Zl(e),t.set(e,n)),n}},Zl=class{constructor(e){this.id=d0++,this.code=e,this.usedTimes=0}};function f0(i){return i===_i||i===tr||i===nr}function p0(i,e,t,n,s,r){let o=new Ns,a=new Yl,c=new Set,l=[],h=new Map,u=n.logarithmicDepthBuffer,d={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 f(g){return c.add(g),g===0?"uv":`uv${g}`}function _(g,v,L,R,D,N){let B=R.fog,C=D.geometry,W=g.isMeshStandardMaterial||g.isMeshLambertMaterial||g.isMeshPhongMaterial?R.environment:null,Z=g.isMeshStandardMaterial||g.isMeshLambertMaterial&&!g.envMap||g.isMeshPhongMaterial&&!g.envMap,z=e.get(g.envMap||W,Z),ee=d[g.type],q=n.precision;g.precision!==null&&(q=n.getMaxPrecision(g.precision),q!==g.precision&&Fe("WebGLProgram.getParameters:",g.precision,"not supported, using",q,"instead."));let J=C.morphAttributes.position||C.morphAttributes.normal||C.morphAttributes.color,O=J!==void 0?J.length:0,ae=0;C.morphAttributes.position!==void 0&&(ae=1),C.morphAttributes.normal!==void 0&&(ae=2),C.morphAttributes.color!==void 0&&(ae=3);let xe,H,ue,de;if(ee){let ce=Nn[ee];xe=ce.vertexShader,H=ce.fragmentShader}else{xe=g.vertexShader,H=g.fragmentShader;let ce=a.getVertexShaderStage(g),Ue=a.getFragmentShaderStage(g);a.update(g,ce,Ue),ue=ce.id,de=Ue.id}let we=i.getRenderTarget(),fe=i.state.buffers.depth.getReversed(),Te=D.isInstancedMesh===!0,He=D.isBatchedMesh===!0,me=!!g.map,Ie=!!g.matcap,Ne=!!z,Oe=Ne&&z.isPMREMTexture===!0,Ce=!!g.aoMap,We=!!g.lightMap,vt=!!g.bumpMap&&g.wireframe===!1,nt=!!g.normalMap,gt=!!g.displacementMap,Xe=!!g.emissiveMap,ft=!!g.metalnessMap,It=!!g.roughnessMap,Ft=g.anisotropy>0,F=g.clearcoat>0,Lt=g.diffuseRoughness>0,st=g.dispersion>0,rt=g.retroreflectivity>0,_e=g.iridescence>0,ht=g.sheen>0,De=g.transmission>0,Be=Ft&&!!g.anisotropyMap,A=F&&!!g.clearcoatMap,y=F&&!!g.clearcoatNormalMap,V=F&&!!g.clearcoatRoughnessMap,le=Lt&&!!g.diffuseRoughnessMap,se=_e&&!!g.iridescenceMap,he=_e&&!!g.iridescenceThicknessMap,ye=ht&&!!g.sheenColorMap,j=ht&&!!g.sheenRoughnessMap,Q=!!g.specularMap,ge=!!g.specularColorMap,I=!!g.specularIntensityMap,te=De&&!!g.transmissionMap,P=De&&!!g.thicknessMap,ne=!!g.gradientMap,$=!!g.alphaMap,ie=g.alphaTest>0,oe=!!g.alphaHash,re=!!g.extensions,K=Ln;g.toneMapped&&(we===null||we.isXRRenderTarget===!0)&&(K=i.toneMapping);let pe=Oe?z.isCompressedCubeTexture?z.image[0].mipmaps:z.mipmaps:null,Le={shaderID:ee,shaderType:g.type,shaderName:g.name,vertexShader:xe,fragmentShader:H,defines:g.defines,customVertexShaderID:ue,customFragmentShaderID:de,isRawShaderMaterial:g.isRawShaderMaterial===!0,glslVersion:g.glslVersion,precision:q,batching:He,batchingColor:He&&D._colorsTexture!==null,instancing:Te,instancingColor:Te&&D.instanceColor!==null,instancingMorph:Te&&D.morphTexture!==null,outputColorSpace:we===null?i.outputColorSpace:we.isXRRenderTarget===!0?we.texture.colorSpace:et.workingColorSpace,alphaToCoverage:!!g.alphaToCoverage,map:me,matcap:Ie,envMap:Ne,envMapMode:Ne&&z.mapping,envMapPMREM:Oe,envMapMaxLod:Oe?pe.length-1:null,envMapSize:Oe?pe[0].width:null,aoMap:Ce,lightMap:We,bumpMap:vt,normalMap:nt,displacementMap:gt,emissiveMap:Xe,normalMapObjectSpace:nt&&g.normalMapType===yh,normalMapTangentSpace:nt&&g.normalMapType===ha,packedNormalMap:nt&&g.normalMapType===ha&&f0(g.normalMap.format),metalnessMap:ft,roughnessMap:It,anisotropy:Ft,anisotropyMap:Be,clearcoat:F,clearcoatMap:A,clearcoatNormalMap:y,clearcoatRoughnessMap:V,diffuseRoughness:Lt,diffuseRoughnessMap:le,dispersion:st,retroreflection:rt,iridescence:_e,iridescenceMap:se,iridescenceThicknessMap:he,sheen:ht,sheenColorMap:ye,sheenRoughnessMap:j,specularMap:Q,specularColorMap:ge,specularIntensityMap:I,transmission:De,transmissionMap:te,thicknessMap:P,gradientMap:ne,opaque:g.transparent===!1&&g.blending===ds&&g.alphaToCoverage===!1,alphaMap:$,alphaTest:ie,alphaHash:oe,combine:g.combine,mapUv:me&&f(g.map.channel),aoMapUv:Ce&&f(g.aoMap.channel),lightMapUv:We&&f(g.lightMap.channel),bumpMapUv:vt&&f(g.bumpMap.channel),normalMapUv:nt&&f(g.normalMap.channel),displacementMapUv:gt&&f(g.displacementMap.channel),emissiveMapUv:Xe&&f(g.emissiveMap.channel),metalnessMapUv:ft&&f(g.metalnessMap.channel),roughnessMapUv:It&&f(g.roughnessMap.channel),anisotropyMapUv:Be&&f(g.anisotropyMap.channel),clearcoatMapUv:A&&f(g.clearcoatMap.channel),clearcoatNormalMapUv:y&&f(g.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:V&&f(g.clearcoatRoughnessMap.channel),diffuseRoughnessMapUv:le&&f(g.diffuseRoughnessMap.channel),iridescenceMapUv:se&&f(g.iridescenceMap.channel),iridescenceThicknessMapUv:he&&f(g.iridescenceThicknessMap.channel),sheenColorMapUv:ye&&f(g.sheenColorMap.channel),sheenRoughnessMapUv:j&&f(g.sheenRoughnessMap.channel),specularMapUv:Q&&f(g.specularMap.channel),specularColorMapUv:ge&&f(g.specularColorMap.channel),specularIntensityMapUv:I&&f(g.specularIntensityMap.channel),transmissionMapUv:te&&f(g.transmissionMap.channel),thicknessMapUv:P&&f(g.thicknessMap.channel),alphaMapUv:$&&f(g.alphaMap.channel),vertexTangents:!!C.attributes.tangent&&(nt||Ft),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&&(me||$),fog:!!B,useFog:g.fog===!0,fogExp2:!!B&&B.isFogExp2,flatShading:g.wireframe===!1&&(g.flatShading===!0||C.attributes.normal===void 0&&nt===!1&&(g.isMeshLambertMaterial||g.isMeshPhongMaterial||g.isMeshStandardMaterial||g.isMeshPhysicalMaterial)),sizeAttenuation:g.sizeAttenuation===!0,logarithmicDepthBuffer:u,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:O,morphTextureStride:ae,numSunLights:v.sun.length,numDirLights:v.directional.length,numPointLights:v.point.length,numSpotLights:v.spot.length,numSpotLightMaps:v.spotLightMap.length,numRectAreaLights:v.rectArea.length,numHemiLights:v.hemi.length,numSunLightShadows:v.sunShadowMap.length,numDirLightShadows:v.directionalShadowMap.length,numPointLightShadows:v.pointShadowMap.length,numSpotLightShadows:v.spotShadowMap.length,numSpotLightShadowsWithMaps:v.numSpotLightShadowsWithMaps,numLightProbes:v.numLightProbes,numLightProbeGrids:N.filter(ce=>ce.texture!==null).length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:g.dithering,shadowMapEnabled:i.shadowMap.enabled&&L.length>0,shadowMapType:i.shadowMap.type,toneMapping:K,decodeVideoTexture:me&&g.map.isVideoTexture===!0&&et.getTransfer(g.map.colorSpace)===ct,decodeVideoTextureEmissive:Xe&&g.emissiveMap.isVideoTexture===!0&&et.getTransfer(g.emissiveMap.colorSpace)===ct,premultipliedAlpha:g.premultipliedAlpha,doubleSided:g.side===_n,flipSided:g.side===Jt,useDepthPacking:g.depthPacking>=0,depthPacking:g.depthPacking||0,index0AttributeName:g.index0AttributeName,extensionClipCullDistance:re&&g.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(re&&g.extensions.multiDraw===!0||He)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:g.customProgramCacheKey()};return Le.vertexUv1s=c.has(1),Le.vertexUv2s=c.has(2),Le.vertexUv3s=c.has(3),c.clear(),Le}function x(g){let v=[];if(g.shaderID?v.push(g.shaderID):(v.push(g.customVertexShaderID),v.push(g.customFragmentShaderID)),g.defines!==void 0)for(let L in g.defines)v.push(L),v.push(g.defines[L]);return g.isRawShaderMaterial===!1&&(m(v,g),p(v,g),v.push(i.outputColorSpace)),v.push(g.customProgramCacheKey),v.join()}function m(g,v){g.push(v.precision),g.push(v.outputColorSpace),g.push(v.envMapMode),g.push(v.envMapPMREM),g.push(v.envMapMaxLod),g.push(v.envMapSize),g.push(v.mapUv),g.push(v.alphaMapUv),g.push(v.lightMapUv),g.push(v.aoMapUv),g.push(v.bumpMapUv),g.push(v.normalMapUv),g.push(v.displacementMapUv),g.push(v.emissiveMapUv),g.push(v.metalnessMapUv),g.push(v.roughnessMapUv),g.push(v.anisotropyMapUv),g.push(v.clearcoatMapUv),g.push(v.clearcoatNormalMapUv),g.push(v.clearcoatRoughnessMapUv),g.push(v.diffuseRoughnessMapUv),g.push(v.iridescenceMapUv),g.push(v.iridescenceThicknessMapUv),g.push(v.sheenColorMapUv),g.push(v.sheenRoughnessMapUv),g.push(v.specularMapUv),g.push(v.specularColorMapUv),g.push(v.specularIntensityMapUv),g.push(v.transmissionMapUv),g.push(v.thicknessMapUv),g.push(v.combine),g.push(v.fogExp2),g.push(v.sizeAttenuation),g.push(v.morphTargetsCount),g.push(v.numSunLights),g.push(v.numDirLights),g.push(v.numPointLights),g.push(v.numSpotLights),g.push(v.numSpotLightMaps),g.push(v.numHemiLights),g.push(v.numRectAreaLights),g.push(v.numSunLightShadows),g.push(v.numDirLightShadows),g.push(v.numPointLightShadows),g.push(v.numSpotLightShadows),g.push(v.numSpotLightShadowsWithMaps),g.push(v.numLightProbes),g.push(v.numLightProbeGrids),g.push(v.shadowMapType),g.push(v.toneMapping),g.push(v.numClippingPlanes),g.push(v.numClipIntersection),g.push(v.depthPacking)}function p(g,v){o.disableAll(),v.instancing&&o.enable(0),v.instancingColor&&o.enable(1),v.instancingMorph&&o.enable(2),v.matcap&&o.enable(3),v.envMap&&o.enable(4),v.normalMapObjectSpace&&o.enable(5),v.normalMapTangentSpace&&o.enable(6),v.clearcoat&&o.enable(7),v.iridescence&&o.enable(8),v.alphaTest&&o.enable(9),v.vertexColors&&o.enable(10),v.vertexAlphas&&o.enable(11),v.vertexUv1s&&o.enable(12),v.vertexUv2s&&o.enable(13),v.vertexUv3s&&o.enable(14),v.vertexTangents&&o.enable(15),v.anisotropy&&o.enable(16),v.alphaHash&&o.enable(17),v.batching&&o.enable(18),v.dispersion&&o.enable(19),v.retroreflection&&o.enable(24),v.diffuseRoughness&&o.enable(25),v.batchingColor&&o.enable(20),v.gradientMap&&o.enable(21),v.packedNormalMap&&o.enable(22),v.vertexNormals&&o.enable(23),g.push(o.mask),o.disableAll(),v.fog&&o.enable(0),v.useFog&&o.enable(1),v.flatShading&&o.enable(2),v.logarithmicDepthBuffer&&o.enable(3),v.reversedDepthBuffer&&o.enable(4),v.skinning&&o.enable(5),v.morphTargets&&o.enable(6),v.morphNormals&&o.enable(7),v.morphColors&&o.enable(8),v.premultipliedAlpha&&o.enable(9),v.shadowMapEnabled&&o.enable(10),v.doubleSided&&o.enable(11),v.flipSided&&o.enable(12),v.useDepthPacking&&o.enable(13),v.dithering&&o.enable(14),v.transmission&&o.enable(15),v.sheen&&o.enable(16),v.opaque&&o.enable(17),v.pointsUvs&&o.enable(18),v.decodeVideoTexture&&o.enable(19),v.decodeVideoTextureEmissive&&o.enable(20),v.alphaToCoverage&&o.enable(21),v.numLightProbeGrids>0&&o.enable(22),v.hasPositionAttribute&&o.enable(23),g.push(o.mask)}function w(g){let v=d[g.type],L;if(v){let R=Nn[v];L=Nh.clone(R.uniforms)}else L=g.uniforms;return L}function T(g,v){let L=h.get(v);return L!==void 0?++L.usedTimes:(L=new u0(i,v,g,s),l.push(L),h.set(v,L)),L}function S(g){if(--g.usedTimes===0){let v=l.indexOf(g);l[v]=l[l.length-1],l.pop(),h.delete(g.cacheKey),g.destroy()}}function E(g){a.remove(g)}function M(){a.dispose()}return{getParameters:_,getProgramCacheKey:x,getUniforms:w,acquireProgram:T,releaseProgram:S,releaseShaderCache:E,programs:l,dispose:M}}function m0(){let i=new WeakMap;function e(o){return i.has(o)}function t(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function s(o,a,c){i.get(o)[a]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function g0(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 eu(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 tu(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function o(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function a(d,f,_,x,m,p){let w=i[e];return w===void 0?(w={id:d.id,object:d,geometry:f,material:_,materialVariant:o(d),groupOrder:x,renderOrder:d.renderOrder,z:m,group:p},i[e]=w):(w.id=d.id,w.object=d,w.geometry=f,w.material=_,w.materialVariant=o(d),w.groupOrder=x,w.renderOrder=d.renderOrder,w.z=m,w.group=p),e++,w}function c(d,f,_,x,m,p,w){w.reversedDepth===!0&&(m=-m);let T=a(d,f,_,x,m,p);_.transmission>0?n.push(T):_.transparent===!0?s.push(T):t.push(T)}function l(d,f,_,x,m,p){let w=a(d,f,_,x,m,p);_.transmission>0?n.unshift(w):_.transparent===!0?s.unshift(w):t.unshift(w)}function h(d,f){t.length>1&&t.sort(d||g0),n.length>1&&n.sort(f||eu),s.length>1&&s.sort(f||eu)}function u(){for(let d=e,f=i.length;d<f;d++){let _=i[d];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:u,sort:h}}function _0(){let i=new WeakMap;function e(n,s){let r=i.get(n),o;return r===void 0?(o=new tu,i.set(n,[o])):s>=r.length?(o=new tu,r.push(o)):o=r[s],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function x0(){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 k,color:new Ye};break;case"SpotLight":t={position:new k,direction:new k,color:new Ye,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new k,color:new Ye,distance:0,decay:0};break;case"HemisphereLight":t={direction:new k,skyColor:new Ye,groundColor:new Ye};break;case"RectAreaLight":t={color:new Ye,position:new k,halfWidth:new k,halfHeight:new k};break}return i[e.id]=t,t}}}function y0(){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 Ve};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var v0=0;function b0(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function M0(i){let e=new x0,t=y0(),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 k);let s=new k,r=new mt,o=new mt;function a(l){let h=0,u=0,d=0;for(let N=0;N<9;N++)n.probe[N].set(0,0,0);let f=0,_=0,x=0,m=0,p=0,w=0,T=0,S=0,E=0,M=0,g=0,v=0,L=0,R=0;l.sort(b0);for(let N=0,B=l.length;N<B;N++){let C=l[N],W=C.color,Z=C.intensity,z=C.distance,ee=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===_i?ee=C.shadow.map.texture:ee=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=W.r*Z,u+=W.g*Z,d+=W.b*Z;else if(C.isLightProbe){for(let q=0;q<9;q++)n.probe[q].addScaledVector(C.sh.coefficients[q],Z);R++}else if(C.isSunLight){let q=e.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let J=C.shadow,O=t.get(C);O.shadowIntensity=J.intensity,O.shadowBias=J.bias,O.shadowNormalBias=J.normalBias,O.shadowRadius=J.radius,O.shadowMapSize.copy(J.mapSize).multiply(J.getFrameExtents()),n.sunShadow[_]=O,n.sunShadowMap[_]=ee;let ae=J.getViewportCount();for(let xe=0;xe<ae;xe++)n.sunShadowMatrix[x+xe]=J.getMatrix(xe),n.sunShadowCascade[x+xe]=J._cascadeData[xe];x+=ae,_++}n.sun[f]=q,f++}else if(C.isDirectionalLight){let q=e.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let J=C.shadow,O=t.get(C);O.shadowIntensity=J.intensity,O.shadowBias=J.bias,O.shadowNormalBias=J.normalBias,O.shadowRadius=J.radius,O.shadowMapSize=J.mapSize,n.directionalShadow[m]=O,n.directionalShadowMap[m]=ee,n.directionalShadowMatrix[m]=C.shadow.matrix,E++}n.directional[m]=q,m++}else if(C.isSpotLight){let q=e.get(C);q.position.setFromMatrixPosition(C.matrixWorld),q.color.copy(W).multiplyScalar(Z),q.distance=z,q.coneCos=Math.cos(C.angle),q.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),q.decay=C.decay,n.spot[w]=q;let J=C.shadow;if(C.map&&(n.spotLightMap[v]=C.map,v++,J.updateMatrices(C),C.castShadow&&L++),n.spotLightMatrix[w]=J.matrix,C.castShadow){let O=t.get(C);O.shadowIntensity=J.intensity,O.shadowBias=J.bias,O.shadowNormalBias=J.normalBias,O.shadowRadius=J.radius,O.shadowMapSize=J.mapSize,n.spotShadow[w]=O,n.spotShadowMap[w]=ee,g++}w++}else if(C.isRectAreaLight){let q=e.get(C);q.color.copy(W).multiplyScalar(Z),q.halfWidth.set(C.width*.5,0,0),q.halfHeight.set(0,C.height*.5,0),n.rectArea[T]=q,T++}else if(C.isPointLight){let q=e.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),q.distance=C.distance,q.decay=C.decay,C.castShadow){let J=C.shadow,O=t.get(C);O.shadowIntensity=J.intensity,O.shadowBias=J.bias,O.shadowNormalBias=J.normalBias,O.shadowRadius=J.radius,O.shadowMapSize=J.mapSize,O.shadowCameraNear=J.camera.near,O.shadowCameraFar=J.camera.far,n.pointShadow[p]=O,n.pointShadowMap[p]=ee,n.pointShadowMatrix[p]=C.shadow.matrix,M++}n.point[p]=q,p++}else if(C.isHemisphereLight){let q=e.get(C);q.skyColor.copy(C.color).multiplyScalar(Z),q.groundColor.copy(C.groundColor).multiplyScalar(Z),n.hemi[S]=q,S++}}T>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]=u,n.ambient[2]=d;let D=n.hash;(D.sunLength!==f||D.directionalLength!==m||D.pointLength!==p||D.spotLength!==w||D.rectAreaLength!==T||D.hemiLength!==S||D.numSunShadows!==_||D.numDirectionalShadows!==E||D.numPointShadows!==M||D.numSpotShadows!==g||D.numSpotMaps!==v||D.numLightProbes!==R)&&(n.sun.length=f,n.directional.length=m,n.spot.length=w,n.rectArea.length=T,n.point.length=p,n.hemi.length=S,n.sunShadow.length=_,n.sunShadowMap.length=_,n.sunShadowMatrix.length=x,n.sunShadowCascade.length=x,n.directionalShadow.length=E,n.directionalShadowMap.length=E,n.directionalShadowMatrix.length=E,n.pointShadow.length=M,n.pointShadowMap.length=M,n.pointShadowMatrix.length=M,n.spotShadow.length=g,n.spotShadowMap.length=g,n.spotLightMatrix.length=g+v-L,n.spotLightMap.length=v,n.numSpotLightShadowsWithMaps=L,n.numLightProbes=R,D.sunLength=f,D.directionalLength=m,D.pointLength=p,D.spotLength=w,D.rectAreaLength=T,D.hemiLength=S,D.numSunShadows=_,D.numDirectionalShadows=E,D.numPointShadows=M,D.numSpotShadows=g,D.numSpotMaps=v,D.numLightProbes=R,n.version=v0++)}function c(l,h){let u=0,d=0,f=0,_=0,x=0,m=0,p=h.matrixWorldInverse;for(let w=0,T=l.length;w<T;w++){let S=l[w];if(S.isSunLight){let E=n.sun[u];E.direction.setFromMatrixPosition(S.matrixWorld),E.direction.transformDirection(p),u++}else if(S.isDirectionalLight){let E=n.directional[d];E.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(p),d++}else if(S.isSpotLight){let E=n.spot[_];E.position.setFromMatrixPosition(S.matrixWorld),E.position.applyMatrix4(p),E.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(p),_++}else if(S.isRectAreaLight){let E=n.rectArea[x];E.position.setFromMatrixPosition(S.matrixWorld),E.position.applyMatrix4(p),o.identity(),r.copy(S.matrixWorld),r.premultiply(p),o.extractRotation(r),E.halfWidth.set(S.width*.5,0,0),E.halfHeight.set(0,S.height*.5,0),E.halfWidth.applyMatrix4(o),E.halfHeight.applyMatrix4(o),x++}else if(S.isPointLight){let E=n.point[f];E.position.setFromMatrixPosition(S.matrixWorld),E.position.applyMatrix4(p),f++}else if(S.isHemisphereLight){let E=n.hemi[m];E.direction.setFromMatrixPosition(S.matrixWorld),E.direction.transformDirection(p),m++}}}return{setup:a,setupView:c,state:n}}function nu(i){let e=new M0(i),t=[],n=[],s=[];function r(u){h.camera=u,t.length=0,n.length=0,s.length=0}function o(u){u.isLightProbeGrid?s.push(u):t.push(u)}function a(u){n.push(u)}function c(){e.setup(t),s.sort((u,d)=>u.priority-d.priority||u.id-d.id)}function l(u){e.setupView(t,u)}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:o,pushShadow:a}}function S0(i){let e=new WeakMap;function t(s,r=0){let o=e.get(s),a;return o===void 0?(a=new nu(i),e.set(s,[a])):r>=o.length?(a=new nu(i),o.push(a)):a=o[r],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var w0=`void main() {
|
|
4175
4175
|
gl_Position = vec4( position, 1.0 );
|
|
4176
|
-
}`,
|
|
4176
|
+
}`,E0=`uniform sampler2D shadow_pass;
|
|
4177
4177
|
uniform vec2 resolution;
|
|
4178
4178
|
uniform float radius;
|
|
4179
4179
|
void main() {
|
|
@@ -4198,12 +4198,12 @@ void main() {
|
|
|
4198
4198
|
squared_mean = squared_mean / samples;
|
|
4199
4199
|
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
|
4200
4200
|
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
|
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_=`
|
|
4201
|
+
}`,T0=[new k(1,0,0),new k(-1,0,0),new k(0,1,0),new k(0,-1,0),new k(0,0,1),new k(0,0,-1)],A0=[new k(0,-1,0),new k(0,-1,0),new k(0,0,1),new k(0,0,-1),new k(0,-1,0),new k(0,-1,0)],iu=new mt,ir=new k,Gl=new k;function R0(i,e,t){let n=new hi,s=new Ve,r=new Ve,o=new _t,a=new lo,c=new co,l={},h=t.maxTextureSize,u={[gi]:Jt,[Jt]:gi,[_n]:_n},d=new In({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ve},radius:{value:4}},vertexShader:w0,fragmentShader:E0}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let _=new $t;_.setAttribute("position",new Vt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new Qt(_,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Zs;let p=this.type;this.render=function(M,g,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||M.length===0)return;this.type===Jc&&(Fe("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Zs);let L=i.getRenderTarget(),R=i.getActiveCubeFace(),D=i.getActiveMipmapLevel(),N=i.state;N.setBlending(Ii),N.buffers.depth.getReversed()===!0?N.buffers.color.setClear(0,0,0,0):N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);let B=p!==this.type;B&&g.traverse(function(C){C.material&&(Array.isArray(C.material)?C.material.forEach(W=>W.needsUpdate=!0):C.material.needsUpdate=!0)});for(let C=0,W=M.length;C<W;C++){let Z=M[C],z=Z.shadow;if(z===void 0){Fe("WebGLShadowMap:",Z,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;s.copy(z.mapSize);let ee=z.getFrameExtents();s.multiply(ee),r.copy(z.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/ee.x),s.x=r.x*ee.x,z.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/ee.y),s.y=r.y*ee.y,z.mapSize.y=r.y));let q=i.state.buffers.depth.getReversed();if(z.camera._reversedDepth=q,z.map===null||B===!0){if(z.map!==null&&(z.map.depthTexture!==null&&(z.map.depthTexture.dispose(),z.map.depthTexture=null),z.map.dispose()),this.type===us){if(Z.isPointLight){Fe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}z.map=new cn(s.x,s.y,{format:_i,type:Tn,minFilter:Zt,magFilter:Zt,generateMipmaps:!1}),z.map.texture.name=Z.name+".shadowMap",z.map.depthTexture=new Jn(s.x,s.y,En),z.map.depthTexture.name=Z.name+".shadowMapDepth",z.map.depthTexture.format=Yn,z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Pt,z.map.depthTexture.magFilter=Pt}else Z.isPointLight?(z.map=new rr(s.x),z.map.depthTexture=new zs(s.x,wn)):(z.map=new cn(s.x,s.y),z.map.depthTexture=new Jn(s.x,s.y,wn)),z.map.depthTexture.name=Z.name+".shadowMap",z.map.depthTexture.format=Yn,this.type===Zs?(z.map.depthTexture.compareFunction=q?wl:Sl,z.map.depthTexture.minFilter=Zt,z.map.depthTexture.magFilter=Zt):(z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Pt,z.map.depthTexture.magFilter=Pt);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 J=z.map.isWebGLCubeRenderTarget?6:z.getViewportCount();Z.isPointLight!==!0&&z.updateMatrices(Z,v);let O=(z.camera.layers.mask&4294967294)!==0?z.camera.layers:v.layers;for(let ae=0;ae<J;ae++){let xe=z.getCamera(ae);if(Z.isPointLight){let H=z.camera,ue=z.matrix,de=Z.distance||H.far;de!==H.far&&(H.far=de,H.updateProjectionMatrix()),ir.setFromMatrixPosition(Z.matrixWorld),H.position.copy(ir),Gl.copy(H.position),Gl.add(T0[ae]),H.up.copy(A0[ae]),H.lookAt(Gl),H.updateMatrixWorld(),ue.makeTranslation(-ir.x,-ir.y,-ir.z),iu.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse),z._frustum.setFromProjectionMatrix(iu,H.coordinateSystem,H.reversedDepth)}if(z.map.isWebGLCubeRenderTarget)i.setRenderTarget(z.map,ae),i.clear();else{ae===0&&(i.setRenderTarget(z.map),i.clear());let H=z.getViewport(ae);o.set(r.x*H.x,r.y*H.y,r.x*H.z,r.y*H.w),N.viewport(o)}n=z.getFrustum(ae),S(g,v,xe,Z,O,this.type)}z.isPointLightShadow!==!0&&this.type===us&&w(z,v),z.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(L,R,D)};function w(M,g){let v=e.update(x);d.defines.VSM_SAMPLES!==M.blurSamples&&(d.defines.VSM_SAMPLES=M.blurSamples,f.defines.VSM_SAMPLES=M.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),M.mapPass===null?M.mapPass=new cn(s.x,s.y,{format:_i,type:Tn}):(M.mapPass.width!==M.map.width||M.mapPass.height!==M.map.height)&&M.mapPass.setSize(M.map.width,M.map.height),d.uniforms.shadow_pass.value=M.map.depthTexture,d.uniforms.resolution.value.set(M.map.width,M.map.height),d.uniforms.radius.value=M.radius,i.setRenderTarget(M.mapPass),i.clear(),i.renderBufferDirect(g,null,v,d,x,null),f.uniforms.shadow_pass.value=M.mapPass.texture,f.uniforms.resolution.value.set(M.map.width,M.map.height),f.uniforms.radius.value=M.radius,i.setRenderTarget(M.map),i.clear(),i.renderBufferDirect(g,null,v,f,x,null)}function T(M,g,v,L){let R=null,D=v.isPointLight===!0?M.customDistanceMaterial:M.customDepthMaterial;if(D!==void 0)R=D;else if(R=v.isPointLight===!0?c:a,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 N=R.uuid,B=g.uuid,C=l[N];C===void 0&&(C={},l[N]=C);let W=C[B];W===void 0&&(W=R.clone(),C[B]=W,g.addEventListener("dispose",E)),R=W}if(R.visible=g.visible,R.wireframe=g.wireframe,L===us?R.side=g.shadowSide!==null?g.shadowSide:g.side:R.side=g.shadowSide!==null?g.shadowSide:u[g.side],R.alphaMap=g.alphaMap,R.alphaTest=g.alphaToCoverage===!0?.5:g.alphaTest,R.map=g.map,R.clipShadows=g.clipShadows,R.clippingPlanes=g.clippingPlanes,R.clipIntersection=g.clipIntersection,R.displacementMap=g.displacementMap,R.displacementScale=g.displacementScale,R.displacementBias=g.displacementBias,R.wireframeLinewidth=g.wireframeLinewidth,R.linewidth=g.linewidth,v.isPointLight===!0&&R.isMeshDistanceMaterial===!0){let N=i.properties.get(R);N.light=v}return R}function S(M,g,v,L,R,D){if(M.visible===!1)return;if(M.layers.test(R)&&(M.isMesh||M.isLine||M.isPoints)&&(M.castShadow||M.receiveShadow&&D===us)&&(!M.frustumCulled||M.intersectsFrustum(n))){M.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,M.matrixWorld);let C=e.update(M),W=M.material;if(Array.isArray(W)){let Z=C.groups;for(let z=0,ee=Z.length;z<ee;z++){let q=Z[z],J=W[q.materialIndex];if(J&&J.visible){let O=T(M,J,L,D);M.onBeforeShadow(i,M,g,v,C,O,q),i.renderBufferDirect(v,null,C,O,M,q),M.onAfterShadow(i,M,g,v,C,O,q)}}}else if(W.visible){let Z=T(M,W,L,D);M.onBeforeShadow(i,M,g,v,C,Z,null),i.renderBufferDirect(v,null,C,Z,M,null),M.onAfterShadow(i,M,g,v,C,Z,null)}}let B=M.children;for(let C=0,W=B.length;C<W;C++)S(B[C],g,v,L,R,D)}function E(M){M.target.removeEventListener("dispose",E);for(let v in l){let L=l[v],R=M.target.uuid;R in L&&(L[R].dispose(),delete L[R])}}}function C0(i,e){function t(){let I=!1,te=new _t,P=null,ne=new _t(0,0,0,0);return{setMask:function($){P!==$&&!I&&(i.colorMask($,$,$,$),P=$)},setLocked:function($){I=$},setClear:function($,ie,oe,re,K){K===!0&&($*=re,ie*=re,oe*=re),te.set($,ie,oe,re),ne.equals(te)===!1&&(i.clearColor($,ie,oe,re),ne.copy(te))},reset:function(){I=!1,P=null,ne.set(-1,0,0,0)}}}function n(){let I=!1,te=!1,P=null,ne=null,$=null;return{setReversed:function(ie){if(te!==ie){let oe=e.get("EXT_clip_control");ie?oe.clipControlEXT(oe.LOWER_LEFT_EXT,oe.ZERO_TO_ONE_EXT):oe.clipControlEXT(oe.LOWER_LEFT_EXT,oe.NEGATIVE_ONE_TO_ONE_EXT),te=ie;let re=$;$=null,this.setClear(re)}},getReversed:function(){return te},setTest:function(ie){ie?fe(i.DEPTH_TEST):Te(i.DEPTH_TEST)},setMask:function(ie){P!==ie&&!I&&(i.depthMask(ie),P=ie)},setFunc:function(ie){if(te&&(ie=Ph[ie]),ne!==ie){switch(ie){case Hr:i.depthFunc(i.NEVER);break;case Wr:i.depthFunc(i.ALWAYS);break;case Xr:i.depthFunc(i.LESS);break;case ji:i.depthFunc(i.LEQUAL);break;case qr:i.depthFunc(i.EQUAL);break;case Yr:i.depthFunc(i.GEQUAL);break;case Zr:i.depthFunc(i.GREATER);break;case $r:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ne=ie}},setLocked:function(ie){I=ie},setClear:function(ie){$!==ie&&($=ie,te&&(ie=1-ie),i.clearDepth(ie))},reset:function(){I=!1,P=null,ne=null,$=null,te=!1}}}function s(){let I=!1,te=null,P=null,ne=null,$=null,ie=null,oe=null,re=null,K=null;return{setTest:function(pe){I||(pe?fe(i.STENCIL_TEST):Te(i.STENCIL_TEST))},setMask:function(pe){te!==pe&&!I&&(i.stencilMask(pe),te=pe)},setFunc:function(pe,Le,ce){(P!==pe||ne!==Le||$!==ce)&&(i.stencilFunc(pe,Le,ce),P=pe,ne=Le,$=ce)},setOp:function(pe,Le,ce){(ie!==pe||oe!==Le||re!==ce)&&(i.stencilOp(pe,Le,ce),ie=pe,oe=Le,re=ce)},setLocked:function(pe){I=pe},setClear:function(pe){K!==pe&&(i.clearStencil(pe),K=pe)},reset:function(){I=!1,te=null,P=null,ne=null,$=null,ie=null,oe=null,re=null,K=null}}}let r=new t,o=new n,a=new s,c={},l=new WeakMap,h={},u={},d={},f=new WeakMap,_=[],x=null,m=!1,p=null,w=null,T=null,S=null,E=null,M=null,g=null,v=new Ye(0,0,0),L=0,R=!1,D=null,N=null,B=null,C=null,W=null,Z=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),z=!1,ee=0,q=i.getParameter(i.VERSION);q.indexOf("WebGL")!==-1?(ee=parseFloat(/^WebGL (\d)/.exec(q)[1]),z=ee>=1):q.indexOf("OpenGL ES")!==-1&&(ee=parseFloat(/^OpenGL ES (\d)/.exec(q)[1]),z=ee>=2);let J=null,O={},ae=i.getParameter(i.SCISSOR_BOX),xe=i.getParameter(i.VIEWPORT),H=new _t().fromArray(ae),ue=new _t().fromArray(xe);function de(I,te,P,ne){let $=new Uint8Array(4),ie=i.createTexture();i.bindTexture(I,ie),i.texParameteri(I,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(I,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let oe=0;oe<P;oe++)I===i.TEXTURE_3D||I===i.TEXTURE_2D_ARRAY?i.texImage3D(te,0,i.RGBA,1,1,ne,0,i.RGBA,i.UNSIGNED_BYTE,$):i.texImage2D(te+oe,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,$);return ie}let we={};we[i.TEXTURE_2D]=de(i.TEXTURE_2D,i.TEXTURE_2D,1),we[i.TEXTURE_CUBE_MAP]=de(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),we[i.TEXTURE_2D_ARRAY]=de(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),we[i.TEXTURE_3D]=de(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),fe(i.DEPTH_TEST),o.setFunc(ji),vt(!1),nt(il),fe(i.CULL_FACE),Ce(Ii);function fe(I){h[I]!==!0&&(i.enable(I),h[I]=!0)}function Te(I){h[I]!==!1&&(i.disable(I),h[I]=!1)}function He(I,te){return d[I]!==te?(i.bindFramebuffer(I,te),d[I]=te,I===i.DRAW_FRAMEBUFFER&&(d[i.FRAMEBUFFER]=te),I===i.FRAMEBUFFER&&(d[i.DRAW_FRAMEBUFFER]=te),!0):!1}function me(I,te){let P=_,ne=!1;if(I){P=f.get(te),P===void 0&&(P=[],f.set(te,P));let $=I.textures;if(P.length!==$.length||P[0]!==i.COLOR_ATTACHMENT0){for(let ie=0,oe=$.length;ie<oe;ie++)P[ie]=i.COLOR_ATTACHMENT0+ie;P.length=$.length,ne=!0}}else P[0]!==i.BACK&&(P[0]=i.BACK,ne=!0);ne&&i.drawBuffers(P)}function Ie(I){return x!==I?(i.useProgram(I),x=I,!0):!1}let Ne={[Li]:i.FUNC_ADD,[jc]:i.FUNC_SUBTRACT,[Qc]:i.FUNC_REVERSE_SUBTRACT};Ne[eh]=i.MIN,Ne[th]=i.MAX;let Oe={[nh]:i.ZERO,[ih]:i.ONE,[sh]:i.SRC_COLOR,[al]:i.SRC_ALPHA,[hh]:i.SRC_ALPHA_SATURATE,[lh]:i.DST_COLOR,[oh]:i.DST_ALPHA,[rh]:i.ONE_MINUS_SRC_COLOR,[ll]:i.ONE_MINUS_SRC_ALPHA,[ch]:i.ONE_MINUS_DST_COLOR,[ah]:i.ONE_MINUS_DST_ALPHA,[uh]:i.CONSTANT_COLOR,[dh]:i.ONE_MINUS_CONSTANT_COLOR,[fh]:i.CONSTANT_ALPHA,[ph]:i.ONE_MINUS_CONSTANT_ALPHA};function Ce(I,te,P,ne,$,ie,oe,re,K,pe){if(I===Ii){m===!0&&(Te(i.BLEND),m=!1);return}if(m===!1&&(fe(i.BLEND),m=!0),I!==Kc){if(I!==p||pe!==R){if((w!==Li||E!==Li)&&(i.blendEquation(i.FUNC_ADD),w=Li,E=Li),pe)switch(I){case ds:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case sl:i.blendFunc(i.ONE,i.ONE);break;case rl:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case ol:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:ke("WebGLState: Invalid blending: ",I);break}else switch(I){case ds:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case sl:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case rl:ke("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case ol:ke("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ke("WebGLState: Invalid blending: ",I);break}T=null,S=null,M=null,g=null,v.set(0,0,0),L=0,p=I,R=pe}return}$=$||te,ie=ie||P,oe=oe||ne,(te!==w||$!==E)&&(i.blendEquationSeparate(Ne[te],Ne[$]),w=te,E=$),(P!==T||ne!==S||ie!==M||oe!==g)&&(i.blendFuncSeparate(Oe[P],Oe[ne],Oe[ie],Oe[oe]),T=P,S=ne,M=ie,g=oe),(re.equals(v)===!1||K!==L)&&(i.blendColor(re.r,re.g,re.b,K),v.copy(re),L=K),p=I,R=!1}function We(I,te){I.side===_n?Te(i.CULL_FACE):fe(i.CULL_FACE);let P=I.side===Jt;te&&(P=!P),vt(P),I.blending===ds&&I.transparent===!1?Ce(Ii):Ce(I.blending,I.blendEquation,I.blendSrc,I.blendDst,I.blendEquationAlpha,I.blendSrcAlpha,I.blendDstAlpha,I.blendColor,I.blendAlpha,I.premultipliedAlpha),o.setFunc(I.depthFunc),o.setTest(I.depthTest),o.setMask(I.depthWrite),r.setMask(I.colorWrite);let ne=I.stencilWrite;a.setTest(ne),ne&&(a.setMask(I.stencilWriteMask),a.setFunc(I.stencilFunc,I.stencilRef,I.stencilFuncMask),a.setOp(I.stencilFail,I.stencilZFail,I.stencilZPass)),Xe(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),I.alphaToCoverage===!0?fe(i.SAMPLE_ALPHA_TO_COVERAGE):Te(i.SAMPLE_ALPHA_TO_COVERAGE)}function vt(I){D!==I&&(I?i.frontFace(i.CW):i.frontFace(i.CCW),D=I)}function nt(I){I!==Zc?(fe(i.CULL_FACE),I!==N&&(I===il?i.cullFace(i.BACK):I===$c?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Te(i.CULL_FACE),N=I}function gt(I){I!==B&&(z&&i.lineWidth(I),B=I)}function Xe(I,te,P){I?(fe(i.POLYGON_OFFSET_FILL),(C!==te||W!==P)&&(C=te,W=P,o.getReversed()&&(te=-te,P=-P),i.polygonOffset(te,P))):Te(i.POLYGON_OFFSET_FILL)}function ft(I){I?fe(i.SCISSOR_TEST):Te(i.SCISSOR_TEST)}function It(I){I===void 0&&(I=i.TEXTURE0+Z-1),J!==I&&(i.activeTexture(I),J=I)}function Ft(I,te,P){P===void 0&&(J===null?P=i.TEXTURE0+Z-1:P=J);let ne=O[P];ne===void 0&&(ne={type:void 0,texture:void 0},O[P]=ne),(ne.type!==I||ne.texture!==te)&&(J!==P&&(i.activeTexture(P),J=P),i.bindTexture(I,te||we[I]),ne.type=I,ne.texture=te)}function F(){let I=O[J];I!==void 0&&I.type!==void 0&&(i.bindTexture(I.type,null),I.type=void 0,I.texture=void 0)}function Lt(){try{i.compressedTexImage2D(...arguments)}catch(I){ke("WebGLState:",I)}}function st(){try{i.compressedTexImage3D(...arguments)}catch(I){ke("WebGLState:",I)}}function rt(){try{i.texSubImage2D(...arguments)}catch(I){ke("WebGLState:",I)}}function _e(){try{i.texSubImage3D(...arguments)}catch(I){ke("WebGLState:",I)}}function ht(){try{i.compressedTexSubImage2D(...arguments)}catch(I){ke("WebGLState:",I)}}function De(){try{i.compressedTexSubImage3D(...arguments)}catch(I){ke("WebGLState:",I)}}function Be(){try{i.texStorage2D(...arguments)}catch(I){ke("WebGLState:",I)}}function A(){try{i.texStorage3D(...arguments)}catch(I){ke("WebGLState:",I)}}function y(){try{i.texImage2D(...arguments)}catch(I){ke("WebGLState:",I)}}function V(){try{i.texImage3D(...arguments)}catch(I){ke("WebGLState:",I)}}function le(I){return u[I]!==void 0?u[I]:i.getParameter(I)}function se(I,te){u[I]!==te&&(i.pixelStorei(I,te),u[I]=te)}function he(I){H.equals(I)===!1&&(i.scissor(I.x,I.y,I.z,I.w),H.copy(I))}function ye(I){ue.equals(I)===!1&&(i.viewport(I.x,I.y,I.z,I.w),ue.copy(I))}function j(I,te){let P=l.get(te);P===void 0&&(P=new WeakMap,l.set(te,P));let ne=P.get(I);ne===void 0&&(ne=i.getUniformBlockIndex(te,I.name),i.uniformBlockBinding(te,ne,ne),P.set(I,ne))}function Q(I,te,P){let $=l.get(te).get(I);c[$]!==P&&(i.bindBufferBase(i.UNIFORM_BUFFER,$,P),c[$]=P)}function ge(){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),o.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={},u={},J=null,O={},d={},c={},f=new WeakMap,_=[],x=null,m=!1,p=null,w=null,T=null,S=null,E=null,M=null,g=null,v=new Ye(0,0,0),L=0,R=!1,D=null,N=null,B=null,C=null,W=null,H.set(0,0,i.canvas.width,i.canvas.height),ue.set(0,0,i.canvas.width,i.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:fe,disable:Te,bindFramebuffer:He,drawBuffers:me,useProgram:Ie,setBlending:Ce,setMaterial:We,setFlipSided:vt,setCullFace:nt,setLineWidth:gt,setPolygonOffset:Xe,setScissorTest:ft,activeTexture:It,bindTexture:Ft,unbindTexture:F,compressedTexImage2D:Lt,compressedTexImage3D:st,texImage2D:y,texImage3D:V,pixelStorei:se,getParameter:le,updateUBOMapping:j,uniformBlockBinding:Q,texStorage2D:Be,texStorage3D:A,texSubImage2D:rt,texSubImage3D:_e,compressedTexSubImage2D:ht,compressedTexSubImage3D:De,scissor:he,viewport:ye,reset:ge}}function P0(i,e,t,n,s,r,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ve,h=new WeakMap,u=new Set,d,f=new WeakMap,_=new Set,x=new FinalizationRegistry(A=>_.delete(A)),m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(A,y){return m?new OffscreenCanvas(A,y):Ls("canvas")}function w(A,y,V){let le=1,se=Be(A);if((se.width>V||se.height>V)&&(le=V/Math.max(se.width,se.height)),le<1)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap||typeof VideoFrame<"u"&&A instanceof VideoFrame){let he=Math.floor(le*se.width),ye=Math.floor(le*se.height);d===void 0&&(d=p(he,ye));let j=y?p(he,ye):d;return j.width=he,j.height=ye,j.getContext("2d").drawImage(A,0,0,he,ye),Fe("WebGLRenderer: Texture has been resized from ("+se.width+"x"+se.height+") to ("+he+"x"+ye+")."),j}else return"data"in A&&Fe("WebGLRenderer: Image in DataTexture is too big ("+se.width+"x"+se.height+")."),A;return A}function T(A){return A.generateMipmaps}function S(A){i.generateMipmap(A)}function E(A){return A.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:A.isWebGL3DRenderTarget?i.TEXTURE_3D:A.isWebGLArrayRenderTarget||A.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(A,y,V,le,se,he=!1){if(A!==null){if(i[A]!==void 0)return i[A];Fe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let ye;le&&(ye=e.get("EXT_texture_norm16"),ye||Fe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let j=y;if(y===i.RED&&(V===i.FLOAT&&(j=i.R32F),V===i.HALF_FLOAT&&(j=i.R16F),V===i.UNSIGNED_BYTE&&(j=i.R8),V===i.UNSIGNED_SHORT&&ye&&(j=ye.R16_EXT),V===i.SHORT&&ye&&(j=ye.R16_SNORM_EXT)),y===i.RED_INTEGER&&(V===i.UNSIGNED_BYTE&&(j=i.R8UI),V===i.UNSIGNED_SHORT&&(j=i.R16UI),V===i.UNSIGNED_INT&&(j=i.R32UI),V===i.BYTE&&(j=i.R8I),V===i.SHORT&&(j=i.R16I),V===i.INT&&(j=i.R32I)),y===i.RG&&(V===i.FLOAT&&(j=i.RG32F),V===i.HALF_FLOAT&&(j=i.RG16F),V===i.UNSIGNED_BYTE&&(j=i.RG8),V===i.UNSIGNED_SHORT&&ye&&(j=ye.RG16_EXT),V===i.SHORT&&ye&&(j=ye.RG16_SNORM_EXT)),y===i.RG_INTEGER&&(V===i.UNSIGNED_BYTE&&(j=i.RG8UI),V===i.UNSIGNED_SHORT&&(j=i.RG16UI),V===i.UNSIGNED_INT&&(j=i.RG32UI),V===i.BYTE&&(j=i.RG8I),V===i.SHORT&&(j=i.RG16I),V===i.INT&&(j=i.RG32I)),y===i.RGB_INTEGER&&(V===i.UNSIGNED_BYTE&&(j=i.RGB8UI),V===i.UNSIGNED_SHORT&&(j=i.RGB16UI),V===i.UNSIGNED_INT&&(j=i.RGB32UI),V===i.BYTE&&(j=i.RGB8I),V===i.SHORT&&(j=i.RGB16I),V===i.INT&&(j=i.RGB32I)),y===i.RGBA_INTEGER&&(V===i.UNSIGNED_BYTE&&(j=i.RGBA8UI),V===i.UNSIGNED_SHORT&&(j=i.RGBA16UI),V===i.UNSIGNED_INT&&(j=i.RGBA32UI),V===i.BYTE&&(j=i.RGBA8I),V===i.SHORT&&(j=i.RGBA16I),V===i.INT&&(j=i.RGBA32I)),y===i.RGB&&(V===i.UNSIGNED_SHORT&&ye&&(j=ye.RGB16_EXT),V===i.SHORT&&ye&&(j=ye.RGB16_SNORM_EXT),V===i.UNSIGNED_INT_5_9_9_9_REV&&(j=i.RGB9_E5),V===i.UNSIGNED_INT_10F_11F_11F_REV&&(j=i.R11F_G11F_B10F)),y===i.RGBA){let Q=he?Is:et.getTransfer(se);V===i.FLOAT&&(j=i.RGBA32F),V===i.HALF_FLOAT&&(j=i.RGBA16F),V===i.UNSIGNED_BYTE&&(j=Q===ct?i.SRGB8_ALPHA8:i.RGBA8),V===i.UNSIGNED_SHORT&&ye&&(j=ye.RGBA16_EXT),V===i.SHORT&&ye&&(j=ye.RGBA16_SNORM_EXT),V===i.UNSIGNED_SHORT_4_4_4_4&&(j=i.RGBA4),V===i.UNSIGNED_SHORT_5_5_5_1&&(j=i.RGB5_A1)}return(j===i.R16F||j===i.R32F||j===i.RG16F||j===i.RG32F||j===i.RGBA16F||j===i.RGBA32F)&&e.get("EXT_color_buffer_float"),j}function g(A,y){let V;return A?y===null||y===wn||y===Ni?V=i.DEPTH24_STENCIL8:y===En?V=i.DEPTH32F_STENCIL8:y===ps&&(V=i.DEPTH24_STENCIL8,Fe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):y===null||y===wn||y===Ni?V=i.DEPTH_COMPONENT24:y===En?V=i.DEPTH_COMPONENT32F:y===ps&&(V=i.DEPTH_COMPONENT16),V}function v(A,y){return T(A)===!0||A.isFramebufferTexture&&A.minFilter!==Pt&&A.minFilter!==Zt?Math.log2(Math.max(y.width,y.height))+1:A.mipmaps.length>0?A.mipmaps.length:A.isCompressedTexture&&Array.isArray(A.image)?y.mipmaps.length:1}function L(A){let y=new WeakRef(A);n.get(A).__ref=y,_.add(y),x.register(A,y,y)}function R(A){let y=n.get(A).__ref;y!==void 0&&(_.delete(y),x.unregister(y))}function D(A){B(A.target)}function N(A){C(A.target)}function B(A){A.removeEventListener("dispose",D),R(A),Z(A),A.isVideoTexture&&h.delete(A),A.isHTMLTexture&&u.delete(A)}function C(A){A.removeEventListener("dispose",N),R(A),ee(A)}function W(){for(let A of _){let y=A.deref();y!==void 0&&(y.isRenderTarget===!0?C(y):B(y))}_.clear(),u.clear()}function Z(A){let y=n.get(A);if(y.__webglInit===void 0)return;let V=A.source,le=f.get(V);if(le){let se=le[y.__cacheKey];se.usedTimes--,se.usedTimes===0&&z(A),Object.keys(le).length===0&&f.delete(V)}n.remove(A)}function z(A){let y=n.get(A);i.deleteTexture(y.__webglTexture);let V=A.source,le=f.get(V);delete le[y.__cacheKey],o.memory.textures--}function ee(A){let y=n.get(A);y.__depthDisposeCallback&&y.__depthDisposeCallback();let V=A.depthTexture;if(V&&V.renderTarget===A&&B(V),A.isWebGLCubeRenderTarget)for(let se=0;se<6;se++){if(Array.isArray(y.__webglFramebuffer[se]))for(let he=0;he<y.__webglFramebuffer[se].length;he++)i.deleteFramebuffer(y.__webglFramebuffer[se][he]);else i.deleteFramebuffer(y.__webglFramebuffer[se]);y.__webglDepthbuffer&&i.deleteRenderbuffer(y.__webglDepthbuffer[se])}else{if(Array.isArray(y.__webglFramebuffer))for(let se=0;se<y.__webglFramebuffer.length;se++)i.deleteFramebuffer(y.__webglFramebuffer[se]);else i.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer&&i.deleteRenderbuffer(y.__webglDepthbuffer),y.__webglMultisampledFramebuffer&&i.deleteFramebuffer(y.__webglMultisampledFramebuffer),y.__webglColorRenderbuffer)for(let se=0;se<y.__webglColorRenderbuffer.length;se++)y.__webglColorRenderbuffer[se]&&i.deleteRenderbuffer(y.__webglColorRenderbuffer[se]);y.__webglDepthRenderbuffer&&i.deleteRenderbuffer(y.__webglDepthRenderbuffer)}let le=A.textures;for(let se=0,he=le.length;se<he;se++){let ye=n.get(le[se]);ye.__webglTexture&&(i.deleteTexture(ye.__webglTexture),o.memory.textures--),n.remove(le[se])}n.remove(A)}let q=0;function J(){q=0}function O(){return q}function ae(A){q=A}function xe(){let A=q;return A>=s.maxTextures&&Fe("WebGLTextures: Trying to use "+(A+1)+" texture units while this GPU supports only "+s.maxTextures),q+=1,A}function H(A){let y=[];return y.push(A.wrapS),y.push(A.wrapT),y.push(A.wrapR||0),y.push(A.magFilter),y.push(A.minFilter),y.push(A.anisotropy),y.push(A.internalFormat),y.push(A.format),y.push(A.type),y.push(A.generateMipmaps),y.push(A.mipmapsAutoUpdate),y.push(A.premultiplyAlpha),y.push(A.flipY),y.push(A.unpackAlignment),y.push(A.colorSpace),y.join()}function ue(A,y){let V=n.get(A);if(A.isVideoTexture&&ht(A),A.isRenderTargetTexture===!1&&A.isExternalTexture!==!0&&A.version>0&&V.__version!==A.version){let le=A.image;if(le===null)Fe("WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)Fe("WebGLRenderer: Texture marked for update but image is incomplete");else{We(V,A,y);return}}else A.isExternalTexture&&(V.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,V.__webglTexture,i.TEXTURE0+y)}function de(A,y){let V=n.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&V.__version!==A.version){We(V,A,y);return}else A.isExternalTexture&&(V.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,V.__webglTexture,i.TEXTURE0+y)}function we(A,y){let V=n.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&V.__version!==A.version){We(V,A,y);return}t.bindTexture(i.TEXTURE_3D,V.__webglTexture,i.TEXTURE0+y)}function fe(A,y){let V=n.get(A);if(A.version>0&&V.__version!==A.version){vt(V,A,y);return}t.bindTexture(i.TEXTURE_CUBE_MAP,V.__webglTexture,i.TEXTURE0+y)}let Te={[Jr]:i.REPEAT,[Cn]:i.CLAMP_TO_EDGE,[Kr]:i.MIRRORED_REPEAT},He={[Pt]:i.NEAREST,[_h]:i.NEAREST_MIPMAP_NEAREST,[Js]:i.NEAREST_MIPMAP_LINEAR,[Zt]:i.LINEAR,[Ao]:i.LINEAR_MIPMAP_NEAREST,[Kn]:i.LINEAR_MIPMAP_LINEAR},me={[bh]:i.NEVER,[El]:i.ALWAYS,[Mh]:i.LESS,[Sl]:i.LEQUAL,[Sh]:i.EQUAL,[wl]:i.GEQUAL,[wh]:i.GREATER,[Eh]:i.NOTEQUAL};function Ie(A,y){if(y.type===En&&e.has("OES_texture_float_linear")===!1&&(y.magFilter===Zt||y.magFilter===Ao||y.magFilter===Js||y.magFilter===Kn||y.minFilter===Zt||y.minFilter===Ao||y.minFilter===Js||y.minFilter===Kn)&&Fe("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(A,i.TEXTURE_WRAP_S,Te[y.wrapS]),i.texParameteri(A,i.TEXTURE_WRAP_T,Te[y.wrapT]),(A===i.TEXTURE_3D||A===i.TEXTURE_2D_ARRAY)&&i.texParameteri(A,i.TEXTURE_WRAP_R,Te[y.wrapR]),i.texParameteri(A,i.TEXTURE_MAG_FILTER,He[y.magFilter]),i.texParameteri(A,i.TEXTURE_MIN_FILTER,He[y.minFilter]),y.compareFunction&&(i.texParameteri(A,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(A,i.TEXTURE_COMPARE_FUNC,me[y.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===Pt||y.minFilter!==Js&&y.minFilter!==Kn||y.type===En&&e.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||n.get(y).__currentAnisotropy){let V=e.get("EXT_texture_filter_anisotropic");i.texParameterf(A,V.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,s.getMaxAnisotropy())),n.get(y).__currentAnisotropy=y.anisotropy}}}function Ne(A,y){let V=!1;A.__webglInit===void 0&&(A.__webglInit=!0,y.addEventListener("dispose",D),L(y));let le=y.source,se=f.get(le);se===void 0&&(se={},f.set(le,se));let he=H(y);if(he!==A.__cacheKey){se[he]===void 0&&(se[he]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,V=!0),se[he].usedTimes++;let ye=se[A.__cacheKey];ye!==void 0&&(se[A.__cacheKey].usedTimes--,ye.usedTimes===0&&z(y)),A.__cacheKey=he,A.__webglTexture=se[he].texture}return V}function Oe(A,y,V){return Math.floor(Math.floor(A/V)/y)}function Ce(A,y,V,le){let he=A.updateRanges;if(he.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,y.width,y.height,V,le,y.data);else{he.sort((I,te)=>I.start-te.start);let ye=0;for(let I=1;I<he.length;I++){let te=he[ye],P=he[I],ne=te.start+te.count,$=Oe(P.start,y.width,4),ie=Oe(te.start,y.width,4);P.start<=ne+1&&$===ie&&Oe(P.start+P.count-1,y.width,4)===$?te.count=Math.max(te.count,P.start+P.count-te.start):(++ye,he[ye]=P)}he.length=ye+1;let j=t.getParameter(i.UNPACK_ROW_LENGTH),Q=t.getParameter(i.UNPACK_SKIP_PIXELS),ge=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,y.width);for(let I=0,te=he.length;I<te;I++){let P=he[I],ne=Math.floor(P.start/4),$=Math.ceil(P.count/4),ie=ne%y.width,oe=Math.floor(ne/y.width),re=$,K=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,ie),t.pixelStorei(i.UNPACK_SKIP_ROWS,oe),t.texSubImage2D(i.TEXTURE_2D,0,ie,oe,re,K,V,le,y.data)}A.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,j),t.pixelStorei(i.UNPACK_SKIP_PIXELS,Q),t.pixelStorei(i.UNPACK_SKIP_ROWS,ge)}}function We(A,y,V){let le=i.TEXTURE_2D;(y.isDataArrayTexture||y.isCompressedArrayTexture)&&(le=i.TEXTURE_2D_ARRAY),y.isData3DTexture&&(le=i.TEXTURE_3D);let se=Ne(A,y),he=y.source;t.bindTexture(le,A.__webglTexture,i.TEXTURE0+V);let ye=n.get(he);if(he.version!==ye.__version||se===!0){if(t.activeTexture(i.TEXTURE0+V),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){let K=et.getPrimaries(et.workingColorSpace),pe=y.colorSpace===Qn?null:et.getPrimaries(y.colorSpace),Le=y.colorSpace===Qn||K===pe?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,y.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Le)}t.pixelStorei(i.UNPACK_ALIGNMENT,y.unpackAlignment);let Q=w(y.image,!1,s.maxTextureSize);Q=De(y,Q);let ge=r.convert(y.format,y.colorSpace),I=r.convert(y.type),te=M(y.internalFormat,ge,I,y.normalized,y.colorSpace,y.isVideoTexture);Ie(le,y);let P,ne=y.mipmaps,$=y.isVideoTexture!==!0,ie=ye.__version===void 0||se===!0,oe=he.dataReady,re=v(y,Q);if(y.isDepthTexture)te=g(y.format===jn,y.type),ie&&($?t.texStorage2D(i.TEXTURE_2D,1,te,Q.width,Q.height):t.texImage2D(i.TEXTURE_2D,0,te,Q.width,Q.height,0,ge,I,null));else if(y.isDataTexture)if(ne.length>0){$&&ie&&t.texStorage2D(i.TEXTURE_2D,re,te,ne[0].width,ne[0].height);for(let K=0,pe=ne.length;K<pe;K++)P=ne[K],$?oe&&t.texSubImage2D(i.TEXTURE_2D,K,0,0,P.width,P.height,ge,I,P.data):t.texImage2D(i.TEXTURE_2D,K,te,P.width,P.height,0,ge,I,P.data);y.generateMipmaps=!1}else $?(ie&&t.texStorage2D(i.TEXTURE_2D,re,te,Q.width,Q.height),oe&&Ce(y,Q,ge,I)):t.texImage2D(i.TEXTURE_2D,0,te,Q.width,Q.height,0,ge,I,Q.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){$&&ie&&t.texStorage3D(i.TEXTURE_2D_ARRAY,re,te,ne[0].width,ne[0].height,Q.depth);for(let K=0,pe=ne.length;K<pe;K++)if(P=ne[K],y.format!==An)if(ge!==null)if($){if(oe)if(y.layerUpdates.size>0){let Le=Ul(P.width,P.height,y.format,y.type);for(let ce of y.layerUpdates){let Ue=P.data.subarray(ce*Le/P.data.BYTES_PER_ELEMENT,(ce+1)*Le/P.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,ce,P.width,P.height,1,ge,Ue)}}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,0,P.width,P.height,Q.depth,ge,P.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,K,te,P.width,P.height,Q.depth,0,P.data,0,0);else Fe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else $?oe&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,0,P.width,P.height,Q.depth,ge,I,P.data):t.texImage3D(i.TEXTURE_2D_ARRAY,K,te,P.width,P.height,Q.depth,0,ge,I,P.data);y.layerUpdates.size>0&&y.clearLayerUpdates()}else{$&&ie&&t.texStorage2D(i.TEXTURE_2D,re,te,ne[0].width,ne[0].height);for(let K=0,pe=ne.length;K<pe;K++)P=ne[K],y.format!==An?ge!==null?$?oe&&t.compressedTexSubImage2D(i.TEXTURE_2D,K,0,0,P.width,P.height,ge,P.data):t.compressedTexImage2D(i.TEXTURE_2D,K,te,P.width,P.height,0,P.data):Fe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):$?oe&&t.texSubImage2D(i.TEXTURE_2D,K,0,0,P.width,P.height,ge,I,P.data):t.texImage2D(i.TEXTURE_2D,K,te,P.width,P.height,0,ge,I,P.data)}else if(y.isDataArrayTexture)if($){if(ie&&t.texStorage3D(i.TEXTURE_2D_ARRAY,re,te,Q.width,Q.height,Q.depth),oe)if(y.layerUpdates.size>0){let K=Ul(Q.width,Q.height,y.format,y.type);for(let pe of y.layerUpdates){let Le=Q.data.subarray(pe*K/Q.data.BYTES_PER_ELEMENT,(pe+1)*K/Q.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,pe,Q.width,Q.height,1,ge,I,Le)}y.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ge,I,Q.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,te,Q.width,Q.height,Q.depth,0,ge,I,Q.data);else if(y.isData3DTexture)$?(ie&&t.texStorage3D(i.TEXTURE_3D,re,te,Q.width,Q.height,Q.depth),oe&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ge,I,Q.data)):t.texImage3D(i.TEXTURE_3D,0,te,Q.width,Q.height,Q.depth,0,ge,I,Q.data);else if(y.isFramebufferTexture){if(ie)if($)t.texStorage2D(i.TEXTURE_2D,re,te,Q.width,Q.height);else{let K=Q.width,pe=Q.height;for(let Le=0;Le<re;Le++)t.texImage2D(i.TEXTURE_2D,Le,te,K,pe,0,ge,I,null),K>>=1,pe>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in i){let K=i.canvas;if(K.hasAttribute("layoutsubtree")||K.setAttribute("layoutsubtree","true"),Q.parentNode!==K){K.appendChild(Q),u.add(y),K.onpaint=pe=>{let Le=pe.changedElements;for(let ce of u)Le.includes(ce.image)&&(ce.needsUpdate=!0)},K.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,Q);else{let Le=i.RGBA,ce=i.RGBA,Ue=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,Le,ce,Ue,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(ne.length>0){if($&&ie){let K=Be(ne[0]);t.texStorage2D(i.TEXTURE_2D,re,te,K.width,K.height)}for(let K=0,pe=ne.length;K<pe;K++)P=ne[K],$?oe&&t.texSubImage2D(i.TEXTURE_2D,K,0,0,ge,I,P):t.texImage2D(i.TEXTURE_2D,K,te,ge,I,P);y.generateMipmaps=!1}else if($){if(ie){let K=Be(Q);t.texStorage2D(i.TEXTURE_2D,re,te,K.width,K.height)}oe&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,ge,I,Q)}else t.texImage2D(i.TEXTURE_2D,0,te,ge,I,Q);T(y)&&y.mipmapsAutoUpdate===!0&&S(le),ye.__version=he.version,y.onUpdate&&y.onUpdate(y)}A.__version=y.version}function vt(A,y,V){if(y.image.length!==6)return;let le=Ne(A,y),se=y.source;t.bindTexture(i.TEXTURE_CUBE_MAP,A.__webglTexture,i.TEXTURE0+V);let he=n.get(se);if(se.version!==he.__version||le===!0){t.activeTexture(i.TEXTURE0+V);let ye=et.getPrimaries(et.workingColorSpace),j=y.colorSpace===Qn?null:et.getPrimaries(y.colorSpace),Q=y.colorSpace===Qn||ye===j?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,y.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,y.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);let ge=y.isCompressedTexture||y.image[0].isCompressedTexture,I=y.image[0]&&y.image[0].isDataTexture,te=[];for(let ce=0;ce<6;ce++)!ge&&!I?te[ce]=w(y.image[ce],!0,s.maxCubemapSize):te[ce]=I?y.image[ce].image:y.image[ce],te[ce]=De(y,te[ce]);let P=te[0],ne=r.convert(y.format,y.colorSpace),$=r.convert(y.type),ie=M(y.internalFormat,ne,$,y.normalized,y.colorSpace),oe=y.isVideoTexture!==!0,re=he.__version===void 0||le===!0,K=se.dataReady,pe=v(y,P);Ie(i.TEXTURE_CUBE_MAP,y);let Le;if(y.isDepthTexture){if(ie=g(y.format===jn,y.type),re)if(oe)t.texStorage2D(i.TEXTURE_CUBE_MAP,1,ie,P.width,P.height);else for(let ce=0;ce<6;ce++)t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ie,P.width,P.height,0,ne,$,null)}else if(ge){oe&&re&&t.texStorage2D(i.TEXTURE_CUBE_MAP,pe,ie,P.width,P.height);for(let ce=0;ce<6;ce++){Le=te[ce].mipmaps;for(let Ue=0;Ue<Le.length;Ue++){let tt=Le[Ue];y.format!==An?ne!==null?oe?K&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue,0,0,tt.width,tt.height,ne,tt.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue,ie,tt.width,tt.height,0,tt.data):Fe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):oe?K&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue,0,0,tt.width,tt.height,ne,$,tt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue,ie,tt.width,tt.height,0,ne,$,tt.data)}}}else{if(Le=y.mipmaps,oe&&re){Le.length>0&&pe++;let ce=Be(te[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,pe,ie,ce.width,ce.height)}for(let ce=0;ce<6;ce++)if(I){oe?K&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,te[ce].width,te[ce].height,ne,$,te[ce].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ie,te[ce].width,te[ce].height,0,ne,$,te[ce].data);for(let Ue=0;Ue<Le.length;Ue++){let xt=Le[Ue].image[ce].image;oe?K&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue+1,0,0,xt.width,xt.height,ne,$,xt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue+1,ie,xt.width,xt.height,0,ne,$,xt.data)}}else{oe?K&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,ne,$,te[ce]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ie,ne,$,te[ce]);for(let Ue=0;Ue<Le.length;Ue++){let tt=Le[Ue];oe?K&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue+1,0,0,ne,$,tt.image[ce]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue+1,ie,ne,$,tt.image[ce])}}}T(y)&&y.mipmapsAutoUpdate===!0&&S(i.TEXTURE_CUBE_MAP),he.__version=se.version,y.onUpdate&&y.onUpdate(y)}A.__version=y.version}function nt(A,y,V,le,se,he){let ye=r.convert(V.format,V.colorSpace),j=r.convert(V.type),Q=M(V.internalFormat,ye,j,V.normalized,V.colorSpace),ge=n.get(y),I=n.get(V);if(I.__renderTarget=y,!ge.__hasExternalTextures){let te=Math.max(1,y.width>>he),P=Math.max(1,y.height>>he);se===i.TEXTURE_3D||se===i.TEXTURE_2D_ARRAY?t.texImage3D(se,he,Q,te,P,y.depth,0,ye,j,null):t.texImage2D(se,he,Q,te,P,0,ye,j,null)}t.bindFramebuffer(i.FRAMEBUFFER,A),_e(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,le,se,I.__webglTexture,0,rt(y)):(se===i.TEXTURE_2D||se>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&se<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,le,se,I.__webglTexture,he),t.bindFramebuffer(i.FRAMEBUFFER,null)}function gt(A,y,V){if(i.bindRenderbuffer(i.RENDERBUFFER,A),y.depthBuffer){let le=y.depthTexture,se=le&&le.isDepthTexture?le.type:null,he=g(y.stencilBuffer,se),ye=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;_e(y)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,rt(y),he,y.width,y.height):V?i.renderbufferStorageMultisample(i.RENDERBUFFER,rt(y),he,y.width,y.height):i.renderbufferStorage(i.RENDERBUFFER,he,y.width,y.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ye,i.RENDERBUFFER,A)}else{let le=y.textures;for(let se=0;se<le.length;se++){let he=le[se],ye=r.convert(he.format,he.colorSpace),j=r.convert(he.type),Q=M(he.internalFormat,ye,j,he.normalized,he.colorSpace);_e(y)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,rt(y),Q,y.width,y.height):V?i.renderbufferStorageMultisample(i.RENDERBUFFER,rt(y),Q,y.width,y.height):i.renderbufferStorage(i.RENDERBUFFER,Q,y.width,y.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Xe(A,y,V){let le=y.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,A),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let se=n.get(y.depthTexture);se.__renderTarget=y;let he=le?y.depthTexture.image[0]:y.depthTexture.image;(!se.__webglTexture||he.width!==y.width||he.height!==y.height)&&(he.width=y.width,he.height=y.height,y.depthTexture.needsUpdate=!0),le?fe(y.depthTexture,0):ue(y.depthTexture,0);let ye=se.__webglTexture,j=rt(y),Q=le?i.TEXTURE_CUBE_MAP_POSITIVE_X+V:i.TEXTURE_2D,ge=y.depthTexture.format===jn?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(y.depthTexture.format===Yn)_e(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,ge,Q,ye,0,j):i.framebufferTexture2D(i.FRAMEBUFFER,ge,Q,ye,0);else if(y.depthTexture.format===jn)_e(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,ge,Q,ye,0,j):i.framebufferTexture2D(i.FRAMEBUFFER,ge,Q,ye,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function ft(A){let y=n.get(A),V=A.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==A.depthTexture){let le=A.depthTexture;if(y.__depthDisposeCallback&&y.__depthDisposeCallback(),le){let se=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,le.removeEventListener("dispose",se)};le.addEventListener("dispose",se),y.__depthDisposeCallback=se}y.__boundDepthTexture=le}if(A.depthTexture&&!y.__autoAllocateDepthBuffer)if(V)for(let le=0;le<6;le++)Xe(y.__webglFramebuffer[le],A,le);else A.texture.mipmaps.length>0?Xe(y.__webglFramebuffer[0],A,0):Xe(y.__webglFramebuffer,A,0);else if(V){y.__webglDepthbuffer=[];for(let le=0;le<6;le++)if(t.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer[le]),y.__webglDepthbuffer[le]===void 0)y.__webglDepthbuffer[le]=i.createRenderbuffer(),gt(y.__webglDepthbuffer[le],A,!1);else{let se=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,he=y.__webglDepthbuffer[le];i.bindRenderbuffer(i.RENDERBUFFER,he),i.framebufferRenderbuffer(i.FRAMEBUFFER,se,i.RENDERBUFFER,he)}}else if(A.texture.mipmaps.length>0?t.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer),y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=i.createRenderbuffer(),gt(y.__webglDepthbuffer,A,!1);else{let se=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,he=y.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,he),i.framebufferRenderbuffer(i.FRAMEBUFFER,se,i.RENDERBUFFER,he)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function It(A,y,V){let le=n.get(A);y!==void 0&&nt(le.__webglFramebuffer,A,A.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),V!==void 0&&ft(A)}function Ft(A){let y=A.texture,V=n.get(A),le=n.get(y);A.addEventListener("dispose",N),L(A);let se=A.textures,he=A.isWebGLCubeRenderTarget===!0,ye=se.length>1;if(ye||(le.__webglTexture===void 0&&(le.__webglTexture=i.createTexture()),le.__version=y.version,o.memory.textures++),he){V.__webglFramebuffer=[];for(let j=0;j<6;j++)if(y.mipmaps.length>0){V.__webglFramebuffer[j]=[];for(let Q=0;Q<y.mipmaps.length;Q++)V.__webglFramebuffer[j][Q]=i.createFramebuffer()}else V.__webglFramebuffer[j]=i.createFramebuffer()}else{if(y.mipmaps.length>0){V.__webglFramebuffer=[];for(let j=0;j<y.mipmaps.length;j++)V.__webglFramebuffer[j]=i.createFramebuffer()}else V.__webglFramebuffer=i.createFramebuffer();if(ye)for(let j=0,Q=se.length;j<Q;j++){let ge=n.get(se[j]);ge.__webglTexture===void 0&&(ge.__webglTexture=i.createTexture(),o.memory.textures++)}if(A.samples>0&&_e(A)===!1){V.__webglMultisampledFramebuffer=i.createFramebuffer(),V.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,V.__webglMultisampledFramebuffer);for(let j=0;j<se.length;j++){let Q=se[j];V.__webglColorRenderbuffer[j]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,V.__webglColorRenderbuffer[j]);let ge=r.convert(Q.format,Q.colorSpace),I=r.convert(Q.type),te=M(Q.internalFormat,ge,I,Q.normalized,Q.colorSpace,A.isXRRenderTarget===!0),P=rt(A);i.renderbufferStorageMultisample(i.RENDERBUFFER,P,te,A.width,A.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+j,i.RENDERBUFFER,V.__webglColorRenderbuffer[j])}i.bindRenderbuffer(i.RENDERBUFFER,null),A.depthBuffer&&(V.__webglDepthRenderbuffer=i.createRenderbuffer(),gt(V.__webglDepthRenderbuffer,A,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(he){t.bindTexture(i.TEXTURE_CUBE_MAP,le.__webglTexture),Ie(i.TEXTURE_CUBE_MAP,y);for(let j=0;j<6;j++)if(y.mipmaps.length>0)for(let Q=0;Q<y.mipmaps.length;Q++)nt(V.__webglFramebuffer[j][Q],A,y,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Q);else nt(V.__webglFramebuffer[j],A,y,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0);T(y)?S(i.TEXTURE_CUBE_MAP):y.mipmaps.length>0&&i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,y.mipmaps.length-1),t.unbindTexture()}else if(ye){for(let j=0,Q=se.length;j<Q;j++){let ge=se[j],I=n.get(ge),te=i.TEXTURE_2D;(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(te=A.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(te,I.__webglTexture),Ie(te,ge),nt(V.__webglFramebuffer,A,ge,i.COLOR_ATTACHMENT0+j,te,0),T(ge)&&S(te)}t.unbindTexture()}else{let j=i.TEXTURE_2D;if((A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(j=A.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(j,le.__webglTexture),Ie(j,y),y.mipmaps.length>0)for(let Q=0;Q<y.mipmaps.length;Q++)nt(V.__webglFramebuffer[Q],A,y,i.COLOR_ATTACHMENT0,j,Q);else nt(V.__webglFramebuffer,A,y,i.COLOR_ATTACHMENT0,j,0);T(y)?S(j):y.mipmaps.length>0&&i.texParameteri(j,i.TEXTURE_MAX_LEVEL,y.mipmaps.length-1),t.unbindTexture()}A.depthBuffer&&ft(A)}function F(A){let y=A.textures;for(let V=0,le=y.length;V<le;V++){let se=y[V];if(T(se)&&se.mipmapsAutoUpdate===!0){let he=E(A),ye=n.get(se).__webglTexture;t.bindTexture(he,ye),S(he),t.unbindTexture()}}}let Lt=[];function st(A){if(A.samples>0){if(_e(A)===!1){let y=A.textures,V=A.width,le=A.height,se=i.COLOR_BUFFER_BIT,he=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ye=n.get(A),j=y.length>1;if(j)for(let ge=0;ge<y.length;ge++)t.bindFramebuffer(i.FRAMEBUFFER,ye.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ge,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,ye.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ge,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,ye.__webglMultisampledFramebuffer),A.texture.mipmaps.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ye.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ye.__webglFramebuffer);for(let ge=0;ge<y.length;ge++){if(A.resolveDepthBuffer&&(A.depthBuffer&&(se|=i.DEPTH_BUFFER_BIT),A.stencilBuffer&&A.resolveStencilBuffer&&(se|=i.STENCIL_BUFFER_BIT)),j){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ye.__webglColorRenderbuffer[ge]);let I=n.get(y[ge]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,I,0)}i.blitFramebuffer(0,0,V,le,0,0,V,le,se,i.NEAREST),c===!0&&(Lt.length=0,Lt.push(i.COLOR_ATTACHMENT0+ge),A.depthBuffer&&A.storeMultisampledDepthBuffer===!1&&Lt.push(he),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Lt))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),j)for(let ge=0;ge<y.length;ge++){t.bindFramebuffer(i.FRAMEBUFFER,ye.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ge,i.RENDERBUFFER,ye.__webglColorRenderbuffer[ge]);let I=n.get(y[ge]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,ye.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ge,i.TEXTURE_2D,I,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ye.__webglMultisampledFramebuffer)}else if(A.depthBuffer&&A.storeMultisampledDepthBuffer===!1&&c){let y=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[y])}}}function rt(A){return Math.min(s.maxSamples,A.samples)}function _e(A){let y=n.get(A);return A.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function ht(A){let y=o.render.frame;h.get(A)!==y&&(h.set(A,y),A.update())}function De(A,y){let V=A.colorSpace,le=A.format,se=A.type;return A.isCompressedTexture===!0||A.isVideoTexture===!0||V!==Ps&&V!==Qn&&(et.getTransfer(V)===ct?(le!==An||se!==en)&&Fe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ke("WebGLTextures: Unsupported texture color space:",V)),y}function Be(A){return typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement?(l.width=A.naturalWidth||A.width,l.height=A.naturalHeight||A.height):typeof VideoFrame<"u"&&A instanceof VideoFrame?(l.width=A.displayWidth,l.height=A.displayHeight):(l.width=A.width,l.height=A.height),l}this.allocateTextureUnit=xe,this.resetTextureUnits=J,this.getTextureUnits=O,this.setTextureUnits=ae,this.setTexture2D=ue,this.setTexture2DArray=de,this.setTexture3D=we,this.setTextureCube=fe,this.rebindTextures=It,this.setupRenderTarget=Ft,this.updateRenderTargetMipmap=F,this.updateMultisampleRenderTarget=st,this.setupDepthRenderbuffer=ft,this.setupFrameBufferTexture=nt,this.useMultisampledRTT=_e,this.dispose=W}function I0(i,e){function t(n,s=Qn){let r,o=et.getTransfer(s);if(n===en)return i.UNSIGNED_BYTE;if(n===Co)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Po)return i.UNSIGNED_SHORT_5_5_5_1;if(n===xl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===yl)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===gl)return i.BYTE;if(n===_l)return i.SHORT;if(n===ps)return i.UNSIGNED_SHORT;if(n===Ro)return i.INT;if(n===wn)return i.UNSIGNED_INT;if(n===En)return i.FLOAT;if(n===Tn)return i.HALF_FLOAT;if(n===vl)return i.ALPHA;if(n===bl)return i.RGB;if(n===An)return i.RGBA;if(n===Yn)return i.DEPTH_COMPONENT;if(n===jn)return i.DEPTH_STENCIL;if(n===Ml)return i.RED;if(n===Io)return i.RED_INTEGER;if(n===_i)return i.RG;if(n===Lo)return i.RG_INTEGER;if(n===Do)return i.RGBA_INTEGER;if(n===Ks||n===js||n===Qs||n===er)if(o===ct)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Ks)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===js)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Qs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===er)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Ks)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===js)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Qs)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===er)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===No||n===Uo||n===Fo||n===Oo)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===No)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Uo)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Fo)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Oo)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Bo||n===zo||n===ko||n===Vo||n===Go||n===tr||n===Ho)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Bo||n===zo)return o===ct?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===ko)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Vo)return r.COMPRESSED_R11_EAC;if(n===Go)return r.COMPRESSED_SIGNED_R11_EAC;if(n===tr)return r.COMPRESSED_RG11_EAC;if(n===Ho)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Wo||n===Xo||n===qo||n===Yo||n===Zo||n===$o||n===Jo||n===Ko||n===jo||n===Qo||n===ea||n===ta||n===na||n===ia)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Wo)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Xo)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===qo)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Yo)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Zo)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===$o)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Jo)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ko)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===jo)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Qo)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ea)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ta)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===na)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ia)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===sa||n===ra||n===oa)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===sa)return o===ct?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ra)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===oa)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===aa||n===la||n===nr||n===ca)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===aa)return r.COMPRESSED_RED_RGTC1_EXT;if(n===la)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===nr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ca)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ni?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var L0=`
|
|
4202
4202
|
void main() {
|
|
4203
4203
|
|
|
4204
4204
|
gl_Position = vec4( position, 1.0 );
|
|
4205
4205
|
|
|
4206
|
-
}`,
|
|
4206
|
+
}`,D0=`
|
|
4207
4207
|
uniform sampler2DArray depthColor;
|
|
4208
4208
|
uniform float depthWidth;
|
|
4209
4209
|
uniform float depthHeight;
|
|
@@ -4222,4 +4222,4 @@ void main() {
|
|
|
4222
4222
|
|
|
4223
4223
|
}
|
|
4224
4224
|
|
|
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_();})();
|
|
4225
|
+
}`,$l=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new ks(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 In({vertexShader:L0,fragmentShader:D0,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Qt(new Gs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Jl=class extends Sn{constructor(e,t){super();let n=this,s=null,r=1,o=null,a="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,_=null,x=typeof XRWebGLBinding<"u",m=new $l,p={},w=t.getContextAttributes(),T=null,S=null,E=[],M=[],g=new Ve,v=null,L=null,R=new qt;R.viewport=new _t;let D=new qt;D.viewport=new _t;let N=[R,D],B=new Mo,C=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(H){let ue=E[H];return ue===void 0&&(ue=new is,E[H]=ue),ue.getTargetRaySpace()},this.getControllerGrip=function(H){let ue=E[H];return ue===void 0&&(ue=new is,E[H]=ue),ue.getGripSpace()},this.getHand=function(H){let ue=E[H];return ue===void 0&&(ue=new is,E[H]=ue),ue.getHandSpace()};function Z(H){let ue=M.indexOf(H.inputSource);if(ue===-1)return;let de=E[ue];de!==void 0&&(de.update(H.inputSource,H.frame,l||o),de.dispatchEvent({type:H.type,data:H.inputSource}))}function z(){s.removeEventListener("select",Z),s.removeEventListener("selectstart",Z),s.removeEventListener("selectend",Z),s.removeEventListener("squeeze",Z),s.removeEventListener("squeezestart",Z),s.removeEventListener("squeezeend",Z),s.removeEventListener("end",z),s.removeEventListener("inputsourceschange",ee);for(let H=0;H<E.length;H++){let ue=M[H];ue!==null&&(M[H]=null,E[H].disconnect(ue))}C=null,W=null,m.reset();for(let H in p)delete p[H];if(e.setRenderTarget(T),f=null,d=null,u=null,s=null,S=null,xe.stop(),n.isPresenting=!1,e.setPixelRatio(v),e.setSize(g.width,g.height,!1),L!==null){let H=L.camera;H.fov=L.fov,H.zoom=L.zoom,H.updateProjectionMatrix(),L=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(H){r=H,n.isPresenting===!0&&Fe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(H){a=H,n.isPresenting===!0&&Fe("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(H){l=H},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&x&&(u=new XRWebGLBinding(s,t)),u},this.getFrame=function(){return _},this.getSession=function(){return s},this.setSession=async function(H){if(s=H,s!==null){if(T=e.getRenderTarget(),s.addEventListener("select",Z),s.addEventListener("selectstart",Z),s.addEventListener("selectend",Z),s.addEventListener("squeeze",Z),s.addEventListener("squeezestart",Z),s.addEventListener("squeezeend",Z),s.addEventListener("end",z),s.addEventListener("inputsourceschange",ee),w.xrCompatible!==!0&&await t.makeXRCompatible(),v=e.getPixelRatio(),e.getSize(g),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let de=null,we=null,fe=null;w.depth&&(fe=w.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,de=w.stencil?jn:Yn,we=w.stencil?Ni:wn);let Te={colorFormat:t.RGBA8,depthFormat:fe,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Te),s.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),S=new cn(d.textureWidth,d.textureHeight,{format:An,type:en,depthTexture:new Jn(d.textureWidth,d.textureHeight,we,void 0,void 0,void 0,void 0,void 0,void 0,de),stencilBuffer:w.stencil,colorSpace:e.outputColorSpace,samples:w.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}else{let de={antialias:w.antialias,alpha:!0,depth:w.depth,stencil:w.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,t,de),s.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),S=new cn(f.framebufferWidth,f.framebufferHeight,{format:An,type:en,colorSpace:e.outputColorSpace,stencilBuffer:w.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await s.requestReferenceSpace(a),xe.setContext(s),xe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function ee(H){for(let ue=0;ue<H.removed.length;ue++){let de=H.removed[ue],we=M.indexOf(de);we>=0&&(M[we]=null,E[we].disconnect(de))}for(let ue=0;ue<H.added.length;ue++){let de=H.added[ue],we=M.indexOf(de);if(we===-1){for(let Te=0;Te<E.length;Te++)if(Te>=M.length){M.push(de),we=Te;break}else if(M[Te]===null){M[Te]=de,we=Te;break}if(we===-1)break}let fe=E[we];fe&&fe.connect(de)}}function q(H,ue){ue===null?H.matrixWorld.copy(H.matrix):H.matrixWorld.multiplyMatrices(ue.matrixWorld,H.matrix),H.matrixWorldInverse.copy(H.matrixWorld).invert()}this.updateCamera=function(H){if(s===null)return;let ue=H.near,de=H.far;m.texture!==null&&(m.depthNear>0&&(ue=m.depthNear),m.depthFar>0&&(de=m.depthFar)),B.near=D.near=R.near=ue,B.far=D.far=R.far=de,(C!==B.near||W!==B.far)&&(s.updateRenderState({depthNear:B.near,depthFar:B.far}),C=B.near,W=B.far),B.layers.mask=H.layers.mask|6,R.layers.mask=B.layers.mask&-5,D.layers.mask=B.layers.mask&-3;let we=H.parent,fe=B.cameras;q(B,we);for(let Te=0;Te<fe.length;Te++)q(fe[Te],we);B.projectionMatrix.copy(R.projectionMatrix),B.projectionMatrixInverse.copy(R.projectionMatrixInverse),L===null&&H.isPerspectiveCamera&&(L={camera:H,fov:H.fov,zoom:H.zoom}),J(H,B,we)};function J(H,ue,de){de===null?H.matrix.copy(ue.matrixWorld):(H.matrix.copy(de.matrixWorld),H.matrix.invert(),H.matrix.multiply(ue.matrixWorld)),H.matrix.decompose(H.position,H.quaternion,H.scale),H.updateMatrixWorld(!0),H.projectionMatrix.copy(ue.projectionMatrix),H.projectionMatrixInverse.copy(ue.projectionMatrixInverse),H.isPerspectiveCamera&&(H.fov=ts*2*Math.atan(1/H.projectionMatrix.elements[5]),H.zoom=1)}this.getCamera=function(){return B},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(H){c=H,d!==null&&(d.fixedFoveation=H),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=H)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(B)},this.getCameraTexture=function(H){return p[H]};let O=null;function ae(H,ue){if(h=ue.getViewerPose(l||o),_=ue,h!==null){let de=h.views;f!==null&&(e.setRenderTargetFramebuffer(S,f.framebuffer),e.setRenderTarget(S));let we=!1;de.length!==B.cameras.length&&(B.cameras.length=0,we=!0);for(let me=0;me<de.length;me++){let Ie=de[me],Ne=null;if(f!==null)Ne=f.getViewport(Ie);else{let Ce=u.getViewSubImage(d,Ie);Ne=Ce.viewport,me===0&&(e.setRenderTargetTextures(S,Ce.colorTexture,Ce.depthStencilTexture),e.setRenderTarget(S))}let Oe=N[me];Oe===void 0&&(Oe=new qt,Oe.layers.enable(me),Oe.viewport=new _t,N[me]=Oe),Oe.matrix.fromArray(Ie.transform.matrix),Oe.matrix.decompose(Oe.position,Oe.quaternion,Oe.scale),Oe.projectionMatrix.fromArray(Ie.projectionMatrix),Oe.projectionMatrixInverse.copy(Oe.projectionMatrix).invert(),Oe.viewport.set(Ne.x,Ne.y,Ne.width,Ne.height),me===0&&(B.matrix.copy(Oe.matrix),B.matrix.decompose(B.position,B.quaternion,B.scale)),we===!0&&B.cameras.push(Oe)}let fe=s.enabledFeatures;if(fe&&fe.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&x){u=n.getBinding();let me=u.getDepthInformation(de[0]);me&&me.isValid&&me.texture&&m.init(me,s.renderState)}if(fe&&fe.includes("camera-access")&&x){e.state.unbindTexture(),u=n.getBinding();for(let me=0;me<de.length;me++){let Ie=de[me].camera;if(Ie){let Ne=p[Ie];Ne||(Ne=new ks,p[Ie]=Ne);let Oe=u.getCameraImage(Ie);Ne.sourceTexture=Oe}}}}for(let de=0;de<E.length;de++){let we=M[de],fe=E[de];we!==null&&fe!==void 0&&fe.update(we,ue,l||o)}O&&O(H,ue),ue.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ue}),_=null}let xe=new su;xe.setAnimationLoop(ae),this.setAnimationLoop=function(H){O=H},this.dispose=function(){}}},N0=new mt,pu=new Ge;pu.set(-1,0,0,0,1,0,0,0,1);function U0(i,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,Ll(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function s(m,p,w,T,S){p.isNodeMaterial?p.uniformsNeedUpdate=!1:p.isMeshBasicMaterial?r(m,p):p.isMeshLambertMaterial?(r(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshToonMaterial?(r(m,p),u(m,p)):p.isMeshPhongMaterial?(r(m,p),h(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshStandardMaterial?(r(m,p),d(m,p),p.isMeshPhysicalMaterial&&f(m,p,S)):p.isMeshMatcapMaterial?(r(m,p),_(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),x(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(o(m,p),p.isLineDashedMaterial&&a(m,p)):p.isPointsMaterial?c(m,p,w,T):p.isSpriteMaterial?l(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===Jt&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===Jt&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);let w=e.get(p),T=w.envMap,S=w.envMapRotation;T&&(m.envMap.value=T,m.envMapRotation.value.setFromMatrix4(N0.makeRotationFromEuler(S)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(pu),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function o(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function a(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function c(m,p,w,T){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*w,m.scale.value=T*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function l(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function u(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,w){m.ior.value=p.ior,p.diffuseRoughness>0&&(m.diffuseRoughness.value=p.diffuseRoughness,p.diffuseRoughnessMap&&(m.diffuseRoughnessMap.value=p.diffuseRoughnessMap,t(p.diffuseRoughnessMap,m.diffuseRoughnessMapTransform))),p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Jt&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.retroreflectivity>0&&(m.retroreflectivity.value=p.retroreflectivity),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessMinimum,m.iridescenceThicknessMaximum.value=p.iridescenceThicknessMaximum,p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=w.texture,m.transmissionSamplerSize.value.set(w.width,w.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function _(m,p){p.matcap&&(m.matcap.value=p.matcap)}function x(m,p){let w=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(w.matrixWorld),m.nearDistance.value=w.shadow.camera.near,m.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function F0(i,e,t,n){let s={},r={};function o(w,T){let S=T.program;n.uniformBlockBinding(w,S,s[w.id])}function a(w,T){let S=s[w.id];S===void 0&&(_(w),S=c(w),s[w.id]=S,w.addEventListener("dispose",m));let E=T.program;n.updateUBOMapping(w,E);let M=e.render.frame;r[w.id]!==M&&(l(w),r[w.id]=M)}function c(w){let T=i.createBuffer(),S=w.__size,E=w.usage;return i.bindBuffer(i.UNIFORM_BUFFER,T),i.bufferData(i.UNIFORM_BUFFER,S,E),i.bindBuffer(i.UNIFORM_BUFFER,null),T}function l(w){let T=s[w.id],S=w.uniforms,E=w.__cache;i.bindBuffer(i.UNIFORM_BUFFER,T);for(let M=0,g=S.length;M<g;M++){let v=S[M];if(Array.isArray(v))for(let L=0,R=v.length;L<R;L++)h(v[L],M,L,E);else h(v,M,0,E)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function h(w,T,S,E){if(d(w,T,S,E)===!0){let M=w.__offset,g=w.value;if(Array.isArray(g)){let v=0;for(let L=0;L<g.length;L++){let R=g[L],D=x(R,!0);u(R,w.__data,v),v+=D.storage/Float32Array.BYTES_PER_ELEMENT}}else u(g,w.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,M,w.__data)}}function u(w,T,S){typeof w=="number"||typeof w=="boolean"?T[S]=w:w.isMatrix3?(T[S]=w.elements[0],T[S+1]=w.elements[1],T[S+2]=w.elements[2],T[S+3]=0,T[S+4]=w.elements[3],T[S+5]=w.elements[4],T[S+6]=w.elements[5],T[S+7]=0,T[S+8]=w.elements[6],T[S+9]=w.elements[7],T[S+10]=w.elements[8],T[S+11]=0):ArrayBuffer.isView(w)?T.set(w.subarray(0,T.length-S),S):w.toArray(T,S)}function d(w,T,S,E){let M=w.value,g=T+"_"+S;if(Array.isArray(M)){E[g]===void 0&&(E[g]=[]);let v=E[g],L=!1;for(let R=0;R<M.length;R++)f(M[R],v,R)===!0&&(L=!0);return L}return f(M,E,g)}function f(w,T,S){if(T[S]===void 0)return typeof w=="number"||typeof w=="boolean"?T[S]=w:ArrayBuffer.isView(w)?T[S]=w.slice():T[S]=w.clone(),!0;{let E=T[S];if(typeof w=="number"||typeof w=="boolean"){if(E!==w)return T[S]=w,!0}else{if(ArrayBuffer.isView(w))return!0;if(E.equals(w)===!1)return E.copy(w),!0}}return!1}function _(w){let T=w.uniforms,S=0,E=16;for(let g=0,v=T.length;g<v;g++){let L=Array.isArray(T[g])?T[g]:[T[g]];for(let R=0,D=L.length;R<D;R++){let N=L[R],B=Array.isArray(N.value)?N.value:[N.value],C=Array.isArray(T[g])||Array.isArray(N.value),W=S;for(let z=0,ee=B.length;z<ee;z++){let q=B[z],J=x(q,C),O=S%E,ae=O%J.boundary,xe=O+ae;S+=ae,xe!==0&&E-xe<J.storage&&(S+=E-xe),z===0&&(W=S),S+=J.storage}let Z=N.type==="int"?Int32Array:N.type==="uint"?Uint32Array:Float32Array;N.__data=new Z((S-W)/Float32Array.BYTES_PER_ELEMENT),N.__offset=W}}let M=S%E;return M>0&&(S+=E-M),w.__size=S,w.__cache={},this}function x(w,T){let S={boundary:0,storage:0};return typeof w=="number"||typeof w=="boolean"?(S.boundary=4,S.storage=4):w.isVector2?(S.boundary=8,S.storage=8):w.isVector3||w.isColor?(S.boundary=16,S.storage=12):w.isVector4?(S.boundary=16,S.storage=16):w.isMatrix3?(S.boundary=16,S.storage=48):w.isMatrix4?(S.boundary=16,S.storage=64):w.isTexture?Fe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(w)?(S.boundary=16,S.storage=w.byteLength):Fe("WebGLRenderer: Unsupported uniform value type.",w),T===!0&&(S.boundary=16,S.storage=Math.ceil(S.storage/16)*16),S}function m(w){let T=w.target;T.removeEventListener("dispose",m),i.deleteBuffer(s[T.id]),delete s[T.id],delete r[T.id]}function p(){for(let w in s)i.deleteBuffer(s[w]);s={},r={}}return{bind:o,update:a,dispose:p}}var O0=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]),Dn=null;function B0(){return Dn===null&&(Dn=new no(O0,16,16,_i,Tn),Dn.name="DFG_LUT",Dn.minFilter=Zt,Dn.magFilter=Zt,Dn.wrapS=Cn,Dn.wrapT=Cn,Dn.generateMipmaps=!1,Dn.needsUpdate=!0),Dn}var pa=class{constructor(e={}){let{canvas:t=Ah(),context:n=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=en}=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 _=o;let x=f,m=new Set([Do,Lo,Io]),p=new Set([en,wn,ps,Ni,Co,Po]),w=new Uint32Array(4),T=new Int32Array(4),S={textures:[],min:[],max:[],resolution:[]},E=null,M=null,g=[],v=[],L=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=Ln,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let R=this,D=!1,N=null,B=null,C=null,W=null;this._outputColorSpace=on;let Z=0,z=0,ee=null,q=-1,J=null,O=new _t,ae=new _t,xe=null,H=new Ye(0),ue=0,de=t.width,we=t.height,fe=1,Te=null,He=null,me=new _t(0,0,de,we),Ie=new _t(0,0,de,we),Ne=!1,Oe=new hi,Ce=new io,We=!1,vt=!1,nt=new mt,gt=new k,Xe=new _t,ft={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},It=!1;function Ft(){return ee===null?fe:1}let F=n;function Lt(b,U){return t.getContext(b,U)}let st,rt,_e,ht,De,Be,A,y,V,le,se,he,ye,j,Q,ge,I,te,P,ne,$,ie,oe;try{let b={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"187"}`),t.addEventListener("webglcontextlost",pe,!1),t.addEventListener("webglcontextrestored",Le,!1),t.addEventListener("webglcontextcreationerror",ce,!1),F===null){let U="webgl2";if(F=Lt(U,b),F===null)throw Lt(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}re()}catch(b){throw t.removeEventListener("webglcontextlost",pe,!1),t.removeEventListener("webglcontextrestored",Le,!1),t.removeEventListener("webglcontextcreationerror",ce,!1),ke("WebGLRenderer: "+b.message),b}function re(){st=new $m(F),st.init(),$=new I0(F,st),rt=new Bm(F,st,e,$),_e=new C0(F,st),rt.reversedDepthBuffer&&d&&_e.buffers.depth.setReversed(!0),B=F.createFramebuffer(),C=F.createFramebuffer(),W=F.createFramebuffer(),ht=new jm(F),De=new m0,Be=new P0(F,st,_e,De,rt,$,ht),A=new Zm(R),y=new Qd(F),ie=new Fm(F,y),V=new Jm(F,y,ht,ie),le=new eg(F,V,y,ie,ht),te=new Qm(F,rt,Be),Q=new zm(De),se=new p0(R,A,st,rt,ie,Q),he=new U0(R,De),ye=new _0,j=new S0(st),I=new Um(R,A,_e,le,_,c),ge=new R0(R,le,rt),oe=new F0(F,ht,rt,_e),P=new Om(F,st,ht),ne=new Km(F,st,ht),ht.programs=se.programs,R.capabilities=rt,R.extensions=st,R.properties=De,R.renderLists=ye,R.shadowMap=ge,R.state=_e,R.info=ht}x!==en&&(L=new ng(x,t.width,t.height,a,s,r));let K=new Jl(R,F);this.xr=K,this.getContext=function(){return F},this.getContextAttributes=function(){return F.getContextAttributes()},this.forceContextLoss=function(){let b=st.get("WEBGL_lose_context");b&&b.loseContext()},this.forceContextRestore=function(){let b=st.get("WEBGL_lose_context");b&&b.restoreContext()},this.getPixelRatio=function(){return fe},this.setPixelRatio=function(b){b!==void 0&&(fe=b,this.setSize(de,we,!1))},this.getSize=function(b){return b.set(de,we)},this.setSize=function(b,U,Y=!0){if(K.isPresenting){Fe("WebGLRenderer: Can't change size while VR device is presenting.");return}de=b,we=U,t.width=Math.floor(b*fe),t.height=Math.floor(U*fe),Y===!0&&(t.style.width=b+"px",t.style.height=U+"px"),L!==null&&L.setSize(t.width,t.height),this.setViewport(0,0,b,U)},this.getDrawingBufferSize=function(b){return b.set(de*fe,we*fe).floor()},this.setDrawingBufferSize=function(b,U,Y){de=b,we=U,fe=Y,t.width=Math.floor(b*Y),t.height=Math.floor(U*Y),this.setViewport(0,0,b,U)},this.setEffects=function(b){if(x===en){ke("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let U=0;U<b.length;U++)if(b[U].isOutputPass===!0){Fe("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}L.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(O)},this.getViewport=function(b){return b.copy(me)},this.setViewport=function(b,U,Y,G){b.isVector4?me.set(b.x,b.y,b.z,b.w):me.set(b,U,Y,G),_e.viewport(O.copy(me).multiplyScalar(Ft()).round())},this.getScissor=function(b){return b.copy(Ie)},this.setScissor=function(b,U,Y,G){b.isVector4?Ie.set(b.x,b.y,b.z,b.w):Ie.set(b,U,Y,G),_e.scissor(ae.copy(Ie).multiplyScalar(Ft()).round())},this.getScissorTest=function(){return Ne},this.setScissorTest=function(b){_e.setScissorTest(Ne=b)},this.setOpaqueSort=function(b){Te=b},this.setTransparentSort=function(b){He=b},this.getClearColor=function(b){return b.copy(I.getClearColor())},this.setClearColor=function(){I.setClearColor(...arguments)},this.getClearAlpha=function(){return I.getClearAlpha()},this.setClearAlpha=function(){I.setClearAlpha(...arguments)},this.clear=function(b=!0,U=!0,Y=!0){let G=0;if(b){let X=!1;if(ee!==null){let be=ee.texture.format;X=m.has(be)}if(X){let be=ee.texture.type,Ee=p.has(be),ve=I.getClearColor(),Se=I.getClearAlpha(),Pe=ve.r,qe=ve.g,je=ve.b;Ee?(w[0]=Pe,w[1]=qe,w[2]=je,w[3]=Se,F.clearBufferuiv(F.COLOR,0,w)):(T[0]=Pe,T[1]=qe,T[2]=je,T[3]=Se,F.clearBufferiv(F.COLOR,0,T))}else G|=F.COLOR_BUFFER_BIT}U&&(G|=F.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Y&&(G|=F.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),G!==0&&F.clear(G)},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(b){b.setRenderer(this),N=b},this.dispose=function(){t.removeEventListener("webglcontextlost",pe,!1),t.removeEventListener("webglcontextrestored",Le,!1),t.removeEventListener("webglcontextcreationerror",ce,!1),I.dispose(),ye.dispose(),j.dispose(),Be.dispose(),De.dispose(),A.dispose(),le.dispose(),V.dispose(),ie.dispose(),oe.dispose(),se.dispose(),K.dispose(),K.removeEventListener("sessionstart",lt),K.removeEventListener("sessionend",nn),ze.stop()};function pe(b){b.preventDefault(),Al("WebGLRenderer: Context Lost."),D=!0}function Le(){Al("WebGLRenderer: Context Restored."),D=!1;let b=ht.autoReset,U=ge.enabled,Y=ge.autoUpdate,G=ge.needsUpdate,X=ge.type;re(),ht.autoReset=b,ge.enabled=U,ge.autoUpdate=Y,ge.needsUpdate=G,ge.type=X}function ce(b){ke("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function Ue(b){let U=b.target;U.removeEventListener("dispose",Ue),tt(U)}function tt(b){xt(b),De.remove(b)}function xt(b){let U=De.get(b).programs;U!==void 0&&(U.forEach(function(Y){se.releaseProgram(Y)}),b.isShaderMaterial&&se.releaseShaderCache(b))}this.renderBufferDirect=function(b,U,Y,G,X,be){U===null&&(U=ft);let Ee=X.isMesh&&X.matrixWorld.determinantAffine()<0,ve=ju(b,U,Y,G,X);_e.setMaterial(G,Ee);let Se=Y.index,Pe=1;if(G.wireframe===!0){if(Se=V.getWireframeAttribute(Y),Se===void 0)return;Pe=2}let qe=Y.drawRange,je=Y.attributes.position,Ae=qe.start*Pe,Qe=(qe.start+qe.count)*Pe;be!==null&&(Ae=Math.max(Ae,be.start*Pe),Qe=Math.min(Qe,(be.start+be.count)*Pe)),Se!==null?(Ae=Math.max(Ae,0),Qe=Math.min(Qe,Se.count)):je!=null&&(Ae=Math.max(Ae,0),Qe=Math.min(Qe,je.count));let Mt=Qe-Ae;if(Mt<0||Mt===1/0)return;ie.setup(X,G,ve,Y,Se);let dt,ut=P;if(Se!==null&&(dt=y.get(Se),ut=ne,ut.setIndex(dt)),X.isMesh)G.wireframe===!0?(_e.setLineWidth(G.wireframeLinewidth*Ft()),ut.setMode(F.LINES)):ut.setMode(F.TRIANGLES);else if(X.isLine){let Ot=G.linewidth;Ot===void 0&&(Ot=1),_e.setLineWidth(Ot*Ft()),X.isLineSegments?ut.setMode(F.LINES):X.isLineLoop?ut.setMode(F.LINE_LOOP):ut.setMode(F.LINE_STRIP)}else X.isPoints?ut.setMode(F.POINTS):X.isSprite&&ut.setMode(F.TRIANGLES);if(X.isBatchedMesh)if(st.get("WEBGL_multi_draw"))ut.renderMultiDraw(X._multiDrawStarts,X._multiDrawCounts,X._multiDrawCount);else{let Ot=X._multiDrawStarts,Re=X._multiDrawCounts,Xt=X._multiDrawCount,ot=Se?y.get(Se).bytesPerElement:1,bi=De.get(G).currentProgram.getUniforms();for(let Bt=0;Bt<Xt;Bt++)bi.setValue(F,"_gl_DrawID",Bt),ut.render(Ot[Bt]/ot,Re[Bt])}else if(X.isInstancedMesh)ut.renderInstances(Ae,Mt,X.count);else if(Y.isInstancedBufferGeometry){let Ot=Y._maxInstanceCount!==void 0?Y._maxInstanceCount:1/0,Re=Math.min(Y.instanceCount,Ot);ut.renderInstances(Ae,Mt,Re)}else ut.render(Ae,Mt)};function Ze(b,U,Y,G){N!==null&&b.isNodeMaterial&&N.setObject(G,b),We===!0&&Q.setState(b,Y,!1),b.transparent===!0&&b.side===_n&&b.forceSinglePass===!1?(b.side=Jt,b.needsUpdate=!0,ni(b,U,G),b.side=gi,b.needsUpdate=!0,ni(b,U,G),b.side=_n):ni(b,U,G)}this.compile=function(b,U,Y=null){Y===null&&(Y=b),N!==null&&N.renderStart(b,U,Y),M=j.get(Y),M.init(U),v.push(M),Y.traverseVisible(function(X){X.isLight&&X.layers.test(U.layers)&&(M.pushLight(X),X.castShadow&&M.pushShadow(X))}),b!==Y&&b.traverseVisible(function(X){X.isLight&&X.layers.test(U.layers)&&(M.pushLight(X),X.castShadow&&M.pushShadow(X))}),M.setupLights(),N!==null&&N.updateLights(M.state.lightsArray),vt=this.localClippingEnabled,We=Q.init(this.clippingPlanes,vt),We===!0&&Q.setGlobalState(this.clippingPlanes,U),N!==null&&ge.render(M.state.shadowsArray,Y,U);let G=new Set;return b.traverse(function(X){if(!(X.isMesh||X.isPoints||X.isLine||X.isSprite))return;let be=X.material;if(be)if(Array.isArray(be))for(let Ee=0;Ee<be.length;Ee++){let ve=be[Ee];Ze(ve,Y,U,X),G.add(ve)}else Ze(be,Y,U,X),G.add(be)}),M=v.pop(),N!==null&&N.renderEnd(),G},this.compileAsync=function(b,U,Y=null){let G=this.compile(b,U,Y);return new Promise(X=>{function be(){if(G.forEach(function(Ee){let Se=De.get(Ee).currentProgram;(Se===void 0||Se.isReady())&&G.delete(Ee)}),G.size===0){X(b);return}setTimeout(be,10)}st.get("KHR_parallel_shader_compile")!==null?be():setTimeout(be,10)})};let bt=null;function Dt(b){bt&&bt(b)}function lt(){ze.stop()}function nn(){ze.start()}let ze=new su;ze.setAnimationLoop(Dt),typeof self<"u"&&ze.setContext(self),this.setAnimationLoop=function(b){bt=b,K.setAnimationLoop(b),b===null?ze.stop():ze.start()},K.addEventListener("sessionstart",lt),K.addEventListener("sessionend",nn),this.render=function(b,U){if(U!==void 0&&U.isCamera!==!0){ke("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;N!==null&&N.renderStart(b,U);let Y=K.enabled===!0&&K.isPresenting===!0,G=L!==null&&(ee===null||Y)&&L.begin(R,ee);if(b.matrixWorldAutoUpdate===!0&&b.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),K.enabled===!0&&K.isPresenting===!0&&(L===null||L.isCompositing()===!1)&&(K.cameraAutoUpdate===!0&&K.updateCamera(U),U=K.getCamera()),b.isScene===!0&&b.onBeforeRender(R,b,U,ee),M=j.get(b,v.length),M.init(U),M.state.textureUnits=Be.getTextureUnits(),v.push(M),nt.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),U.isArrayCamera?Ce.setFromArrayCamera(U):Oe.setFromProjectionMatrix(nt,gn,U.reversedDepth),vt=this.localClippingEnabled,We=Q.init(this.clippingPlanes,vt),E=ye.get(b,g.length),E.init(),g.push(E),this.info.render.frame++,K.enabled===!0&&K.isPresenting===!0){let Ee=R.xr.getDepthSensingMesh();Ee!==null&&dn(Ee,U,-1/0,R.sortObjects)}dn(b,U,0,R.sortObjects),E.finish(),N!==null&&N.updateLights(M.state.lightsArray),R.sortObjects===!0&&E.sort(Te,He),It=K.enabled===!1||K.isPresenting===!1||K.hasDepthSensing()===!1,It&&I.addToRenderList(E,b),this.info.autoReset===!0&&this.info.reset(),We===!0&&Q.beginShadows();let X=M.state.shadowsArray;if(ge.render(X,b,U),We===!0&&Q.endShadows(),(G&&L.hasRenderPass())===!1){let Ee=E.opaque,ve=E.transmissive;if(M.setupLights(),U.isArrayCamera){let Se=U.cameras;if(ve.length>0)for(let Pe=0,qe=Se.length;Pe<qe;Pe++){let je=Se[Pe];On(Ee,ve,b,je)}It&&I.render(b);for(let Pe=0,qe=Se.length;Pe<qe;Pe++){let je=Se[Pe];fn(E,b,je,je.viewport)}}else ve.length>0&&On(Ee,ve,b,U),It&&I.render(b),fn(E,b,U)}ee!==null&&z===0&&(Be.updateMultisampleRenderTarget(ee),Be.updateRenderTargetMipmap(ee)),G&&L.end(R),b.isScene===!0&&b.onAfterRender(R,b,U),ie.resetDefaultState(),q=-1,J=null,v.pop(),v.length>0?(M=v[v.length-1],Be.setTextureUnits(M.state.textureUnits),We===!0&&Q.setGlobalState(R.clippingPlanes,M.state.camera)):M=null,g.pop(),g.length>0?E=g[g.length-1]:E=null,N!==null&&N.renderEnd()};function dn(b,U,Y,G){if(b.visible===!1)return;if(b.layers.test(U.layers)){if(b.isGroup)Y=b.renderOrder;else if(b.isLOD)b.autoUpdate===!0&&b.update(U);else if(b.isLight)M.pushLight(b),b.castShadow&&M.pushShadow(b);else if(b.isSprite){let Ee=U.isArrayCamera?Ce:Oe;if(!b.frustumCulled||b.intersectsFrustum(Ee)){G&&Xe.setFromMatrixPosition(b.matrixWorld).applyMatrix4(nt);let ve=le.update(b),Se=b.material;Se.visible&&E.push(b,ve,Se,Y,Xe.z,null,U)}}else if(b.isMesh||b.isLine||b.isPoints){let Ee=U.isArrayCamera?Ce:Oe;if(!b.frustumCulled||b.intersectsFrustum(Ee)){let ve=le.update(b),Se=b.material;if(G&&(b.boundingSphere!==void 0?(b.boundingSphere===null&&b.computeBoundingSphere(),Xe.copy(b.boundingSphere.center)):(ve.boundingSphere===null&&ve.computeBoundingSphere(),Xe.copy(ve.boundingSphere.center)),Xe.applyMatrix4(b.matrixWorld).applyMatrix4(nt)),Array.isArray(Se)){let Pe=ve.groups;for(let qe=0,je=Pe.length;qe<je;qe++){let Ae=Pe[qe],Qe=Se[Ae.materialIndex];Qe&&Qe.visible&&E.push(b,ve,Qe,Y,Xe.z,Ae,U)}}else Se.visible&&E.push(b,ve,Se,Y,Xe.z,null,U)}}}let be=b.children;for(let Ee=0,ve=be.length;Ee<ve;Ee++)dn(be[Ee],U,Y,G)}function fn(b,U,Y,G){let{opaque:X,transmissive:be,transparent:Ee}=b;M.setupLightsView(Y),We===!0&&Q.setGlobalState(R.clippingPlanes,Y),G&&_e.viewport(O.copy(G)),X.length>0&&Bn(X,U,Y),be.length>0&&Bn(be,U,Y),Ee.length>0&&Bn(Ee,U,Y),_e.buffers.depth.setTest(!0),_e.buffers.depth.setMask(!0),_e.buffers.color.setMask(!0),_e.setPolygonOffset(!1)}function On(b,U,Y,G){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;if(M.state.transmissionRenderTarget[G.id]===void 0){let Ae=st.has("EXT_color_buffer_half_float")||st.has("EXT_color_buffer_float");M.state.transmissionRenderTarget[G.id]=new cn(1,1,{generateMipmaps:!0,type:Ae?Tn:en,minFilter:Kn,samples:Math.max(4,rt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:et.workingColorSpace})}let be=M.state.transmissionRenderTarget[G.id],Ee=G.viewport||O;be.setSize(Ee.z*R.transmissionResolutionScale,Ee.w*R.transmissionResolutionScale);let ve=R.getRenderTarget(),Se=R.getActiveCubeFace(),Pe=R.getActiveMipmapLevel();R.setRenderTarget(be),R.getClearColor(H),ue=R.getClearAlpha(),ue<1&&R.setClearColor(16777215,.5),R.clear(),It&&I.render(Y);let qe=R.toneMapping;R.toneMapping=Ln;let je=G.viewport;if(G.viewport!==void 0&&(G.viewport=void 0),M.setupLightsView(G),We===!0&&Q.setGlobalState(R.clippingPlanes,G),Bn(b,Y,G),Be.updateMultisampleRenderTarget(be),Be.updateRenderTargetMipmap(be),st.has("WEBGL_multisampled_render_to_texture")===!1){let Ae=!1;for(let Qe=0,Mt=U.length;Qe<Mt;Qe++){let dt=U[Qe],{object:ut,geometry:Ot,material:Re,group:Xt}=dt;if(Re.side===_n&&ut.layers.test(G.layers)){let ot=Re.side;Re.side=Jt,Re.needsUpdate=!0,vs(ut,Y,G,Ot,Re,Xt),Re.side=ot,Re.needsUpdate=!0,Ae=!0}}Ae===!0&&(Be.updateMultisampleRenderTarget(be),Be.updateRenderTargetMipmap(be))}R.setRenderTarget(ve,Se,Pe),R.setClearColor(H,ue),je!==void 0&&(G.viewport=je),R.toneMapping=qe}function Bn(b,U,Y){let G=U.isScene===!0?U.overrideMaterial:null;for(let X=0,be=b.length;X<be;X++){let Ee=b[X],{object:ve,geometry:Se,group:Pe}=Ee,qe=Ee.material;qe.allowOverride===!0&&G!==null&&(qe=G),ve.layers.test(Y.layers)&&vs(ve,U,Y,Se,qe,Pe)}}function vs(b,U,Y,G,X,be){N!==null&&X.isNodeMaterial&&N.setObject(b,X),b.onBeforeRender(R,U,Y,G,X,be),b.modelViewMatrix.multiplyMatrices(Y.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),X.onBeforeRender(R,U,Y,G,b,be),X.transparent===!0&&X.side===_n&&X.forceSinglePass===!1?(X.side=Jt,X.needsUpdate=!0,R.renderBufferDirect(Y,U,G,X,b,be),X.side=gi,X.needsUpdate=!0,R.renderBufferDirect(Y,U,G,X,b,be),X.side=_n):R.renderBufferDirect(Y,U,G,X,b,be),b.onAfterRender(R,U,Y,G,X,be)}function bs(b){let U=0;for(let Y of b)Y.texture!==null&&U++;return U}function ni(b,U,Y){U.isScene!==!0&&(U=ft);let G=De.get(b),X=M.state.lights,be=M.state.shadowsArray,Ee=X.state.version,ve=se.getParameters(b,X.state,be,U,Y,M.state.lightProbeGridArray),Se=se.getProgramCacheKey(ve),Pe=G.programs;G.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?U.environment:null,G.fog=U.fog;let qe=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;G.envMap=A.get(b.envMap||G.environment,qe),G.envMapRotation=G.environment!==null&&b.envMap===null?U.environmentRotation:b.envMapRotation,Pe===void 0&&(b.addEventListener("dispose",Ue),Pe=new Map,G.programs=Pe,G.programVariants=new Map);let je=Pe.get(Se);if(je!==void 0){if(G.currentProgram===je&&G.lightsStateVersion===Ee)return _c(b,ve),je}else ve.uniforms=se.getUniforms(b),N!==null&&b.isNodeMaterial&&N.build(b,Y,ve),b.onBeforeCompile(ve,R),je=se.acquireProgram(ve,Se),Pe.set(Se,je),G.uniforms=ve.uniforms;let Ae=G.uniforms;return(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)&&(Ae.clippingPlanes=Q.uniform),_c(b,ve),G.needsLights=ed(b),G.lightsStateVersion=Ee,G.needsLights&&(Ae.ambientLightColor.value=X.state.ambient,Ae.lightProbe.value=X.state.probe,Ae.sunLights.value=X.state.sun,Ae.sunLightShadows.value=X.state.sunShadow,Ae.directionalLights.value=X.state.directional,Ae.directionalLightShadows.value=X.state.directionalShadow,Ae.spotLights.value=X.state.spot,Ae.spotLightShadows.value=X.state.spotShadow,Ae.rectAreaLights.value=X.state.rectArea,Ae.ltc_1.value=X.state.rectAreaLTC1,Ae.ltc_2.value=X.state.rectAreaLTC2,Ae.pointLights.value=X.state.point,Ae.pointLightShadows.value=X.state.pointShadow,Ae.hemisphereLights.value=X.state.hemi,Ae.sunShadowMatrix.value=X.state.sunShadowMatrix,Ae.sunShadowCascade.value=X.state.sunShadowCascade,Ae.directionalShadowMatrix.value=X.state.directionalShadowMatrix,Ae.spotLightMatrix.value=X.state.spotLightMatrix,Ae.spotLightMap.value=X.state.spotLightMap,Ae.pointShadowMatrix.value=X.state.pointShadowMatrix),G.numLightProbeGrids=bs(M.state.lightProbeGridArray),G.currentProgram=je,G.uniformsList=null,je}function pr(b,U,Y,G,X){let be=De.get(b),Ee=be.currentProgram.id+","+G+","+X,ve=be.programVariants.get(Ee);return ve===void 0?(ve=ni(b,U,Y),be.programVariants.set(Ee,ve)):(be.currentProgram=ve,be.uniformsList=null,be.outputColorSpace=G,be.toneMapping=X),ve}function gc(b){if(b.uniformsList===null){let U=b.currentProgram.getUniforms();b.uniformsList=gs.seqWithValue(U.seq,b.uniforms)}return b.uniformsList}function _c(b,U){let Y=De.get(b);Y.outputColorSpace=U.outputColorSpace,Y.batching=U.batching,Y.batchingColor=U.batchingColor,Y.instancing=U.instancing,Y.instancingColor=U.instancingColor,Y.instancingMorph=U.instancingMorph,Y.skinning=U.skinning,Y.morphTargets=U.morphTargets,Y.morphNormals=U.morphNormals,Y.morphColors=U.morphColors,Y.morphTargetsCount=U.morphTargetsCount,Y.numClippingPlanes=U.numClippingPlanes,Y.numIntersection=U.numClipIntersection,Y.vertexAlphas=U.vertexAlphas,Y.vertexTangents=U.vertexTangents,Y.toneMapping=U.toneMapping}function ju(b,U,Y,G,X){U.isScene!==!0&&(U=ft),Be.resetTextureUnits();let be=U.fog,Ee=G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial?U.environment:null,ve=ee===null?R.outputColorSpace:ee.isXRRenderTarget===!0?ee.texture.colorSpace:et.workingColorSpace,Se=G.isMeshStandardMaterial||G.isMeshLambertMaterial&&!G.envMap||G.isMeshPhongMaterial&&!G.envMap,Pe=A.get(G.envMap||Ee,Se),qe=G.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,je=!!Y.attributes.tangent&&(!!G.normalMap||G.anisotropy>0),Ae=!!Y.morphAttributes.position,Qe=!!Y.morphAttributes.normal,Mt=!!Y.morphAttributes.color,dt=Ln;G.toneMapped&&(ee===null||ee.isXRRenderTarget===!0)&&(dt=R.toneMapping);let ut=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,Ot=ut!==void 0?ut.length:0,Re=De.get(G),Xt=M.state.lights;if(We===!0&&(vt===!0||b!==J)){let yt=b===J&&G.id===q;Q.setState(G,b,yt)}let ot=!1,bi=!1;G.version===Re.__version?Re.needsLights&&Re.lightsStateVersion!==Xt.state.version||X.isBatchedMesh&&Re.batching===!1||!X.isBatchedMesh&&Re.batching===!0||X.isBatchedMesh&&Re.batchingColor===!0&&X._colorsTexture===null||X.isBatchedMesh&&Re.batchingColor===!1&&X._colorsTexture!==null||X.isInstancedMesh&&Re.instancing===!1||!X.isInstancedMesh&&Re.instancing===!0||X.isSkinnedMesh&&Re.skinning===!1||!X.isSkinnedMesh&&Re.skinning===!0||X.isInstancedMesh&&Re.instancingColor===!0&&X.instanceColor===null||X.isInstancedMesh&&Re.instancingColor===!1&&X.instanceColor!==null||X.isInstancedMesh&&Re.instancingMorph===!0&&X.morphTexture===null||X.isInstancedMesh&&Re.instancingMorph===!1&&X.morphTexture!==null||Re.envMap!==Pe||G.fog===!0&&Re.fog!==be||Re.numClippingPlanes!==void 0&&(Re.numClippingPlanes!==Q.numPlanes||Re.numIntersection!==Q.numIntersection)||Re.vertexAlphas!==qe||Re.vertexTangents!==je||Re.morphTargets!==Ae||Re.morphNormals!==Qe||Re.morphColors!==Mt||Re.morphTargetsCount!==Ot||Re.numLightProbeGrids!==bs(M.state.lightProbeGridArray)?ot=!0:(Re.outputColorSpace!==ve||Re.toneMapping!==dt)&&(bi=!0):(ot=!0,Re.__version=G.version);let Bt=Re.currentProgram;(ot===!0||bi===!0)&&(Bt=bi===!0?pr(G,U,X,ve,dt):ni(G,U,X),N&&G.isNodeMaterial&&N.onUpdateProgram(G,Bt,Re));let mr=!1,ii=!1,Mi=!1,it=Bt.getUniforms(),Nt=Re.uniforms;if(_e.useProgram(Bt.program)&&(mr=!0,ii=!0,Mi=!0),G.id!==q&&(q=G.id,ii=!0),mr||J!==b){_e.buffers.depth.getReversed()&&b.reversedDepth!==!0&&(b._reversedDepth=!0,b.updateProjectionMatrix()),it.setValue(F,"projectionMatrix",b.projectionMatrix),it.setValue(F,"viewMatrix",b.matrixWorldInverse);let Rt=it.map.cameraPosition;Rt!==void 0&&Rt.setValue(F,gt.setFromMatrixPosition(b.matrixWorld)),rt.logarithmicDepthBuffer&&it.setValue(F,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2)),(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial)&&it.setValue(F,"isOrthographic",b.isOrthographicCamera===!0),J!==b&&(J=b,ii=!0,Mi=!0)}if(Re.needsLights&&(Xt.state.sunShadowMap.length>0&&it.setValue(F,"sunShadowMap",Xt.state.sunShadowMap,Be),Xt.state.directionalShadowMap.length>0&&it.setValue(F,"directionalShadowMap",Xt.state.directionalShadowMap,Be),Xt.state.spotShadowMap.length>0&&it.setValue(F,"spotShadowMap",Xt.state.spotShadowMap,Be),Xt.state.pointShadowMap.length>0&&it.setValue(F,"pointShadowMap",Xt.state.pointShadowMap,Be)),X.isSkinnedMesh){it.setOptional(F,X,"bindMatrix"),it.setOptional(F,X,"bindMatrixInverse");let yt=X.skeleton;yt&&(yt.boneTexture===null&&yt.computeBoneTexture(),it.setValue(F,"boneTexture",yt.boneTexture,Be))}X.isBatchedMesh&&(it.setOptional(F,X,"batchingTexture"),it.setValue(F,"batchingTexture",X._matricesTexture,Be),it.setOptional(F,X,"batchingIdTexture"),it.setValue(F,"batchingIdTexture",X._indirectTexture,Be),it.setOptional(F,X,"batchingColorTexture"),X._colorsTexture!==null&&it.setValue(F,"batchingColorTexture",X._colorsTexture,Be));let yn=Y.morphAttributes;if((yn.position!==void 0||yn.normal!==void 0||yn.color!==void 0)&&te.update(X,Y,Bt),(ii||Re.receiveShadow!==X.receiveShadow)&&(Re.receiveShadow=X.receiveShadow,it.setValue(F,"receiveShadow",X.receiveShadow)),(G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial)&&G.envMap===null&&U.environment!==null&&(Nt.envMapIntensity.value=U.environmentIntensity),Nt.dfgLUT!==void 0&&(Nt.dfgLUT.value=B0()),ii){if(it.setValue(F,"toneMappingExposure",R.toneMappingExposure),Re.needsLights&&Qu(Nt,Mi),be&&G.fog===!0&&he.refreshFogUniforms(Nt,be),he.refreshMaterialUniforms(Nt,G,fe,we,M.state.transmissionRenderTarget[b.id]),Re.needsLights&&Re.numLightProbeGrids>0){let yt=S,Rt=0;for(let zn of M.state.lightProbeGridArray)zn.texture!==null&&(yt.textures[Rt]=zn.texture,yt.min[Rt]=zn.boundingBox.min,yt.max[Rt]=zn.boundingBox.max,yt.resolution[Rt]=zn.resolution,Rt++);for(let zn in yt)yt[zn].length=Rt;Nt.probesSH.value=yt.textures,Nt.probesMin.value=yt.min,Nt.probesMax.value=yt.max,Nt.probesResolution.value=yt.resolution}gs.upload(F,gc(Re),Nt,Be)}if(G.isShaderMaterial&&G.uniformsNeedUpdate===!0&&(gs.upload(F,gc(Re),Nt,Be),G.uniformsNeedUpdate=!1),G.isSpriteMaterial&&it.setValue(F,"center",X.center),it.setValue(F,"modelViewMatrix",X.modelViewMatrix),it.setValue(F,"normalMatrix",X.normalMatrix),it.setValue(F,"modelMatrix",X.matrixWorld),G.uniformsGroups!==void 0){let yt=G.uniformsGroups;for(let Rt=0,zn=yt.length;Rt<zn;Rt++){let yc=yt[Rt];oe.update(yc,Bt),oe.bind(yc,Bt)}}return Bt}function Qu(b,U){b.ambientLightColor.needsUpdate=U,b.lightProbe.needsUpdate=U,b.sunLights.needsUpdate=U,b.sunLightShadows.needsUpdate=U,b.directionalLights.needsUpdate=U,b.directionalLightShadows.needsUpdate=U,b.pointLights.needsUpdate=U,b.pointLightShadows.needsUpdate=U,b.spotLights.needsUpdate=U,b.spotLightShadows.needsUpdate=U,b.rectAreaLights.needsUpdate=U,b.hemisphereLights.needsUpdate=U}function ed(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return Z},this.getActiveMipmapLevel=function(){return z},this.getRenderTarget=function(){return ee},this.setRenderTargetTextures=function(b,U,Y){let G=De.get(b);G.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,G.__autoAllocateDepthBuffer===!1&&(G.__useRenderToTexture=!1),De.get(b.texture).__webglTexture=U,De.get(b.depthTexture).__webglTexture=G.__autoAllocateDepthBuffer?void 0:Y,G.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,U){let Y=De.get(b);Y.__webglFramebuffer=U,Y.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(b,U=0,Y=0){ee=b,Z=U,z=Y;let G=null,X=!1,be=!1;if(b){let ve=De.get(b);if(ve.__useDefaultFramebuffer!==void 0){_e.bindFramebuffer(F.FRAMEBUFFER,ve.__webglFramebuffer),O.copy(b.viewport),ae.copy(b.scissor),xe=b.scissorTest,_e.viewport(O),_e.scissor(ae),_e.setScissorTest(xe),q=-1;return}else if(ve.__webglFramebuffer===void 0)Be.setupRenderTarget(b);else if(ve.__hasExternalTextures)Be.rebindTextures(b,De.get(b.texture).__webglTexture,De.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let qe=b.depthTexture;if(ve.__boundDepthTexture!==qe){if(qe!==null&&De.has(qe)&&(b.width!==qe.image.width||b.height!==qe.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Be.setupDepthRenderbuffer(b)}}let Se=b.texture;(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)&&(be=!0);let Pe=De.get(b).__webglFramebuffer;b.isWebGLCubeRenderTarget?(Array.isArray(Pe[U])?G=Pe[U][Y]:G=Pe[U],X=!0):b.samples>0&&Be.useMultisampledRTT(b)===!1?G=De.get(b).__webglMultisampledFramebuffer:Array.isArray(Pe)?G=Pe[Y]:G=Pe,O.copy(b.viewport),ae.copy(b.scissor),xe=b.scissorTest}else O.copy(me).multiplyScalar(fe).floor(),ae.copy(Ie).multiplyScalar(fe).floor(),xe=Ne;if(Y!==0&&(G=B),_e.bindFramebuffer(F.FRAMEBUFFER,G)&&_e.drawBuffers(b,G),_e.viewport(O),_e.scissor(ae),_e.setScissorTest(xe),X){let ve=De.get(b.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+U,ve.__webglTexture,Y)}else if(be){let ve=U;for(let Se=0;Se<b.textures.length;Se++){let Pe=De.get(b.textures[Se]);F.framebufferTextureLayer(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0+Se,Pe.__webglTexture,Y,ve)}}else if(b!==null&&Y!==0){let ve=De.get(b.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,ve.__webglTexture,Y)}q=-1};function xc(b){let U=De.get(b);return(U.__readFormat!==b.format||U.__readType!==b.type)&&(U.__readFormat=b.format,U.__readType=b.type,U.__formatReadable=rt.textureFormatReadable(b.format),U.__typeReadable=rt.textureTypeReadable(b.type)),U}this.readRenderTargetPixels=function(b,U,Y,G,X,be,Ee,ve=0){if(!(b&&b.isWebGLRenderTarget)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=De.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Ee!==void 0&&(Se=Se[Ee],Array.isArray(Se)&&(Se=Se[0])),Se){_e.bindFramebuffer(F.FRAMEBUFFER,Se);try{let Pe=b.textures[ve],qe=Pe.format,je=Pe.type;b.textures.length>1&&F.readBuffer(F.COLOR_ATTACHMENT0+ve);let Ae=xc(Pe);if(Ae.__formatReadable===!1){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Ae.__typeReadable===!1){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=b.width-G&&Y>=0&&Y<=b.height-X&&F.readPixels(U,Y,G,X,$.convert(qe),$.convert(je),be)}finally{let Pe=ee!==null?De.get(ee).__webglFramebuffer:null;_e.bindFramebuffer(F.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(b,U,Y,G,X,be,Ee,ve=0){if(!(b&&b.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=De.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Ee!==void 0&&(Se=Se[Ee],Array.isArray(Se)&&(Se=Se[0])),Se)if(U>=0&&U<=b.width-G&&Y>=0&&Y<=b.height-X){_e.bindFramebuffer(F.FRAMEBUFFER,Se);let Pe=b.textures[ve],qe=Pe.format,je=Pe.type;b.textures.length>1&&F.readBuffer(F.COLOR_ATTACHMENT0+ve);let Ae=xc(Pe);if(Ae.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Ae.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Qe=F.createBuffer();F.bindBuffer(F.PIXEL_PACK_BUFFER,Qe),F.bufferData(F.PIXEL_PACK_BUFFER,be.byteLength,F.STREAM_READ),F.readPixels(U,Y,G,X,$.convert(qe),$.convert(je),0),F.bindBuffer(F.PIXEL_PACK_BUFFER,null);let Mt=ee!==null?De.get(ee).__webglFramebuffer:null;_e.bindFramebuffer(F.FRAMEBUFFER,Mt);let dt=F.fenceSync(F.SYNC_GPU_COMMANDS_COMPLETE,0);return F.flush(),await Ch(F,dt,4),F.bindBuffer(F.PIXEL_PACK_BUFFER,Qe),F.getBufferSubData(F.PIXEL_PACK_BUFFER,0,be),F.bindBuffer(F.PIXEL_PACK_BUFFER,null),F.deleteBuffer(Qe),F.deleteSync(dt),be}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,U=null,Y=0){let G=Math.pow(2,-Y),X=Math.floor(b.image.width*G),be=Math.floor(b.image.height*G),Ee=U!==null?U.x:0,ve=U!==null?U.y:0;Be.setTexture2D(b,0),F.copyTexSubImage2D(F.TEXTURE_2D,Y,0,0,Ee,ve,X,be),_e.unbindTexture()},this.copyTextureToTexture=function(b,U,Y=null,G=null,X=0,be=0){let Ee,ve,Se,Pe,qe,je,Ae,Qe,Mt,dt=b.isCompressedTexture?b.mipmaps[be]:b.image;if(Y!==null)Ee=Y.max.x-Y.min.x,ve=Y.max.y-Y.min.y,Se=Y.isBox3?Y.max.z-Y.min.z:1,Pe=Y.min.x,qe=Y.min.y,je=Y.isBox3?Y.min.z:0;else{let it=Math.pow(2,-X);Ee=Math.floor(dt.width*it),ve=Math.floor(dt.height*it),b.isDataArrayTexture?Se=dt.depth:b.isData3DTexture?Se=Math.floor(dt.depth*it):Se=1,Pe=0,qe=0,je=0}G!==null?(Ae=G.x,Qe=G.y,Mt=G.z):(Ae=0,Qe=0,Mt=0);let ut=$.convert(U.format),Ot=$.convert(U.type),Re;U.isData3DTexture?(Be.setTexture3D(U,0),Re=F.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(Be.setTexture2DArray(U,0),Re=F.TEXTURE_2D_ARRAY):(Be.setTexture2D(U,0),Re=F.TEXTURE_2D),_e.activeTexture(F.TEXTURE0),_e.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,U.flipY),_e.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),_e.pixelStorei(F.UNPACK_ALIGNMENT,U.unpackAlignment);let Xt=_e.getParameter(F.UNPACK_ROW_LENGTH),ot=_e.getParameter(F.UNPACK_IMAGE_HEIGHT),bi=_e.getParameter(F.UNPACK_SKIP_PIXELS),Bt=_e.getParameter(F.UNPACK_SKIP_ROWS),mr=_e.getParameter(F.UNPACK_SKIP_IMAGES);_e.pixelStorei(F.UNPACK_ROW_LENGTH,dt.width),_e.pixelStorei(F.UNPACK_IMAGE_HEIGHT,dt.height),_e.pixelStorei(F.UNPACK_SKIP_PIXELS,Pe),_e.pixelStorei(F.UNPACK_SKIP_ROWS,qe),_e.pixelStorei(F.UNPACK_SKIP_IMAGES,je);let ii=b.isDataArrayTexture||b.isData3DTexture,Mi=U.isDataArrayTexture||U.isData3DTexture;if(b.isDepthTexture){let it=De.get(b),Nt=De.get(U),yn=De.get(it.__renderTarget),yt=De.get(Nt.__renderTarget);_e.bindFramebuffer(F.READ_FRAMEBUFFER,yn.__webglFramebuffer),_e.bindFramebuffer(F.DRAW_FRAMEBUFFER,yt.__webglFramebuffer);for(let Rt=0;Rt<Se;Rt++)ii&&(F.framebufferTextureLayer(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,De.get(b).__webglTexture,X,je+Rt),F.framebufferTextureLayer(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,De.get(U).__webglTexture,be,Mt+Rt)),F.blitFramebuffer(Pe,qe,Pe+Ee,qe+ve,Ae,Qe,Ae+Ee,Qe+ve,F.DEPTH_BUFFER_BIT,F.NEAREST);_e.bindFramebuffer(F.READ_FRAMEBUFFER,null),_e.bindFramebuffer(F.DRAW_FRAMEBUFFER,null)}else if(X!==0||b.isRenderTargetTexture||De.has(b)){let it=De.get(b),Nt=De.get(U);_e.bindFramebuffer(F.READ_FRAMEBUFFER,C),_e.bindFramebuffer(F.DRAW_FRAMEBUFFER,W);for(let yn=0;yn<Se;yn++)ii?F.framebufferTextureLayer(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,it.__webglTexture,X,je+yn):F.framebufferTexture2D(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,it.__webglTexture,X),Mi?F.framebufferTextureLayer(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,Nt.__webglTexture,be,Mt+yn):F.framebufferTexture2D(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,Nt.__webglTexture,be),X!==0?F.blitFramebuffer(Pe,qe,Pe+Ee,qe+ve,Ae,Qe,Ae+Ee,Qe+ve,F.COLOR_BUFFER_BIT,F.NEAREST):Mi?F.copyTexSubImage3D(Re,be,Ae,Qe,Mt+yn,Pe,qe,Ee,ve):F.copyTexSubImage2D(Re,be,Ae,Qe,Pe,qe,Ee,ve);_e.bindFramebuffer(F.READ_FRAMEBUFFER,null),_e.bindFramebuffer(F.DRAW_FRAMEBUFFER,null)}else Mi?b.isDataTexture||b.isData3DTexture?F.texSubImage3D(Re,be,Ae,Qe,Mt,Ee,ve,Se,ut,Ot,dt.data):U.isCompressedArrayTexture?F.compressedTexSubImage3D(Re,be,Ae,Qe,Mt,Ee,ve,Se,ut,dt.data):F.texSubImage3D(Re,be,Ae,Qe,Mt,Ee,ve,Se,ut,Ot,dt):b.isDataTexture?F.texSubImage2D(F.TEXTURE_2D,be,Ae,Qe,Ee,ve,ut,Ot,dt.data):b.isCompressedTexture?F.compressedTexSubImage2D(F.TEXTURE_2D,be,Ae,Qe,dt.width,dt.height,ut,dt.data):F.texSubImage2D(F.TEXTURE_2D,be,Ae,Qe,Ee,ve,ut,Ot,dt);_e.pixelStorei(F.UNPACK_ROW_LENGTH,Xt),_e.pixelStorei(F.UNPACK_IMAGE_HEIGHT,ot),_e.pixelStorei(F.UNPACK_SKIP_PIXELS,bi),_e.pixelStorei(F.UNPACK_SKIP_ROWS,Bt),_e.pixelStorei(F.UNPACK_SKIP_IMAGES,mr),be===0&&U.generateMipmaps===!0&&U.mipmapsAutoUpdate===!0&&F.generateMipmap(Re),_e.unbindTexture()},this.initRenderTarget=function(b){De.get(b).__webglFramebuffer===void 0&&Be.setupRenderTarget(b)},this.initTexture=function(b){b.isCubeTexture?Be.setTextureCube(b,0):b.isData3DTexture?Be.setTexture3D(b,0):b.isDataArrayTexture||b.isCompressedArrayTexture?Be.setTexture2DArray(b,0):Be.setTexture2D(b,0),_e.unbindTexture()},this.resetState=function(){Z=0,z=0,ee=null,_e.reset(),ie.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return gn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=et._getDrawingBufferColorSpace(e),t.unpackColorSpace=et._getUnpackColorSpace()}};var mu={type:"change"},jl={type:"start"},_u={type:"end"},_a=new Ri,gu=new an,z0=Math.cos(70*Il.DEG2RAD),At=new k,tn=2*Math.PI,at={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Kl=1e-6,xa=class extends Ys{constructor(e,t=null){super(e,t),this.state=at.NONE,this.target=new k,this.cursor=new k,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:pi.ROTATE,MIDDLE:pi.DOLLY,RIGHT:pi.PAN},this.touches={ONE:mi.ROTATE,TWO:mi.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 k,this._lastQuaternion=new ln,this._lastTargetPosition=new k,this._quat=new ln().setFromUnitVectors(e.up,new k(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new hs,this._sphericalDelta=new hs,this._scale=1,this._panOffset=new k,this._rotateStart=new Ve,this._rotateEnd=new Ve,this._rotateDelta=new Ve,this._panStart=new Ve,this._panEnd=new Ve,this._panDelta=new Ve,this._dollyStart=new Ve,this._dollyEnd=new Ve,this._dollyDelta=new Ve,this._dollyDirection=new k,this._mouse=new Ve,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=V0.bind(this),this._onPointerDown=k0.bind(this),this._onPointerUp=G0.bind(this),this._onContextMenu=$0.bind(this),this._onMouseWheel=X0.bind(this),this._onKeyDown=q0.bind(this),this._onTouchStart=Y0.bind(this),this._onTouchMove=Z0.bind(this),this._onMouseDown=H0.bind(this),this._onMouseMove=W0.bind(this),this._interceptControlDown=J0.bind(this),this._interceptControlUp=K0.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=at.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(mu),this.update(),this.state=at.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;At.copy(t).sub(this.target),At.applyQuaternion(this._quat),this._spherical.setFromVector3(At),this.autoRotate&&this.state===at.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+=tn:n>Math.PI&&(n-=tn),s<-Math.PI?s+=tn:s>Math.PI&&(s-=tn),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 o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(At.setFromSpherical(this._spherical),At.applyQuaternion(this._quatInverse),t.copy(this.target).add(At),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){let a=At.length();o=this._clampDistance(a*this._scale);let c=a-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),r=!!c}else if(this.object.isOrthographicCamera){let a=new k(this._mouse.x,this._mouse.y,0);a.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 k(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(a),this.object.updateMatrixWorld(),o=At.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(_a.origin.copy(this.object.position),_a.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(_a.direction))<z0?this.object.lookAt(this.target):(gu.setFromNormalAndCoplanarPoint(this.object.up,this.target),_a.intersectPlane(gu,this.target))))}else if(this.object.isOrthographicCamera){let o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Kl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Kl||this._lastTargetPosition.distanceToSquared(this.target)>Kl?(this.dispatchEvent(mu),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?tn/60*this.autoRotateSpeed*e:tn/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){At.setFromMatrixColumn(t,0),At.multiplyScalar(-e),this._panOffset.add(At)}_panUp(e,t){this.screenSpacePanning===!0?At.setFromMatrixColumn(t,1):(At.setFromMatrixColumn(t,0),At.crossVectors(this.object.up,At)),At.multiplyScalar(e),this._panOffset.add(At)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let s=this.object.position;At.copy(s).sub(this.target);let r=At.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,o=n.width,a=n.height;this._mouse.x=s/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.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(tn*this._rotateDelta.x/t.clientHeight),this._rotateUp(tn*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(tn*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(-tn*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(tn*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(-tn*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(tn*this._rotateDelta.x/t.clientHeight),this._rotateUp(tn*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 o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Ve,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 k0(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 V0(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function G0(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(_u),this.state=at.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 H0(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 pi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=at.DOLLY;break;case pi.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=at.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=at.ROTATE}break;case pi.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=at.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=at.PAN}break;default:this.state=at.NONE}this.state!==at.NONE&&this.dispatchEvent(jl)}function W0(i){switch(this.state){case at.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case at.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case at.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function X0(i){this.enabled===!1||this.enableZoom===!1||this.state!==at.NONE||(i.preventDefault(),this.dispatchEvent(jl),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(_u))}function q0(i){this.enabled!==!1&&this._handleKeyDown(i)}function Y0(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case mi.ROTATE:if(this.enableRotate===!1){this.state=at.NONE;break}this._handleTouchStartRotate(i),this.state=at.TOUCH_ROTATE;break;case mi.PAN:if(this.enablePan===!1){this.state=at.NONE;break}this._handleTouchStartPan(i),this.state=at.TOUCH_PAN;break;default:this.state=at.NONE}break;case 2:switch(this.touches.TWO){case mi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=at.TOUCH_DOLLY_PAN;break;case mi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=at.TOUCH_DOLLY_ROTATE;break;default:this.state=at.NONE}break;default:this.state=at.NONE}this.state!==at.NONE&&this.dispatchEvent(jl)}function Z0(i){switch(this._trackPointer(i),this.state){case at.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case at.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case at.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case at.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=at.NONE}}function $0(i){this.enabled!==!1&&i.preventDefault()}function J0(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.ownerDocument.addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function K0(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.ownerDocument.removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}var wt={drawn:.4,svgIn:.5,rise:.55,svgOut:.62,tilted:.78,wallsUp:.84,done:.96};var xu=i=>i<0?0:i>1?1:i,ei=i=>{let e=xu(i);return e*e*(3-2*e)};function ar(i,e){let t=xu(e),n=t<wt.drawn?0:t<wt.svgIn?ei((t-wt.drawn)/(wt.svgIn-wt.drawn)):t<wt.rise?1:1-ei((t-wt.rise)/(wt.svgOut-wt.rise)),s=new Map;for(let h of i){let u=!h.hidden&&t>=h.appear,d=h.riseTo<=h.riseFrom?t>=h.riseFrom?1:0:ei((t-h.riseFrom)/(h.riseTo-h.riseFrom));s.set(h.key,{visible:u,rise:d})}let r=[],o=[];for(let h of i)h.storey===void 0||h.hidden||(r[h.storey]=Math.max(r[h.storey]??0,h.riseTo),o[h.storey]=Math.min(o[h.storey]??1,h.appear));let a=r[0]??1,c=0;for(let h=1;h<r.length;h++){let u=r[h-1],d=o[h];t>u&&(c=h-1+(d>u?ei((t-u)/(d-u)):1))}let l=0;if(r.length>1){let h=j0(r);l=h<1?ei((t-h)/(1-h)):t>=1?1:0,l>0&&(c=r.length-1+l)}return{tilt:ei((t-wt.rise)/(Math.min(wt.tilted,a)-wt.rise)),dolly:ei((t-wt.rise)/(a-wt.rise)),stop:c,settle:l,svg:n,ground:t>=wt.rise?1-n:0,nodes:s}}var j0=i=>Math.max(wt.done,...i);var yu=.88,xi=i=>i*Math.PI/180;function ec(i){let e=xi(i.elevation),t=xi(i.azimuth);return[Math.cos(e)*Math.sin(t),Math.sin(e),Math.cos(e)*Math.cos(t)]}function tc(i,e,t){let n=ec(t);return[i[0]+e*n[0],i[1]+e*n[1],i[2]+e*n[2]]}function Mu(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 Su(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 Q0(i,e,t){let n=ec(t),{right:s,up:r}=Mu(n),o=Math.tan(xi(t.fov)/2),a=1/0,c=-1/0,l=1/0,h=-1/0;for(let u of Su(i)){let d=[u[0]-e.target[0],u[1]-e.target[1],u[2]-e.target[2]],f=e.dist-(d[0]*n[0]+d[1]*n[1]+d[2]*n[2]),_=(d[0]*s[0]+d[2]*s[2])/(f*o*t.aspect),x=(d[0]*r[0]+d[1]*r[1]+d[2]*r[2])/(f*o);a=Math.min(a,_),c=Math.max(c,_),l=Math.min(l,x),h=Math.max(h,x)}return{x:[a,c],y:[l,h]}}function Ql(i,e){let t=ec(e),{right:n,up:s}=Mu(t),r=Math.tan(xi(e.fov)/2),o=[(i.lo[0]+i.hi[0])/2,(i.lo[1]+i.hi[1])/2,(i.lo[2]+i.hi[2])/2],a=1e3;for(let c=0;c<4;c++){a=0;for(let d of Su(i)){let f=[d[0]-o[0],d[1]-o[1],d[2]-o[2]],_=f[0]*t[0]+f[1]*t[1]+f[2]*t[2],x=Math.abs(f[0]*n[0]+f[2]*n[2]),m=Math.abs(f[0]*s[0]+f[1]*s[1]+f[2]*s[2]);a=Math.max(a,_+x/(yu*r*e.aspect),_+m/(yu*r))}if(c===3)break;let l=Q0(i,{target:o,dist:a},e),h=(l.x[0]+l.x[1])/2*a*r*e.aspect,u=(l.y[0]+l.y[1])/2*a*r;o=[o[0]+h*n[0]+u*s[0],o[1]+h*n[1]+u*s[1],o[2]+h*n[2]+u*s[2]]}return{target:o,dist:a}}var Un=30,nc=-32;function lr(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 o=e.settle===void 0?r.lift??0:va(r.lift,e.settle);for(let a=0;a<r.positions.length;a+=3){let c=[r.positions[a]/1e3,r.positions[a+1]/1e3+o,r.positions[a+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 va=(i,e)=>(i??0)*(1-e),ba=i=>Math.max(1,...i.map(e=>(e.storey??0)+1)),ya=1.5;function wu(i,e,t){let n=new Map(e.map(o=>[o.key,o.storey??0])),s=ba(e),r=[];for(let o=0;o<s;o++)r.push(Ql(lr(i.filter(a=>(n.get(a.key)??0)<=o)),t));return s>1&&r.push(Ql(lr(i,{settle:1}),t)),r}function e_(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(o=>n.target[o]*(1-r)+s.target[o]*r),dist:n.dist*(1-r)+s.dist*r}}function Ma(i,e,t){let n=h=>h*Math.PI/180,s=e_(e,i.stop),r=2*s.dist*Math.tan(n(Un)/2),o=ya+(Un-ya)*i.dolly,c=(t.oh+(r-t.oh)*i.dolly)/(2*Math.tan(n(o)/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:o,elevation:90-(90-t.elevation)*i.tilt,azimuth:nc*i.tilt}}function ic(i,e){let[t,n,s,r]=i,o=Math.max(s,r*e);return{cx:t+s/2,cz:n+r/2,ow:o,oh:o/e}}var vu={north:180,east:90,south:0,west:-90},cr={min:0,max:90};function Eu(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 Tu(i,e){if(i==="iso")return Ma(ar(e.events,1),e.fits,e.frame);let t=i==="top"?{elevation:cr.max,azimuth:vu.south}:{elevation:cr.min,azimuth:vu[i]},n=Ql(e.box,{...t,fov:Un,aspect:e.aspect});return{target:n.target,dist:n.dist,fov:Un,...t}}function Au(i){return i.fov===Un?i:{...i,fov:Un,dist:i.dist*Math.tan(xi(i.fov)/2)/Math.tan(xi(Un)/2)}}var bu={in:8,out:3};function Ru(i,e){let t=i[i.length-1].dist,n=Math.tan(xi(Un)/2)/Math.tan(xi(e)/2);return{min:t*n/bu.in,max:t*n*bu.out}}function Cu(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}),Kt={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)},t_="wood",n_="wood_dark",sc=Ke("#c2a27e",.7),Pu=Ke("#55534f",.5),Fn={slab:Ke("#bdb6ab",.9),column:Ke("#e6e1d8",.85),wall:Ke("#f2f0eb",.9),door:sc,"window:frame":Pu,"window:glass":Ke("#bcd6e0",.05,0,.4),"window:reveal":Pu,"window:sill":Kt.stone,"window:board":Kt.wood,"opening:lining":sc,"opening:casing":sc,opening:Ke("#e6e1d8",.85),furniture:Ke("#d6cec1",.9),roof:Ke("#9c958a",.9),"wall:demolish":Ke("#c8553d",.9,0,.3),stair:Kt[t_],"stair:rail":Kt[n_]},lb={"door:lining":{material:"door",srgb:Fn.door.srgb},"door:casing":{material:"door",srgb:Fn.door.srgb},"opening:lining":{material:"opening:lining",srgb:Fn["opening:lining"].srgb},"opening:casing":{material:"opening:casing",srgb:Fn["opening:casing"].srgb},"window:reveal":{material:"window:reveal",srgb:Fn["window:reveal"].srgb},"window:sill":{material:"window:sill",srgb:Fn["window:sill"].srgb},"window:board":{material:"window:board",srgb:Fn["window:board"].srgb}},Iu="#8f877d";var i_={timber:Ke("#cdb596",.6),tile:Ke("#e3e1db",.35),neutral:Ke("#e8e2d7",.9),carpeting:Kt.wool,stone:Kt.stone,deck:Kt.wood,paving:Ke("#ab9f87",.85),concrete:Ke("#c9c5be",.6)};var rc={gravel:Ke("#cbc3b4",.95),tarmac:Ke("#8c8984",.85),sand:Ke("#dcc9a3",.95)},cb={planting:Kt.foliage,deck:Kt.wood,gravel:rc.gravel,driveway:rc.tarmac,sand:rc.sand,soil:Kt.soil};var hb={picket:Ke("#eeebe4",.8),panel:Kt.wood,post:Kt.wood_dark},Sa={light:"#e2ddd3",dark:"#16293d",marginMm:6e3},xs={wall:{of:.75,minMm:80,maxMm:200},furniture:{of:.12,minMm:30,maxMm:120},fence:{of:1.5,minMm:40,maxMm:120},stairThicknessMm:100,alpha:{floor:.2,corner:.12,furniture:.18},alphaDark:{floor:.3,corner:.18,furniture:.27},liftMm:1};function Lu(i,e,t){if(e==="light")return i;let n=s=>{let r=Number.parseInt(i.slice(s,s+2),16),o=Number.parseInt(t.slice(s,s+2),16);return Math.round(r*.4+o*.6).toString(16).padStart(2,"0")};return`#${n(1)}${n(3)}${n(5)}`}function Du(i,e,t){let n=Kt[i].srgb;if(e==="light")return n;let s=r=>{let o=Number.parseInt(n.slice(r,r+2),16),a=Number.parseInt(t.slice(r,r+2),16);return Math.round(o*.4+a*.6).toString(16).padStart(2,"0")};return`#${s(1)}${s(3)}${s(5)}`}function Nu(i,e,t){let n=i_[i].srgb;if(e==="light")return n;let s=r=>{let o=Number.parseInt(n.slice(r,r+2),16),a=Number.parseInt(t.slice(r,r+2),16);return Math.round(o*.4+a*.6).toString(16).padStart(2,"0")};return`#${s(1)}${s(3)}${s(5)}`}var wa=[1,.9238795325112867,Math.SQRT1_2,.3826834323650898,0,-.3826834323650898,-Math.SQRT1_2,-.9238795325112867,-1,-.9238795325112867,-Math.SQRT1_2,-.3826834323650898,0,.3826834323650898,Math.SQRT1_2,.9238795325112867],Uu=wa.map((i,e)=>wa[(e+12)%16]);function Ta(i){return i.kind==="wall"&&i.part===void 0||i.kind==="column"}var yi=2**26;function Fi(i,e,t,n){if(Math.abs(i)<yi&&Math.abs(e)<yi&&Math.abs(t)<yi&&Math.abs(n)<yi)return i*n-e*t;let s=BigInt(i)*BigInt(n)-BigInt(e)*BigInt(t);return s>0n?1:s<0n?-1:0}function s_(i,e,t,n){return Math.abs(i)<yi&&Math.abs(e)<yi&&Math.abs(t)<yi&&Math.abs(n)<yi?String(i*n-e*t):(BigInt(i)*BigInt(n)-BigInt(e)*BigInt(t)).toString()}function r_(i,e){let t=Math.abs(i),n=Math.abs(e);for(;n!==0;)[t,n]=[n,t%n];return t}function ac(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]),o=t*n>0?s:-s;return o>0n&&o*o>3n*r*r}function ys(i,e,t,n){let s=t-i,r=n-e,o=r_(s,r);return s/=o,r/=o,(s<0||s===0&&r<0)&&(s=0-s,r=0-r),{dx:s,dz:r,key:`${s},${r},${s_(s,r,i,e)}`}}var oc=(i,e)=>{for(let t=0;t<i.length;t++){let n=i[t]-e[t];if(n!==0)return n}return 0},hr=i=>[...i.keys()].sort((e,t)=>e<t?-1:e>t?1:0),ur=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 Fu(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 Ou(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 Bu(i){let e=new Map;return i.forEach((t,n)=>{if(!Ta(t))return;let s=/^L(-?\d+)\//.exec(t.key)?.[1]??"",r=e.get(s);r?r.push(n):e.set(s,[n])}),hr(e).map(t=>e.get(t)??[])}function zu(i,e){let t=l_(i),n=i.map((s,r)=>Ta(s)?{...s,...c_(s,t[r])}:s);return{faces:t,lines:o_(n,e)}}function o_(i,e){let t=i.map(s=>Ta(s)?[]:void 0),n=i.map(()=>[]);for(let s of Bu(i))a_(i,s,n,e);return n.forEach((s,r)=>{if(!t[r])return;let o=s.map(a=>oc(a.slice(0,3),a.slice(3))<=0?a:[a[3],a[4],a[5],a[0],a[1],a[2]]).sort(oc);t[r]=o.flat()}),t}function Ea(i,e){let t=i.map((o,a)=>[o,a]).sort((o,a)=>o[0].t0-a[0].t0||o[1]-a[1]),n=ur(i.flatMap(o=>[o.t0,o.t1])),s=0,r=[];for(let o=0;o+1<n.length;o++){let a=n[o],c=n[o+1];for(r.some(l=>l.t1<=a)&&(r=r.filter(l=>l.t1>a));s<t.length&&t[s]?.[0].t0<=a;)r.push(t[s++]?.[0]);r.length>0&&e(a,c,r)}}function a_(i,e,t,n){let s=new Map,r=new Map,o=new Map,a=new Map,c=(_,x,m)=>{let p=`${_}|${x}`,w=s.get(p);w?w.edges.push(m):s.set(p,{line:x,plane:_,edges:[m]})},l=(_,x,m,p)=>{let w=oc(x,m)<0,[T,S]=w?[x,m]:[m,x],E=`${_}|${T[0]},${T[1]},${T[2]}|${S[0]},${S[1]},${S[2]}`,M=a.get(E);M?(M.net+=w?1:-1,M.nodes.push(p)):a.set(E,{a:T,b:S,net:w?1:-1,nodes:[p]})},h=(_,x,m,p)=>{let w=`h${_}:${x.key}`,T=r.get(w);if(T||(T={kind:"horizontal",y:_,alongX:x.dx!==0,other:new Map},r.set(w,T)),T.kind==="horizontal")for(let S of[m,p]){let[E,,M]=S;T.alongX?T.other.set(E,M):T.other.set(M,E)}return w},u=(_,x)=>_.dx!==0?x[0]:x[2],d=(_,x,m,p)=>_<x?{t0:_,t1:x,k:1,node:m,f:p}:{t0:x,t1:_,k:-1,node:m,f:p};for(let _ of e){let x=i[_],m=p=>[Math.round(x.positions[p*3]),Math.round(x.positions[p*3+1]),Math.round(x.positions[p*3+2])];for(let p=0;p+2<x.indices.length;p+=3){let w=[m(x.indices[p]),m(x.indices[p+1]),m(x.indices[p+2])],[T,S,E]=w,M=T[0],g=T[1],v=T[2],L=[[T,S],[S,E],[E,T]];if(g===S[1]&&g===E[1]){if(Fi(S[0]-M,S[2]-v,E[0]-M,E[2]-v)===0)continue;let z=`H${g}`;for(let[ee,q]of L){if(ee[0]===q[0]&&ee[2]===q[2])continue;let J=ys(ee[0],ee[2],q[0],q[2]);c(z,h(g,J,ee,q),d(u(J,ee),u(J,q),_,0))}continue}if(!(Fi(S[0]-M,S[2]-v,E[0]-M,E[2]-v)===0)){for(let[z,ee]of L)t[_].push([...z,...ee]);continue}let D=T[0]!==S[0]||T[2]!==S[2]?S:E;if(D[0]===M&&D[2]===v)continue;let N=ys(M,v,D[0],D[2]),B=`V${N.key}`;o.has(B)||o.set(B,[N.dx,N.dz]);let C=z=>u(N,z),W=Fi(C(S)-C(T),S[1]-g,C(E)-C(T),E[1]-g);if(W===0)continue;let Z=W>0?1:-1;for(let[z,ee]of L)if(z[0]===ee[0]&&z[2]===ee[2]){if(z[1]===ee[1])continue;let q=`v${z[0]},${z[2]}`;r.has(q)||r.set(q,{kind:"vertical",x:z[0],z:z[2]}),c(B,q,d(z[1],ee[1],_,Z))}else z[1]===ee[1]?c(B,h(z[1],N,z,ee),d(u(N,z),u(N,ee),_,Z)):l(B,z,ee,_)}}let f=new Map;for(let _ of hr(s)){let{line:x,plane:m,edges:p}=s.get(_),[w,T]=p;p.length===2&&T&&w.t0===T.t0&&w.t1===T.t1&&w.k!==T.k||Ea(p,(S,E,M)=>{let g=0;for(let B of M)g+=B.k;if(g===0)return;let v=new Map;for(let B of M)v.set(B.node,(v.get(B.node)??0)+B.k);let L=ur(M.filter(B=>v.get(B.node)!==0).map(B=>B.node)),R=ur(M.filter(B=>B.k===Math.sign(g)).map(B=>B.f)),D={t0:S,t1:E,nodes:L,plane:m,f:R.length===1?R[0]:0},N=f.get(x);N?N.push(D):f.set(x,[D])})}for(let _ of hr(f)){let x=f.get(_),m=r.get(_),p=[];Ea(x,(w,T,S)=>{if(m.kind==="vertical"&&S.length===2){let[g,v]=S,L=o.get(g.plane),R=o.get(v.plane);if(L&&R&&g.f!==0&&v.f!==0&&ac(L,R,g.f,v.f))return}let E=Ou(S.flatMap(g=>g.nodes),n),M=p[p.length-1];M&&M.t1===w&&M.node===E?M.t1=T:p.push({t0:w,t1:T,node:E})});for(let w of p){let T=S=>{if(m.kind==="vertical")return[m.x,S,m.z];let E=m.other.get(S);return m.alongX?[S,m.y,E]:[E,m.y,S]};t[w.node].push([...T(w.t0),...T(w.t1)])}}for(let _ of hr(a)){let{a:x,b:m,net:p,nodes:w}=a.get(_);p!==0&&t[Ou(w,n)].push([...x,...m])}}function ku(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 l_(i){let e=i.map(o=>Ta(o)?{hide:[],add:[],alone:[],joined:[],group:-1}:void 0),t=i.map((o,a)=>a),n=o=>{let a=o;for(;t[a]!==a;)a=t[a];for(;t[o]!==a;)[o,t[o]]=[t[o],a];return a},s=(o,a)=>{let c=n(o),l=n(a);c<l?t[l]=c:l<c&&(t[c]=l)},r=new Set;for(let o of Bu(i))u_(i,o,e,s,r);return e.forEach((o,a)=>{o&&(o.hide.sort((c,l)=>c-l),r.has(a)&&(o.group=n(a)))}),e}function lc(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 o=r(e.alone),a=r(e.joined);return{positions:i.positions.concat(e.add,e.alone,e.joined),base:n,alone:o,joined:a}}function c_(i,e,t="joined"){if(!e)return{positions:i.positions,indices:i.indices};let n=lc(i,e);return{positions:n.positions,indices:n.base.concat(t==="joined"?n.joined:n.alone)}}function h_(i){let e=i.map(s=>{let[r,o]=Fu(s.s),[a,c]=Fu(s.p.map(l=>l[1]));return{s0:r,s1:o,y0:a,y1:c,f:s.f}});e.sort((s,r)=>s.s0-r.s0);let t=[],n=[];for(let s of e){if(t.some(o=>o.s1<=s.s0)&&(t=t.filter(o=>o.s1>s.s0)),n.some(o=>o.s1<=s.s0)&&(n=n.filter(o=>o.s1>s.s0)),(s.f>0?n:t).some(o=>Math.min(o.y1,s.y1)>Math.max(o.y0,s.y0)))return!0;(s.f>0?t:n).push(s)}return!1}function u_(i,e,t,n,s){let r=new Map;for(let o of e){let a=i[o],c=l=>[Math.round(a.positions[l*3]),Math.round(a.positions[l*3+1]),Math.round(a.positions[l*3+2])];for(let l=0;l+2<a.indices.length;l+=3){let h=c(a.indices[l]),u=c(a.indices[l+1]),d=c(a.indices[l+2]),f=h[0],_=h[1],x=h[2];if(_===u[1]&&_===d[1]||Fi(u[0]-f,u[2]-x,d[0]-f,d[2]-x)!==0)continue;let m=h[0]!==u[0]||h[2]!==u[2]?u:d;if(m[0]===f&&m[2]===x)continue;let p=ys(f,x,m[0],m[2]),w=v=>p.dx!==0?v[0]:v[2],T=[w(h),w(u),w(d)],S=Fi(T[1]-T[0],u[1]-_,T[2]-T[0],d[1]-_);if(S===0)continue;let E=`V${p.key}`,M={node:o,tri:l/3,p:[h,u,d],f:S>0?1:-1,s:T},g=r.get(E);g?g.tris.push(M):r.set(E,{pl:p,tris:[M]})}}for(let o of hr(r)){let{tris:a}=r.get(o);if(!h_(a))continue;let c=ur(a.flatMap(S=>S.s)),l=ur(a.flatMap(S=>S.p.map(E=>E[1]))),h=new Map;for(let S of a)for(let E=0;E<3;E++)h.set(S.s[E],S.p[E]);let u=new Map(c.map((S,E)=>[S,E])),d=new Map(l.map((S,E)=>[S,E])),f=l.length-1,_=c.map(()=>[]);for(let S of a)for(let E=0;E<3;E++){let M=S.p[E],g=S.p[(E+1)%3];if(M[0]!==g[0]||M[2]!==g[2]||M[1]===g[1])continue;let v=u.get(S.s[E]),L=Math.min(M[1],g[1]),R=Math.max(M[1],g[1]);_[v].push([S.node,d.get(L),d.get(R),g[1]>M[1]?1:-1])}let x=new Map,m=new Map,p=[],w=new Int32Array(f),T=(S,E,M,g,v)=>{let L=l[g],R=l[g+1],D=(Z,z)=>{let ee=h.get(Z);return[ee[0],z,ee[2]]},[N,B,C,W]=[D(E,L),D(M,L),D(M,R),D(E,R)];v>0?S.push(...N,...B,...C,...N,...C,...W):S.push(...N,...C,...B,...N,...W,...C)};for(let S=0;S+1<c.length;S++){let E=_[S];for(let[v,L,R,D]of E){let N=x.get(v);N||(N=new Int32Array(f),x.set(v,N));let B=m.get(v)??0;for(let C=L;C<R;C++){let W=N[C],Z=W-D;N[C]=Z,w[C]=w[C]-D,W===0?B++:Z===0&&B--}m.set(v,B)}if(E.length>0){for(let v of[...x.keys()])m.get(v)===0&&(x.delete(v),m.delete(v));p=[...x.keys()].sort((v,L)=>v-L)}let M=c[S],g=c[S+1];for(let v=0;v<f;v++){let L=p.filter(N=>x.get(N)[v]!==0);if(L.length===0)continue;if(L.length===1){let N=L[0];T(t[N].add,M,g,v,x.get(N)[v]);continue}for(let N of L)T(t[N].alone,M,g,v,x.get(N)[v]),s.add(N),n(N,L[0]);let R=w[v];if(R===0)continue;let D=L.find(N=>Math.sign(x.get(N)[v])===Math.sign(R));T(t[D].joined,M,g,v,R)}}for(let S of a)t[S.node].hide.push(S.tri)}}var Wt=(i,e,t,n)=>Fi(i,e,t,n),Vu=i=>Number(/^L(-?\d+)\//.exec(i)?.[1]??0),Ht=i=>Math.round(i)+0,Wu=(i,e)=>Math.sqrt(Number(BigInt(i)*BigInt(i)+BigInt(e)*BigInt(e)));function Xu(i,e){if(!i||i.hidden)return 0;let t=i.riseTo-i.riseFrom;if(t<=0)return e>=i.riseTo?1:0;let n=t/4;return ei((e-(i.riseTo-n))/n)}function Gu(i,e){let t=Wt(i.b[0]-i.a[0],i.b[1]-i.a[1],e[0]-i.a[0],e[1]-i.a[1]),n=Wt(i.c[0]-i.b[0],i.c[1]-i.b[1],e[0]-i.b[0],e[1]-i.b[1]),s=Wt(i.a[0]-i.c[0],i.a[1]-i.c[1],e[0]-i.c[0],e[1]-i.c[1]);return t>=0&&n>=0&&s>=0||t<=0&&n<=0&&s<=0}var d_=2,Hu=65536;function f_(i,e,t,n,s){return Math.max(i.a[0],i.b[0],i.c[0])>=e&&Math.min(i.a[0],i.b[0],i.c[0])<=n&&Math.max(i.a[1],i.b[1],i.c[1])>=t&&Math.min(i.a[1],i.b[1],i.c[1])<=s&&!cc(i.a,i.b,i.c,e,t,n,s)&&!cc(i.b,i.c,i.a,e,t,n,s)&&!cc(i.c,i.a,i.b,e,t,n,s)}function cc(i,e,t,n,s,r,o){let a=e[0]-i[0],c=e[1]-i[1],l=Math.sign(Wt(a,c,t[0]-i[0],t[1]-i[1]));return l===0?!1:l*Wt(a,c,n-i[0],s-i[1])<0&&l*Wt(a,c,r-i[0],s-i[1])<0&&l*Wt(a,c,r-i[0],o-i[1])<0&&l*Wt(a,c,n-i[0],o-i[1])<0}var fc=class{constructor(e){pn(this,"x0");pn(this,"z0");pn(this,"w");pn(this,"h");pn(this,"kx");pn(this,"kz");pn(this,"cells");let[t,n,s,r]=[1/0,1/0,-1/0,-1/0];for(let h of e)for(let u of[h.a,h.b,h.c])u[0]<t&&(t=u[0]),u[0]>s&&(s=u[0]),u[1]<n&&(n=u[1]),u[1]>r&&(r=u[1]);if(this.x0=t,this.z0=n,e.length===0){[this.kx,this.kz,this.w,this.h]=[0,0,1,1],this.cells=[];return}let o=s-t+1,a=r-n+1,c=Math.min(Hu,d_*e.length),l=Math.sqrt(o*a/c);this.kx=Math.max(1,Math.min(c,Math.ceil(o/l))),this.kz=Math.max(1,Math.min(Math.floor(Hu/this.kx),Math.ceil(a/l))),this.w=Math.max(1,Math.ceil(o/this.kx)),this.h=Math.max(1,Math.ceil(a/this.kz)),this.cells=new Array(this.kx*this.kz);for(let h of e){let u=this.col(Math.min(h.a[0],h.b[0],h.c[0])),d=this.col(Math.max(h.a[0],h.b[0],h.c[0])),f=this.row(Math.min(h.a[1],h.b[1],h.c[1])),_=this.row(Math.max(h.a[1],h.b[1],h.c[1]));for(let x=f;x<=_;x++){let m=this.z0+x*this.h,p=m+this.h,[w,T]=p_(h,m,p),S=this.col(w),E=this.col(T),M=Math.min(d,E+1);for(let g=Math.max(u,S-1);g<=M;g++){let v=this.x0+g*this.w;if(!(g>S&&g<E||f_(h,v,m,v+this.w,p)))continue;let L=x*this.kx+g,R=this.cells[L];R?R.push(h):this.cells[L]=[h]}}}}col(e){return Math.floor((e-this.x0)/this.w)}row(e){return Math.floor((e-this.z0)/this.h)}at(e){if(this.kx===0)return[];let t=this.col(e[0]),n=this.row(e[1]);return t<0||n<0||t>=this.kx||n>=this.kz?[]:this.cells[n*this.kx+t]??[]}near(e,t,n,s){if(this.kx===0)return[];let r=c=>Math.max(0,Math.min(this.kx-1,c)),o=c=>Math.max(0,Math.min(this.kz-1,c)),a=new Set;for(let c=o(this.row(t));c<=o(this.row(s));c++)for(let l=r(this.col(e));l<=r(this.col(n));l++)for(let h of this.cells[c*this.kx+l]??[])a.add(h);return[...a]}};function p_(i,e,t){let n=1/0,s=-1/0,r=a=>{a<n&&(n=a),a>s&&(s=a)},o=[i.a,i.b,i.c];for(let a of o)a[1]>=e&&a[1]<=t&&r(a[0]);for(let a=0;a<3;a++){let c=o[a],l=o[(a+1)%3];if(c[1]!==l[1])for(let h of[e,t])(c[1]-h)*(l[1]-h)<0&&r(c[0]+(l[0]-c[0])*(h-c[1])/(l[1]-c[1]))}return n>s?[Math.min(i.a[0],i.b[0],i.c[0]),Math.max(i.a[0],i.b[0],i.c[0])]:[n,s]}function m_(i,e,t,n){let s=i.positions;for(let r=0;r<i.indices.length;r+=3){let[o,a,c]=[i.indices[r],i.indices[r+1],i.indices[r+2]],l=s[o*3+1];if(s[a*3+1]!==l||s[c*3+1]!==l||t!==void 0&&l!==t)continue;let h=[s[o*3],s[o*3+2]],u=[s[a*3],s[a*3+2]],d=[s[c*3],s[c*3+2]],f=Wt(u[0]-h[0],u[1]-h[1],d[0]-h[0],d[1]-h[1]);(e?f<0:f>0)&&n.push({a:h,b:u,c:d,y:l})}}function g_(i,e){let t=new Map;for(let o of i){let a=ys(o.a[0],o.a[1],o.b[0],o.b[1]),c=`${a.dx},${a.dz}`,l=t.get(c);l?l.push(o):t.set(c,[o])}let n=new Map,s=(o,a)=>{let c=o.b[0]-o.a[0],l=o.b[1]-o.a[1],h=c*c+l*l,u=((a.a[0]-o.a[0])*c+(a.a[1]-o.a[1])*l)/h,d=((a.b[0]-o.a[0])*c+(a.b[1]-o.a[1])*l)/h,f=Math.max(0,Math.min(u,d)),_=Math.min(1,Math.max(u,d));return _>f?[f,_]:void 0},r=(o,a,c)=>{if(c>=e(o))return;let l=s(o,a);if(!l)return;let h=n.get(o);h?h.push({t0:l[0],t1:l[1],w:c}):n.set(o,[{t0:l[0],t1:l[1],w:c}])};for(let o of[...t.keys()].sort()){let a=t.get(o);if(a.length<2)continue;let[c,l]=o.split(",").map(Number),h=Wu(c,l),u=0;for(let x of a)u=Math.max(u,e(x));let d=2e3*u,f=a.map(x=>{let[m,p]=[(c*x.a[0]+l*x.a[1])/h,(c*x.b[0]+l*x.b[1])/h];return{s:x,off:(c*x.a[1]-l*x.a[0])/h,lo:Math.min(m,p),hi:Math.max(m,p)}}).sort((x,m)=>x.lo-m.lo||x.off-m.off),_=[];for(let x of f){_=_.filter(m=>m.hi>x.lo);for(let m of _){if(Math.abs(m.off-x.off)>d)continue;let[p,w]=[x.s,m.s],T=un(p),S=un(w);if(T.d[0]*S.d[0]+T.d[1]*S.d[1]>=0)continue;let E=w.a[0]-p.a[0],M=w.a[1]-p.a[1];if(Wt(T.d[0],T.d[1],E,M)>=0)continue;let g=BigInt(T.d[0])*BigInt(M)-BigInt(T.d[1])*BigInt(E),v=Math.max(0,-Number(g)/T.len/2e3);r(p,w,v),r(w,p,v)}_.push(x)}}return i.flatMap(o=>{let a=n.get(o);if(!a)return[o];let c=e(o),l=[...new Set([0,1,...a.flatMap(f=>[f.t0,f.t1])])].sort((f,_)=>f-_),h=un(o),u=f=>f===0?o.a:f===1?o.b:[Ht(o.a[0]+h.d[0]*f),Ht(o.a[1]+h.d[1]*f)],d=[];for(let f=0;f+1<l.length;f++){let[_,x]=[l[f],l[f+1]],m=(_+x)/2,p=c;for(let S of a)S.t0<=m&&m<=S.t1&&S.w<p&&(p=S.w);let w=d[d.length-1],T=w?w.w??c:void 0;w&&T===p?w.b=u(x):d.push({a:u(_),b:u(x),node:o.node,...p<c?{w:p}:{}})}return d.filter(f=>f.a[0]!==f.b[0]||f.a[1]!==f.b[1])})}function hc(i){let e=new Map;for(let{node:n,p:s}of i)for(let r=0;r<3;r++){let o=s[r],a=s[(r+1)%3];if(o[0]===a[0]&&o[1]===a[1])continue;let c=ys(o[0],o[1],a[0],a[1]),l=c.dx!==0,h=l?o[0]:o[1],u=l?a[0]:a[1],d=e.get(c.key);d||(d={edges:[],at:new Map},e.set(c.key,d)),d.at.set(h,o),d.at.set(u,a),d.edges.push(h<u?{t0:h,t1:u,k:1,node:n}:{t0:u,t1:h,k:-1,node:n})}let t=[];for(let n of[...e.keys()].sort()){let s=e.get(n);if(!s)continue;let r=[];Ea(s.edges,(o,a,c)=>{let l=0,h=1/0;for(let f of c)l+=f.k,f.node<h&&(h=f.node);if(l===0)return;let u=l>0?1:-1,d=r[r.length-1];d&&d.t1===o&&d.s===u&&d.node===h?d.t1=a:r.push({t0:o,t1:a,s:u,node:h})});for(let o of r){let a=s.at.get(o.t0),c=s.at.get(o.t1);t.push(o.s>0?{a,b:c,node:o.node}:{a:c,b:a,node:o.node})}}return t}function uc(i,e,t,n){let s=i.positions;for(let r=0;r<i.indices.length;r+=3){let[o,a,c]=[i.indices[r],i.indices[r+1],i.indices[r+2]];if(t!==void 0&&(s[o*3+1]!==t||s[a*3+1]!==t||s[c*3+1]!==t))continue;let l=[s[o*3],s[o*3+2]],h=[s[a*3],s[a*3+2]],u=[s[c*3],s[c*3+2]];Wt(h[0]-l[0],h[1]-l[1],u[0]-l[0],u[1]-l[1])>0&&n.push({node:e,p:[l,h,u]})}}var dc=i=>{let e=1/0,t=-1/0;for(let n=1;n<i.positions.length;n+=3){let s=i.positions[n];s<e&&(e=s),s>t&&(t=s)}return[e,t]},dr=class{constructor(){pn(this,"positions",[]);pn(this,"weight",[]);pn(this,"caster",[]);pn(this,"indices",[])}vertex(e,t,n,s,r){return this.positions.push(e,t,n),this.weight.push(s),this.caster.push(r),this.weight.length-1}tri(e,t,n){this.indices.push(e,t,n)}quad(e,t,n,s){this.indices.push(e,t,n,e,n,s)}};function un(i){let e=i.b[0]-i.a[0],t=i.b[1]-i.a[1],n=Wu(e,t);return{d:[e,t],len:n,u:[e/n,t/n],n:[t/n,-e/n]}}var xn=(i,e)=>[Ht(i[0]*e*1e3),Ht(i[1]*e*1e3)],vi=(i,e)=>[i[0]+e[0],i[1]+e[1]],__=8;function qu(i,e,t){return x_(i,e,t,n=>new fc(n))}function x_(i,e,t,n){let s={edges:0,convex:0,concave:0,flatJoints:0,dropped:0,furniture:0,fenceSides:0,stairEdges:0,triangles:0,probes:0,tests:0},r=[],o=[],a=[...new Set(i.map(h=>Vu(h.key)))].sort((h,u)=>h-u),c=a[0],l=xs.liftMm*1e3;for(let h of a){let u=i.map((M,g)=>[M,g]).filter(([M])=>Vu(M.key)===h),d=[];for(let[M]of u)(M.kind==="floor"||M.kind==="slab"||M.kind==="outdoor"||M.flat===!0)&&m_(M,!0,void 0,d);let f=n(d),_=h===c?e?.y:void 0,x=M=>{let g;for(let v of M){s.probes++;let L=_;for(let R of f.at(v))s.tests++,!(L!==void 0&&R.y<=L)&&Gu(R,v)&&(L=R.y);L!==void 0&&(g===void 0||L>g)&&(g=L)}return g===void 0?void 0:g+l},m=new dr,p=new dr,w=new dr,T=(M,g,v,L,R)=>{let D=m.vertex(M.a[0],L,M.a[1],1,R),N=m.vertex(M.b[0],L,M.b[1],1,R),B=m.vertex(M.b[0]+v[0],L,M.b[1]+v[1],0,R),C=m.vertex(M.a[0]+g[0],L,M.a[1]+g[1],0,R);m.quad(D,N,B,C)},S=(M,g,v)=>{let L=un(M),R=[Ht((M.a[0]+M.b[0])/2),Ht((M.a[1]+M.b[1])/2)],D=C=>[Ht(C[0]/2),Ht(C[1]/2)],N=[Ht((g[0]+v[0])/4),Ht((g[1]+v[1])/4)],B=[vi(R,N)];return L.len>2e3&&B.push(vi(vi(M.a,xn(L.u,1)),D(g)),vi(vi(M.b,xn(L.u,-1)),D(v))),B},E=u.filter(([M])=>M.band!==void 0&&(M.kind==="wall"||M.kind==="column"));if(E.length>0){let M=r.push(E.map(([O])=>O.key))-1,g=1/0;for(let[O]of E)g=Math.min(g,dc(O)[0]);let v=[];for(let[O,ae]of E)uc(O,ae,g,v);let L=n(v.map(O=>({a:O.p[0],b:O.p[1],c:O.p[2],y:g,node:O.node}))),R=O=>{s.probes++;for(let ae of L.at(O))if(s.tests++,Gu(ae,O))return!0;return!1},D=hc(v).flatMap(O=>{let ae=un(O),xe=[0,1],[H,ue]=[Math.min(O.a[0],O.b[0]),Math.max(O.a[0],O.b[0])],[de,we]=[Math.min(O.a[1],O.b[1]),Math.max(O.a[1],O.b[1])];for(let me of L.near(H,de,ue,we))if(me.node!==O.node){s.tests++;for(let[Ie,Ne]of[[me.a,me.b],[me.b,me.c],[me.c,me.a]]){let Oe=ae.d[0]*(Ne[1]-Ie[1])-ae.d[1]*(Ne[0]-Ie[0]);if(Oe===0)continue;let Ce=((Ie[0]-O.a[0])*(Ne[1]-Ie[1])-(Ie[1]-O.a[1])*(Ne[0]-Ie[0]))/Oe,We=((Ie[0]-O.a[0])*ae.d[1]-(Ie[1]-O.a[1])*ae.d[0])/Oe;Ce>0&&Ce<1&&We>=0&&We<=1&&xe.push(Ce)}}xe.sort((me,Ie)=>me-Ie);let fe=me=>me===0?O.a:me===1?O.b:[Ht(O.a[0]+ae.d[0]*me),Ht(O.a[1]+ae.d[1]*me)],Te=[],He;for(let me=0;me+1<xe.length;me++){let Ie=xe[me],Ne=xe[me+1];if(Ne-Ie<=0)continue;let Oe=fe((Ie+Ne)/2),Ce=!R(vi(Oe,xn(ae.n,1)));Ce&&He===void 0&&(He=Ie),Ce||(s.dropped++,He!==void 0&&Te.push({a:fe(He),b:fe(Ie),node:O.node}),He=void 0)}return He!==void 0&&Te.push({a:fe(He),b:O.b,node:O.node}),Te.filter(me=>me.a[0]!==me.b[0]||me.a[1]!==me.b[1])}),N=O=>O.w??i[O.node]?.band??0,B=g_(D,N),C=O=>`${O[0]},${O[1]}`,W=new Map,Z=new Map;for(let O of B)W.set(C(O.b),[...W.get(C(O.b))??[],O]),Z.set(C(O.a),[...Z.get(C(O.a))??[],O]);let z=new Map,ee=new Map;for(let O of B){let ae=xn(un(O).n,N(O));z.set(O,ae),ee.set(O,ae)}let q=[];for(let O of[...W.keys()].sort()){let ae=W.get(O)??[],xe=Z.get(O)??[];if(ae.length!==1||xe.length!==1)continue;let H=ae[0],ue=xe[0],de=un(H),we=un(ue),fe=Wt(de.d[0],de.d[1],we.d[0],we.d[1]);if(ac(de.d,we.d,1,1)){let Te=[de.n[0]+we.n[0],de.n[1]+we.n[1]],He=1+de.n[0]*we.n[0]+de.n[1]*we.n[1];ee.set(H,xn([Te[0]/He,Te[1]/He],N(H))),z.set(ue,xn([Te[0]/He,Te[1]/He],N(ue))),fe!==0&&s.flatJoints++;continue}fe!==0&&q.push({v:H.b,si:H,so:ue,turn:fe})}for(let O of B){let ae=z.get(O),xe=ee.get(O),H=x(S(O,ae,xe));H!==void 0&&(T(O,ae,xe,H,M),s.edges++)}let J=[];for(let[,O]of E){let ae=t?.[O]??[];for(let xe=0;xe+5<ae.length;xe+=6)ae[xe]===ae[xe+3]&&ae[xe+2]===ae[xe+5]&&ae[xe+1]!==ae[xe+4]&&J.push([ae[xe],ae[xe+2]])}for(let{v:O,si:ae,so:xe,turn:H}of q){let ue=un(ae),de=un(xe),we=N(ae),fe=N(xe);if(H>0){let Te=[];for(let Ce=0;Ce<16;Ce++){let We=[wa[Ce],Uu[Ce]];Wt(ue.n[0],ue.n[1],We[0],We[1])>0&&Wt(We[0],We[1],de.n[0],de.n[1])>0&&Te.push(We)}Te.sort((Ce,We)=>-Math.sign(Wt(Ce[0],Ce[1],We[0],We[1])));let He=[ue.n,...Te.slice(0,__-1),de.n],me=He.map((Ce,We)=>xn(Ce,we+(fe-we)*We/(He.length-1))),Ie=x(me.map(Ce=>vi(O,[Ht(Ce[0]/2),Ht(Ce[1]/2)])));if(Ie===void 0)continue;let Ne=m.vertex(O[0],Ie,O[1],1,M),Oe=me.map(Ce=>m.vertex(O[0]+Ce[0],Ie,O[1]+Ce[1],0,M));for(let Ce=0;Ce+1<Oe.length;Ce++)m.tri(Ne,Oe[Ce],Oe[Ce+1]);s.convex++}else{let Te=Math.max(we,fe),He=x([vi(O,xn([ue.n[0]+de.n[0],ue.n[1]+de.n[1]],Te/2))]);if(He===void 0)continue;let me=Math.min(dc(i[ae.node])[1],dc(i[xe.node])[1]);if(me<=He)continue;let Ie=(Ne,Oe,Ce)=>{let We=Ce?[-Ne.d[0],-Ne.d[1]]:Ne.d,vt=Math.min(Oe*1e3,Ne.len);for(let st of J){let rt=st[0]-O[0],_e=st[1]-O[1];if(Wt(We[0],We[1],rt,_e)!==0)continue;let ht=(We[0]*rt+We[1]*_e)/Ne.len;ht>0&&ht<vt&&(vt=ht)}if(vt<=0)return;let nt=xn(Ne.n,xs.liftMm),gt=xn(Ce?[-Ne.u[0],-Ne.u[1]]:Ne.u,vt/1e3),Xe=O[0]+nt[0],ft=O[1]+nt[1],It=p.vertex(Xe,He,ft,1,M),Ft=p.vertex(Xe,me,ft,1,M),F=p.vertex(Xe+gt[0],me,ft+gt[1],0,M),Lt=p.vertex(Xe+gt[0],He,ft+gt[1],0,M);p.quad(It,Ft,F,Lt)};Ie(ue,we,!0),Ie(de,fe,!1),s.concave++}}}for(let[M,g]of u){if(M.kind!=="fence"||M.band===void 0)continue;let v=r.push([M.key])-1,L=[...new Set(M.positions.filter((D,N)=>N%3===1))].sort((D,N)=>D-N),R=new Set;for(let D of L){let N=[];uc(M,g,D,N);for(let B of hc(N)){if(un(B).len<=2*M.band*1e3)continue;let C=`${B.a[0]},${B.a[1]},${B.b[0]},${B.b[1]}`;if(R.has(C))continue;R.add(C);let W=xn(un(B).n,M.band),Z=x(S(B,W,W));Z!==void 0&&(T(B,W,W,Z,v),s.fenceSides++)}}}for(let[M,g]of u){if(M.kind!=="stair"||M.band===void 0)continue;let v=r.push([M.key])-1,L=[];uc(M,g,void 0,L);for(let R of hc(L)){let D=xn(un(R).n,M.band),N=x(S(R,D,D));N!==void 0&&(T(R,D,D,N,v),s.stairEdges++)}}for(let[M]of u){if(M.kind!=="furniture"||M.band===void 0||M.positions.length===0)continue;let g=1/0,v=-1/0,L=1/0,R=-1/0;for(let J=0;J<M.positions.length;J+=3){let O=M.positions[J],ae=M.positions[J+2];O<g&&(g=O),O>v&&(v=O),ae<L&&(L=ae),ae>R&&(R=ae)}let D=M.band*1e3,N=Ht((g+v)/2),B=Ht((L+R)/2),C=x([[N,B],[N,L-D/2],[v+D/2,B],[N,R+D/2],[g-D/2,B]]);if(C===void 0)continue;let W=r.push([M.key])-1,Z=[[g,L],[v,L],[v,R],[g,R]],z=[[g-D,L-D],[v+D,L-D],[v+D,R+D],[g-D,R+D]],ee=Z.map(J=>w.vertex(J[0],C,J[1],1,W)),q=z.map(J=>w.vertex(J[0],C,J[1],0,W));for(let J=0;J<4;J++){let O=(J+1)%4;w.quad(ee[J],ee[O],q[O],q[J])}s.furniture++}for(let[M,g]of[["foot",m],["corner",p],["halo",w]])g.indices.length!==0&&(s.triangles+=g.indices.length/3,o.push({level:h,cls:M,...g}))}return{layers:o,casters:r,counts:s}}var fr=(i,e,t)=>`${i} ${i===1?e:t}`,Yu=i=>`${Number(i.toFixed(2))} m\xB2`;function pc(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 Zu(i,e,t){let n=pc(e,"rooms",wt.drawn),s=pc(e,"openings",wt.drawn),r=[],o=(a,c)=>{t>=a&&r.push(c)};return i.storeys!==void 0&&o(pc(e,"brief",0),{id:"storeys",text:fr(i.storeys,"storey","storeys")}),o(n,{id:"rooms",text:fr(i.rooms,"room","rooms")}),i.areaNet!==void 0&&o(n,{id:"area-net",text:`floor area ${Yu(i.areaNet)} (net)`}),o(n,{id:"area-centre",text:`floor area ${Yu(i.areaCentre)} (to wall centre lines)`}),o(s,{id:"doors",text:fr(i.doors,"door","doors")}),o(s,{id:"windows",text:fr(i.windows,"window","windows")}),o(wt.svgIn,{id:"warnings",text:i.warnings===0?"no warnings":fr(i.warnings,"warning","warnings")}),r}function $u(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)}var y_=5,Aa=.9,mc={light:{background:"#f7f5f0",edge:"#8f877c",cap:Iu,colors:Object.fromEntries(Object.entries(Fn).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"}}},ti={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]},v_=12;function Ju(i,e,t,n={}){let s=mc[e.theme],r=s.colors.furniture,o=e.width,a=e.height,c=document.createElement("canvas");c.width=o,c.height=a,i.width=o,i.height=a;let l=i.getContext("2d",{willReadFrequently:!0}),h=new pa({canvas:c,antialias:!1,preserveDrawingBuffer:!0});h.setPixelRatio(1),h.setSize(o,a,!1),h.toneMapping=$s;let u=new Us;u.background=new Ye(s.background),u.add(new Xs(ti.sky,ti.ground,ti.hemi));let d=new ls(ti.keyColour,ti.key);d.position.set(...ti.keyFrom),u.add(d);let f=new ls(ti.fillColour,ti.fill);f.position.set(...ti.fillFrom),u.add(f);let _=new Map,x=[],m=new Map(e.events.map(P=>[P.key,P.rank])),{faces:p,lines:w}=zu(e.nodes,e.nodes.map(P=>m.get(P.key)??0)),T=[];for(let[P,ne]of e.nodes.entries()){let $=w[P],ie=p[P],oe=lc(ne,ie),re={...ne,positions:oe.positions,indices:oe.base},K=new Float32Array(re.positions.length),pe=1/0,Le=-1/0;for(let Ze=1;Ze<re.positions.length;Ze+=3)pe=Math.min(pe,re.positions[Ze]/1e3),Le=Math.max(Le,re.positions[Ze]/1e3);for(let Ze=0;Ze<re.positions.length;Ze+=3){let bt=re.positions[Ze]/1e3,Dt=re.positions[Ze+1]/1e3,lt=re.positions[Ze+2]/1e3;K[Ze]=bt,K[Ze+1]=Dt-pe,K[Ze+2]=lt}let ce=re.part?`${re.kind}:${re.part}`:re.kind,Ue=new Pn;Ue.position.y=pe+(re.lift??0);let tt=(Ze,bt,Dt,lt,nn,ze,dn=!0)=>{let fn=new $t;fn.setAttribute("position",Ze),fn.setIndex(bt),ze&&fn.computeVertexNormals();let On=ce==="wall:demolish",Bn=re.kind==="floor"||re.kind==="slab",vs=new as({color:new Ye(Dt),transparent:lt||On,opacity:lt?nn:On?.3:1,depthWrite:!On,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:re.kind==="outdoor"?8:Bn?4:1});x.push(fn,vs);let bs=new Qt(fn,vs);if(Ue.add(bs),re.kind!=="slab"&&!lt&&dn){let ni=new Vs(fn,30),pr=new Ci({color:new Ye(s.edge)});x.push(ni,pr),Ue.add(new rs(ni,pr))}return bs},xt=new Vt(K,3);if(re.groups){let Ze=0;for(let{slot:bt,count:Dt}of re.groups){let lt=re.indices.slice(Ze,Ze+Dt);if(Ze+=Dt,bt==="body")tt(xt,lt,s.colors[ce]??s.colors[re.kind]??r,!1,1,!1);else{let{alpha:nn}=Kt[bt];tt(xt,lt,Du(bt,e.theme,r),nn<1,nn,!1)}}}else if(re.colour)tt(xt,re.indices,Lu(re.colour,e.theme,mc.dark.colors.floor),!1,1,!0,re.kind!=="fence");else if(re.finish)tt(xt,re.indices,Nu(re.finish,e.theme,mc.dark.colors.floor),!1,1,!0);else if(ce==="wall"){let Ze=lt=>re.positions[lt*3+1]/1e3===Le,bt=[],Dt=[];for(let lt=0;lt<re.indices.length;lt+=3){let nn=re.indices.slice(lt,lt+3);(nn.every(Ze)?bt:Dt).push(...nn)}tt(xt,Dt,s.colors.wall??r,!1,1,!0,$===void 0),bt.length&&tt(xt,bt,s.cap,!1,1,!0,!1)}else{let Ze=ce==="window:glass";tt(xt,re.indices,s.colors[ce]??s.colors[re.kind]??r,Ze,Ze?Fn["window:glass"].alpha:1,!0,$===void 0)}if(ie&&ie.group>=0){let Ze=s.colors[ce]??s.colors[re.kind]??r;T.push({key:re.key,...oe.alone.length>0?{alone:tt(xt,oe.alone,Ze,!1,1,!0,!1)}:{},...oe.joined.length>0?{joined:tt(xt,oe.joined,Ze,!1,1,!0,!1)}:{},group:ie.group})}if($&&$.length>0){let Ze=new Float32Array($.length);for(let lt=0;lt<$.length;lt+=3)Ze[lt]=$[lt]/1e3,Ze[lt+1]=$[lt+1]/1e3-pe,Ze[lt+2]=$[lt+2]/1e3;let bt=new $t;bt.setAttribute("position",new Vt(Ze,3));let Dt=new Ci({color:new Ye(s.edge)});x.push(bt,Dt),Ue.add(new rs(bt,Dt))}Ue.visible=!1,u.add(Ue),_.set(re.key,{g:Ue,flat:Math.min(1,v_/Math.max(1e-6,Le-pe)),base:pe,lift:re.lift??0})}let[S,E,M,g]=e.viewBox,v=o/a,{cx:L,cz:R,ow:D,oh:N}=ic(e.viewBox,v),B=lr(e.nodes,{ghosts:!0}),C=new k(...B.lo),W=new k(...B.hi),Z=W.y+1e3,z,ee;if(e.ground){let P=e.ground.y/1e3,ne=Sa.marginMm,[$,ie,oe,re]=[C.x-ne,C.z-ne,W.x+ne,W.z+ne],K=new $t;K.setAttribute("position",new Vt(new Float32Array([$,P,ie,$,P,re,oe,P,re,oe,P,ie]),3)),K.setIndex([0,1,2,0,2,3]);let pe=new as({color:new Ye(e.theme==="light"?Sa.light:Sa.dark),transparent:!0,opacity:0,depthWrite:!0,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:2,polygonOffsetUnits:16});x.push(K,pe),z=new Qt(K,pe),ee=pe,z.renderOrder=-1,z.visible=!1,u.add(z)}let q=e.theme==="light"?xs.alpha:xs.alphaDark,J=[],O=new Map(e.events.map(P=>[P.key,P])),ae=[];if(e.shadows!==!1){let P=qu(e.nodes,e.ground,w);ae=P.casters.map($=>{let ie;for(let oe of $){let re=O.get(oe);re&&(!ie||re.riseTo>ie.riseTo)&&(ie=re)}return ie});let ne=new Map(e.nodes.map($=>[$.key,$.lift??0]));for(let $ of P.layers){let ie=new Float32Array($.positions.length);for(let Ue=0;Ue<$.positions.length;Ue++)ie[Ue]=$.positions[Ue]/1e3;let oe=new Vt(new Float32Array($.weight.length*4),4),re=new $t;re.setAttribute("position",new Vt(ie,3)),re.setAttribute("color",oe),re.setIndex($.indices);let K=new ss({color:16777215,vertexColors:!0,transparent:!0,depthWrite:!1,side:_n,polygonOffset:!0,polygonOffsetFactor:0,polygonOffsetUnits:-2});x.push(re,K);let pe=new Qt(re,K);pe.renderOrder=-.5,pe.visible=!1;let Le=new Pn;Le.add(pe),u.add(Le);let ce=P.casters[$.caster[0]]?.[0]??"";J.push({mesh:pe,group:Le,alpha:oe,weight:$.weight,caster:$.caster,scale:$.cls==="corner"?q.corner:$.cls==="halo"?q.furniture:q.floor,key:ce,lift:ne.get(ce)??0})}}let xe=new Pi(-D/2,D/2,N/2,-N/2,1,Z+1e5);xe.up.set(0,0,-1),xe.position.set(L,Z+5e4,R),xe.lookAt(L,0,R);let H=new qt(ya,v,10,1e9),ue=P=>wu(e.nodes,e.events,{elevation:e.elevation,azimuth:nc,fov:Un,aspect:P}),de=ue(v),we=W.clone().sub(C),fe=C.clone().add(W).multiplyScalar(.5),Te=P=>{let ne=Math.max(...P.map($=>fe.distanceTo(new k(...$.target))));return Math.max(we.length()*.75+ne+Math.hypot(fe.x-(S+M/2),fe.z-(E+g/2)),1e3)},He=Te(de.slice(0,ba(e.events))),me=Te(de),Ie=P=>P*Math.PI/180,Ne=new Image,Oe=new Promise(P=>{Ne.onload=()=>P(),Ne.onerror=()=>P()});Ne.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(e.svg)))}`;let Ce=!1,We={cx:L,cz:R,oh:N,elevation:e.elevation},vt=new Map(e.events.map(P=>[P.key,P.storey??0])),nt=Math.max(1,...e.events.filter(P=>!P.hidden).map(P=>(P.storey??0)+1)),gt=nt,Xe="replay",ft=0,It=!1,Ft=we.length()/2,F=P=>Math.max(me,fe.distanceTo(P)+Ft);function Lt(P,ne){let{fov:$,dist:ie,elevation:oe,azimuth:re}=P,K=new k(...P.target),pe=Ie(oe);H.fov=$,H.near=Math.max(10,ie-ne),H.far=ie+ne,H.updateProjectionMatrix(),H.up.set(0,0,-1),pe<Ie(89.99)&&H.up.set(0,1,0),H.position.set(...tc([K.x,K.y,K.z],ie,{elevation:oe,azimuth:re})),H.lookAt(K)}let st={events:e.events,fits:de,frame:We,box:lr(e.nodes,{settle:1}),aspect:v},rt=new Map,_e=P=>{let ne=rt.get(P);if(ne)return ne;let $=Tu(P,st);return rt.set(P,$),$},ht,De=()=>{},Be=()=>{},A=()=>{},y=new Set,V=()=>{for(let P of y)P()},le=Math.max(1,Math.min(4,Math.floor(e.supersample??1)));function se(P){let ne=le*le,$=new Uint32Array(o*a*4);l.globalAlpha=1;for(let oe=0;oe<le;oe++)for(let re=0;re<le;re++){P.setViewOffset(o,a,(re+.5)/le-.5,(oe+.5)/le-.5,o,a),h.render(u,P),l.drawImage(c,0,0);let K=l.getImageData(0,0,o,a).data;for(let pe=0;pe<K.length;pe++)$[pe]=$[pe]+K[pe]}P.clearViewOffset();let ie=l.createImageData(o,a);for(let oe=0;oe<$.length;oe++)ie.data[oe]=Math.floor(($[oe]+(ne>>1))/ne);l.putImageData(ie,0,0)}function he(P){ft=P,It=!0,t&&e.facts&&$u(t,Zu(e.facts,e.events,Math.min(1,Math.max(0,P))));let ne=ar(e.events,P);z&&ee&&(z.visible=ne.ground>0,ee.opacity=ne.ground);for(let[oe,{g:re,flat:K,base:pe,lift:Le}]of _){let ce=ne.nodes.get(oe);re.visible=ce?.visible===!0&&(vt.get(oe)??0)<gt,re.scale.y=Math.max(K,ce?.rise??0),Le!==0&&(re.position.y=pe+va(Le,ne.settle))}let $=ku(p,oe=>{let re=e.nodes[oe]?.key??"";return _.get(re)?.g.visible===!0&&(ne.nodes.get(re)?.rise??0)>=1});for(let{group:oe,alone:re,joined:K}of T){let pe=$.has(oe);re&&(re.visible=!pe),K&&(K.visible=pe)}if(J.length>0){let oe=Math.min(1,Math.max(0,P)),re=ae.map(K=>Xu(K,oe));for(let K of J){let pe=K.alpha.array,Le=!1,ce=!1;for(let Ue=0;Ue<K.weight.length;Ue++){let tt=Math.fround(K.weight[Ue]*K.scale*re[K.caster[Ue]]);pe[Ue*4+3]!==tt&&(pe[Ue*4+3]=tt,Le=!0),tt>0&&(ce=!0)}Le&&(K.alpha.needsUpdate=!0),K.mesh.visible=ce&&(vt.get(K.key)??0)<gt,K.group.position.y=va(K.lift,ne.settle)}}let ie=xe;if(Xe==="free"&&ht){let oe=H.position.distanceTo(ht.target),re=F(ht.target);H.near=Math.max(10,oe-re),H.far=oe+re,H.updateProjectionMatrix(),ie=H}else if(Xe!=="replay"&&Xe!=="free"){let oe=_e(Xe);Lt(oe,F(new k(...oe.target))),ie=H}else(ne.tilt>0||ne.dolly>0)&&(Lt(Ma(ne,de,We),ne.settle>0?me:He),ie=H);if(le===1?(h.render(u,ie),l.globalAlpha=1,l.drawImage(c,0,0)):se(ie),Xe==="replay"&&ne.svg>0&&Ne.complete&&Ne.naturalWidth>0){let oe=Math.min(o/M,a/g),re=M*oe,K=g*oe;l.globalAlpha=ne.svg,l.drawImage(Ne,(o-re)/2,(a-K)/2,re,K),l.globalAlpha=1}}function ye(P){Ce||(Xe!=="replay"&&(De(),Xe="replay",V()),he(P),A())}async function j(){let P=l.getImageData(0,0,o,a).data,ne=await crypto.subtle.digest("SHA-256",P);return[...new Uint8Array(ne)].map($=>$.toString(16).padStart(2,"0")).join("")}let Q=n.interactive?ge():void 0;function ge(){let P=new xa(H,i);ht=P,P.enableDamping=!1,P.screenSpacePanning=!1,P.minPolarAngle=Ie(90-cr.max),P.maxPolarAngle=Ie(90-cr.min);let ne=Cu(B);P.cursor.set(...ne.centre);let $=i.getAttribute("tabindex");i.tabIndex=0;let ie=0,oe=!1,re=!1,K=()=>window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,pe=()=>{ie=0,!(Ce||Xe!=="free")&&(P.update()||oe)&&(ie=requestAnimationFrame(pe))},Le=()=>{P.enableDamping&&!ie&&(ie=requestAnimationFrame(pe))};De=()=>{ie&&cancelAnimationFrame(ie),ie=0,oe=!1,P.enableDamping&&(re=!0,P.enableDamping=!1,P.update(),re=!1)};let ce=(ze,dn,fn)=>{H.fov=fn,H.up.set(0,1,0),H.position.set(...ze),P.target.set(...Eu(ze,dn,st.box.lo[1])),H.lookAt(P.target);let On=H.position.distanceTo(P.target),Bn=Ru(de,fn);P.minDistance=Math.min(Bn.min,On),P.maxDistance=Math.max(Bn.max,On),P.maxTargetRadius=Math.max(ne.radius,P.target.distanceTo(P.cursor)),P.enableDamping=!K()},Ue=()=>{if(Xe==="free")return;let ze=Xe==="replay"?Au(Ma(ar(e.events,ft),de,We)):_e(Xe);ce(tc(ze.target,ze.dist,ze),ze.target,ze.fov)},tt=()=>{Xe!=="free"&&(Xe="free",n.onTake?.(),V(),Le())},xt=!1;A=()=>{xt&&Ue()},P.addEventListener("start",()=>{Ue(),xt=!0,oe=!0}),P.addEventListener("end",()=>{xt=!1,oe=!1}),P.addEventListener("change",()=>{re||Ce||(xt=!1,tt(),he(ft))});let Ze=Ie(y_),bt=new Map([["ArrowLeft",()=>P.rotateLeft(Ze)],["ArrowRight",()=>P.rotateLeft(-Ze)],["ArrowUp",()=>P.rotateUp(Ze)],["ArrowDown",()=>P.rotateUp(-Ze)],["+",()=>P.dollyIn(Aa)],["=",()=>P.dollyIn(Aa)],["-",()=>P.dollyOut(Aa)],["_",()=>P.dollyOut(Aa)]]),Dt=ze=>{let dn=bt.get(ze.key);!dn||Ce||ze.ctrlKey||ze.metaKey||ze.altKey||(ze.preventDefault(),Ue(),dn(),Le())};i.addEventListener("keydown",Dt),Be=()=>{i.removeEventListener("keydown",Dt),P.dispose(),$===null?i.removeAttribute("tabindex"):i.setAttribute("tabindex",$),y.clear()};let lt=ze=>Math.min(nt,Math.max(1,Math.round(ze))),nn=()=>gt===nt?"all":gt;return{at:ze=>{Ce||he(ze)},preset:ze=>{Ce||(De(),Xe=ze,n.onTake?.(),V(),he(ft))},reset:()=>{Ce||(De(),Xe="replay",gt=nt,V(),he(ft))},storeys:nt,showStoreys:ze=>{Ce||(gt=lt(ze),V(),he(ft))},onChange:ze=>(y.add(ze),()=>y.delete(ze)),spin:ze=>{if(Ce||oe||!Number.isFinite(ze)||ze===0)return;Ue();let dn=P.enableDamping;P.enableDamping=!1,P.rotateLeft(Ie(ze)),P.update(),P.enableDamping=dn},get shown(){return gt},get camera(){return Xe},state:()=>Xe==="free"?{camera:"free",position:H.position.toArray(),target:P.target.toArray(),fov:H.fov,storeys:nn()}:{camera:Xe,storeys:nn()},restore:ze=>{Ce||(De(),gt=ze.storeys==="all"?nt:lt(ze.storeys),ze.camera==="free"&&ce(ze.position,ze.target,ze.fov),Xe=ze.camera,Xe!=="replay"&&n.onTake?.(),V())}}}function I(P,ne){if(Ce)return;let $=Math.max(1,Math.round(P)),ie=Math.max(1,Math.round(ne));$===o&&ie===a||(o=$,a=ie,c.width=o,c.height=a,i.width=o,i.height=a,h.setSize(o,a,!1),v=o/a,{cx:L,cz:R,ow:D,oh:N}=ic(e.viewBox,v),xe.left=-D/2,xe.right=D/2,xe.top=N/2,xe.bottom=-N/2,xe.position.set(L,Z+5e4,R),xe.lookAt(L,0,R),xe.updateProjectionMatrix(),H.aspect=v,H.updateProjectionMatrix(),de=ue(v),He=Te(de.slice(0,ba(e.events))),me=Te(de),We={cx:L,cz:R,oh:N,elevation:e.elevation},st={...st,fits:de,frame:We,aspect:v},rt.clear(),It&&he(ft))}function te(){if(!Ce){De(),Ce=!0,Be();for(let P of x)P.dispose();h.dispose(),h.forceContextLoss()}}return{seek:ye,frameHash:j,ready:Oe,dispose:te,resize:I,...Q?{view:Q}:{}}}var b_=[["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"]],M_="Drag to turn, right-drag to pan, scroll to zoom; on the focused view, arrow keys turn and + / \u2212 zoom.";function Ku(i,e={}){let t=document.createElement("div");t.className="archlang-views",t.setAttribute("role","toolbar"),t.setAttribute("aria-label","3D view");let n=(h,u,d)=>{let f=document.createElement("button");return f.type="button",e.buttonClass&&(f.className=e.buttonClass),f.textContent=h,f.setAttribute("aria-label",u),f.addEventListener("click",d),f},s=[],r=[],o=()=>{for(let[h,u]of s)u.setAttribute("aria-pressed",String(i.camera===h));for(let[h,u]of r.entries())u.setAttribute("aria-pressed",String(h+1===i.shown))},a=h=>{};for(let[h,u,d]of b_){let f=n(u,d,()=>{i.preset(h),a(!0)});f.dataset.preset=h,s.push([h,f])}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 u=document.createElement("span");u.className="archlang-views-presets",u.id=`${e.hintId??"archlang-views"}-presets`,u.setAttribute("role","group"),u.setAttribute("aria-label","Preset views"),u.hidden=!0,u.append(...s.map(([,x])=>x));let d=n("View \u25BE","View presets: iso, top, and from north, east, south and west",()=>u.hidden?_():a(!1));d.setAttribute("aria-expanded","false"),d.setAttribute("aria-controls",u.id);let f=x=>{h.contains(x.target)||a(!1)},_=()=>{u.hidden=!1,d.setAttribute("aria-expanded","true"),document.addEventListener("pointerdown",f,!0),(s.find(([x])=>i.camera===x)?.[1]??s[0]?.[1])?.focus()};a=x=>{u.hidden||(u.hidden=!0,d.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",f,!0),x&&d.focus())},h.addEventListener("keydown",x=>{x.key!=="Escape"||u.hidden||(x.preventDefault(),x.stopPropagation(),a(!0))}),h.addEventListener("focusout",x=>{h.contains(x.relatedTarget)||a(!1)}),h.append(d,u),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 u=1;u<=i.storeys;u++){let d=u===i.storeys,f=n(d?"All":u===1?"1":`1\u2013${u}`,d?"Show every storey":`Show storeys 1 to ${u}, hide the ones above`,()=>i.showStoreys(u));f.dataset.storeys=String(u),r.push(f),h.append(f)}t.append(h)}i.onChange(o),o();let l=document.createElement("span");return l.className="archlang-views-hint",e.hintId&&(l.id=e.hintId),l.textContent=M_,t.append(l),t}function S_(){let i=document.getElementById("archlang-replay-payload");return JSON.parse(i?.textContent??"{}")}function w_(){let i=S_(),e=document.getElementById("archlang-replay"),t=document.getElementById("archlang-replay-strip")??void 0,n=0,s=()=>{n&&cancelAnimationFrame(n),n=0},{seek:r,frameHash:o,ready:a,view:c}=Ju(e,i,t,{interactive:!0,onTake:s});window.__seek=r,window.__frameHash=o,window.__ready=a.then(()=>r(0));let l=document.getElementById("archlang-replay-views");c&&l&&(l.replaceWith(Ku(c,{hintId:"archlang-replay-hint"})),e.setAttribute("aria-describedby","archlang-replay-hint"));let h=document.getElementById("archlang-replay-t"),u=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;window.__ready.then(()=>{if(window.__replayAutoplay===!1)return;if(u){r(1),h&&(h.value="1");return}let d,f=_=>{d??(d=_);let x=Math.min(1,(_-d)/(i.seconds*1e3));r(x),h&&(h.value=String(x)),n=x<1?requestAnimationFrame(f):0};n=requestAnimationFrame(f)}),h?.addEventListener("input",()=>{s(),r(Number(h.value))})}w_();})();
|