diff --git a/docs/getting-started.md b/docs/getting-started.md index 3567034..926c1b4 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -151,6 +151,8 @@ arrow keys to look around, and use the wheel to zoom. Arrows inside the photogra heading. The minimap remains available while the photo panel is open. The generated HTML embeds the photographs. Use **Enlarge** to expand a panorama. Pick a minimap size, drag the plan to pan it and use the wheel or the zoom buttons to change its scale. +The blue spheres mark camera positions in the 3D view. Click a sphere to open its panorama. Use **Panorama spheres in 3D** +on the minimap to hide or show the spheres. The spheres follow the selected height band and the model's visibility. The **+** beside the level list starts a level from two clicks in a panorama, lower elevation first. Each elevation comes from the sampled scan point at that location. Selecting a level filters the map points and stations to that height range. Clear station groups separated vertically by more than 2 m can create levels automatically. Use **All heights** to return to the full plan. Level ranges diff --git a/src/IOViewer/Viewer/dist/viewer.js b/src/IOViewer/Viewer/dist/viewer.js index 45c0058..e5379fc 100644 --- a/src/IOViewer/Viewer/dist/viewer.js +++ b/src/IOViewer/Viewer/dist/viewer.js @@ -1,10 +1,10 @@ -(()=>{var jh=i=>{throw TypeError(i)};var Rl=(i,t,e)=>t.has(i)||jh("Cannot "+e);var li=(i,t,e)=>(Rl(i,t,"read from private field"),e?e.call(i):t.get(i)),Cl=(i,t,e)=>t.has(i)?jh("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),Qh=(i,t,e,n)=>(Rl(i,t,"write to private field"),n?n.call(i,e):t.set(i,e),e),Wr=(i,t,e)=>(Rl(i,t,"access private method"),e);var Du=0,lc=1,Nu=2;var fr=1,Uu=2,Ts=3,zn=0,De=1,Ne=2,kn=0,As=1,cc=2,hc=3,uc=4,Fu=5;var zi=100,Bu=101,Ou=102,zu=103,ku=104,Hu=200,Vu=201,Gu=202,Wu=203,dc=204,fc=205,Xu=206,qu=207,Yu=208,$u=209,Zu=210,Ju=211,Ku=212,ju=213,Qu=214,bo=0,So=1,wo=2,us=3,Eo=4,To=5,Ao=6,Ro=7,ea=0,td=1,ed=2,Mn=0,pc=1,mc=2,gc=3,_c=4,xc=5,vc=6,yc=7;var Mc=300,vi=301,ki=302,na=303,ia=304,pr=306,ds=1e3,In=1001,Co=1002,ze=1003,nd=1004;var mr=1005;var Xe=1006,sa=1007;var yi=1008;var nn=1009,bc=1010,Sc=1011,Rs=1012,ra=1013,bn=1014,Ye=1015,Sn=1016,oa=1017,aa=1018,Cs=1020,wc=35902,Ec=35899,Tc=1021,Ac=1022,sn=1023,Pn=1026,Mi=1027,Is=1028,la=1029,bi=1030,ca=1031;var ha=1033,gr=33776,_r=33777,xr=33778,vr=33779,ua=35840,da=35841,fa=35842,pa=35843,ma=36196,ga=37492,_a=37496,xa=37488,va=37489,yr=37490,ya=37491,Ma=37808,ba=37809,Sa=37810,wa=37811,Ea=37812,Ta=37813,Aa=37814,Ra=37815,Ca=37816,Ia=37817,Pa=37818,La=37819,Da=37820,Na=37821,Ua=36492,Fa=36494,Ba=36495,Oa=36283,za=36284,Mr=36285,ka=36286;var $s=2300,Io=2301,vo=2302,Ql=2303,tc=2400,ec=2401,nc=2402;var id=3200;var Ha=0,sd=1,ni="",Te="srgb",Zs="srgb-linear",Js="linear",he="srgb";var yo=7680;var Rc=34055,Cc=34056;var Ic=517;var rd=519,od=512,ad=513,ld=514,Va=515,cd=516,hd=517,Ga=518,ud=519,Pc=35044,Lc=35048;var Dc="300 es",xn=2e3,fs=2001;function Op(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function zp(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function ps(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function dd(){let i=ps("canvas");return i.style.display="block",i}var tu={},ms=null;function Ks(...i){let t="THREE."+i.shift();ms?ms("log",t,...i):console.log(t,...i)}function fd(i){let t=i[0];if(typeof t=="string"&&t.startsWith("TSL:")){let e=i[1];e&&e.isStackTrace?i[0]+=" "+e.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function zt(...i){i=fd(i);let t="THREE."+i.shift();if(ms)ms("warn",t,...i);else{let e=i[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...i)}}function Ht(...i){i=fd(i);let t="THREE."+i.shift();if(ms)ms("error",t,...i);else{let e=i[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...i)}}function Ni(...i){let t=i.join(" ");t in tu||(tu[t]=!0,zt(...i))}function pd(i,t,e){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}var md={[bo]:So,[wo]:Ao,[Eo]:Ro,[us]:To,[So]:bo,[Ao]:wo,[Ro]:Eo,[To]:us},Ln=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){let n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){let n=this._listeners;if(n===void 0)return;let s=n[t];if(s!==void 0){let r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let n=e[t.type];if(n!==void 0){t.target=this;let s=n.slice(0);for(let r=0,o=s.length;r>8&255]+Ze[i>>16&255]+Ze[i>>24&255]+"-"+Ze[t&255]+Ze[t>>8&255]+"-"+Ze[t>>16&15|64]+Ze[t>>24&255]+"-"+Ze[e&63|128]+Ze[e>>8&255]+"-"+Ze[e>>16&255]+Ze[e>>24&255]+Ze[n&255]+Ze[n>>8&255]+Ze[n>>16&255]+Ze[n>>24&255]).toLowerCase()}function ee(i,t,e){return Math.max(t,Math.min(e,i))}function Nc(i,t){return(i%t+t)%t}function kp(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function Hp(i,t,e){return i!==t?(e-i)/(t-i):0}function Ys(i,t,e){return(1-e)*i+e*t}function Vp(i,t,e,n){return Ys(i,t,1-Math.exp(-e*n))}function Gp(i,t=1){return t-Math.abs(Nc(i,t*2)-t)}function Wp(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Xp(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function qp(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Yp(i,t){return i+Math.random()*(t-i)}function $p(i){return i*(.5-Math.random())}function Zp(i){i!==void 0&&(eu=i);let t=eu+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Jp(i){return i*cs}function Kp(i){return i*gs}function jp(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function Qp(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function tm(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function em(i,t,e,n,s){let r=Math.cos,o=Math.sin,a=r(e/2),l=o(e/2),c=r((t+n)/2),h=o((t+n)/2),d=r((t-n)/2),u=o((t-n)/2),f=r((n-t)/2),g=o((n-t)/2);switch(s){case"XYX":i.set(a*h,l*d,l*u,a*c);break;case"YZY":i.set(l*u,a*h,l*d,a*c);break;case"ZXZ":i.set(l*d,l*u,a*h,a*c);break;case"XZX":i.set(a*h,l*g,l*f,a*c);break;case"YXY":i.set(l*f,a*h,l*g,a*c);break;case"ZYZ":i.set(l*g,l*f,a*h,a*c);break;default:zt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function _n(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:case Uint8ClampedArray:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function ue(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}var re={DEG2RAD:cs,RAD2DEG:gs,generateUUID:Jn,clamp:ee,euclideanModulo:Nc,mapLinear:kp,inverseLerp:Hp,lerp:Ys,damp:Vp,pingpong:Gp,smoothstep:Wp,smootherstep:Xp,randInt:qp,randFloat:Yp,randFloatSpread:$p,seededRandom:Zp,degToRad:Jp,radToDeg:Kp,isPowerOfTwo:jp,ceilPowerOfTwo:Qp,floorPowerOfTwo:tm,setQuaternionFromProperEuler:em,normalize:ue,denormalize:_n},zc=class zc{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=ee(this.x,t.x,e.x),this.y=ee(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=ee(this.x,t,e),this.y=ee(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ee(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(ee(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*n-o*s+t.x,this.y=r*s+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};zc.prototype.isVector2=!0;var $t=zc,Le=class{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,o,a){let l=n[s+0],c=n[s+1],h=n[s+2],d=n[s+3],u=r[o+0],f=r[o+1],g=r[o+2],_=r[o+3];if(d!==_||l!==u||c!==f||h!==g){let m=l*u+c*f+h*g+d*_;m<0&&(u=-u,f=-f,g=-g,_=-_,m=-m);let p=1-a;if(m<.9995){let b=Math.acos(m),w=Math.sin(b);p=Math.sin(p*b)/w,a=Math.sin(a*b)/w,l=l*p+u*a,c=c*p+f*a,h=h*p+g*a,d=d*p+_*a}else{l=l*p+u*a,c=c*p+f*a,h=h*p+g*a,d=d*p+_*a;let b=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=b,c*=b,h*=b,d*=b}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=d}static multiplyQuaternionsFlat(t,e,n,s,r,o){let a=n[s],l=n[s+1],c=n[s+2],h=n[s+3],d=r[o],u=r[o+1],f=r[o+2],g=r[o+3];return t[e]=a*g+h*d+l*f-c*u,t[e+1]=l*g+h*u+c*d-a*f,t[e+2]=c*g+h*f+a*u-l*d,t[e+3]=h*g-a*d-l*u-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let n=t._x,s=t._y,r=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(s/2),d=a(r/2),u=l(n/2),f=l(s/2),g=l(r/2);switch(o){case"XYZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"YXZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"ZXY":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"ZYX":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"YZX":this._x=u*h*d+c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d-u*f*g;break;case"XZY":this._x=u*h*d-c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d+u*f*g;break;default:zt("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],s=e[4],r=e[8],o=e[1],a=e[5],l=e[9],c=e[2],h=e[6],d=e[10],u=n+a+d;if(u>0){let f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(h-l)*f,this._y=(r-c)*f,this._z=(o-s)*f}else if(n>a&&n>d){let f=2*Math.sqrt(1+n-a-d);this._w=(h-l)/f,this._x=.25*f,this._y=(s+o)/f,this._z=(r+c)/f}else if(a>d){let f=2*Math.sqrt(1+a-n-d);this._w=(r-c)/f,this._x=(s+o)/f,this._y=.25*f,this._z=(l+h)/f}else{let f=2*Math.sqrt(1+d-n-a);this._w=(o-s)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ee(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let n=t._x,s=t._y,r=t._z,o=t._w,a=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+o*a+s*c-r*l,this._y=s*h+o*l+r*a-n*c,this._z=r*h+o*c+n*l-s*a,this._w=o*h-n*a-s*l-r*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,s=t._y,r=t._z,o=t._w,a=this.dot(t);a<0&&(n=-n,s=-s,r=-r,o=-o,a=-a);let l=1-e;if(a<.9995){let c=Math.acos(a),h=Math.sin(c);l=Math.sin(l*c)/h,e=Math.sin(e*c)/h,this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+o*e,this._onChangeCallback()}else this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+o*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},kc=class kc{constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(nu.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(nu.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=t.elements,o=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*o,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*o,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*o,this}applyQuaternion(t){let e=this.x,n=this.y,s=this.z,r=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*s-a*n),h=2*(a*e-r*s),d=2*(r*n-o*e);return this.x=e+l*c+o*d-a*h,this.y=n+l*h+a*c-r*d,this.z=s+l*d+r*h-o*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=ee(this.x,t.x,e.x),this.y=ee(this.y,t.y,e.y),this.z=ee(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=ee(this.x,t,e),this.y=ee(this.y,t,e),this.z=ee(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ee(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,s=t.y,r=t.z,o=e.x,a=e.y,l=e.z;return this.x=s*l-r*a,this.y=r*o-n*l,this.z=n*a-s*o,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Il.copy(this).projectOnVector(t),this.sub(Il)}reflect(t){return this.sub(Il.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(ee(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};kc.prototype.isVector3=!0;var I=kc,Il=new I,nu=new Le,Hc=class Hc{constructor(t,e,n,s,r,o,a,l,c){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,o,a,l,c)}set(t,e,n,s,r,o,a,l,c){let h=this.elements;return h[0]=t,h[1]=s,h[2]=a,h[3]=e,h[4]=r,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],d=n[7],u=n[2],f=n[5],g=n[8],_=s[0],m=s[3],p=s[6],b=s[1],w=s[4],v=s[7],y=s[2],S=s[5],A=s[8];return r[0]=o*_+a*b+l*y,r[3]=o*m+a*w+l*S,r[6]=o*p+a*v+l*A,r[1]=c*_+h*b+d*y,r[4]=c*m+h*w+d*S,r[7]=c*p+h*v+d*A,r[2]=u*_+f*b+g*y,r[5]=u*m+f*w+g*S,r[8]=u*p+f*v+g*A,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e*o*h-e*a*c-n*r*h+n*a*l+s*r*c-s*o*l}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],d=h*o-a*c,u=a*l-h*r,f=c*r-o*l,g=e*d+n*u+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let _=1/g;return t[0]=d*_,t[1]=(s*c-h*n)*_,t[2]=(a*n-s*o)*_,t[3]=u*_,t[4]=(h*e-s*l)*_,t[5]=(s*r-a*e)*_,t[6]=f*_,t[7]=(n*l-c*e)*_,t[8]=(o*e-n*r)*_,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,o,a){let l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*o+c*a)+o+t,-s*c,s*l,-s*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return Ni("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Pl.makeScale(t,e)),this}rotate(t){return Ni("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Pl.makeRotation(-t)),this}translate(t,e){return Ni("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Pl.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}};Hc.prototype.isMatrix3=!0;var qt=Hc,Pl=new qt,iu=new qt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),su=new qt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function nm(){let i={enabled:!0,workingColorSpace:Zs,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===he&&(s.r=Kn(s.r),s.g=Kn(s.g),s.b=Kn(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===he&&(s.r=hs(s.r),s.g=hs(s.g),s.b=hs(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===ni?Js: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[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Ni("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ni("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Zs]:{primaries:t,whitePoint:n,transfer:Js,toXYZ:iu,fromXYZ:su,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Te},outputColorSpaceConfig:{drawingBufferColorSpace:Te}},[Te]:{primaries:t,whitePoint:n,transfer:he,toXYZ:iu,fromXYZ:su,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Te}}}),i}var te=nm();function Kn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function hs(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var $i,Po=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{$i===void 0&&($i=ps("canvas")),$i.width=t.width,$i.height=t.height;let s=$i.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=$i}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=ps("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let o=0;o1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Dl).x}get height(){return this.source.getSize(Dl).y}get depth(){return this.source.getSize(Dl).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let n=t[e];if(n===void 0){zt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){zt(`Texture.setValues(): property '${e}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Mc)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ds:t.x=t.x-Math.floor(t.x);break;case In:t.x=t.x<0?0:1;break;case Co:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case ds:t.y=t.y-Math.floor(t.y);break;case In:t.y=t.y<0?0:1;break;case Co:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};ke.DEFAULT_IMAGE=null;ke.DEFAULT_MAPPING=Mc;ke.DEFAULT_ANISOTROPY=1;var Vc=class Vc{constructor(t=0,e=0,n=0,s=1){this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*s+o[12]*r,this.y=o[1]*e+o[5]*n+o[9]*s+o[13]*r,this.z=o[2]*e+o[6]*n+o[10]*s+o[14]*r,this.w=o[3]*e+o[7]*n+o[11]*s+o[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r,l=t.elements,c=l[0],h=l[4],d=l[8],u=l[1],f=l[5],g=l[9],_=l[2],m=l[6],p=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-_)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+_)<.1&&Math.abs(g+m)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let w=(c+1)/2,v=(f+1)/2,y=(p+1)/2,S=(h+u)/4,A=(d+_)/4,x=(g+m)/4;return w>v&&w>y?w<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(w),s=S/n,r=A/n):v>y?v<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(v),n=S/s,r=x/s):y<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(y),n=A/r,s=x/r),this.set(n,s,r,e),this}let b=Math.sqrt((m-g)*(m-g)+(d-_)*(d-_)+(u-h)*(u-h));return Math.abs(b)<.001&&(b=1),this.x=(m-g)/b,this.y=(d-_)/b,this.z=(u-h)/b,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=ee(this.x,t.x,e.x),this.y=ee(this.y,t.y,e.y),this.z=ee(this.z,t.z,e.z),this.w=ee(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=ee(this.x,t,e),this.y=ee(this.y,t,e),this.z=ee(this.z,t,e),this.w=ee(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ee(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};Vc.prototype.isVector4=!0;var ge=Vc,Lo=class extends Ln{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xe,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new ge(0,0,t,e),this.scissorTest=!1,this.viewport=new ge(0,0,t,e),this.textures=[];let s={width:t,height:e,depth:n.depth},r=new ke(s),o=n.count;for(let a=0;a1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let n=0;n0&&(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(t),s.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c0){s.children=[];for(let a=0;a0){s.animations=[];for(let a=0;a0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=s,n;function o(a){let l=[];for(let c in a){let h=a[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;nf+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&u<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:t,target:this})));a!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,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(um)))}return a!==null&&(a.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new Re;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},gd={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},hi={h:0,s:0,l:0},Yr={h:0,s:0,l:0};function Ul(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}var Vt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Te){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,te.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=te.workingColorSpace){return this.r=t,this.g=e,this.b=n,te.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=te.workingColorSpace){if(t=Nc(t,1),e=ee(e,0,1),n=ee(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,o=2*n-r;this.r=Ul(o,r,t+1/3),this.g=Ul(o,r,t),this.b=Ul(o,r,t-1/3)}return te.colorSpaceToWorking(this,s),this}setStyle(t,e=Te){function n(r){r!==void 0&&parseFloat(r)<1&&zt("Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){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+)\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,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:zt("Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){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,e);if(o===6)return this.setHex(parseInt(r,16),e);zt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Te){let n=gd[t.toLowerCase()];return n!==void 0?this.setHex(n,e):zt("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Kn(t.r),this.g=Kn(t.g),this.b=Kn(t.b),this}copyLinearToSRGB(t){return this.r=hs(t.r),this.g=hs(t.g),this.b=hs(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Te){return te.workingToColorSpace(Je.copy(this),t),Math.round(ee(Je.r*255,0,255))*65536+Math.round(ee(Je.g*255,0,255))*256+Math.round(ee(Je.b*255,0,255))}getHexString(t=Te){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=te.workingColorSpace){te.workingToColorSpace(Je.copy(this),e);let n=Je.r,s=Je.g,r=Je.b,o=Math.max(n,s,r),a=Math.min(n,s,r),l,c,h=(a+o)/2;if(a===o)l=0,c=0;else{let d=o-a;switch(c=h<=.5?d/(o+a):d/(2-o-a),o){case n:l=(s-r)/d+(s0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){mn.subVectors(s,e),Xn.subVectors(n,e),Fl.subVectors(t,e);let o=mn.dot(mn),a=mn.dot(Xn),l=mn.dot(Fl),c=Xn.dot(Xn),h=Xn.dot(Fl),d=o*c-a*a;if(d===0)return r.set(0,0,0),null;let u=1/d,f=(c*l-a*h)*u,g=(o*h-a*l)*u;return r.set(1-f-g,g,f)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,qn)===null?!1:qn.x>=0&&qn.y>=0&&qn.x+qn.y<=1}static getInterpolation(t,e,n,s,r,o,a,l){return this.getBarycoord(t,e,n,s,qn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,qn.x),l.addScaledVector(o,qn.y),l.addScaledVector(a,qn.z),l)}static getInterpolatedAttribute(t,e,n,s,r,o){return kl.setScalar(0),Hl.setScalar(0),Vl.setScalar(0),kl.fromBufferAttribute(t,e),Hl.fromBufferAttribute(t,n),Vl.fromBufferAttribute(t,s),o.setScalar(0),o.addScaledVector(kl,r.x),o.addScaledVector(Hl,r.y),o.addScaledVector(Vl,r.z),o}static isFrontFacing(t,e,n,s){return mn.subVectors(n,e),Xn.subVectors(t,e),mn.cross(Xn).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return mn.subVectors(this.c,this.b),Xn.subVectors(this.a,this.b),mn.cross(Xn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return i.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return i.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return i.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return i.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return i.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,s=this.b,r=this.c,o,a;ji.subVectors(s,n),Qi.subVectors(r,n),Bl.subVectors(t,n);let l=ji.dot(Bl),c=Qi.dot(Bl);if(l<=0&&c<=0)return e.copy(n);Ol.subVectors(t,s);let h=ji.dot(Ol),d=Qi.dot(Ol);if(h>=0&&d<=h)return e.copy(s);let u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return o=l/(l-h),e.copy(n).addScaledVector(ji,o);zl.subVectors(t,r);let f=ji.dot(zl),g=Qi.dot(zl);if(g>=0&&f<=g)return e.copy(r);let _=f*c-l*g;if(_<=0&&c>=0&&g<=0)return a=c/(c-g),e.copy(n).addScaledVector(Qi,a);let m=h*g-f*d;if(m<=0&&d-h>=0&&f-g>=0)return du.subVectors(r,s),a=(d-h)/(d-h+(f-g)),e.copy(s).addScaledVector(du,a);let p=1/(m+_+u);return o=_*p,a=u*p,e.copy(n).addScaledVector(ji,o).addScaledVector(Qi,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},oe=class{constructor(t=new I(1/0,1/0,1/0),e=new I(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,gn),gn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Hs),Zr.subVectors(this.max,Hs),ts.subVectors(t.a,Hs),es.subVectors(t.b,Hs),ns.subVectors(t.c,Hs),ui.subVectors(es,ts),di.subVectors(ns,es),Ii.subVectors(ts,ns);let e=[0,-ui.z,ui.y,0,-di.z,di.y,0,-Ii.z,Ii.y,ui.z,0,-ui.x,di.z,0,-di.x,Ii.z,0,-Ii.x,-ui.y,ui.x,0,-di.y,di.x,0,-Ii.y,Ii.x,0];return!Gl(e,ts,es,ns,Zr)||(e=[1,0,0,0,1,0,0,0,1],!Gl(e,ts,es,ns,Zr))?!1:(Jr.crossVectors(ui,di),e=[Jr.x,Jr.y,Jr.z],Gl(e,ts,es,ns,Zr))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,gn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(gn).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Yn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Yn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Yn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Yn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Yn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Yn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Yn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Yn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Yn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}},Yn=[new I,new I,new I,new I,new I,new I,new I,new I],gn=new I,$r=new oe,ts=new I,es=new I,ns=new I,ui=new I,di=new I,Ii=new I,Hs=new I,Zr=new I,Jr=new I,Pi=new I;function Gl(i,t,e,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){Pi.fromArray(i,r);let a=s.x*Math.abs(Pi.x)+s.y*Math.abs(Pi.y)+s.z*Math.abs(Pi.z),l=t.dot(Pi),c=e.dot(Pi),h=n.dot(Pi);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}var Pe=new I,Kr=new $t,dm=0,Ae=class extends Ln{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:dm++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Pc,this.updateRanges=[],this.gpuType=Ye,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Vs.subVectors(t,this.center);let e=Vs.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Vs,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Wl.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Vs.copy(t.center).add(Wl)),this.expandByPoint(Vs.copy(t.center).sub(Wl))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}},pm=0,un=new Jt,Xl=new Ve,is=new I,on=new oe,Gs=new oe,Be=new I,de=class i extends Ln{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:pm++}),this.uuid=Jn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(Op(t)?tr:Qs)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new qt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return un.makeRotationFromQuaternion(t),this.applyMatrix4(un),this}rotateX(t){return un.makeRotationX(t),this.applyMatrix4(un),this}rotateY(t){return un.makeRotationY(t),this.applyMatrix4(un),this}rotateZ(t){return un.makeRotationZ(t),this.applyMatrix4(un),this}translate(t,e,n){return un.makeTranslation(t,e,n),this.applyMatrix4(un),this}scale(t,e,n){return un.makeScale(t,e,n),this.applyMatrix4(un),this}lookAt(t){return Xl.lookAt(t),Xl.updateMatrix(),this.applyMatrix4(Xl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(is).negate(),this.translate(is.x,is.y,is.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let s=0,r=t.length;se.count&&zt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new oe);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Ht("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new I(-1/0,-1/0,-1/0),new I(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n0&&(t.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let l in n){let c=n[l];t.data.attributes[l]=c.toJSON(t.data)}let s={},r=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d0&&(s[l]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone());let s=t.attributes;for(let c in s){let h=s[c];this.setAttribute(c,h.clone(e))}let r=t.morphAttributes;for(let c in r){let h=[],d=r[c];for(let u=0,f=d.length;u1)?null:e.copy(t.start).addScaledVector(s,o)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||gm.getNormalMatrix(t),s=this.coplanarPoint(ql).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(t){return this.normal.fromArray(t.normal),this.constant=t.constant,this}},_m=0,Dn=class extends Ln{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:_m++}),this.uuid=Jn(),this.name="",this.type="Material",this.blending=As,this.side=zn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=dc,this.blendDst=fc,this.blendEquation=zi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Vt(0,0,0),this.blendAlpha=0,this.depthFunc=us,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=rd,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=yo,this.stencilZFail=yo,this.stencilZPass=yo,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){zt(`Material: parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){zt(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(r=>r.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let o=[];for(let a in r){let l=r[a];delete l.metadata,o.push(l)}return o}if(e){let r=s(t.textures),o=s(t.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}fromJSON(t,e){if(t.uuid!==void 0&&(this.uuid=t.uuid),t.name!==void 0&&(this.name=t.name),t.color!==void 0&&this.color!==void 0&&this.color.setHex(t.color),t.roughness!==void 0&&(this.roughness=t.roughness),t.metalness!==void 0&&(this.metalness=t.metalness),t.sheen!==void 0&&(this.sheen=t.sheen),t.sheenColor!==void 0&&(this.sheenColor=new Vt().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(this.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(t.emissive),t.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(t.specular),t.specularIntensity!==void 0&&(this.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(this.shininess=t.shininess),t.clearcoat!==void 0&&(this.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(this.dispersion=t.dispersion),t.retroreflectivity!==void 0&&(this.retroreflectivity=t.retroreflectivity),t.iridescence!==void 0&&(this.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(this.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(this.transmission=t.transmission),t.thickness!==void 0&&(this.thickness=t.thickness),t.attenuationDistance!==void 0&&(this.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(this.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(this.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(this.fog=t.fog),t.flatShading!==void 0&&(this.flatShading=t.flatShading),t.blending!==void 0&&(this.blending=t.blending),t.combine!==void 0&&(this.combine=t.combine),t.side!==void 0&&(this.side=t.side),t.shadowSide!==void 0&&(this.shadowSide=t.shadowSide),t.opacity!==void 0&&(this.opacity=t.opacity),t.transparent!==void 0&&(this.transparent=t.transparent),t.alphaTest!==void 0&&(this.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(this.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(this.depthFunc=t.depthFunc),t.depthTest!==void 0&&(this.depthTest=t.depthTest),t.depthWrite!==void 0&&(this.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(this.colorWrite=t.colorWrite),t.clippingPlanes!==void 0&&(this.clippingPlanes=t.clippingPlanes.map(n=>new we().fromJSON(n))),t.clipIntersection!==void 0&&(this.clipIntersection=t.clipIntersection),t.clipShadows!==void 0&&(this.clipShadows=t.clipShadows),t.depthPacking!==void 0&&(this.depthPacking=t.depthPacking),t.blendSrc!==void 0&&(this.blendSrc=t.blendSrc),t.blendDst!==void 0&&(this.blendDst=t.blendDst),t.blendEquation!==void 0&&(this.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(this.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(this.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(this.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(this.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(this.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(this.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(this.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(this.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(this.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(this.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(this.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(this.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(this.rotation=t.rotation),t.linewidth!==void 0&&(this.linewidth=t.linewidth),t.linecap!==void 0&&(this.linecap=t.linecap),t.linejoin!==void 0&&(this.linejoin=t.linejoin),t.dashSize!==void 0&&(this.dashSize=t.dashSize),t.gapSize!==void 0&&(this.gapSize=t.gapSize),t.scale!==void 0&&(this.scale=t.scale),t.polygonOffset!==void 0&&(this.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(this.dithering=t.dithering),t.alphaToCoverage!==void 0&&(this.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(this.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(this.allowOverride=t.allowOverride),t.visible!==void 0&&(this.visible=t.visible),t.toneMapped!==void 0&&(this.toneMapped=t.toneMapped),t.userData!==void 0&&(this.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),t.size!==void 0&&(this.size=t.size),t.sizeAttenuation!==void 0&&(this.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(this.map=e[t.map]||null),t.matcap!==void 0&&(this.matcap=e[t.matcap]||null),t.alphaMap!==void 0&&(this.alphaMap=e[t.alphaMap]||null),t.bumpMap!==void 0&&(this.bumpMap=e[t.bumpMap]||null),t.bumpScale!==void 0&&(this.bumpScale=t.bumpScale),t.normalMap!==void 0&&(this.normalMap=e[t.normalMap]||null),t.normalMapType!==void 0&&(this.normalMapType=t.normalMapType),t.normalScale!==void 0){let n=t.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new $t().fromArray(n)}return t.displacementMap!==void 0&&(this.displacementMap=e[t.displacementMap]||null),t.displacementScale!==void 0&&(this.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(this.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(this.roughnessMap=e[t.roughnessMap]||null),t.metalnessMap!==void 0&&(this.metalnessMap=e[t.metalnessMap]||null),t.emissiveMap!==void 0&&(this.emissiveMap=e[t.emissiveMap]||null),t.emissiveIntensity!==void 0&&(this.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(this.specularMap=e[t.specularMap]||null),t.specularIntensityMap!==void 0&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),t.specularColorMap!==void 0&&(this.specularColorMap=e[t.specularColorMap]||null),t.envMap!==void 0&&(this.envMap=e[t.envMap]||null),t.envMapRotation!==void 0&&this.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(this.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(this.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(this.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(this.lightMap=e[t.lightMap]||null),t.lightMapIntensity!==void 0&&(this.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(this.aoMap=e[t.aoMap]||null),t.aoMapIntensity!==void 0&&(this.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(this.gradientMap=e[t.gradientMap]||null),t.clearcoatMap!==void 0&&(this.clearcoatMap=e[t.clearcoatMap]||null),t.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),t.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),t.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new $t().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(this.iridescenceMap=e[t.iridescenceMap]||null),t.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),t.transmissionMap!==void 0&&(this.transmissionMap=e[t.transmissionMap]||null),t.thicknessMap!==void 0&&(this.thicknessMap=e[t.thicknessMap]||null),t.anisotropyMap!==void 0&&(this.anisotropyMap=e[t.anisotropyMap]||null),t.sheenColorMap!==void 0&&(this.sheenColorMap=e[t.sheenColorMap]||null),t.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}};var $n=new I,Yl=new I,jr=new I,Qr=new I,Ui=class{constructor(t=new I,e=new I(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,$n)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=$n.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):($n.copy(this.origin).addScaledVector(this.direction,e),$n.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){Yl.copy(t).add(e).multiplyScalar(.5),jr.copy(e).sub(t).normalize(),Qr.copy(this.origin).sub(Yl);let r=t.distanceTo(e)*.5,o=-this.direction.dot(jr),a=Qr.dot(this.direction),l=-Qr.dot(jr),c=Qr.lengthSq(),h=Math.abs(1-o*o),d,u,f,g;if(h>0)if(d=o*l-a,u=o*a-l,g=r*h,d>=0)if(u>=-g)if(u<=g){let _=1/h;d*=_,u*=_,f=d*(d+o*u+2*a)+u*(o*d+u+2*l)+c}else u=r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u<=-g?(d=Math.max(0,-(-o*r+a)),u=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c):u<=g?(d=0,u=Math.min(Math.max(-r,-l),r),f=u*(u+2*l)+c):(d=Math.max(0,-(o*r+a)),u=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c);else u=o>0?-r:r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(Yl).addScaledVector(jr,u),f}intersectSphere(t,e){if(t.radius<0)return null;$n.subVectors(t.center,this.origin);let n=$n.dot(this.direction),s=$n.dot($n)-n*n,r=t.radius*t.radius;if(s>r)return null;let o=Math.sqrt(r-s),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,o,a,l,c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(n=(t.min.x-u.x)*c,s=(t.max.x-u.x)*c):(n=(t.max.x-u.x)*c,s=(t.min.x-u.x)*c),h>=0?(r=(t.min.y-u.y)*h,o=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,o=(t.min.y-u.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o=0?(a=(t.min.z-u.z)*d,l=(t.max.z-u.z)*d):(a=(t.max.z-u.z)*d,l=(t.min.z-u.z)*d),n>l||a>s)||((a>n||n!==n)&&(n=a),(l=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,$n)!==null}intersectTriangle(t,e,n,s,r){let o=this.origin,a=this.direction,l=a.x,c=a.y,h=a.z,d=t.x-o.x,u=t.y-o.y,f=t.z-o.z,g=e.x-o.x,_=e.y-o.y,m=e.z-o.z,p=n.x-o.x,b=n.y-o.y,w=n.z-o.z,v=Math.abs(l),y=Math.abs(c),S=Math.abs(h),A,x,T,R,D,F,U,C,B,W,q,O;if(v>=y&&v>=S?(T=l,F=d,B=g,O=p,l>=0?(A=c,x=h,R=u,D=f,U=_,C=m,W=b,q=w):(A=h,x=c,R=f,D=u,U=m,C=_,W=w,q=b)):y>=S?(T=c,F=u,B=_,O=b,c>=0?(A=h,x=l,R=f,D=d,U=m,C=g,W=w,q=p):(A=l,x=h,R=d,D=f,U=g,C=m,W=p,q=w)):(T=h,F=f,B=m,O=w,h>=0?(A=l,x=c,R=d,D=u,U=g,C=_,W=p,q=b):(A=c,x=l,R=u,D=d,U=_,C=g,W=b,q=p)),T===0)return null;let L=A/T,H=x/T,X=1/T,z=R-L*F,Q=D-H*F,lt=U-L*B,ut=C-H*B,ct=W-L*O,G=q-H*O,tt=ct*ut-G*lt,rt=z*G-Q*ct,yt=lt*Q-ut*z;if(s){if(tt<0||rt<0||yt<0)return null}else if((tt<0||rt<0||yt<0)&&(tt>0||rt>0||yt>0))return null;let ft=tt+rt+yt;if(ft===0)return null;let Ot=X*(tt*F+rt*B+yt*O);return(ft>0?Ot<0:Ot>0)?null:this.at(Ot/ft,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ke=class extends Dn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Vt(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 jn,this.combine=ea,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},fu=new Jt,Li=new Ui,to=new Ge,pu=new I,eo=new I,no=new I,io=new I,$l=new I,so=new I,mu=new I,ro=new I,_e=class extends Ve{constructor(t=new de,e=new Ke){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r(t.far-t.near)**2))&&(fu.copy(r).invert(),Li.copy(t.ray).applyMatrix4(fu),!(n.boundingBox!==null&&Li.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Li)))}_computeIntersections(t,e,n){let s,r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,_=u.length;g<_;g++){let m=u[g],p=o[m.materialIndex],b=Math.max(m.start,f.start),w=Math.min(a.count,Math.min(m.start+m.count,f.start+f.count));for(let v=b,y=w;ve.far?null:{distance:c,point:ro.clone(),object:i}}function oo(i,t,e,n,s,r,o,a,l,c){i.getVertexPosition(a,eo),i.getVertexPosition(l,no),i.getVertexPosition(c,io);let h=xm(i,t,e,n,eo,no,io,mu);if(h){let d=new I;Zn.getBarycoord(mu,eo,no,io,d),s&&(h.uv=Zn.getInterpolatedAttribute(s,a,l,c,d,new $t)),r&&(h.uv1=Zn.getInterpolatedAttribute(r,a,l,c,d,new $t)),o&&(h.normal=Zn.getInterpolatedAttribute(o,a,l,c,d,new I),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a,b:l,c,normal:new I,materialIndex:0};Zn.getNormal(eo,no,io,u.normal),h.face=u,h.barycoord=d}return h}var Nn=class extends ke{constructor(t=null,e=1,n=1,s,r,o,a,l,c=ze,h=ze,d,u){super(null,o,a,l,c,h,s,r,d,u),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var ti=class extends Ae{constructor(t,e,n,s=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}},ss=new Jt,gu=new Jt,ao=[],_u=new oe,vm=new Jt,Ws=new _e,Xs=new Ge,Ms=class extends _e{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new ti(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let s=0;s0?t.max.x:t.min.x,lo.y=s.normal.y>0?t.max.y:t.min.y,lo.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(lo)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var an=class extends Dn{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Vt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},Uo=new I,Fo=new I,xu=new Jt,qs=new Ui,co=new Ge,Zl=new I,vu=new I,Fi=class extends Ve{constructor(t=new de,e=new an){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let s=1,r=e.count;s0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;rn)return;Zl.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(Zl);if(!(ct.far))return{distance:c,point:vu.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var yu=new I,Mu=new I,vn=class extends Fi{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let s=0,r=e.count;s0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;rs.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var nr=class extends ke{constructor(t=[],e=vi,n,s,r,o,a,l,c,h){super(t,e,n,s,r,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},ir=class extends ke{constructor(t,e,n,s,r,o,a,l,c){super(t,e,n,s,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}};var pi=class extends ke{constructor(t,e,n=bn,s,r,o,a=ze,l=ze,c,h=Pn,d=1){if(h!==Pn&&h!==Mi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let u={width:t,height:e,depth:d};super(u,s,r,o,a,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new _s(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return e.compareFunction=this.compareFunction,e}},Bo=class extends pi{constructor(t,e=bn,n=vi,s,r,o=ze,a=ze,l,c=Pn){let h={width:t,height:t,depth:1},d=[h,h,h,h,h,h];super(t,t,e,n,s,r,o,a,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}},sr=class extends ke{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}},dn=class i extends de{constructor(t=1,e=1,n=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:o};let a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);let l=[],c=[],h=[],d=[],u=0,f=0;g("z","y","x",-1,-1,n,e,t,o,r,0),g("z","y","x",1,-1,n,e,-t,o,r,1),g("x","z","y",1,1,t,n,e,s,o,2),g("x","z","y",1,-1,t,n,-e,s,o,3),g("x","y","z",1,-1,t,e,n,s,r,4),g("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new ye(c,3)),this.setAttribute("normal",new ye(h,3)),this.setAttribute("uv",new ye(d,2));function g(_,m,p,b,w,v,y,S,A,x,T){let R=v/A,D=y/x,F=v/2,U=y/2,C=S/2,B=A+1,W=x+1,q=0,O=0,L=new I;for(let H=0;H0?1:-1,h.push(L.x,L.y,L.z),d.push(z/A),d.push(1-H/x),q+=1}}for(let H=0;H0&&w(!0),e>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new ye(d,3)),this.setAttribute("normal",new ye(u,3)),this.setAttribute("uv",new ye(f,2));function b(){let v=new I,y=new I,S=0,A=(e-t)/n;for(let x=0;x<=r;x++){let T=[],R=x/r,D=R*(e-t)+t;for(let F=0;F<=s;F++){let U=F/s,C=U*l+a,B=Math.sin(C),W=Math.cos(C);y.x=D*B,y.y=-R*n+m,y.z=D*W,d.push(y.x,y.y,y.z),v.set(B,A,W).normalize(),u.push(v.x,v.y,v.z),f.push(U,1-R),T.push(g++)}_.push(T)}for(let x=0;x0||T!==0)&&(h.push(R,D,U),S+=3),(e>0||T!==r-1)&&(h.push(D,F,U),S+=3)}c.addGroup(p,S,0),p+=S}function w(v){let y=g,S=new $t,A=new I,x=0,T=v===!0?t:e,R=v===!0?1:-1;for(let F=1;F<=s;F++)d.push(0,m*R,0),u.push(0,R,0),f.push(.5,.5),g++;let D=g;for(let F=0;F<=s;F++){let C=F/s*l+a,B=Math.cos(C),W=Math.sin(C);A.x=T*W,A.y=m*R,A.z=T*B,d.push(A.x,A.y,A.z),u.push(0,R,0),S.x=B*.5+.5,S.y=W*.5*R+.5,f.push(S.x,S.y),g++}for(let F=0;F0)&&f.push(w,v,S),(p!==n-1||l{var tu=i=>{throw TypeError(i)};var Pl=(i,t,e)=>t.has(i)||tu("Cannot "+e);var hi=(i,t,e)=>(Pl(i,t,"read from private field"),e?e.call(i):t.get(i)),Ll=(i,t,e)=>t.has(i)?tu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),eu=(i,t,e,n)=>(Pl(i,t,"write to private field"),n?n.call(i,e):t.set(i,e),e),Zr=(i,t,e)=>(Pl(i,t,"access private method"),e);var Uu=0,uc=1,Fu=2;var mr=1,Bu=2,Ts=3,Hn=0,De=1,Ne=2,Vn=0,As=1,dc=2,fc=3,pc=4,Ou=5;var ki=100,zu=101,ku=102,Hu=103,Vu=104,Gu=200,Wu=201,Xu=202,qu=203,mc=204,gc=205,Yu=206,$u=207,Zu=208,Ju=209,Ku=210,ju=211,Qu=212,td=213,ed=214,Ao=0,Ro=1,Co=2,ds=3,Io=4,Po=5,Lo=6,Do=7,gr=0,nd=1,id=2,bn=0,_c=1,xc=2,vc=3,yc=4,Mc=5,bc=6,Sc=7;var wc=300,Mi=301,Hi=302,oa=303,aa=304,_r=306,fs=1e3,Pn=1001,No=1002,ke=1003,sd=1004;var xr=1005;var Xe=1006,la=1007;var bi=1008;var nn=1009,Ec=1010,Tc=1011,Rs=1012,ca=1013,Sn=1014,Ye=1015,wn=1016,ha=1017,ua=1018,Cs=1020,Ac=35902,Rc=35899,Cc=1021,Ic=1022,sn=1023,Ln=1026,Si=1027,Is=1028,da=1029,wi=1030,fa=1031;var pa=1033,vr=33776,yr=33777,Mr=33778,br=33779,ma=35840,ga=35841,_a=35842,xa=35843,va=36196,ya=37492,Ma=37496,ba=37488,Sa=37489,Sr=37490,wa=37491,Ea=37808,Ta=37809,Aa=37810,Ra=37811,Ca=37812,Ia=37813,Pa=37814,La=37815,Da=37816,Na=37817,Ua=37818,Fa=37819,Ba=37820,Oa=37821,za=36492,ka=36494,Ha=36495,Va=36283,Ga=36284,wr=36285,Wa=36286;var Zs=2300,Uo=2301,wo=2302,nc=2303,ic=2400,sc=2401,rc=2402;var rd=3200;var Er=0,od=1,ii="",Te="srgb",Js="srgb-linear",Ks="linear",ue="srgb";var Eo=7680;var Pc=34055,Lc=34056;var Dc=517;var ad=519,ld=512,cd=513,hd=514,Xa=515,ud=516,dd=517,qa=518,fd=519,Nc=35044,Tr=35048;var Uc="300 es",xn=2e3,ps=2001;function Hp(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function Vp(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function ms(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function pd(){let i=ms("canvas");return i.style.display="block",i}var nu={},gs=null;function js(...i){let t="THREE."+i.shift();gs?gs("log",t,...i):console.log(t,...i)}function md(i){let t=i[0];if(typeof t=="string"&&t.startsWith("TSL:")){let e=i[1];e&&e.isStackTrace?i[0]+=" "+e.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Ht(...i){i=md(i);let t="THREE."+i.shift();if(gs)gs("warn",t,...i);else{let e=i[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...i)}}function Wt(...i){i=md(i);let t="THREE."+i.shift();if(gs)gs("error",t,...i);else{let e=i[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...i)}}function Ui(...i){let t=i.join(" ");t in nu||(nu[t]=!0,Ht(...i))}function gd(i,t,e){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}var _d={[Ao]:Ro,[Co]:Lo,[Io]:Do,[ds]:Po,[Ro]:Ao,[Lo]:Co,[Do]:Io,[Po]:ds},Dn=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){let n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){let n=this._listeners;if(n===void 0)return;let s=n[t];if(s!==void 0){let r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let n=e[t.type];if(n!==void 0){t.target=this;let s=n.slice(0);for(let r=0,o=s.length;r>8&255]+Ze[i>>16&255]+Ze[i>>24&255]+"-"+Ze[t&255]+Ze[t>>8&255]+"-"+Ze[t>>16&15|64]+Ze[t>>24&255]+"-"+Ze[e&63|128]+Ze[e>>8&255]+"-"+Ze[e>>16&255]+Ze[e>>24&255]+Ze[n&255]+Ze[n>>8&255]+Ze[n>>16&255]+Ze[n>>24&255]).toLowerCase()}function ee(i,t,e){return Math.max(t,Math.min(e,i))}function Fc(i,t){return(i%t+t)%t}function Gp(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function Wp(i,t,e){return i!==t?(e-i)/(t-i):0}function $s(i,t,e){return(1-e)*i+e*t}function Xp(i,t,e,n){return $s(i,t,1-Math.exp(-e*n))}function qp(i,t=1){return t-Math.abs(Fc(i,t*2)-t)}function Yp(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function $p(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Zp(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Jp(i,t){return i+Math.random()*(t-i)}function Kp(i){return i*(.5-Math.random())}function jp(i){i!==void 0&&(iu=i);let t=iu+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Qp(i){return i*hs}function tm(i){return i*_s}function em(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function nm(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function im(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function sm(i,t,e,n,s){let r=Math.cos,o=Math.sin,a=r(e/2),l=o(e/2),c=r((t+n)/2),h=o((t+n)/2),d=r((t-n)/2),u=o((t-n)/2),f=r((n-t)/2),g=o((n-t)/2);switch(s){case"XYX":i.set(a*h,l*d,l*u,a*c);break;case"YZY":i.set(l*u,a*h,l*d,a*c);break;case"ZXZ":i.set(l*d,l*u,a*h,a*c);break;case"XZX":i.set(a*h,l*g,l*f,a*c);break;case"YXY":i.set(l*f,a*h,l*g,a*c);break;case"ZYZ":i.set(l*g,l*f,a*h,a*c);break;default:Ht("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function _n(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:case Uint8ClampedArray:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function de(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}var ae={DEG2RAD:hs,RAD2DEG:_s,generateUUID:jn,clamp:ee,euclideanModulo:Fc,mapLinear:Gp,inverseLerp:Wp,lerp:$s,damp:Xp,pingpong:qp,smoothstep:Yp,smootherstep:$p,randInt:Zp,randFloat:Jp,randFloatSpread:Kp,seededRandom:jp,degToRad:Qp,radToDeg:tm,isPowerOfTwo:em,ceilPowerOfTwo:nm,floorPowerOfTwo:im,setQuaternionFromProperEuler:sm,normalize:de,denormalize:_n},Hc=class Hc{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=ee(this.x,t.x,e.x),this.y=ee(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=ee(this.x,t,e),this.y=ee(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ee(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(ee(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*n-o*s+t.x,this.y=r*s+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Hc.prototype.isVector2=!0;var Xt=Hc,Le=class{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,o,a){let l=n[s+0],c=n[s+1],h=n[s+2],d=n[s+3],u=r[o+0],f=r[o+1],g=r[o+2],_=r[o+3];if(d!==_||l!==u||c!==f||h!==g){let m=l*u+c*f+h*g+d*_;m<0&&(u=-u,f=-f,g=-g,_=-_,m=-m);let p=1-a;if(m<.9995){let b=Math.acos(m),E=Math.sin(b);p=Math.sin(p*b)/E,a=Math.sin(a*b)/E,l=l*p+u*a,c=c*p+f*a,h=h*p+g*a,d=d*p+_*a}else{l=l*p+u*a,c=c*p+f*a,h=h*p+g*a,d=d*p+_*a;let b=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=b,c*=b,h*=b,d*=b}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=d}static multiplyQuaternionsFlat(t,e,n,s,r,o){let a=n[s],l=n[s+1],c=n[s+2],h=n[s+3],d=r[o],u=r[o+1],f=r[o+2],g=r[o+3];return t[e]=a*g+h*d+l*f-c*u,t[e+1]=l*g+h*u+c*d-a*f,t[e+2]=c*g+h*f+a*u-l*d,t[e+3]=h*g-a*d-l*u-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let n=t._x,s=t._y,r=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(s/2),d=a(r/2),u=l(n/2),f=l(s/2),g=l(r/2);switch(o){case"XYZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"YXZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"ZXY":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"ZYX":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"YZX":this._x=u*h*d+c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d-u*f*g;break;case"XZY":this._x=u*h*d-c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d+u*f*g;break;default:Ht("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],s=e[4],r=e[8],o=e[1],a=e[5],l=e[9],c=e[2],h=e[6],d=e[10],u=n+a+d;if(u>0){let f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(h-l)*f,this._y=(r-c)*f,this._z=(o-s)*f}else if(n>a&&n>d){let f=2*Math.sqrt(1+n-a-d);this._w=(h-l)/f,this._x=.25*f,this._y=(s+o)/f,this._z=(r+c)/f}else if(a>d){let f=2*Math.sqrt(1+a-n-d);this._w=(r-c)/f,this._x=(s+o)/f,this._y=.25*f,this._z=(l+h)/f}else{let f=2*Math.sqrt(1+d-n-a);this._w=(o-s)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ee(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let n=t._x,s=t._y,r=t._z,o=t._w,a=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+o*a+s*c-r*l,this._y=s*h+o*l+r*a-n*c,this._z=r*h+o*c+n*l-s*a,this._w=o*h-n*a-s*l-r*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,s=t._y,r=t._z,o=t._w,a=this.dot(t);a<0&&(n=-n,s=-s,r=-r,o=-o,a=-a);let l=1-e;if(a<.9995){let c=Math.acos(a),h=Math.sin(c);l=Math.sin(l*c)/h,e=Math.sin(e*c)/h,this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+o*e,this._onChangeCallback()}else this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+o*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Vc=class Vc{constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(su.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(su.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=t.elements,o=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*o,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*o,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*o,this}applyQuaternion(t){let e=this.x,n=this.y,s=this.z,r=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*s-a*n),h=2*(a*e-r*s),d=2*(r*n-o*e);return this.x=e+l*c+o*d-a*h,this.y=n+l*h+a*c-r*d,this.z=s+l*d+r*h-o*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=ee(this.x,t.x,e.x),this.y=ee(this.y,t.y,e.y),this.z=ee(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=ee(this.x,t,e),this.y=ee(this.y,t,e),this.z=ee(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ee(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,s=t.y,r=t.z,o=e.x,a=e.y,l=e.z;return this.x=s*l-r*a,this.y=r*o-n*l,this.z=n*a-s*o,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Dl.copy(this).projectOnVector(t),this.sub(Dl)}reflect(t){return this.sub(Dl.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(ee(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Vc.prototype.isVector3=!0;var L=Vc,Dl=new L,su=new Le,Gc=class Gc{constructor(t,e,n,s,r,o,a,l,c){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,o,a,l,c)}set(t,e,n,s,r,o,a,l,c){let h=this.elements;return h[0]=t,h[1]=s,h[2]=a,h[3]=e,h[4]=r,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],d=n[7],u=n[2],f=n[5],g=n[8],_=s[0],m=s[3],p=s[6],b=s[1],E=s[4],v=s[7],y=s[2],S=s[5],A=s[8];return r[0]=o*_+a*b+l*y,r[3]=o*m+a*E+l*S,r[6]=o*p+a*v+l*A,r[1]=c*_+h*b+d*y,r[4]=c*m+h*E+d*S,r[7]=c*p+h*v+d*A,r[2]=u*_+f*b+g*y,r[5]=u*m+f*E+g*S,r[8]=u*p+f*v+g*A,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e*o*h-e*a*c-n*r*h+n*a*l+s*r*c-s*o*l}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],d=h*o-a*c,u=a*l-h*r,f=c*r-o*l,g=e*d+n*u+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let _=1/g;return t[0]=d*_,t[1]=(s*c-h*n)*_,t[2]=(a*n-s*o)*_,t[3]=u*_,t[4]=(h*e-s*l)*_,t[5]=(s*r-a*e)*_,t[6]=f*_,t[7]=(n*l-c*e)*_,t[8]=(o*e-n*r)*_,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,o,a){let l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*o+c*a)+o+t,-s*c,s*l,-s*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return Ui("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Nl.makeScale(t,e)),this}rotate(t){return Ui("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Nl.makeRotation(-t)),this}translate(t,e){return Ui("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Nl.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}};Gc.prototype.isMatrix3=!0;var qt=Gc,Nl=new qt,ru=new qt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ou=new qt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function rm(){let i={enabled:!0,workingColorSpace:Js,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===ue&&(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===ue&&(s.r=us(s.r),s.g=us(s.g),s.b=us(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===ii?Ks: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[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Ui("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ui("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Js]:{primaries:t,whitePoint:n,transfer:Ks,toXYZ:ru,fromXYZ:ou,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Te},outputColorSpaceConfig:{drawingBufferColorSpace:Te}},[Te]:{primaries:t,whitePoint:n,transfer:ue,toXYZ:ru,fromXYZ:ou,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Te}}}),i}var te=rm();function Qn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function us(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Zi,Fo=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{Zi===void 0&&(Zi=ms("canvas")),Zi.width=t.width,Zi.height=t.height;let s=Zi.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=Zi}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=ms("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let o=0;o1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Fl).x}get height(){return this.source.getSize(Fl).y}get depth(){return this.source.getSize(Fl).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let n=t[e];if(n===void 0){Ht(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){Ht(`Texture.setValues(): property '${e}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==wc)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case fs:t.x=t.x-Math.floor(t.x);break;case Pn:t.x=t.x<0?0:1;break;case No:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case fs:t.y=t.y-Math.floor(t.y);break;case Pn:t.y=t.y<0?0:1;break;case No:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};He.DEFAULT_IMAGE=null;He.DEFAULT_MAPPING=wc;He.DEFAULT_ANISOTROPY=1;var Wc=class Wc{constructor(t=0,e=0,n=0,s=1){this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*s+o[12]*r,this.y=o[1]*e+o[5]*n+o[9]*s+o[13]*r,this.z=o[2]*e+o[6]*n+o[10]*s+o[14]*r,this.w=o[3]*e+o[7]*n+o[11]*s+o[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r,l=t.elements,c=l[0],h=l[4],d=l[8],u=l[1],f=l[5],g=l[9],_=l[2],m=l[6],p=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-_)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+_)<.1&&Math.abs(g+m)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let E=(c+1)/2,v=(f+1)/2,y=(p+1)/2,S=(h+u)/4,A=(d+_)/4,x=(g+m)/4;return E>v&&E>y?E<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(E),s=S/n,r=A/n):v>y?v<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(v),n=S/s,r=x/s):y<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(y),n=A/r,s=x/r),this.set(n,s,r,e),this}let b=Math.sqrt((m-g)*(m-g)+(d-_)*(d-_)+(u-h)*(u-h));return Math.abs(b)<.001&&(b=1),this.x=(m-g)/b,this.y=(d-_)/b,this.z=(u-h)/b,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=ee(this.x,t.x,e.x),this.y=ee(this.y,t.y,e.y),this.z=ee(this.z,t.z,e.z),this.w=ee(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=ee(this.x,t,e),this.y=ee(this.y,t,e),this.z=ee(this.z,t,e),this.w=ee(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ee(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};Wc.prototype.isVector4=!0;var ge=Wc,Bo=class extends Dn{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xe,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new ge(0,0,t,e),this.scissorTest=!1,this.viewport=new ge(0,0,t,e),this.textures=[];let s={width:t,height:e,depth:n.depth},r=new He(s),o=n.count;for(let a=0;a1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let n=0;n0&&(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(t),s.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c0){s.children=[];for(let a=0;a0){s.animations=[];for(let a=0;a0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=s,n;function o(a){let l=[];for(let c in a){let h=a[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;nf+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&u<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:t,target:this})));a!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,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(pm)))}return a!==null&&(a.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new Re;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},xd={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},di={h:0,s:0,l:0},jr={h:0,s:0,l:0};function Ol(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}var Vt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Te){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,te.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=te.workingColorSpace){return this.r=t,this.g=e,this.b=n,te.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=te.workingColorSpace){if(t=Fc(t,1),e=ee(e,0,1),n=ee(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,o=2*n-r;this.r=Ol(o,r,t+1/3),this.g=Ol(o,r,t),this.b=Ol(o,r,t-1/3)}return te.colorSpaceToWorking(this,s),this}setStyle(t,e=Te){function n(r){r!==void 0&&parseFloat(r)<1&&Ht("Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){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+)\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,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:Ht("Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){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,e);if(o===6)return this.setHex(parseInt(r,16),e);Ht("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Te){let n=xd[t.toLowerCase()];return n!==void 0?this.setHex(n,e):Ht("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Qn(t.r),this.g=Qn(t.g),this.b=Qn(t.b),this}copyLinearToSRGB(t){return this.r=us(t.r),this.g=us(t.g),this.b=us(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Te){return te.workingToColorSpace(Je.copy(this),t),Math.round(ee(Je.r*255,0,255))*65536+Math.round(ee(Je.g*255,0,255))*256+Math.round(ee(Je.b*255,0,255))}getHexString(t=Te){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=te.workingColorSpace){te.workingToColorSpace(Je.copy(this),e);let n=Je.r,s=Je.g,r=Je.b,o=Math.max(n,s,r),a=Math.min(n,s,r),l,c,h=(a+o)/2;if(a===o)l=0,c=0;else{let d=o-a;switch(c=h<=.5?d/(o+a):d/(2-o-a),o){case n:l=(s-r)/d+(s0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){mn.subVectors(s,e),Yn.subVectors(n,e),zl.subVectors(t,e);let o=mn.dot(mn),a=mn.dot(Yn),l=mn.dot(zl),c=Yn.dot(Yn),h=Yn.dot(zl),d=o*c-a*a;if(d===0)return r.set(0,0,0),null;let u=1/d,f=(c*l-a*h)*u,g=(o*h-a*l)*u;return r.set(1-f-g,g,f)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,$n)===null?!1:$n.x>=0&&$n.y>=0&&$n.x+$n.y<=1}static getInterpolation(t,e,n,s,r,o,a,l){return this.getBarycoord(t,e,n,s,$n)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,$n.x),l.addScaledVector(o,$n.y),l.addScaledVector(a,$n.z),l)}static getInterpolatedAttribute(t,e,n,s,r,o){return Gl.setScalar(0),Wl.setScalar(0),Xl.setScalar(0),Gl.fromBufferAttribute(t,e),Wl.fromBufferAttribute(t,n),Xl.fromBufferAttribute(t,s),o.setScalar(0),o.addScaledVector(Gl,r.x),o.addScaledVector(Wl,r.y),o.addScaledVector(Xl,r.z),o}static isFrontFacing(t,e,n,s){return mn.subVectors(n,e),Yn.subVectors(t,e),mn.cross(Yn).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return mn.subVectors(this.c,this.b),Yn.subVectors(this.a,this.b),mn.cross(Yn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return i.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return i.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return i.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return i.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return i.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,s=this.b,r=this.c,o,a;Qi.subVectors(s,n),ts.subVectors(r,n),kl.subVectors(t,n);let l=Qi.dot(kl),c=ts.dot(kl);if(l<=0&&c<=0)return e.copy(n);Hl.subVectors(t,s);let h=Qi.dot(Hl),d=ts.dot(Hl);if(h>=0&&d<=h)return e.copy(s);let u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return o=l/(l-h),e.copy(n).addScaledVector(Qi,o);Vl.subVectors(t,r);let f=Qi.dot(Vl),g=ts.dot(Vl);if(g>=0&&f<=g)return e.copy(r);let _=f*c-l*g;if(_<=0&&c>=0&&g<=0)return a=c/(c-g),e.copy(n).addScaledVector(ts,a);let m=h*g-f*d;if(m<=0&&d-h>=0&&f-g>=0)return pu.subVectors(r,s),a=(d-h)/(d-h+(f-g)),e.copy(s).addScaledVector(pu,a);let p=1/(m+_+u);return o=_*p,a=u*p,e.copy(n).addScaledVector(Qi,o).addScaledVector(ts,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},le=class{constructor(t=new L(1/0,1/0,1/0),e=new L(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,gn),gn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Vs),to.subVectors(this.max,Vs),es.subVectors(t.a,Vs),ns.subVectors(t.b,Vs),is.subVectors(t.c,Vs),fi.subVectors(ns,es),pi.subVectors(is,ns),Pi.subVectors(es,is);let e=[0,-fi.z,fi.y,0,-pi.z,pi.y,0,-Pi.z,Pi.y,fi.z,0,-fi.x,pi.z,0,-pi.x,Pi.z,0,-Pi.x,-fi.y,fi.x,0,-pi.y,pi.x,0,-Pi.y,Pi.x,0];return!ql(e,es,ns,is,to)||(e=[1,0,0,0,1,0,0,0,1],!ql(e,es,ns,is,to))?!1:(eo.crossVectors(fi,pi),e=[eo.x,eo.y,eo.z],ql(e,es,ns,is,to))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,gn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(gn).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Zn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Zn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Zn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Zn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Zn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Zn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Zn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Zn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Zn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}},Zn=[new L,new L,new L,new L,new L,new L,new L,new L],gn=new L,Qr=new le,es=new L,ns=new L,is=new L,fi=new L,pi=new L,Pi=new L,Vs=new L,to=new L,eo=new L,Li=new L;function ql(i,t,e,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){Li.fromArray(i,r);let a=s.x*Math.abs(Li.x)+s.y*Math.abs(Li.y)+s.z*Math.abs(Li.z),l=t.dot(Li),c=e.dot(Li),h=n.dot(Li);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}var Pe=new L,no=new Xt,mm=0,Ae=class extends Dn{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:mm++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Nc,this.updateRanges=[],this.gpuType=Ye,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Gs.subVectors(t,this.center);let e=Gs.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Gs,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Yl.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Gs.copy(t.center).add(Yl)),this.expandByPoint(Gs.copy(t.center).sub(Yl))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}},_m=0,un=new Yt,$l=new Ge,ss=new L,on=new le,Ws=new le,Oe=new L,fe=class i extends Dn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:_m++}),this.uuid=jn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(Hp(t)?er:tr)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new qt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return un.makeRotationFromQuaternion(t),this.applyMatrix4(un),this}rotateX(t){return un.makeRotationX(t),this.applyMatrix4(un),this}rotateY(t){return un.makeRotationY(t),this.applyMatrix4(un),this}rotateZ(t){return un.makeRotationZ(t),this.applyMatrix4(un),this}translate(t,e,n){return un.makeTranslation(t,e,n),this.applyMatrix4(un),this}scale(t,e,n){return un.makeScale(t,e,n),this.applyMatrix4(un),this}lookAt(t){return $l.lookAt(t),$l.updateMatrix(),this.applyMatrix4($l.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ss).negate(),this.translate(ss.x,ss.y,ss.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let s=0,r=t.length;se.count&&Ht("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new le);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Wt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new L(-1/0,-1/0,-1/0),new L(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n0&&(t.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let l in n){let c=n[l];t.data.attributes[l]=c.toJSON(t.data)}let s={},r=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d0&&(s[l]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone());let s=t.attributes;for(let c in s){let h=s[c];this.setAttribute(c,h.clone(e))}let r=t.morphAttributes;for(let c in r){let h=[],d=r[c];for(let u=0,f=d.length;u1)?null:e.copy(t.start).addScaledVector(s,o)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||vm.getNormalMatrix(t),s=this.coplanarPoint(Zl).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(t){return this.normal.fromArray(t.normal),this.constant=t.constant,this}},ym=0,vn=class extends Dn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ym++}),this.uuid=jn(),this.name="",this.type="Material",this.blending=As,this.side=Hn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=mc,this.blendDst=gc,this.blendEquation=ki,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Vt(0,0,0),this.blendAlpha=0,this.depthFunc=ds,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ad,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Eo,this.stencilZFail=Eo,this.stencilZPass=Eo,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){Ht(`Material: parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){Ht(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(r=>r.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let o=[];for(let a in r){let l=r[a];delete l.metadata,o.push(l)}return o}if(e){let r=s(t.textures),o=s(t.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}fromJSON(t,e){if(t.uuid!==void 0&&(this.uuid=t.uuid),t.name!==void 0&&(this.name=t.name),t.color!==void 0&&this.color!==void 0&&this.color.setHex(t.color),t.roughness!==void 0&&(this.roughness=t.roughness),t.metalness!==void 0&&(this.metalness=t.metalness),t.sheen!==void 0&&(this.sheen=t.sheen),t.sheenColor!==void 0&&(this.sheenColor=new Vt().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(this.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(t.emissive),t.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(t.specular),t.specularIntensity!==void 0&&(this.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(this.shininess=t.shininess),t.clearcoat!==void 0&&(this.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(this.dispersion=t.dispersion),t.retroreflectivity!==void 0&&(this.retroreflectivity=t.retroreflectivity),t.iridescence!==void 0&&(this.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(this.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(this.transmission=t.transmission),t.thickness!==void 0&&(this.thickness=t.thickness),t.attenuationDistance!==void 0&&(this.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(this.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(this.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(this.fog=t.fog),t.flatShading!==void 0&&(this.flatShading=t.flatShading),t.blending!==void 0&&(this.blending=t.blending),t.combine!==void 0&&(this.combine=t.combine),t.side!==void 0&&(this.side=t.side),t.shadowSide!==void 0&&(this.shadowSide=t.shadowSide),t.opacity!==void 0&&(this.opacity=t.opacity),t.transparent!==void 0&&(this.transparent=t.transparent),t.alphaTest!==void 0&&(this.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(this.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(this.depthFunc=t.depthFunc),t.depthTest!==void 0&&(this.depthTest=t.depthTest),t.depthWrite!==void 0&&(this.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(this.colorWrite=t.colorWrite),t.clippingPlanes!==void 0&&(this.clippingPlanes=t.clippingPlanes.map(n=>new we().fromJSON(n))),t.clipIntersection!==void 0&&(this.clipIntersection=t.clipIntersection),t.clipShadows!==void 0&&(this.clipShadows=t.clipShadows),t.depthPacking!==void 0&&(this.depthPacking=t.depthPacking),t.blendSrc!==void 0&&(this.blendSrc=t.blendSrc),t.blendDst!==void 0&&(this.blendDst=t.blendDst),t.blendEquation!==void 0&&(this.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(this.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(this.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(this.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(this.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(this.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(this.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(this.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(this.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(this.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(this.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(this.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(this.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(this.rotation=t.rotation),t.linewidth!==void 0&&(this.linewidth=t.linewidth),t.linecap!==void 0&&(this.linecap=t.linecap),t.linejoin!==void 0&&(this.linejoin=t.linejoin),t.dashSize!==void 0&&(this.dashSize=t.dashSize),t.gapSize!==void 0&&(this.gapSize=t.gapSize),t.scale!==void 0&&(this.scale=t.scale),t.polygonOffset!==void 0&&(this.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(this.dithering=t.dithering),t.alphaToCoverage!==void 0&&(this.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(this.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(this.allowOverride=t.allowOverride),t.visible!==void 0&&(this.visible=t.visible),t.toneMapped!==void 0&&(this.toneMapped=t.toneMapped),t.userData!==void 0&&(this.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),t.size!==void 0&&(this.size=t.size),t.sizeAttenuation!==void 0&&(this.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(this.map=e[t.map]||null),t.matcap!==void 0&&(this.matcap=e[t.matcap]||null),t.alphaMap!==void 0&&(this.alphaMap=e[t.alphaMap]||null),t.bumpMap!==void 0&&(this.bumpMap=e[t.bumpMap]||null),t.bumpScale!==void 0&&(this.bumpScale=t.bumpScale),t.normalMap!==void 0&&(this.normalMap=e[t.normalMap]||null),t.normalMapType!==void 0&&(this.normalMapType=t.normalMapType),t.normalScale!==void 0){let n=t.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Xt().fromArray(n)}return t.displacementMap!==void 0&&(this.displacementMap=e[t.displacementMap]||null),t.displacementScale!==void 0&&(this.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(this.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(this.roughnessMap=e[t.roughnessMap]||null),t.metalnessMap!==void 0&&(this.metalnessMap=e[t.metalnessMap]||null),t.emissiveMap!==void 0&&(this.emissiveMap=e[t.emissiveMap]||null),t.emissiveIntensity!==void 0&&(this.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(this.specularMap=e[t.specularMap]||null),t.specularIntensityMap!==void 0&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),t.specularColorMap!==void 0&&(this.specularColorMap=e[t.specularColorMap]||null),t.envMap!==void 0&&(this.envMap=e[t.envMap]||null),t.envMapRotation!==void 0&&this.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(this.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(this.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(this.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(this.lightMap=e[t.lightMap]||null),t.lightMapIntensity!==void 0&&(this.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(this.aoMap=e[t.aoMap]||null),t.aoMapIntensity!==void 0&&(this.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(this.gradientMap=e[t.gradientMap]||null),t.clearcoatMap!==void 0&&(this.clearcoatMap=e[t.clearcoatMap]||null),t.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),t.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),t.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Xt().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(this.iridescenceMap=e[t.iridescenceMap]||null),t.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),t.transmissionMap!==void 0&&(this.transmissionMap=e[t.transmissionMap]||null),t.thicknessMap!==void 0&&(this.thicknessMap=e[t.thicknessMap]||null),t.anisotropyMap!==void 0&&(this.anisotropyMap=e[t.anisotropyMap]||null),t.sheenColorMap!==void 0&&(this.sheenColorMap=e[t.sheenColorMap]||null),t.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}};var Jn=new L,Jl=new L,io=new L,so=new L,Fi=class{constructor(t=new L,e=new L(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Jn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=Jn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Jn.copy(this.origin).addScaledVector(this.direction,e),Jn.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){Jl.copy(t).add(e).multiplyScalar(.5),io.copy(e).sub(t).normalize(),so.copy(this.origin).sub(Jl);let r=t.distanceTo(e)*.5,o=-this.direction.dot(io),a=so.dot(this.direction),l=-so.dot(io),c=so.lengthSq(),h=Math.abs(1-o*o),d,u,f,g;if(h>0)if(d=o*l-a,u=o*a-l,g=r*h,d>=0)if(u>=-g)if(u<=g){let _=1/h;d*=_,u*=_,f=d*(d+o*u+2*a)+u*(o*d+u+2*l)+c}else u=r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u<=-g?(d=Math.max(0,-(-o*r+a)),u=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c):u<=g?(d=0,u=Math.min(Math.max(-r,-l),r),f=u*(u+2*l)+c):(d=Math.max(0,-(o*r+a)),u=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c);else u=o>0?-r:r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(Jl).addScaledVector(io,u),f}intersectSphere(t,e){if(t.radius<0)return null;Jn.subVectors(t.center,this.origin);let n=Jn.dot(this.direction),s=Jn.dot(Jn)-n*n,r=t.radius*t.radius;if(s>r)return null;let o=Math.sqrt(r-s),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,o,a,l,c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(n=(t.min.x-u.x)*c,s=(t.max.x-u.x)*c):(n=(t.max.x-u.x)*c,s=(t.min.x-u.x)*c),h>=0?(r=(t.min.y-u.y)*h,o=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,o=(t.min.y-u.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o=0?(a=(t.min.z-u.z)*d,l=(t.max.z-u.z)*d):(a=(t.max.z-u.z)*d,l=(t.min.z-u.z)*d),n>l||a>s)||((a>n||n!==n)&&(n=a),(l=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,Jn)!==null}intersectTriangle(t,e,n,s,r){let o=this.origin,a=this.direction,l=a.x,c=a.y,h=a.z,d=t.x-o.x,u=t.y-o.y,f=t.z-o.z,g=e.x-o.x,_=e.y-o.y,m=e.z-o.z,p=n.x-o.x,b=n.y-o.y,E=n.z-o.z,v=Math.abs(l),y=Math.abs(c),S=Math.abs(h),A,x,T,C,D,U,F,I,B,G,q,O;if(v>=y&&v>=S?(T=l,U=d,B=g,O=p,l>=0?(A=c,x=h,C=u,D=f,F=_,I=m,G=b,q=E):(A=h,x=c,C=f,D=u,F=m,I=_,G=E,q=b)):y>=S?(T=c,U=u,B=_,O=b,c>=0?(A=h,x=l,C=f,D=d,F=m,I=g,G=E,q=p):(A=l,x=h,C=d,D=f,F=g,I=m,G=p,q=E)):(T=h,U=f,B=m,O=E,h>=0?(A=l,x=c,C=d,D=u,F=g,I=_,G=p,q=b):(A=c,x=l,C=u,D=d,F=_,I=g,G=b,q=p)),T===0)return null;let N=A/T,z=x/T,W=1/T,k=C-N*U,K=D-z*U,lt=F-N*B,ht=I-z*B,at=G-N*O,Y=q-z*O,tt=at*ht-Y*lt,dt=k*Y-K*at,It=lt*K-ht*k;if(s){if(tt<0||dt<0||It<0)return null}else if((tt<0||dt<0||It<0)&&(tt>0||dt>0||It>0))return null;let ot=tt+dt+It;if(ot===0)return null;let Tt=W*(tt*U+dt*B+It*O);return(ot>0?Tt<0:Tt>0)?null:this.at(Tt/ot,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ke=class extends vn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Vt(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 Nn,this.combine=gr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},mu=new Yt,Di=new Fi,ro=new We,gu=new L,oo=new L,ao=new L,lo=new L,Kl=new L,co=new L,_u=new L,ho=new L,_e=class extends Ge{constructor(t=new fe,e=new Ke){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r(t.far-t.near)**2))&&(mu.copy(r).invert(),Di.copy(t.ray).applyMatrix4(mu),!(n.boundingBox!==null&&Di.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Di)))}_computeIntersections(t,e,n){let s,r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,_=u.length;g<_;g++){let m=u[g],p=o[m.materialIndex],b=Math.max(m.start,f.start),E=Math.min(a.count,Math.min(m.start+m.count,f.start+f.count));for(let v=b,y=E;ve.far?null:{distance:c,point:ho.clone(),object:i}}function uo(i,t,e,n,s,r,o,a,l,c){i.getVertexPosition(a,oo),i.getVertexPosition(l,ao),i.getVertexPosition(c,lo);let h=Mm(i,t,e,n,oo,ao,lo,_u);if(h){let d=new L;Kn.getBarycoord(_u,oo,ao,lo,d),s&&(h.uv=Kn.getInterpolatedAttribute(s,a,l,c,d,new Xt)),r&&(h.uv1=Kn.getInterpolatedAttribute(r,a,l,c,d,new Xt)),o&&(h.normal=Kn.getInterpolatedAttribute(o,a,l,c,d,new L),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a,b:l,c,normal:new L,materialIndex:0};Kn.getNormal(oo,ao,lo,u.normal),h.face=u,h.barycoord=d}return h}var Un=class extends He{constructor(t=null,e=1,n=1,s,r,o,a,l,c=ke,h=ke,d,u){super(null,o,a,l,c,h,s,r,d,u),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var ei=class extends Ae{constructor(t,e,n,s=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}},rs=new Yt,xu=new Yt,fo=[],vu=new le,bm=new Yt,Xs=new _e,qs=new We,gi=class extends _e{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new ei(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let s=0;s0?t.max.x:t.min.x,po.y=s.normal.y>0?t.max.y:t.min.y,po.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(po)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var an=class extends vn{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Vt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},ko=new L,Ho=new L,yu=new Yt,Ys=new Fi,mo=new We,jl=new L,Mu=new L,Bi=class extends Ge{constructor(t=new fe,e=new an){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let s=1,r=e.count;s0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;rn)return;jl.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(jl);if(!(ct.far))return{distance:c,point:Mu.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var bu=new L,Su=new L,yn=class extends Bi{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let s=0,r=e.count;s0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;rs.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var ir=class extends He{constructor(t=[],e=Mi,n,s,r,o,a,l,c,h){super(t,e,n,s,r,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},sr=class extends He{constructor(t,e,n,s,r,o,a,l,c){super(t,e,n,s,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}};var _i=class extends He{constructor(t,e,n=Sn,s,r,o,a=ke,l=ke,c,h=Ln,d=1){if(h!==Ln&&h!==Si)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let u={width:t,height:e,depth:d};super(u,s,r,o,a,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new xs(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return e.compareFunction=this.compareFunction,e}},Vo=class extends _i{constructor(t,e=Sn,n=Mi,s,r,o=ke,a=ke,l,c=Ln){let h={width:t,height:t,depth:1},d=[h,h,h,h,h,h];super(t,t,e,n,s,r,o,a,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}},rr=class extends He{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}},dn=class i extends fe{constructor(t=1,e=1,n=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:o};let a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);let l=[],c=[],h=[],d=[],u=0,f=0;g("z","y","x",-1,-1,n,e,t,o,r,0),g("z","y","x",1,-1,n,e,-t,o,r,1),g("x","z","y",1,1,t,n,e,s,o,2),g("x","z","y",1,-1,t,n,-e,s,o,3),g("x","y","z",1,-1,t,e,n,s,r,4),g("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new ye(c,3)),this.setAttribute("normal",new ye(h,3)),this.setAttribute("uv",new ye(d,2));function g(_,m,p,b,E,v,y,S,A,x,T){let C=v/A,D=y/x,U=v/2,F=y/2,I=S/2,B=A+1,G=x+1,q=0,O=0,N=new L;for(let z=0;z0?1:-1,h.push(N.x,N.y,N.z),d.push(k/A),d.push(1-z/x),q+=1}}for(let z=0;z0&&E(!0),e>0&&E(!1)),this.setIndex(h),this.setAttribute("position",new ye(d,3)),this.setAttribute("normal",new ye(u,3)),this.setAttribute("uv",new ye(f,2));function b(){let v=new L,y=new L,S=0,A=(e-t)/n;for(let x=0;x<=r;x++){let T=[],C=x/r,D=C*(e-t)+t;for(let U=0;U<=s;U++){let F=U/s,I=F*l+a,B=Math.sin(I),G=Math.cos(I);y.x=D*B,y.y=-C*n+m,y.z=D*G,d.push(y.x,y.y,y.z),v.set(B,A,G).normalize(),u.push(v.x,v.y,v.z),f.push(F,1-C),T.push(g++)}_.push(T)}for(let x=0;x0||T!==0)&&(h.push(C,D,F),S+=3),(e>0||T!==r-1)&&(h.push(D,U,F),S+=3)}c.addGroup(p,S,0),p+=S}function E(v){let y=g,S=new Xt,A=new L,x=0,T=v===!0?t:e,C=v===!0?1:-1;for(let U=1;U<=s;U++)d.push(0,m*C,0),u.push(0,C,0),f.push(.5,.5),g++;let D=g;for(let U=0;U<=s;U++){let I=U/s*l+a,B=Math.cos(I),G=Math.sin(I);A.x=T*G,A.y=m*C,A.z=T*B,d.push(A.x,A.y,A.z),u.push(0,C,0),S.x=B*.5+.5,S.y=G*.5*C+.5,f.push(S.x,S.y),g++}for(let U=0;U0)&&f.push(E,v,S),(p!==n-1||l0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(let n in t.uniforms){let s=t.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=e[s.value]||null;break;case"c":this.uniforms[n].value=new Vt().setHex(s.value);break;case"v2":this.uniforms[n].value=new $t().fromArray(s.value);break;case"v3":this.uniforms[n].value=new I().fromArray(s.value);break;case"v4":this.uniforms[n].value=new ge().fromArray(s.value);break;case"m3":this.uniforms[n].value=new qt().fromArray(s.value);break;case"m4":this.uniforms[n].value=new Jt().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(t.defines!==void 0&&(this.defines=t.defines),t.vertexShader!==void 0&&(this.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(this.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(this.glslVersion=t.glslVersion),t.extensions!==void 0)for(let n in t.extensions)this.extensions[n]=t.extensions[n];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}},Oo=class extends qe{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var Ss=class extends Dn{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Vt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ha,this.normalScale=new $t(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new jn,this.combine=ea,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}},zo=class extends Dn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=id,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},ko=class extends Dn{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}};function rs(i,t){return!i||i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function Kl(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}var gi=class{constructor(t,e,n,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,s=e[n],r=e[n-1];n:{t:{let o;e:{i:if(!(t=r)){let a=e[1];t=r)break t}o=n,n=0;break e}break n}for(;n>>1;te;)--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 t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(Ht("KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Ht("KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==r;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){Ht("KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){Ht("KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(s!==void 0&&zp(s))for(let a=0,l=s.length;a!==l;++a){let c=s[a];if(isNaN(c)){Ht("KeyframeTrack: Value is not a valid number.",this,a,c),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===vo,r=t.length-1,o=1;for(let a=1;a0){t[o]=t[r];for(let a=r*n,l=o*n,c=0;c!==n;++c)e[l+c]=e[a+c];++o}return o!==t.length?(this.times=t.slice(0,o),this.values=e.slice(0,o*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,s=new n(this.name,t,e);return s.createInterpolant=this.createInterpolant,Kl(this.settings)&&(s.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),s}};function Eu(i,t){for(let e=0,n=i.length;e!==n;e+=2)i[e]*=t}ln.prototype.ValueTypeName="";ln.prototype.TimeBufferType=Float32Array;ln.prototype.ValueBufferType=Float32Array;ln.prototype.DefaultInterpolation=Io;var _i=class extends ln{constructor(t,e,n){super(t,e,n)}};_i.prototype.ValueTypeName="bool";_i.prototype.ValueBufferType=Array;_i.prototype.DefaultInterpolation=$s;_i.prototype.InterpolantFactoryMethodLinear=void 0;_i.prototype.InterpolantFactoryMethodSmooth=void 0;var Xo=class extends ln{constructor(t,e,n,s){super(t,e,n,s)}};Xo.prototype.ValueTypeName="color";var qo=class extends ln{constructor(t,e,n,s){super(t,e,n,s)}};qo.prototype.ValueTypeName="number";var Yo=class extends gi{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(s-e),c=t*a;for(let h=c+a;c!==h;c+=4)Le.slerpFlat(r,0,o,c-a,o,c,l);return r}},or=class extends ln{constructor(t,e,n,s){super(t,e,n,s)}InterpolantFactoryMethodLinear(t){return new Yo(this.times,this.values,this.getValueSize(),t)}};or.prototype.ValueTypeName="quaternion";or.prototype.InterpolantFactoryMethodSmooth=void 0;var xi=class extends ln{constructor(t,e,n){super(t,e,n)}};xi.prototype.ValueTypeName="string";xi.prototype.ValueBufferType=Array;xi.prototype.DefaultInterpolation=$s;xi.prototype.InterpolantFactoryMethodLinear=void 0;xi.prototype.InterpolantFactoryMethodSmooth=void 0;var $o=class extends ln{constructor(t,e,n,s){super(t,e,n,s)}};$o.prototype.ValueTypeName="vector";var Mo={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(Tu(i)||(this.files[i]=t))},get:function(i){if(this.enabled!==!1&&!Tu(i))return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};function Tu(i){try{let t=i.slice(i.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}var Zo=class{constructor(t,e,n){let s=this,r=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,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"),l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){let d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=c.length;df.start-g.start);let u=0;for(let f=1;f0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(let n in t.uniforms){let s=t.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=e[s.value]||null;break;case"c":this.uniforms[n].value=new Vt().setHex(s.value);break;case"v2":this.uniforms[n].value=new Xt().fromArray(s.value);break;case"v3":this.uniforms[n].value=new L().fromArray(s.value);break;case"v4":this.uniforms[n].value=new ge().fromArray(s.value);break;case"m3":this.uniforms[n].value=new qt().fromArray(s.value);break;case"m4":this.uniforms[n].value=new Yt().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(t.defines!==void 0&&(this.defines=t.defines),t.vertexShader!==void 0&&(this.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(this.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(this.glslVersion=t.glslVersion),t.extensions!==void 0)for(let n in t.extensions)this.extensions[n]=t.extensions[n];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}},Go=class extends qe{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var ar=class extends vn{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Vt(16777215),this.specular=new Vt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Er,this.normalScale=new Xt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Nn,this.combine=gr,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}};var Ss=class extends vn{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Vt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Er,this.normalScale=new Xt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Nn,this.combine=gr,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}},Wo=class extends vn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=rd,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},Xo=class extends vn{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}};function os(i,t){return!i||i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function tc(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}var xi=class{constructor(t,e,n,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,s=e[n],r=e[n-1];n:{t:{let o;e:{i:if(!(t=r)){let a=e[1];t=r)break t}o=n,n=0;break e}break n}for(;n>>1;te;)--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 t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(Wt("KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Wt("KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==r;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){Wt("KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){Wt("KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(s!==void 0&&Vp(s))for(let a=0,l=s.length;a!==l;++a){let c=s[a];if(isNaN(c)){Wt("KeyframeTrack: Value is not a valid number.",this,a,c),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===wo,r=t.length-1,o=1;for(let a=1;a0){t[o]=t[r];for(let a=r*n,l=o*n,c=0;c!==n;++c)e[l+c]=e[a+c];++o}return o!==t.length?(this.times=t.slice(0,o),this.values=e.slice(0,o*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,s=new n(this.name,t,e);return s.createInterpolant=this.createInterpolant,tc(this.settings)&&(s.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),s}};function Au(i,t){for(let e=0,n=i.length;e!==n;e+=2)i[e]*=t}ln.prototype.ValueTypeName="";ln.prototype.TimeBufferType=Float32Array;ln.prototype.ValueBufferType=Float32Array;ln.prototype.DefaultInterpolation=Uo;var vi=class extends ln{constructor(t,e,n){super(t,e,n)}};vi.prototype.ValueTypeName="bool";vi.prototype.ValueBufferType=Array;vi.prototype.DefaultInterpolation=Zs;vi.prototype.InterpolantFactoryMethodLinear=void 0;vi.prototype.InterpolantFactoryMethodSmooth=void 0;var Jo=class extends ln{constructor(t,e,n,s){super(t,e,n,s)}};Jo.prototype.ValueTypeName="color";var Ko=class extends ln{constructor(t,e,n,s){super(t,e,n,s)}};Ko.prototype.ValueTypeName="number";var jo=class extends xi{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(s-e),c=t*a;for(let h=c+a;c!==h;c+=4)Le.slerpFlat(r,0,o,c-a,o,c,l);return r}},lr=class extends ln{constructor(t,e,n,s){super(t,e,n,s)}InterpolantFactoryMethodLinear(t){return new jo(this.times,this.values,this.getValueSize(),t)}};lr.prototype.ValueTypeName="quaternion";lr.prototype.InterpolantFactoryMethodSmooth=void 0;var yi=class extends ln{constructor(t,e,n){super(t,e,n)}};yi.prototype.ValueTypeName="string";yi.prototype.ValueBufferType=Array;yi.prototype.DefaultInterpolation=Zs;yi.prototype.InterpolantFactoryMethodLinear=void 0;yi.prototype.InterpolantFactoryMethodSmooth=void 0;var Qo=class extends ln{constructor(t,e,n,s){super(t,e,n,s)}};Qo.prototype.ValueTypeName="vector";var To={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(Ru(i)||(this.files[i]=t))},get:function(i){if(this.enabled!==!1&&!Ru(i))return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};function Ru(i){try{let t=i.slice(i.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}var ta=class{constructor(t,e,n){let s=this,r=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,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"),l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){let d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=c.length;df.start-g.start);let u=0;for(let f=1;f 0 +#endif`,eg=`#if NUM_CLIPPING_PLANES > 0 vec4 plane; #ifdef ALPHA_TO_COVERAGE float distanceToPlane, distanceGradient; @@ -254,20 +254,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve if ( clipped ) discard; #endif #endif -#endif`,Qm=`#if NUM_CLIPPING_PLANES > 0 +#endif`,ng=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; -#endif`,tg=`#if NUM_CLIPPING_PLANES > 0 +#endif`,ig=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; -#endif`,eg=`#if NUM_CLIPPING_PLANES > 0 +#endif`,sg=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; -#endif`,ng=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) +#endif`,rg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; -#endif`,ig=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) +#endif`,og=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) varying vec4 vColor; -#endif`,sg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) +#endif`,ag=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec4 vColor; -#endif`,rg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) +#endif`,lg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec4( 1.0 ); #endif #ifdef USE_COLOR_ALPHA @@ -280,7 +280,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve #endif #ifdef USE_BATCHING_COLOR vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); -#endif`,og=`#define PI 3.141592653589793 +#endif`,cg=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 @@ -351,7 +351,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} // validated`,ag=`#ifdef ENVMAP_TYPE_CUBE_UV +} // validated`,hg=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { @@ -444,7 +444,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { return vec4( mix( color0, color1, mipF ), 1.0 ); } } -#endif`,lg=`vec3 transformedNormal = objectNormal; +#endif`,ug=`vec3 transformedNormal = objectNormal; #ifdef USE_TANGENT vec3 transformedTangent = objectTangent; #endif @@ -470,21 +470,21 @@ transformedNormal = normalMatrix * transformedNormal; #endif #ifdef USE_TANGENT transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; -#endif`,cg=`#ifdef USE_DISPLACEMENTMAP +#endif`,dg=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; -#endif`,hg=`#ifdef USE_DISPLACEMENTMAP +#endif`,fg=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); -#endif`,ug=`#ifdef USE_EMISSIVEMAP +#endif`,pg=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; -#endif`,dg=`#ifdef USE_EMISSIVEMAP +#endif`,mg=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; -#endif`,fg="gl_FragColor = linearToOutputTexel( gl_FragColor );",pg=`vec4 LinearTransferOETF( in vec4 value ) { +#endif`,gg="gl_FragColor = linearToOutputTexel( gl_FragColor );",_g=`vec4 LinearTransferOETF( in vec4 value ) { return value; } vec4 sRGBTransferEOTF( in vec4 value ) { @@ -492,7 +492,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) { } vec4 sRGBTransferOETF( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); -}`,mg=`#ifdef USE_ENVMAP +}`,xg=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { @@ -519,7 +519,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif -#endif`,gg=`#ifdef USE_ENVMAP +#endif`,vg=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform mat3 envMapRotation; #ifdef ENVMAP_TYPE_CUBE @@ -527,7 +527,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { #else uniform sampler2D envMap; #endif -#endif`,_g=`#ifdef USE_ENVMAP +#endif`,yg=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS @@ -538,7 +538,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { #else varying vec3 vReflect; #endif -#endif`,xg=`#ifdef USE_ENVMAP +#endif`,Mg=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif @@ -549,7 +549,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { varying vec3 vReflect; uniform float refractionRatio; #endif -#endif`,vg=`#ifdef USE_ENVMAP +#endif`,bg=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else @@ -566,18 +566,18 @@ vec4 sRGBTransferOETF( in vec4 value ) { vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif -#endif`,yg=`#ifdef USE_FOG +#endif`,Sg=`#ifdef USE_FOG vFogDepth = - mvPosition.z; -#endif`,Mg=`#ifdef USE_FOG +#endif`,wg=`#ifdef USE_FOG varying float vFogDepth; -#endif`,bg=`#ifdef USE_FOG +#endif`,Eg=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); -#endif`,Sg=`#ifdef USE_FOG +#endif`,Tg=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 @@ -586,7 +586,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { uniform float fogNear; uniform float fogFar; #endif -#endif`,wg=`#ifdef USE_GRADIENTMAP +#endif`,Ag=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { @@ -598,12 +598,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif -}`,Eg=`#ifdef USE_LIGHTMAP +}`,Rg=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; -#endif`,Tg=`LambertMaterial material; +#endif`,Cg=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; -material.specularStrength = specularStrength;`,Ag=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,Ig=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; @@ -617,7 +617,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert -#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Rg=`uniform bool receiveShadow; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Pg=`uniform bool receiveShadow; uniform vec3 ambientLightColor; #if defined( USE_LIGHT_PROBES ) uniform vec3 lightProbe[ 9 ]; @@ -746,7 +746,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi return irradiance; } #endif -#include `,Cg=`#ifdef USE_ENVMAP +#include `,Lg=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); @@ -803,8 +803,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi } #endif #endif -#endif`,Ig=`ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`,Pg=`varying vec3 vViewPosition; +#endif`,Dg=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Ng=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; @@ -816,11 +816,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon -#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Lg=`BlinnPhongMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Ug=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; -material.specularStrength = specularStrength;`,Dg=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,Fg=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; @@ -837,7 +837,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong -#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Ng=`PhysicalMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Bg=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb; material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); material.metalness = metalnessFactor; @@ -930,7 +930,7 @@ material.roughness = min( material.roughness, 1.0 ); material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; -#endif`,Ug=`uniform sampler2D dfgLUT; +#endif`,Og=`uniform sampler2D dfgLUT; struct PhysicalMaterial { vec3 diffuseColor; vec3 diffuseContribution; @@ -1297,7 +1297,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); -}`,Fg=` +}`,zg=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); @@ -1445,7 +1445,7 @@ IncidentLight directLight; #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); -#endif`,Bg=`#if defined( RE_IndirectDiffuse ) +#endif`,kg=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; @@ -1475,7 +1475,7 @@ IncidentLight directLight; #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif -#endif`,Og=`#if defined( RE_IndirectDiffuse ) +#endif`,Hg=`#if defined( RE_IndirectDiffuse ) #if defined( LAMBERT ) || defined( PHONG ) irradiance += iblIrradiance; #endif @@ -1483,7 +1483,7 @@ IncidentLight directLight; #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); -#endif`,zg=`#ifdef USE_LIGHT_PROBES_GRID +#endif`,Vg=`#ifdef USE_LIGHT_PROBES_GRID uniform highp sampler3D probesSH; uniform vec3 probesMin; uniform vec3 probesMax; @@ -1528,27 +1528,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { result += c8 * 0.429043 * ( x * x - y * y ); return max( result, vec3( 0.0 ) ); } -#endif`,kg=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) +#endif`,Gg=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; -#endif`,Hg=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) +#endif`,Wg=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; -#endif`,Vg=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,Xg=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; -#endif`,Gg=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,qg=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); -#endif`,Wg=`#ifdef USE_MAP +#endif`,Yg=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; -#endif`,Xg=`#ifdef USE_MAP +#endif`,$g=`#ifdef USE_MAP uniform sampler2D map; -#endif`,qg=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) +#endif`,Zg=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else @@ -1560,7 +1560,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; -#endif`,Yg=`#if defined( USE_POINTS_UV ) +#endif`,Jg=`#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) @@ -1572,19 +1572,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; -#endif`,$g=`float metalnessFactor = metalness; +#endif`,Kg=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; -#endif`,Zg=`#ifdef USE_METALNESSMAP +#endif`,jg=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; -#endif`,Jg=`#ifdef USE_INSTANCING_MORPH +#endif`,Qg=`#ifdef USE_INSTANCING_MORPH float morphTargetInfluences[ MORPHTARGETS_COUNT ]; float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; } -#endif`,Kg=`#if defined( USE_MORPHCOLORS ) +#endif`,t_=`#if defined( USE_MORPHCOLORS ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) @@ -1593,12 +1593,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } -#endif`,jg=`#ifdef USE_MORPHNORMALS +#endif`,e_=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } -#endif`,Qg=`#ifdef USE_MORPHTARGETS +#endif`,n_=`#ifdef USE_MORPHTARGETS #ifndef USE_INSTANCING_MORPH uniform float morphTargetBaseInfluence; uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; @@ -1612,12 +1612,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } -#endif`,t_=`#ifdef USE_MORPHTARGETS +#endif`,i_=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } -#endif`,e_=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#endif`,s_=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); @@ -1658,7 +1658,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { tbn2[1] *= faceDirection; #endif #endif -vec3 nonPerturbedNormal = normal;`,n_=`#ifdef USE_NORMALMAP_OBJECTSPACE +vec3 nonPerturbedNormal = normal;`,r_=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; @@ -1676,19 +1676,19 @@ vec3 nonPerturbedNormal = normal;`,n_=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`,i_=`#ifndef FLAT_SHADED +#endif`,o_=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,s_=`#ifndef FLAT_SHADED +#endif`,a_=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,r_=`#ifndef FLAT_SHADED +#endif`,l_=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); @@ -1697,7 +1697,7 @@ vec3 nonPerturbedNormal = normal;`,n_=`#ifdef USE_NORMALMAP_OBJECTSPACE vBitangent = - vBitangent; #endif #endif -#endif`,o_=`#ifdef USE_NORMALMAP +#endif`,c_=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif @@ -1719,13 +1719,13 @@ vec3 nonPerturbedNormal = normal;`,n_=`#ifdef USE_NORMALMAP_OBJECTSPACE float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } -#endif`,a_=`#ifdef USE_CLEARCOAT +#endif`,h_=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; -#endif`,l_=`#ifdef USE_CLEARCOAT_NORMALMAP +#endif`,u_=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); -#endif`,c_=`#ifdef USE_CLEARCOATMAP +#endif`,d_=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP @@ -1734,18 +1734,18 @@ vec3 nonPerturbedNormal = normal;`,n_=`#ifdef USE_NORMALMAP_OBJECTSPACE #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; -#endif`,h_=`#ifdef USE_IRIDESCENCEMAP +#endif`,f_=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; -#endif`,u_=`#ifdef OPAQUE +#endif`,p_=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,d_=`vec3 packNormalToRGB( const in vec3 normal ) { +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,m_=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { @@ -1824,9 +1824,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const #else return ( near * far ) / ( ( far - near ) * depth - far ); #endif -}`,f_=`#ifdef PREMULTIPLIED_ALPHA +}`,g_=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; -#endif`,p_=`vec4 mvPosition = vec4( transformed, 1.0 ); +#endif`,__=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING mvPosition = batchingMatrix * mvPosition; #endif @@ -1834,22 +1834,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; -gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING +gl_Position = projectionMatrix * mvPosition;`,x_=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`,g_=`#ifdef DITHERING +#endif`,v_=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } -#endif`,__=`float roughnessFactor = roughness; +#endif`,y_=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; -#endif`,x_=`#ifdef USE_ROUGHNESSMAP +#endif`,M_=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; -#endif`,v_=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,b_=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 @@ -2100,7 +2100,7 @@ gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING } #endif #endif -#endif`,y_=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,S_=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif @@ -2145,7 +2145,7 @@ gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif -#endif`,M_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) +#endif`,w_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) #ifdef HAS_NORMAL vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); #else @@ -2185,7 +2185,7 @@ gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end -#endif`,b_=`float getShadowMask() { +#endif`,E_=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_SUN_LIGHT_SHADOWS > 0 @@ -2226,12 +2226,12 @@ gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING #endif #endif return shadow; -}`,S_=`#ifdef USE_SKINNING +}`,T_=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`,w_=`#ifdef USE_SKINNING +#endif`,A_=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; @@ -2246,7 +2246,7 @@ gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } -#endif`,E_=`#ifdef USE_SKINNING +#endif`,R_=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; @@ -2254,7 +2254,7 @@ gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`,T_=`#ifdef USE_SKINNING +#endif`,C_=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; @@ -2265,17 +2265,17 @@ gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif -#endif`,A_=`float specularStrength; +#endif`,I_=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; -#endif`,R_=`#ifdef USE_SPECULARMAP +#endif`,P_=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; -#endif`,C_=`#if defined( TONE_MAPPING ) +#endif`,L_=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`,I_=`#ifndef saturate +#endif`,D_=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; @@ -2372,7 +2372,7 @@ vec3 NeutralToneMapping( vec3 color ) { float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); return mix( color, vec3( newPeak ), g ); } -vec3 CustomToneMapping( vec3 color ) { return color; }`,P_=`#ifdef USE_TRANSMISSION +vec3 CustomToneMapping( vec3 color ) { return color; }`,N_=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; @@ -2393,7 +2393,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,P_=`#ifdef USE_TRANSMISS material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); -#endif`,L_=`#ifdef USE_TRANSMISSION +#endif`,U_=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; @@ -2519,7 +2519,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,P_=`#ifdef USE_TRANSMISS float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } -#endif`,D_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,F_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2589,7 +2589,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,P_=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,N_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,B_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2683,7 +2683,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,P_=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,U_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,O_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP @@ -2754,7 +2754,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,P_=`#ifdef USE_TRANSMISS #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; -#endif`,F_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 +#endif`,z_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; @@ -2763,12 +2763,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,P_=`#ifdef USE_TRANSMISS worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; -#endif`,B_=`varying vec2 vUv; +#endif`,k_=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`,O_=`uniform sampler2D t2D; +}`,H_=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { @@ -2780,14 +2780,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,z_=`varying vec3 vWorldDirection; +}`,V_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,k_=`#ifdef ENVMAP_TYPE_CUBE +}`,G_=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; @@ -2809,14 +2809,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,H_=`varying vec3 vWorldDirection; +}`,W_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,V_=`uniform samplerCube tCube; +}`,X_=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; @@ -2826,7 +2826,7 @@ void main() { gl_FragColor.a *= opacity; #include #include -}`,G_=`#include +}`,q_=`#include #include #include #include @@ -2853,7 +2853,7 @@ void main() { #include #include vHighPrecisionZW = gl_Position.zw; -}`,W_=`#if DEPTH_PACKING == 3200 +}`,Y_=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include @@ -2891,7 +2891,7 @@ void main() { #elif DEPTH_PACKING == 3203 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); #endif -}`,X_=`#define DISTANCE +}`,$_=`#define DISTANCE varying vec3 vWorldPosition; #include #include @@ -2918,7 +2918,7 @@ void main() { #include #include vWorldPosition = worldPosition.xyz; -}`,q_=`#define DISTANCE +}`,Z_=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; @@ -2941,13 +2941,13 @@ void main() { dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); -}`,Y_=`varying vec3 vWorldDirection; +}`,J_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include -}`,$_=`uniform sampler2D tEquirect; +}`,K_=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { @@ -2956,7 +2956,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include -}`,Z_=`uniform float scale; +}`,j_=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include @@ -2978,7 +2978,7 @@ void main() { #include #include #include -}`,J_=`uniform vec3 diffuse; +}`,Q_=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; @@ -3006,7 +3006,7 @@ void main() { #include #include #include -}`,K_=`#include +}`,t0=`#include #include #include #include @@ -3038,7 +3038,7 @@ void main() { #include #include #include -}`,j_=`uniform vec3 diffuse; +}`,e0=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; @@ -3086,7 +3086,7 @@ void main() { #include #include #include -}`,Q_=`#define LAMBERT +}`,n0=`#define LAMBERT varying vec3 vViewPosition; #include #include @@ -3125,7 +3125,7 @@ void main() { #include #include #include -}`,t0=`#define LAMBERT +}`,i0=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3183,7 +3183,7 @@ void main() { #include #include #include -}`,e0=`#define MATCAP +}`,s0=`#define MATCAP varying vec3 vViewPosition; #include #include @@ -3217,7 +3217,7 @@ void main() { #include #include vViewPosition = - mvPosition.xyz; -}`,n0=`#define MATCAP +}`,r0=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; @@ -3263,7 +3263,7 @@ void main() { #include #include #include -}`,i0=`#define NORMAL +}`,o0=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif @@ -3296,7 +3296,7 @@ void main() { #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif -}`,s0=`#define NORMAL +}`,a0=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; @@ -3317,7 +3317,7 @@ void main() { #ifdef OPAQUE gl_FragColor.a = 1.0; #endif -}`,r0=`#define PHONG +}`,l0=`#define PHONG varying vec3 vViewPosition; #include #include @@ -3356,7 +3356,7 @@ void main() { #include #include #include -}`,o0=`#define PHONG +}`,c0=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; @@ -3416,7 +3416,7 @@ void main() { #include #include #include -}`,a0=`#define STANDARD +}`,h0=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; @@ -3459,7 +3459,7 @@ void main() { #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif -}`,l0=`#define STANDARD +}`,u0=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR @@ -3587,7 +3587,7 @@ void main() { #include #include #include -}`,c0=`#define TOON +}`,d0=`#define TOON varying vec3 vViewPosition; #include #include @@ -3624,7 +3624,7 @@ void main() { #include #include #include -}`,h0=`#define TOON +}`,f0=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3676,7 +3676,7 @@ void main() { #include #include #include -}`,u0=`uniform float size; +}`,p0=`uniform float size; uniform float scale; #include #include @@ -3707,7 +3707,7 @@ void main() { #include #include #include -}`,d0=`uniform vec3 diffuse; +}`,m0=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3732,7 +3732,7 @@ void main() { #include #include #include -}`,f0=`#include +}`,g0=`#include #include #include #include @@ -3755,7 +3755,7 @@ void main() { #include #include #include -}`,p0=`uniform vec3 color; +}`,_0=`uniform vec3 color; uniform float opacity; #include #include @@ -3771,7 +3771,7 @@ void main() { #include #include #include -}`,m0=`uniform float rotation; +}`,x0=`uniform float rotation; uniform vec2 center; #include #include @@ -3795,7 +3795,7 @@ void main() { #include #include #include -}`,g0=`uniform vec3 diffuse; +}`,v0=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3820,7 +3820,7 @@ void main() { #include #include #include -}`,jt={alphahash_fragment:Bm,alphahash_pars_fragment:Om,alphamap_fragment:zm,alphamap_pars_fragment:km,alphatest_fragment:Hm,alphatest_pars_fragment:Vm,aomap_fragment:Gm,aomap_pars_fragment:Wm,batching_pars_vertex:Xm,batching_vertex:qm,begin_vertex:Ym,beginnormal_vertex:$m,bsdfs:Zm,iridescence_fragment:Jm,bumpmap_pars_fragment:Km,clipping_planes_fragment:jm,clipping_planes_pars_fragment:Qm,clipping_planes_pars_vertex:tg,clipping_planes_vertex:eg,color_fragment:ng,color_pars_fragment:ig,color_pars_vertex:sg,color_vertex:rg,common:og,cube_uv_reflection_fragment:ag,defaultnormal_vertex:lg,displacementmap_pars_vertex:cg,displacementmap_vertex:hg,emissivemap_fragment:ug,emissivemap_pars_fragment:dg,colorspace_fragment:fg,colorspace_pars_fragment:pg,envmap_fragment:mg,envmap_common_pars_fragment:gg,envmap_pars_fragment:_g,envmap_pars_vertex:xg,envmap_physical_pars_fragment:Cg,envmap_vertex:vg,fog_vertex:yg,fog_pars_vertex:Mg,fog_fragment:bg,fog_pars_fragment:Sg,gradientmap_pars_fragment:wg,lightmap_pars_fragment:Eg,lights_lambert_fragment:Tg,lights_lambert_pars_fragment:Ag,lights_pars_begin:Rg,lights_toon_fragment:Ig,lights_toon_pars_fragment:Pg,lights_phong_fragment:Lg,lights_phong_pars_fragment:Dg,lights_physical_fragment:Ng,lights_physical_pars_fragment:Ug,lights_fragment_begin:Fg,lights_fragment_maps:Bg,lights_fragment_end:Og,lightprobes_pars_fragment:zg,logdepthbuf_fragment:kg,logdepthbuf_pars_fragment:Hg,logdepthbuf_pars_vertex:Vg,logdepthbuf_vertex:Gg,map_fragment:Wg,map_pars_fragment:Xg,map_particle_fragment:qg,map_particle_pars_fragment:Yg,metalnessmap_fragment:$g,metalnessmap_pars_fragment:Zg,morphinstance_vertex:Jg,morphcolor_vertex:Kg,morphnormal_vertex:jg,morphtarget_pars_vertex:Qg,morphtarget_vertex:t_,normal_fragment_begin:e_,normal_fragment_maps:n_,normal_pars_fragment:i_,normal_pars_vertex:s_,normal_vertex:r_,normalmap_pars_fragment:o_,clearcoat_normal_fragment_begin:a_,clearcoat_normal_fragment_maps:l_,clearcoat_pars_fragment:c_,iridescence_pars_fragment:h_,opaque_fragment:u_,packing:d_,premultiplied_alpha_fragment:f_,project_vertex:p_,dithering_fragment:m_,dithering_pars_fragment:g_,roughnessmap_fragment:__,roughnessmap_pars_fragment:x_,shadowmap_pars_fragment:v_,shadowmap_pars_vertex:y_,shadowmap_vertex:M_,shadowmask_pars_fragment:b_,skinbase_vertex:S_,skinning_pars_vertex:w_,skinning_vertex:E_,skinnormal_vertex:T_,specularmap_fragment:A_,specularmap_pars_fragment:R_,tonemapping_fragment:C_,tonemapping_pars_fragment:I_,transmission_fragment:P_,transmission_pars_fragment:L_,uv_pars_fragment:D_,uv_pars_vertex:N_,uv_vertex:U_,worldpos_vertex:F_,background_vert:B_,background_frag:O_,backgroundCube_vert:z_,backgroundCube_frag:k_,cube_vert:H_,cube_frag:V_,depth_vert:G_,depth_frag:W_,distance_vert:X_,distance_frag:q_,equirect_vert:Y_,equirect_frag:$_,linedashed_vert:Z_,linedashed_frag:J_,meshbasic_vert:K_,meshbasic_frag:j_,meshlambert_vert:Q_,meshlambert_frag:t0,meshmatcap_vert:e0,meshmatcap_frag:n0,meshnormal_vert:i0,meshnormal_frag:s0,meshphong_vert:r0,meshphong_frag:o0,meshphysical_vert:a0,meshphysical_frag:l0,meshtoon_vert:c0,meshtoon_frag:h0,points_vert:u0,points_frag:d0,shadow_vert:f0,shadow_frag:p0,sprite_vert:m0,sprite_frag:g0},St={common:{diffuse:{value:new Vt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qt},alphaMap:{value:null},alphaMapTransform:{value:new qt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qt}},envmap:{envMap:{value:null},envMapRotation:{value:new qt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qt},normalScale:{value:new $t(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Vt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new I},probesMax:{value:new I},probesResolution:{value:new I}},points:{diffuse:{value:new Vt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qt},alphaTest:{value:0},uvTransform:{value:new qt}},sprite:{diffuse:{value:new Vt(16777215)},opacity:{value:1},center:{value:new $t(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qt},alphaMap:{value:null},alphaMapTransform:{value:new qt},alphaTest:{value:0}}},Vn={basic:{uniforms:je([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.fog]),vertexShader:jt.meshbasic_vert,fragmentShader:jt.meshbasic_frag},lambert:{uniforms:je([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.fog,St.lights,{emissive:{value:new Vt(0)},envMapIntensity:{value:1}}]),vertexShader:jt.meshlambert_vert,fragmentShader:jt.meshlambert_frag},phong:{uniforms:je([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.fog,St.lights,{emissive:{value:new Vt(0)},specular:{value:new Vt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:jt.meshphong_vert,fragmentShader:jt.meshphong_frag},standard:{uniforms:je([St.common,St.envmap,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.roughnessmap,St.metalnessmap,St.fog,St.lights,{emissive:{value:new Vt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag},toon:{uniforms:je([St.common,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.gradientmap,St.fog,St.lights,{emissive:{value:new Vt(0)}}]),vertexShader:jt.meshtoon_vert,fragmentShader:jt.meshtoon_frag},matcap:{uniforms:je([St.common,St.bumpmap,St.normalmap,St.displacementmap,St.fog,{matcap:{value:null}}]),vertexShader:jt.meshmatcap_vert,fragmentShader:jt.meshmatcap_frag},points:{uniforms:je([St.points,St.fog]),vertexShader:jt.points_vert,fragmentShader:jt.points_frag},dashed:{uniforms:je([St.common,St.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:jt.linedashed_vert,fragmentShader:jt.linedashed_frag},depth:{uniforms:je([St.common,St.displacementmap]),vertexShader:jt.depth_vert,fragmentShader:jt.depth_frag},normal:{uniforms:je([St.common,St.bumpmap,St.normalmap,St.displacementmap,{opacity:{value:1}}]),vertexShader:jt.meshnormal_vert,fragmentShader:jt.meshnormal_frag},sprite:{uniforms:je([St.sprite,St.fog]),vertexShader:jt.sprite_vert,fragmentShader:jt.sprite_frag},background:{uniforms:{uvTransform:{value:new qt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:jt.background_vert,fragmentShader:jt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qt}},vertexShader:jt.backgroundCube_vert,fragmentShader:jt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:jt.cube_vert,fragmentShader:jt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:jt.equirect_vert,fragmentShader:jt.equirect_frag},distance:{uniforms:je([St.common,St.displacementmap,{referencePosition:{value:new I},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:jt.distance_vert,fragmentShader:jt.distance_frag},shadow:{uniforms:je([St.lights,St.fog,{color:{value:new Vt(0)},opacity:{value:1}}]),vertexShader:jt.shadow_vert,fragmentShader:jt.shadow_frag}};Vn.physical={uniforms:je([Vn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qt},clearcoatNormalScale:{value:new $t(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qt},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qt},sheen:{value:0},sheenColor:{value:new Vt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qt},transmissionSamplerSize:{value:new $t},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qt},attenuationDistance:{value:0},attenuationColor:{value:new Vt(0)},specularColor:{value:new Vt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qt},anisotropyVector:{value:new $t},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qt}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag};var Wa={r:0,b:0,g:0},_0=new Jt,Vd=new qt;Vd.set(-1,0,0,0,1,0,0,0,1);function x0(i,t,e,n,s,r){let o=new Vt(0),a=s===!0?0:1,l,c,h=null,d=0,u=null;function f(b){let w=b.isScene===!0?b.background:null;if(w&&w.isTexture){let v=b.backgroundBlurriness>0;w=t.get(w,v)}return w}function g(b){let w=!1,v=f(b);v===null?m(o,a):v&&v.isColor&&(m(v,1),w=!0);let y=i.xr.getEnvironmentBlendMode();y==="additive"?e.buffers.color.setClear(0,0,0,1,r):y==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,r),(i.autoClear||w)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function _(b,w){let v=f(w);v&&(v.isCubeTexture||v.mapping===pr)?(c===void 0&&(c=new _e(new dn(1,1,1),new qe({name:"BackgroundCubeMaterial",uniforms:Hi(Vn.backgroundCube.uniforms),vertexShader:Vn.backgroundCube.vertexShader,fragmentShader:Vn.backgroundCube.fragmentShader,side:De,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(y,S,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=v,c.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(_0.makeRotationFromEuler(w.backgroundRotation)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Vd),c.material.toneMapped=te.getTransfer(v.colorSpace)!==he,(h!==v||d!==v.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=v,d=v.version,u=i.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):v&&v.isTexture&&(l===void 0&&(l=new _e(new yn(2,2),new qe({name:"BackgroundMaterial",uniforms:Hi(Vn.background.uniforms),vertexShader:Vn.background.vertexShader,fragmentShader:Vn.background.fragmentShader,side:zn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=v,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.toneMapped=te.getTransfer(v.colorSpace)!==he,v.matrixAutoUpdate===!0&&v.updateMatrix(),l.material.uniforms.uvTransform.value.copy(v.matrix),(h!==v||d!==v.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=v,d=v.version,u=i.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function m(b,w){b.getRGB(Wa,Uc(i)),e.buffers.color.setClear(Wa.r,Wa.g,Wa.b,w,r)}function p(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(b,w=1){o.set(b),a=w,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(b){a=b,m(o,a)},render:g,addToRenderList:_,dispose:p}}function v0(i,t){let e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,o=!1;function a(D,F,U,C,B){let W=!1,q=d(D,C,U,F);r!==q&&(r=q,c(r.object)),W=f(D,C,U,B),W&&g(D,C,U,B),B!==null&&t.update(B,i.ELEMENT_ARRAY_BUFFER),(W||o)&&(o=!1,v(D,F,U,C),B!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(B).buffer))}function l(){return i.createVertexArray()}function c(D){return i.bindVertexArray(D)}function h(D){return i.deleteVertexArray(D)}function d(D,F,U,C){let B=C.wireframe===!0,W=n[F.id];W===void 0&&(W={},n[F.id]=W);let q=D.isInstancedMesh===!0?D.id:0,O=W[q];O===void 0&&(O={},W[q]=O);let L=O[U.id];L===void 0&&(L={},O[U.id]=L);let H=L[B];return H===void 0&&(H=u(l()),L[B]=H),H}function u(D){let F=[],U=[],C=[];for(let B=0;B=0){let X=B[L],z=W[L];if(z===void 0&&(L==="instanceMatrix"&&D.instanceMatrix&&(z=D.instanceMatrix),L==="instanceColor"&&D.instanceColor&&(z=D.instanceColor)),X===void 0||X.attribute!==z||z&&X.data!==z.data)return!0;q++}return r.attributesNum!==q||r.index!==C}function g(D,F,U,C){let B={},W=F.attributes,q=0,O=U.getAttributes();for(let L in O)if(O[L].location>=0){let X=W[L];X===void 0&&(L==="instanceMatrix"&&D.instanceMatrix&&(X=D.instanceMatrix),L==="instanceColor"&&D.instanceColor&&(X=D.instanceColor));let z={};z.attribute=X,X&&X.data&&(z.data=X.data),B[L]=z,q++}r.attributes=B,r.attributesNum=q,r.index=C}function _(){let D=r.newAttributes;for(let F=0,U=D.length;F=0){let H=B[O];if(H===void 0&&(O==="instanceMatrix"&&D.instanceMatrix&&(H=D.instanceMatrix),O==="instanceColor"&&D.instanceColor&&(H=D.instanceColor)),H!==void 0){let X=H.normalized,z=H.itemSize,Q=t.get(H);if(Q===void 0)continue;let lt=Q.buffer,ut=Q.type,ct=Q.bytesPerElement,G=ut===i.INT||ut===i.UNSIGNED_INT||H.gpuType===ra;if(H.isInterleavedBufferAttribute){let tt=H.data,rt=tt.stride,yt=H.offset;if(tt.isInstancedInterleavedBuffer){for(let ft=0;ft0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp",h=l(c);h!==c&&(zt("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);let d=e.logarithmicDepthBuffer===!0,u=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&u===!1&&zt("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),b=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),w=i.getParameter(i.MAX_VARYING_VECTORS),v=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),y=i.getParameter(i.MAX_SAMPLES),S=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:f,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:b,maxVaryings:w,maxFragmentUniforms:v,maxSamples:y,samples:S}}function b0(i){let t=this,e=null,n=0,s=!1,r=!1,o=new we,a=new qt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let f=d.length!==0||u||n!==0||s;return s=u,n=d.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){e=h(d,u,0)},this.setState=function(d,u,f){let g=d.clippingPlanes,_=d.clipIntersection,m=d.clipShadows,p=i.get(d);if(!s||g===null||g.length===0||r&&!m)r?h(null):c();else{let b=r?0:n,w=b*4,v=p.clippingState||null;l.value=v,v=h(g,u,w,f);for(let y=0;y!==w;++y)v[y]=e[y];p.clippingState=v,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(d,u,f,g){let _=d!==null?d.length:0,m=null;if(_!==0){if(m=l.value,g!==!0||m===null){let p=f+_*4,b=u.matrixWorldInverse;a.getNormalMatrix(b),(m===null||m.length0&&this._blur(l,0,0,e),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Sd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=bd(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?y:0,y,y),d.setRenderTarget(s),p&&d.render(_,l),d.render(t,l)}d.toneMapping=f,d.autoClear=u,t.background=b}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===vi||t.mapping===ki;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Sd()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=bd());let r=s?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=r;let a=r.uniforms;a.envMap.value=t;let l=this._cubeSize;Ps(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(o,br)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;rg-Ls?n-g+Ls:0),p=4*(this._cubeSize-_);l.envMap.value=t.texture,l.roughness.value=f,l.mipInt.value=g-e,Ps(r,m,p,3*_,2*_),s.setRenderTarget(r),s.render(a,br),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=g-n,Ps(t,m,p,3*_,2*_),s.setRenderTarget(t),s.render(a,br)}_blur(t,e,n,s){let r=this._pingPongRenderTarget,o=Math.min(s,Math.PI)/Math.SQRT2;this._blurPass(t,r,e,n,o),this._blurPass(r,t,n,n,o)}_blurPass(t,e,n,s,r){let o=this._renderer,a=this._blurMaterial,l=this._lodMeshes[s];l.material=a;let c=a.uniforms;c.envMap.value=t.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let h=this._sizeLods[s],d=3*h*(s>this._lodMax-Ls?s-this._lodMax+Ls:0),u=4*(this._cubeSize-h);Ps(e,d,u,3*h,2*h),o.setRenderTarget(e),o.render(l,br)}};function A0(i){let t=[],e=[],n=i,s=i-Ls+1+S0;for(let r=0;r2?0:-1,v=[b,w,0,b+2/3,w,0,b+2/3,w+1,0,b,w,0,b+2/3,w+1,0,b,w+1,0];g.set(v,f*u*p);for(let y=0;yLs&&n--}return{lodMeshes:e,sizeLods:t}}function Md(i,t,e){let n=new He(i,t,e);return n.texture.mapping=pr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ps(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function R0(i,t,e){return new qe({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:E0,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:$a(),fragmentShader:` +}`,Kt={alphahash_fragment:km,alphahash_pars_fragment:Hm,alphamap_fragment:Vm,alphamap_pars_fragment:Gm,alphatest_fragment:Wm,alphatest_pars_fragment:Xm,aomap_fragment:qm,aomap_pars_fragment:Ym,batching_pars_vertex:$m,batching_vertex:Zm,begin_vertex:Jm,beginnormal_vertex:Km,bsdfs:jm,iridescence_fragment:Qm,bumpmap_pars_fragment:tg,clipping_planes_fragment:eg,clipping_planes_pars_fragment:ng,clipping_planes_pars_vertex:ig,clipping_planes_vertex:sg,color_fragment:rg,color_pars_fragment:og,color_pars_vertex:ag,color_vertex:lg,common:cg,cube_uv_reflection_fragment:hg,defaultnormal_vertex:ug,displacementmap_pars_vertex:dg,displacementmap_vertex:fg,emissivemap_fragment:pg,emissivemap_pars_fragment:mg,colorspace_fragment:gg,colorspace_pars_fragment:_g,envmap_fragment:xg,envmap_common_pars_fragment:vg,envmap_pars_fragment:yg,envmap_pars_vertex:Mg,envmap_physical_pars_fragment:Lg,envmap_vertex:bg,fog_vertex:Sg,fog_pars_vertex:wg,fog_fragment:Eg,fog_pars_fragment:Tg,gradientmap_pars_fragment:Ag,lightmap_pars_fragment:Rg,lights_lambert_fragment:Cg,lights_lambert_pars_fragment:Ig,lights_pars_begin:Pg,lights_toon_fragment:Dg,lights_toon_pars_fragment:Ng,lights_phong_fragment:Ug,lights_phong_pars_fragment:Fg,lights_physical_fragment:Bg,lights_physical_pars_fragment:Og,lights_fragment_begin:zg,lights_fragment_maps:kg,lights_fragment_end:Hg,lightprobes_pars_fragment:Vg,logdepthbuf_fragment:Gg,logdepthbuf_pars_fragment:Wg,logdepthbuf_pars_vertex:Xg,logdepthbuf_vertex:qg,map_fragment:Yg,map_pars_fragment:$g,map_particle_fragment:Zg,map_particle_pars_fragment:Jg,metalnessmap_fragment:Kg,metalnessmap_pars_fragment:jg,morphinstance_vertex:Qg,morphcolor_vertex:t_,morphnormal_vertex:e_,morphtarget_pars_vertex:n_,morphtarget_vertex:i_,normal_fragment_begin:s_,normal_fragment_maps:r_,normal_pars_fragment:o_,normal_pars_vertex:a_,normal_vertex:l_,normalmap_pars_fragment:c_,clearcoat_normal_fragment_begin:h_,clearcoat_normal_fragment_maps:u_,clearcoat_pars_fragment:d_,iridescence_pars_fragment:f_,opaque_fragment:p_,packing:m_,premultiplied_alpha_fragment:g_,project_vertex:__,dithering_fragment:x_,dithering_pars_fragment:v_,roughnessmap_fragment:y_,roughnessmap_pars_fragment:M_,shadowmap_pars_fragment:b_,shadowmap_pars_vertex:S_,shadowmap_vertex:w_,shadowmask_pars_fragment:E_,skinbase_vertex:T_,skinning_pars_vertex:A_,skinning_vertex:R_,skinnormal_vertex:C_,specularmap_fragment:I_,specularmap_pars_fragment:P_,tonemapping_fragment:L_,tonemapping_pars_fragment:D_,transmission_fragment:N_,transmission_pars_fragment:U_,uv_pars_fragment:F_,uv_pars_vertex:B_,uv_vertex:O_,worldpos_vertex:z_,background_vert:k_,background_frag:H_,backgroundCube_vert:V_,backgroundCube_frag:G_,cube_vert:W_,cube_frag:X_,depth_vert:q_,depth_frag:Y_,distance_vert:$_,distance_frag:Z_,equirect_vert:J_,equirect_frag:K_,linedashed_vert:j_,linedashed_frag:Q_,meshbasic_vert:t0,meshbasic_frag:e0,meshlambert_vert:n0,meshlambert_frag:i0,meshmatcap_vert:s0,meshmatcap_frag:r0,meshnormal_vert:o0,meshnormal_frag:a0,meshphong_vert:l0,meshphong_frag:c0,meshphysical_vert:h0,meshphysical_frag:u0,meshtoon_vert:d0,meshtoon_frag:f0,points_vert:p0,points_frag:m0,shadow_vert:g0,shadow_frag:_0,sprite_vert:x0,sprite_frag:v0},yt={common:{diffuse:{value:new Vt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qt},alphaMap:{value:null},alphaMapTransform:{value:new qt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qt}},envmap:{envMap:{value:null},envMapRotation:{value:new qt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qt},normalScale:{value:new Xt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Vt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new L},probesMax:{value:new L},probesResolution:{value:new L}},points:{diffuse:{value:new Vt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qt},alphaTest:{value:0},uvTransform:{value:new qt}},sprite:{diffuse:{value:new Vt(16777215)},opacity:{value:1},center:{value:new Xt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qt},alphaMap:{value:null},alphaMapTransform:{value:new qt},alphaTest:{value:0}}},Wn={basic:{uniforms:je([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.fog]),vertexShader:Kt.meshbasic_vert,fragmentShader:Kt.meshbasic_frag},lambert:{uniforms:je([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,yt.lights,{emissive:{value:new Vt(0)},envMapIntensity:{value:1}}]),vertexShader:Kt.meshlambert_vert,fragmentShader:Kt.meshlambert_frag},phong:{uniforms:je([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,yt.lights,{emissive:{value:new Vt(0)},specular:{value:new Vt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Kt.meshphong_vert,fragmentShader:Kt.meshphong_frag},standard:{uniforms:je([yt.common,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.roughnessmap,yt.metalnessmap,yt.fog,yt.lights,{emissive:{value:new Vt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Kt.meshphysical_vert,fragmentShader:Kt.meshphysical_frag},toon:{uniforms:je([yt.common,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.gradientmap,yt.fog,yt.lights,{emissive:{value:new Vt(0)}}]),vertexShader:Kt.meshtoon_vert,fragmentShader:Kt.meshtoon_frag},matcap:{uniforms:je([yt.common,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,{matcap:{value:null}}]),vertexShader:Kt.meshmatcap_vert,fragmentShader:Kt.meshmatcap_frag},points:{uniforms:je([yt.points,yt.fog]),vertexShader:Kt.points_vert,fragmentShader:Kt.points_frag},dashed:{uniforms:je([yt.common,yt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Kt.linedashed_vert,fragmentShader:Kt.linedashed_frag},depth:{uniforms:je([yt.common,yt.displacementmap]),vertexShader:Kt.depth_vert,fragmentShader:Kt.depth_frag},normal:{uniforms:je([yt.common,yt.bumpmap,yt.normalmap,yt.displacementmap,{opacity:{value:1}}]),vertexShader:Kt.meshnormal_vert,fragmentShader:Kt.meshnormal_frag},sprite:{uniforms:je([yt.sprite,yt.fog]),vertexShader:Kt.sprite_vert,fragmentShader:Kt.sprite_frag},background:{uniforms:{uvTransform:{value:new qt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Kt.background_vert,fragmentShader:Kt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qt}},vertexShader:Kt.backgroundCube_vert,fragmentShader:Kt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Kt.cube_vert,fragmentShader:Kt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Kt.equirect_vert,fragmentShader:Kt.equirect_frag},distance:{uniforms:je([yt.common,yt.displacementmap,{referencePosition:{value:new L},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Kt.distance_vert,fragmentShader:Kt.distance_frag},shadow:{uniforms:je([yt.lights,yt.fog,{color:{value:new Vt(0)},opacity:{value:1}}]),vertexShader:Kt.shadow_vert,fragmentShader:Kt.shadow_frag}};Wn.physical={uniforms:je([Wn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qt},clearcoatNormalScale:{value:new Xt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qt},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qt},sheen:{value:0},sheenColor:{value:new Vt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qt},transmissionSamplerSize:{value:new Xt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qt},attenuationDistance:{value:0},attenuationColor:{value:new Vt(0)},specularColor:{value:new Vt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qt},anisotropyVector:{value:new Xt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qt}}]),vertexShader:Kt.meshphysical_vert,fragmentShader:Kt.meshphysical_frag};var Ya={r:0,b:0,g:0},y0=new Yt,Wd=new qt;Wd.set(-1,0,0,0,1,0,0,0,1);function M0(i,t,e,n,s,r){let o=new Vt(0),a=s===!0?0:1,l,c,h=null,d=0,u=null;function f(b){let E=b.isScene===!0?b.background:null;if(E&&E.isTexture){let v=b.backgroundBlurriness>0;E=t.get(E,v)}return E}function g(b){let E=!1,v=f(b);v===null?m(o,a):v&&v.isColor&&(m(v,1),E=!0);let y=i.xr.getEnvironmentBlendMode();y==="additive"?e.buffers.color.setClear(0,0,0,1,r):y==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,r),(i.autoClear||E)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function _(b,E){let v=f(E);v&&(v.isCubeTexture||v.mapping===_r)?(c===void 0&&(c=new _e(new dn(1,1,1),new qe({name:"BackgroundCubeMaterial",uniforms:Vi(Wn.backgroundCube.uniforms),vertexShader:Wn.backgroundCube.vertexShader,fragmentShader:Wn.backgroundCube.fragmentShader,side:De,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(y,S,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=v,c.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(y0.makeRotationFromEuler(E.backgroundRotation)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Wd),c.material.toneMapped=te.getTransfer(v.colorSpace)!==ue,(h!==v||d!==v.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=v,d=v.version,u=i.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):v&&v.isTexture&&(l===void 0&&(l=new _e(new Mn(2,2),new qe({name:"BackgroundMaterial",uniforms:Vi(Wn.background.uniforms),vertexShader:Wn.background.vertexShader,fragmentShader:Wn.background.fragmentShader,side:Hn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=v,l.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,l.material.toneMapped=te.getTransfer(v.colorSpace)!==ue,v.matrixAutoUpdate===!0&&v.updateMatrix(),l.material.uniforms.uvTransform.value.copy(v.matrix),(h!==v||d!==v.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=v,d=v.version,u=i.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function m(b,E){b.getRGB(Ya,Bc(i)),e.buffers.color.setClear(Ya.r,Ya.g,Ya.b,E,r)}function p(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(b,E=1){o.set(b),a=E,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(b){a=b,m(o,a)},render:g,addToRenderList:_,dispose:p}}function b0(i,t){let e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,o=!1;function a(D,U,F,I,B){let G=!1,q=d(D,I,F,U);r!==q&&(r=q,c(r.object)),G=f(D,I,F,B),G&&g(D,I,F,B),B!==null&&t.update(B,i.ELEMENT_ARRAY_BUFFER),(G||o)&&(o=!1,v(D,U,F,I),B!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(B).buffer))}function l(){return i.createVertexArray()}function c(D){return i.bindVertexArray(D)}function h(D){return i.deleteVertexArray(D)}function d(D,U,F,I){let B=I.wireframe===!0,G=n[U.id];G===void 0&&(G={},n[U.id]=G);let q=D.isInstancedMesh===!0?D.id:0,O=G[q];O===void 0&&(O={},G[q]=O);let N=O[F.id];N===void 0&&(N={},O[F.id]=N);let z=N[B];return z===void 0&&(z=u(l()),N[B]=z),z}function u(D){let U=[],F=[],I=[];for(let B=0;B=0){let W=B[N],k=G[N];if(k===void 0&&(N==="instanceMatrix"&&D.instanceMatrix&&(k=D.instanceMatrix),N==="instanceColor"&&D.instanceColor&&(k=D.instanceColor)),W===void 0||W.attribute!==k||k&&W.data!==k.data)return!0;q++}return r.attributesNum!==q||r.index!==I}function g(D,U,F,I){let B={},G=U.attributes,q=0,O=F.getAttributes();for(let N in O)if(O[N].location>=0){let W=G[N];W===void 0&&(N==="instanceMatrix"&&D.instanceMatrix&&(W=D.instanceMatrix),N==="instanceColor"&&D.instanceColor&&(W=D.instanceColor));let k={};k.attribute=W,W&&W.data&&(k.data=W.data),B[N]=k,q++}r.attributes=B,r.attributesNum=q,r.index=I}function _(){let D=r.newAttributes;for(let U=0,F=D.length;U=0){let z=B[O];if(z===void 0&&(O==="instanceMatrix"&&D.instanceMatrix&&(z=D.instanceMatrix),O==="instanceColor"&&D.instanceColor&&(z=D.instanceColor)),z!==void 0){let W=z.normalized,k=z.itemSize,K=t.get(z);if(K===void 0)continue;let lt=K.buffer,ht=K.type,at=K.bytesPerElement,Y=ht===i.INT||ht===i.UNSIGNED_INT||z.gpuType===ca;if(z.isInterleavedBufferAttribute){let tt=z.data,dt=tt.stride,It=z.offset;if(tt.isInstancedInterleavedBuffer){for(let ot=0;ot0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp",h=l(c);h!==c&&(Ht("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);let d=e.logarithmicDepthBuffer===!0,u=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&u===!1&&Ht("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),b=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),E=i.getParameter(i.MAX_VARYING_VECTORS),v=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),y=i.getParameter(i.MAX_SAMPLES),S=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:f,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:b,maxVaryings:E,maxFragmentUniforms:v,maxSamples:y,samples:S}}function E0(i){let t=this,e=null,n=0,s=!1,r=!1,o=new we,a=new qt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let f=d.length!==0||u||n!==0||s;return s=u,n=d.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){e=h(d,u,0)},this.setState=function(d,u,f){let g=d.clippingPlanes,_=d.clipIntersection,m=d.clipShadows,p=i.get(d);if(!s||g===null||g.length===0||r&&!m)r?h(null):c();else{let b=r?0:n,E=b*4,v=p.clippingState||null;l.value=v,v=h(g,u,E,f);for(let y=0;y!==E;++y)v[y]=e[y];p.clippingState=v,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(d,u,f,g){let _=d!==null?d.length:0,m=null;if(_!==0){if(m=l.value,g!==!0||m===null){let p=f+_*4,b=u.matrixWorldInverse;a.getNormalMatrix(b),(m===null||m.length0&&this._blur(l,0,0,e),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Ed(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=wd(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?y:0,y,y),d.setRenderTarget(s),p&&d.render(_,l),d.render(t,l)}d.toneMapping=f,d.autoClear=u,t.background=b}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===Mi||t.mapping===Hi;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ed()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=wd());let r=s?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=r;let a=r.uniforms;a.envMap.value=t;let l=this._cubeSize;Ps(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(o,Ar)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;rg-Ls?n-g+Ls:0),p=4*(this._cubeSize-_);l.envMap.value=t.texture,l.roughness.value=f,l.mipInt.value=g-e,Ps(r,m,p,3*_,2*_),s.setRenderTarget(r),s.render(a,Ar),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=g-n,Ps(t,m,p,3*_,2*_),s.setRenderTarget(t),s.render(a,Ar)}_blur(t,e,n,s){let r=this._pingPongRenderTarget,o=Math.min(s,Math.PI)/Math.SQRT2;this._blurPass(t,r,e,n,o),this._blurPass(r,t,n,n,o)}_blurPass(t,e,n,s,r){let o=this._renderer,a=this._blurMaterial,l=this._lodMeshes[s];l.material=a;let c=a.uniforms;c.envMap.value=t.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let h=this._sizeLods[s],d=3*h*(s>this._lodMax-Ls?s-this._lodMax+Ls:0),u=4*(this._cubeSize-h);Ps(e,d,u,3*h,2*h),o.setRenderTarget(e),o.render(l,Ar)}};function I0(i){let t=[],e=[],n=i,s=i-Ls+1+T0;for(let r=0;r2?0:-1,v=[b,E,0,b+2/3,E,0,b+2/3,E+1,0,b,E,0,b+2/3,E+1,0,b,E+1,0];g.set(v,f*u*p);for(let y=0;yLs&&n--}return{lodMeshes:e,sizeLods:t}}function Sd(i,t,e){let n=new Ve(i,t,e);return n.texture.mapping=_r,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ps(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function P0(i,t,e){return new qe({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:R0,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Ka(),fragmentShader:` precision highp float; precision highp int; @@ -3924,7 +3924,7 @@ void main() { gl_FragColor = vec4(prefilteredColor, 1.0); } - `,blending:kn,depthTest:!1,depthWrite:!1})}function C0(i,t,e){return new qe({name:"SphericalGaussianBlur",defines:{SAMPLES:w0,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:$a(),fragmentShader:` + `,blending:Vn,depthTest:!1,depthWrite:!1})}function L0(i,t,e){return new qe({name:"SphericalGaussianBlur",defines:{SAMPLES:A0,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:Ka(),fragmentShader:` precision highp float; precision highp int; @@ -3984,7 +3984,7 @@ void main() { gl_FragColor = vec4( accumColor / accumWeight, 1.0 ); } - `,blending:kn,depthTest:!1,depthWrite:!1})}function bd(){return new qe({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:$a(),fragmentShader:` + `,blending:Vn,depthTest:!1,depthWrite:!1})}function wd(){return new qe({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ka(),fragmentShader:` precision mediump float; precision mediump int; @@ -4003,7 +4003,7 @@ void main() { gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } - `,blending:kn,depthTest:!1,depthWrite:!1})}function Sd(){return new qe({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:$a(),fragmentShader:` + `,blending:Vn,depthTest:!1,depthWrite:!1})}function Ed(){return new qe({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ka(),fragmentShader:` precision mediump float; precision mediump int; @@ -4019,7 +4019,7 @@ void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } - `,blending:kn,depthTest:!1,depthWrite:!1})}function $a(){return` + `,blending:Vn,depthTest:!1,depthWrite:!1})}function Ka(){return` precision mediump float; precision mediump int; @@ -4034,7 +4034,7 @@ void main() { gl_Position = vec4( position, 1.0 ); } - `}var Ya=class extends He{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new nr(s),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` + `}var Ja=class extends Ve{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new ir(s),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; @@ -4069,7 +4069,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},s=new dn(5,5,5),r=new qe({name:"CubemapFromEquirect",uniforms:Hi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:De,blending:kn});r.uniforms.tEquirect.value=e;let o=new _e(s,r),a=e.minFilter;return e.minFilter===yi&&(e.minFilter=Xe),new jo(1,10,this).update(t,o),e.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(t,e=!0,n=!0,s=!0){let r=t.getRenderTarget();for(let o=0;o<6;o++)t.setRenderTarget(this,o),t.clear(e,n,s);t.setRenderTarget(r)}};function I0(i){let t=new WeakMap,e=new WeakMap,n=null;function s(u,f=!1){return u==null?null:f?o(u):r(u)}function r(u){if(u&&u.isTexture){let f=u.mapping;if(f===na||f===ia)if(t.has(u)){let g=t.get(u).texture;return a(g,u.mapping)}else{let g=u.image;if(g&&g.height>0){let _=new Ya(g.height);return _.fromEquirectangularTexture(i,u),t.set(u,_),u.addEventListener("dispose",c),a(_.texture,u.mapping)}else return null}}return u}function o(u){if(u&&u.isTexture){let f=u.mapping,g=f===na||f===ia,_=f===vi||f===ki;if(g||_){let m=e.get(u),p=m!==void 0?m.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==p)return n===null&&(n=new qa(i)),m=g?n.fromEquirectangular(u,m):n.fromCubemap(u,m),m.texture.pmremVersion=u.pmremVersion,e.set(u,m),m.texture;if(m!==void 0)return m.texture;{let b=u.image;return g&&b&&b.height>0||_&&b&&l(b)?(n===null&&(n=new qa(i)),m=g?n.fromEquirectangular(u):n.fromCubemap(u),m.texture.pmremVersion=u.pmremVersion,e.set(u,m),u.addEventListener("dispose",h),m.texture):null}}}return u}function a(u,f){return f===na?u.mapping=vi:f===ia&&(u.mapping=ki),u}function l(u){let f=0,g=6;for(let _=0;_=65535?tr:Qs)(u,1);m.version=_;let p=r.get(d);p&&t.remove(p),r.set(d,m)}function h(d){let u=r.get(d);if(u){let f=d.index;f!==null&&u.versiont.maxTextureSize&&(y=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize);let S=new Float32Array(v*y*4*d),A=new js(S,v,y,d);A.type=Ye,A.needsUpdate=!0;let x=w*4;for(let R=0;R0){let _=new Ja(g.height);return _.fromEquirectangularTexture(i,u),t.set(u,_),u.addEventListener("dispose",c),a(_.texture,u.mapping)}else return null}}return u}function o(u){if(u&&u.isTexture){let f=u.mapping,g=f===oa||f===aa,_=f===Mi||f===Hi;if(g||_){let m=e.get(u),p=m!==void 0?m.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==p)return n===null&&(n=new Za(i)),m=g?n.fromEquirectangular(u,m):n.fromCubemap(u,m),m.texture.pmremVersion=u.pmremVersion,e.set(u,m),m.texture;if(m!==void 0)return m.texture;{let b=u.image;return g&&b&&b.height>0||_&&b&&l(b)?(n===null&&(n=new Za(i)),m=g?n.fromEquirectangular(u):n.fromCubemap(u),m.texture.pmremVersion=u.pmremVersion,e.set(u,m),u.addEventListener("dispose",h),m.texture):null}}}return u}function a(u,f){return f===oa?u.mapping=Mi:f===aa&&(u.mapping=Hi),u}function l(u){let f=0,g=6;for(let _=0;_=65535?er:tr)(u,1);m.version=_;let p=r.get(d);p&&t.remove(p),r.set(d,m)}function h(d){let u=r.get(d);if(u){let f=d.index;f!==null&&u.versiont.maxTextureSize&&(y=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize);let S=new Float32Array(v*y*4*d),A=new Qs(S,v,y,d);A.type=Ye,A.needsUpdate=!0;let x=E*4;for(let C=0;C0&&b[0].isRenderPass===!0;let y=o.width,S=o.height;b.length>0&&a===null&&(a=new He(y,S,{type:Sn,depthBuffer:!1,stencilBuffer:!1}),l=new He(y,S,{type:Sn,depthBuffer:!1,stencilBuffer:!1}));for(let A=0;A0)return i;let s=t*e,r=wd[s];if(r===void 0&&(r=new Float32Array(s),wd[s]=r),t!==0){n.toArray(r,0);for(let o=1,a=0;o!==t;++o)a+=e,i[o].toArray(r,a)}return r}function Ue(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e0&&(this.seq=s.concat(r))}setValue(t,e,n,s){let r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){let s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){for(let r=0,o=e.length;r!==o;++r){let a=e[r],l=n[a.id];l.needsUpdate!==!1&&a.setValue(t,l.value,s)}}static seqWithValue(t,e){let n=[];for(let s=0,r=t.length;s!==r;++s){let o=t[s];o.id in e&&n.push(o)}return n}};function Id(i,t,e){let n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}var Tx=37297,Ax=0;function Rx(i,t){let e=i.split(` + }`,depthTest:!1,depthWrite:!1}),d=new _e(c,h),u=new zn(-1,1,1,-1,0,1),f=null,g=null,_=!1,m,p=null,b=[],E=!1;this.setSize=function(v,y){o.setSize(v,y),a!==null&&a.setSize(v,y),l!==null&&l.setSize(v,y);for(let S=0;S0&&b[0].isRenderPass===!0;let y=o.width,S=o.height;b.length>0&&a===null&&(a=new Ve(y,S,{type:wn,depthBuffer:!1,stencilBuffer:!1}),l=new Ve(y,S,{type:wn,depthBuffer:!1,stencilBuffer:!1}));for(let A=0;A0)return i;let s=t*e,r=Td[s];if(r===void 0&&(r=new Float32Array(s),Td[s]=r),t!==0){n.toArray(r,0);for(let o=1,a=0;o!==t;++o)a+=e,i[o].toArray(r,a)}return r}function Ue(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e0&&(this.seq=s.concat(r))}setValue(t,e,n,s){let r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){let s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){for(let r=0,o=e.length;r!==o;++r){let a=e[r],l=n[a.id];l.needsUpdate!==!1&&a.setValue(t,l.value,s)}}static seqWithValue(t,e){let n=[];for(let s=0,r=t.length;s!==r;++s){let o=t[s];o.id in e&&n.push(o)}return n}};function Ld(i,t,e){let n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}var Cx=37297,Ix=0;function Px(i,t){let e=i.split(` `),n=[],s=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let o=s;o":" "} ${a}: ${e[o]}`)}return n.join(` -`)}var Pd=new qt;function Cx(i){te._getMatrix(Pd,te.workingColorSpace,i);let t=`mat3( ${Pd.elements.map(e=>e.toFixed(4))} )`;switch(te.getTransfer(i)){case Js:return[t,"LinearTransferOETF"];case he:return[t,"sRGBTransferOETF"];default:return zt("WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Ld(i,t,e){let n=i.getShaderParameter(t,i.COMPILE_STATUS),r=(i.getShaderInfoLog(t)||"").trim();if(n&&r==="")return"";let o=/ERROR: 0:(\d+)/.exec(r);if(o){let a=parseInt(o[1]);return e.toUpperCase()+` +`)}var Dd=new qt;function Lx(i){te._getMatrix(Dd,te.workingColorSpace,i);let t=`mat3( ${Dd.elements.map(e=>e.toFixed(4))} )`;switch(te.getTransfer(i)){case Ks:return[t,"LinearTransferOETF"];case ue:return[t,"sRGBTransferOETF"];default:return Ht("WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Nd(i,t,e){let n=i.getShaderParameter(t,i.COMPILE_STATUS),r=(i.getShaderInfoLog(t)||"").trim();if(n&&r==="")return"";let o=/ERROR: 0:(\d+)/.exec(r);if(o){let a=parseInt(o[1]);return e.toUpperCase()+` `+r+` -`+Rx(i.getShaderSource(t),a)}else return r}function Ix(i,t){let e=Cx(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(` -`)}var Px={[pc]:"Linear",[mc]:"Reinhard",[gc]:"Cineon",[_c]:"ACESFilmic",[vc]:"AgX",[yc]:"Neutral",[xc]:"Custom"};function Lx(i,t){let e=Px[t];return e===void 0?(zt("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}var Xa=new I;function Dx(){te.getLuminanceCoefficients(Xa);let i=Xa.x.toFixed(4),t=Xa.y.toFixed(4),e=Xa.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(` -`)}function Nx(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(wr).join(` -`)}function Ux(i){let t=[];for(let e in i){let n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(` -`)}function Fx(i,t){let e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function th(i){return i.replace(Bx,zx)}var Ox=new Map;function zx(i,t){let e=jt[t];if(e===void 0){let n=Ox.get(t);if(n!==void 0)e=jt[n],zt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return th(e)}var kx=/#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 Ud(i){return i.replace(kx,Hx)}function Hx(i,t,e,n){let s="";for(let r=parseInt(t);r/gm;function nh(i){return i.replace(kx,Vx)}var Hx=new Map;function Vx(i,t){let e=Kt[t];if(e===void 0){let n=Hx.get(t);if(n!==void 0)e=Kt[n],Ht('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return nh(e)}var Gx=/#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 Bd(i){return i.replace(Gx,Wx)}function Wx(i,t,e,n){let s="";for(let r=parseInt(t);r0&&(m+=` -`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(wr).join(` +`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Cr).join(` `),p.length>0&&(p+=` -`)):(m=[Fd(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexNormals?"#define HAS_NORMAL":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.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",` -`].filter(wr).join(` -`),p=[Fd(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+h:"",e.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.retroreflection?"#define USE_RETROREFLECTION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas||e.batchingColor?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==Mn?"#define TONE_MAPPING":"",e.toneMapping!==Mn?jt.tonemapping_pars_fragment:"",e.toneMapping!==Mn?Lx("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",jt.colorspace_pars_fragment,Ix("linearToOutputTexel",e.outputColorSpace),Dx(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` -`].filter(wr).join(` -`)),o=th(o),o=Dd(o,e),o=Nd(o,e),a=th(a),a=Dd(a,e),a=Nd(a,e),o=Ud(o),a=Ud(a),e.isRawShaderMaterial!==!0&&(b=`#version 300 es +`)):(m=[Od(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexNormals?"#define HAS_NORMAL":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.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",` +`].filter(Cr).join(` +`),p=[Od(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+h:"",e.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.retroreflection?"#define USE_RETROREFLECTION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas||e.batchingColor?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==bn?"#define TONE_MAPPING":"",e.toneMapping!==bn?Kt.tonemapping_pars_fragment:"",e.toneMapping!==bn?Ux("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Kt.colorspace_pars_fragment,Dx("linearToOutputTexel",e.outputColorSpace),Fx(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` +`].filter(Cr).join(` +`)),o=nh(o),o=Ud(o,e),o=Fd(o,e),a=nh(a),a=Ud(a,e),a=Fd(a,e),o=Bd(o),a=Bd(a),e.isRawShaderMaterial!==!0&&(b=`#version 300 es `,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` -`+m,p=["#define varying in",e.glslVersion===Dc?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Dc?"":"#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(` +`+m,p=["#define varying in",e.glslVersion===Uc?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Uc?"":"#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(` `)+` -`+p);let w=b+m+o,v=b+p+a,y=Id(s,s.VERTEX_SHADER,w),S=Id(s,s.FRAGMENT_SHADER,v);s.attachShader(_,y),s.attachShader(_,S),e.index0AttributeName!==void 0?s.bindAttribLocation(_,0,e.index0AttributeName):e.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function A(D){if(i.debug.checkShaderErrors){let F=s.getProgramInfoLog(_)||"",U=s.getShaderInfoLog(y)||"",C=s.getShaderInfoLog(S)||"",B=F.trim(),W=U.trim(),q=C.trim(),O=!0,L=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(O=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,y,S);else{let H=Ld(s,y,"vertex"),X=Ld(s,S,"fragment");Ht("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` +`+p);let E=b+m+o,v=b+p+a,y=Ld(s,s.VERTEX_SHADER,E),S=Ld(s,s.FRAGMENT_SHADER,v);s.attachShader(_,y),s.attachShader(_,S),e.index0AttributeName!==void 0?s.bindAttribLocation(_,0,e.index0AttributeName):e.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function A(D){if(i.debug.checkShaderErrors){let U=s.getProgramInfoLog(_)||"",F=s.getShaderInfoLog(y)||"",I=s.getShaderInfoLog(S)||"",B=U.trim(),G=F.trim(),q=I.trim(),O=!0,N=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(O=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,y,S);else{let z=Nd(s,y,"vertex"),W=Nd(s,S,"fragment");Wt("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` Material Name: `+D.name+` Material Type: `+D.type+` Program Info Log: `+B+` -`+H+` -`+X)}else B!==""?zt("WebGLProgram: Program Info Log:",B):(W===""||q==="")&&(L=!1);L&&(D.diagnostics={runnable:O,programLog:B,vertexShader:{log:W,prefix:m},fragmentShader:{log:q,prefix:p}})}s.deleteShader(y),s.deleteShader(S),x=new Ds(s,_),T=Fx(s,_)}let x;this.getUniforms=function(){return x===void 0&&A(this),x};let T;this.getAttributes=function(){return T===void 0&&A(this),T};let R=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=s.getProgramParameter(_,Tx)),R},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=Ax++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=y,this.fragmentShader=S,this}var jx=0,eh=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){let s=this._getShaderCacheForMaterial(t);return s.has(e)===!1&&(s.add(e),e.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new nh(t),e.set(t,n)),n}},nh=class{constructor(t){this.id=jx++,this.code=t,this.usedTimes=0}};function Qx(i){return i===bi||i===yr||i===Mr}function tv(i,t,e,n,s,r){let o=new xs,a=new eh,l=new Set,c=[],h=new Map,d=n.logarithmicDepthBuffer,u=n.precision,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(x){return l.add(x),x===0?"uv":`uv${x}`}function _(x,T,R,D,F,U){let C=D.fog,B=F.geometry,W=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?D.environment:null,q=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,O=t.get(x.envMap||W,q),L=O&&O.mapping===pr?O.image.height:null,H=f[x.type];x.precision!==null&&(u=n.getMaxPrecision(x.precision),u!==x.precision&&zt("WebGLProgram.getParameters:",x.precision,"not supported, using",u,"instead."));let X=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,z=X!==void 0?X.length:0,Q=0;B.morphAttributes.position!==void 0&&(Q=1),B.morphAttributes.normal!==void 0&&(Q=2),B.morphAttributes.color!==void 0&&(Q=3);let lt,ut,ct,G;if(H){let xe=Vn[H];lt=xe.vertexShader,ut=xe.fragmentShader}else{lt=x.vertexShader,ut=x.fragmentShader;let xe=a.getVertexShaderStage(x),le=a.getFragmentShaderStage(x);a.update(x,xe,le),ct=xe.id,G=le.id}let tt=i.getRenderTarget(),rt=i.state.buffers.depth.getReversed(),yt=F.isInstancedMesh===!0,ft=F.isBatchedMesh===!0,Ot=!!x.map,ae=!!x.matcap,Gt=!!O,dt=!!x.aoMap,Nt=!!x.lightMap,Pt=!!x.bumpMap&&x.wireframe===!1,Wt=!!x.normalMap,fe=!!x.displacementMap,Ee=!!x.emissiveMap,at=!!x.metalnessMap,Mt=!!x.roughnessMap,N=x.anisotropy>0,Yt=x.clearcoat>0,Xt=x.dispersion>0,P=x.retroreflectivity>0,M=x.iridescence>0,Y=x.sheen>0,K=x.transmission>0,nt=N&&!!x.anisotropyMap,pt=Yt&&!!x.clearcoatMap,mt=Yt&&!!x.clearcoatNormalMap,it=Yt&&!!x.clearcoatRoughnessMap,ot=M&&!!x.iridescenceMap,gt=M&&!!x.iridescenceThicknessMap,Ut=Y&&!!x.sheenColorMap,bt=Y&&!!x.sheenRoughnessMap,_t=!!x.specularMap,Ft=!!x.specularColorMap,kt=!!x.specularIntensityMap,Zt=K&&!!x.transmissionMap,V=K&&!!x.thicknessMap,xt=!!x.gradientMap,st=!!x.alphaMap,vt=x.alphaTest>0,Tt=!!x.alphaHash,ht=!!x.extensions,Bt=Mn;x.toneMapped&&(tt===null||tt.isXRRenderTarget===!0)&&(Bt=i.toneMapping);let Lt={shaderID:H,shaderType:x.type,shaderName:x.name,vertexShader:lt,fragmentShader:ut,defines:x.defines,customVertexShaderID:ct,customFragmentShaderID:G,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:u,batching:ft,batchingColor:ft&&F._colorsTexture!==null,instancing:yt,instancingColor:yt&&F.instanceColor!==null,instancingMorph:yt&&F.morphTexture!==null,outputColorSpace:tt===null?i.outputColorSpace:tt.isXRRenderTarget===!0?tt.texture.colorSpace:te.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Ot,matcap:ae,envMap:Gt,envMapMode:Gt&&O.mapping,envMapCubeUVHeight:L,aoMap:dt,lightMap:Nt,bumpMap:Pt,normalMap:Wt,displacementMap:fe,emissiveMap:Ee,normalMapObjectSpace:Wt&&x.normalMapType===sd,normalMapTangentSpace:Wt&&x.normalMapType===Ha,packedNormalMap:Wt&&x.normalMapType===Ha&&Qx(x.normalMap.format),metalnessMap:at,roughnessMap:Mt,anisotropy:N,anisotropyMap:nt,clearcoat:Yt,clearcoatMap:pt,clearcoatNormalMap:mt,clearcoatRoughnessMap:it,dispersion:Xt,retroreflection:P,iridescence:M,iridescenceMap:ot,iridescenceThicknessMap:gt,sheen:Y,sheenColorMap:Ut,sheenRoughnessMap:bt,specularMap:_t,specularColorMap:Ft,specularIntensityMap:kt,transmission:K,transmissionMap:Zt,thicknessMap:V,gradientMap:xt,opaque:x.transparent===!1&&x.blending===As&&x.alphaToCoverage===!1,alphaMap:st,alphaTest:vt,alphaHash:Tt,combine:x.combine,mapUv:Ot&&g(x.map.channel),aoMapUv:dt&&g(x.aoMap.channel),lightMapUv:Nt&&g(x.lightMap.channel),bumpMapUv:Pt&&g(x.bumpMap.channel),normalMapUv:Wt&&g(x.normalMap.channel),displacementMapUv:fe&&g(x.displacementMap.channel),emissiveMapUv:Ee&&g(x.emissiveMap.channel),metalnessMapUv:at&&g(x.metalnessMap.channel),roughnessMapUv:Mt&&g(x.roughnessMap.channel),anisotropyMapUv:nt&&g(x.anisotropyMap.channel),clearcoatMapUv:pt&&g(x.clearcoatMap.channel),clearcoatNormalMapUv:mt&&g(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:it&&g(x.clearcoatRoughnessMap.channel),iridescenceMapUv:ot&&g(x.iridescenceMap.channel),iridescenceThicknessMapUv:gt&&g(x.iridescenceThicknessMap.channel),sheenColorMapUv:Ut&&g(x.sheenColorMap.channel),sheenRoughnessMapUv:bt&&g(x.sheenRoughnessMap.channel),specularMapUv:_t&&g(x.specularMap.channel),specularColorMapUv:Ft&&g(x.specularColorMap.channel),specularIntensityMapUv:kt&&g(x.specularIntensityMap.channel),transmissionMapUv:Zt&&g(x.transmissionMap.channel),thicknessMapUv:V&&g(x.thicknessMap.channel),alphaMapUv:st&&g(x.alphaMap.channel),vertexTangents:!!B.attributes.tangent&&(Wt||N),vertexNormals:!!B.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!B.attributes.uv&&(Ot||st),fog:!!C,useFog:x.fog===!0,fogExp2:!!C&&C.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||B.attributes.normal===void 0&&Wt===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:rt,skinning:F.isSkinnedMesh===!0,hasPositionAttribute:B.attributes.position!==void 0,morphTargets:B.morphAttributes.position!==void 0,morphNormals:B.morphAttributes.normal!==void 0,morphColors:B.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:Q,numSunLights:T.sun.length,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numSunLightShadows:T.sunShadowMap.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:U.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:x.dithering,shadowMapEnabled:i.shadowMap.enabled&&R.length>0,shadowMapType:i.shadowMap.type,toneMapping:Bt,decodeVideoTexture:Ot&&x.map.isVideoTexture===!0&&te.getTransfer(x.map.colorSpace)===he,decodeVideoTextureEmissive:Ee&&x.emissiveMap.isVideoTexture===!0&&te.getTransfer(x.emissiveMap.colorSpace)===he,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===Ne,flipSided:x.side===De,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ht&&x.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ht&&x.extensions.multiDraw===!0||ft)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Lt.vertexUv1s=l.has(1),Lt.vertexUv2s=l.has(2),Lt.vertexUv3s=l.has(3),l.clear(),Lt}function m(x){let T=[];if(x.shaderID?T.push(x.shaderID):(T.push(x.customVertexShaderID),T.push(x.customFragmentShaderID)),x.defines!==void 0)for(let R in x.defines)T.push(R),T.push(x.defines[R]);return x.isRawShaderMaterial===!1&&(p(T,x),b(T,x),T.push(i.outputColorSpace)),T.push(x.customProgramCacheKey),T.join()}function p(x,T){x.push(T.precision),x.push(T.outputColorSpace),x.push(T.envMapMode),x.push(T.envMapCubeUVHeight),x.push(T.mapUv),x.push(T.alphaMapUv),x.push(T.lightMapUv),x.push(T.aoMapUv),x.push(T.bumpMapUv),x.push(T.normalMapUv),x.push(T.displacementMapUv),x.push(T.emissiveMapUv),x.push(T.metalnessMapUv),x.push(T.roughnessMapUv),x.push(T.anisotropyMapUv),x.push(T.clearcoatMapUv),x.push(T.clearcoatNormalMapUv),x.push(T.clearcoatRoughnessMapUv),x.push(T.iridescenceMapUv),x.push(T.iridescenceThicknessMapUv),x.push(T.sheenColorMapUv),x.push(T.sheenRoughnessMapUv),x.push(T.specularMapUv),x.push(T.specularColorMapUv),x.push(T.specularIntensityMapUv),x.push(T.transmissionMapUv),x.push(T.thicknessMapUv),x.push(T.combine),x.push(T.fogExp2),x.push(T.sizeAttenuation),x.push(T.morphTargetsCount),x.push(T.morphAttributeCount),x.push(T.numSunLights),x.push(T.numDirLights),x.push(T.numPointLights),x.push(T.numSpotLights),x.push(T.numSpotLightMaps),x.push(T.numHemiLights),x.push(T.numRectAreaLights),x.push(T.numSunLightShadows),x.push(T.numDirLightShadows),x.push(T.numPointLightShadows),x.push(T.numSpotLightShadows),x.push(T.numSpotLightShadowsWithMaps),x.push(T.numLightProbes),x.push(T.shadowMapType),x.push(T.toneMapping),x.push(T.numClippingPlanes),x.push(T.numClipIntersection),x.push(T.depthPacking)}function b(x,T){o.disableAll(),T.instancing&&o.enable(0),T.instancingColor&&o.enable(1),T.instancingMorph&&o.enable(2),T.matcap&&o.enable(3),T.envMap&&o.enable(4),T.normalMapObjectSpace&&o.enable(5),T.normalMapTangentSpace&&o.enable(6),T.clearcoat&&o.enable(7),T.iridescence&&o.enable(8),T.alphaTest&&o.enable(9),T.vertexColors&&o.enable(10),T.vertexAlphas&&o.enable(11),T.vertexUv1s&&o.enable(12),T.vertexUv2s&&o.enable(13),T.vertexUv3s&&o.enable(14),T.vertexTangents&&o.enable(15),T.anisotropy&&o.enable(16),T.alphaHash&&o.enable(17),T.batching&&o.enable(18),T.dispersion&&o.enable(19),T.retroreflection&&o.enable(24),T.batchingColor&&o.enable(20),T.gradientMap&&o.enable(21),T.packedNormalMap&&o.enable(22),T.vertexNormals&&o.enable(23),x.push(o.mask),o.disableAll(),T.fog&&o.enable(0),T.useFog&&o.enable(1),T.flatShading&&o.enable(2),T.logarithmicDepthBuffer&&o.enable(3),T.reversedDepthBuffer&&o.enable(4),T.skinning&&o.enable(5),T.morphTargets&&o.enable(6),T.morphNormals&&o.enable(7),T.morphColors&&o.enable(8),T.premultipliedAlpha&&o.enable(9),T.shadowMapEnabled&&o.enable(10),T.doubleSided&&o.enable(11),T.flipSided&&o.enable(12),T.useDepthPacking&&o.enable(13),T.dithering&&o.enable(14),T.transmission&&o.enable(15),T.sheen&&o.enable(16),T.opaque&&o.enable(17),T.pointsUvs&&o.enable(18),T.decodeVideoTexture&&o.enable(19),T.decodeVideoTextureEmissive&&o.enable(20),T.alphaToCoverage&&o.enable(21),T.numLightProbeGrids>0&&o.enable(22),T.hasPositionAttribute&&o.enable(23),x.push(o.mask)}function w(x){let T=f[x.type],R;if(T){let D=Vn[T];R=_d.clone(D.uniforms)}else R=x.uniforms;return R}function v(x,T){let R=h.get(T);return R!==void 0?++R.usedTimes:(R=new Kx(i,T,x,s),c.push(R),h.set(T,R)),R}function y(x){if(--x.usedTimes===0){let T=c.indexOf(x);c[T]=c[c.length-1],c.pop(),h.delete(x.cacheKey),x.destroy()}}function S(x){a.remove(x)}function A(){a.dispose()}return{getParameters:_,getProgramCacheKey:m,getUniforms:w,acquireProgram:v,releaseProgram:y,releaseShaderCache:S,programs:c,dispose:A}}function ev(){let i=new WeakMap;function t(o){return i.has(o)}function e(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,l){i.get(o)[a]=l}function r(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:r}}function nv(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.materialVariant!==t.materialVariant?i.materialVariant-t.materialVariant:i.z!==t.z?i.z-t.z:i.id-t.id}function Bd(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function Od(){let i=[],t=0,e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function o(u){let f=0;return u.isInstancedMesh&&(f+=2),u.isSkinnedMesh&&(f+=1),f}function a(u,f,g,_,m,p){let b=i[t];return b===void 0?(b={id:u.id,object:u,geometry:f,material:g,materialVariant:o(u),groupOrder:_,renderOrder:u.renderOrder,z:m,group:p},i[t]=b):(b.id=u.id,b.object=u,b.geometry=f,b.material=g,b.materialVariant=o(u),b.groupOrder=_,b.renderOrder=u.renderOrder,b.z=m,b.group=p),t++,b}function l(u,f,g,_,m,p,b){b.reversedDepth===!0&&(m=-m);let w=a(u,f,g,_,m,p);g.transmission>0?n.push(w):g.transparent===!0?s.push(w):e.push(w)}function c(u,f,g,_,m,p){let b=a(u,f,g,_,m,p);g.transmission>0?n.unshift(b):g.transparent===!0?s.unshift(b):e.unshift(b)}function h(u,f){e.length>1&&e.sort(u||nv),n.length>1&&n.sort(f||Bd),s.length>1&&s.sort(f||Bd)}function d(){for(let u=t,f=i.length;u=r.length?(o=new Od,r.push(o)):o=r[s],o}function e(){i=new WeakMap}return{get:t,dispose:e}}function sv(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"SunLight":case"DirectionalLight":e={direction:new I,color:new Vt};break;case"SpotLight":e={position:new I,direction:new I,color:new Vt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new I,color:new Vt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new I,skyColor:new Vt,groundColor:new Vt};break;case"RectAreaLight":e={color:new Vt,position:new I,halfWidth:new I,halfHeight:new I};break}return i[t.id]=e,e}}}function rv(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"SunLight":case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $t};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $t};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $t,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var ov=0;function av(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function lv(i){let t=new sv,e=rv(),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 c=0;c<9;c++)n.probe.push(new I);let s=new I,r=new Jt,o=new Jt;function a(c){let h=0,d=0,u=0;for(let F=0;F<9;F++)n.probe[F].set(0,0,0);let f=0,g=0,_=0,m=0,p=0,b=0,w=0,v=0,y=0,S=0,A=0,x=0,T=0,R=0;c.sort(av);for(let F=0,U=c.length;F0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=St.LTC_FLOAT_1,n.rectAreaLTC2=St.LTC_FLOAT_2):(n.rectAreaLTC1=St.LTC_HALF_1,n.rectAreaLTC2=St.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let D=n.hash;(D.sunLength!==f||D.directionalLength!==m||D.pointLength!==p||D.spotLength!==b||D.rectAreaLength!==w||D.hemiLength!==v||D.numSunShadows!==g||D.numDirectionalShadows!==y||D.numPointShadows!==S||D.numSpotShadows!==A||D.numSpotMaps!==x||D.numLightProbes!==R)&&(n.sun.length=f,n.directional.length=m,n.spot.length=b,n.rectArea.length=w,n.point.length=p,n.hemi.length=v,n.sunShadow.length=g,n.sunShadowMap.length=g,n.sunShadowMatrix.length=_,n.sunShadowCascade.length=_,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.directionalShadowMatrix.length=y,n.pointShadow.length=S,n.pointShadowMap.length=S,n.pointShadowMatrix.length=S,n.spotShadow.length=A,n.spotShadowMap.length=A,n.spotLightMatrix.length=A+x-T,n.spotLightMap.length=x,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=R,D.sunLength=f,D.directionalLength=m,D.pointLength=p,D.spotLength=b,D.rectAreaLength=w,D.hemiLength=v,D.numSunShadows=g,D.numDirectionalShadows=y,D.numPointShadows=S,D.numSpotShadows=A,D.numSpotMaps=x,D.numLightProbes=R,n.version=ov++)}function l(c,h){let d=0,u=0,f=0,g=0,_=0,m=0,p=h.matrixWorldInverse;for(let b=0,w=c.length;b=o.length?(a=new zd(i),o.push(a)):a=o[r],a}function n(){t=new WeakMap}return{get:e,dispose:n}}var hv=`void main() { +`+z+` +`+W)}else B!==""?Ht("WebGLProgram: Program Info Log:",B):(G===""||q==="")&&(N=!1);N&&(D.diagnostics={runnable:O,programLog:B,vertexShader:{log:G,prefix:m},fragmentShader:{log:q,prefix:p}})}s.deleteShader(y),s.deleteShader(S),x=new Ds(s,_),T=zx(s,_)}let x;this.getUniforms=function(){return x===void 0&&A(this),x};let T;this.getAttributes=function(){return T===void 0&&A(this),T};let C=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return C===!1&&(C=s.getProgramParameter(_,Cx)),C},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=Ix++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=y,this.fragmentShader=S,this}var ev=0,ih=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){let s=this._getShaderCacheForMaterial(t);return s.has(e)===!1&&(s.add(e),e.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new sh(t),e.set(t,n)),n}},sh=class{constructor(t){this.id=ev++,this.code=t,this.usedTimes=0}};function nv(i){return i===wi||i===Sr||i===wr}function iv(i,t,e,n,s,r){let o=new vs,a=new ih,l=new Set,c=[],h=new Map,d=n.logarithmicDepthBuffer,u=n.precision,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(x){return l.add(x),x===0?"uv":`uv${x}`}function _(x,T,C,D,U,F){let I=D.fog,B=U.geometry,G=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?D.environment:null,q=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,O=t.get(x.envMap||G,q),N=O&&O.mapping===_r?O.image.height:null,z=f[x.type];x.precision!==null&&(u=n.getMaxPrecision(x.precision),u!==x.precision&&Ht("WebGLProgram.getParameters:",x.precision,"not supported, using",u,"instead."));let W=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,k=W!==void 0?W.length:0,K=0;B.morphAttributes.position!==void 0&&(K=1),B.morphAttributes.normal!==void 0&&(K=2),B.morphAttributes.color!==void 0&&(K=3);let lt,ht,at,Y;if(z){let xe=Wn[z];lt=xe.vertexShader,ht=xe.fragmentShader}else{lt=x.vertexShader,ht=x.fragmentShader;let xe=a.getVertexShaderStage(x),ce=a.getFragmentShaderStage(x);a.update(x,xe,ce),at=xe.id,Y=ce.id}let tt=i.getRenderTarget(),dt=i.state.buffers.depth.getReversed(),It=U.isInstancedMesh===!0,ot=U.isBatchedMesh===!0,Tt=!!x.map,jt=!!x.matcap,Bt=!!O,ut=!!x.aoMap,Lt=!!x.lightMap,Ot=!!x.bumpMap&&x.wireframe===!1,zt=!!x.normalMap,Zt=!!x.displacementMap,Ee=!!x.emissiveMap,ie=!!x.metalnessMap,re=!!x.roughnessMap,R=x.anisotropy>0,wt=x.clearcoat>0,kt=x.dispersion>0,P=x.retroreflectivity>0,M=x.iridescence>0,X=x.sheen>0,j=x.transmission>0,nt=R&&!!x.anisotropyMap,ft=wt&&!!x.clearcoatMap,pt=wt&&!!x.clearcoatNormalMap,it=wt&&!!x.clearcoatRoughnessMap,rt=M&&!!x.iridescenceMap,mt=M&&!!x.iridescenceThicknessMap,Nt=X&&!!x.sheenColorMap,vt=X&&!!x.sheenRoughnessMap,gt=!!x.specularMap,Ut=!!x.specularColorMap,Gt=!!x.specularIntensityMap,$t=j&&!!x.transmissionMap,V=j&&!!x.thicknessMap,_t=!!x.gradientMap,st=!!x.alphaMap,xt=x.alphaTest>0,St=!!x.alphaHash,ct=!!x.extensions,Ft=bn;x.toneMapped&&(tt===null||tt.isXRRenderTarget===!0)&&(Ft=i.toneMapping);let Pt={shaderID:z,shaderType:x.type,shaderName:x.name,vertexShader:lt,fragmentShader:ht,defines:x.defines,customVertexShaderID:at,customFragmentShaderID:Y,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:u,batching:ot,batchingColor:ot&&U._colorsTexture!==null,instancing:It,instancingColor:It&&U.instanceColor!==null,instancingMorph:It&&U.morphTexture!==null,outputColorSpace:tt===null?i.outputColorSpace:tt.isXRRenderTarget===!0?tt.texture.colorSpace:te.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Tt,matcap:jt,envMap:Bt,envMapMode:Bt&&O.mapping,envMapCubeUVHeight:N,aoMap:ut,lightMap:Lt,bumpMap:Ot,normalMap:zt,displacementMap:Zt,emissiveMap:Ee,normalMapObjectSpace:zt&&x.normalMapType===od,normalMapTangentSpace:zt&&x.normalMapType===Er,packedNormalMap:zt&&x.normalMapType===Er&&nv(x.normalMap.format),metalnessMap:ie,roughnessMap:re,anisotropy:R,anisotropyMap:nt,clearcoat:wt,clearcoatMap:ft,clearcoatNormalMap:pt,clearcoatRoughnessMap:it,dispersion:kt,retroreflection:P,iridescence:M,iridescenceMap:rt,iridescenceThicknessMap:mt,sheen:X,sheenColorMap:Nt,sheenRoughnessMap:vt,specularMap:gt,specularColorMap:Ut,specularIntensityMap:Gt,transmission:j,transmissionMap:$t,thicknessMap:V,gradientMap:_t,opaque:x.transparent===!1&&x.blending===As&&x.alphaToCoverage===!1,alphaMap:st,alphaTest:xt,alphaHash:St,combine:x.combine,mapUv:Tt&&g(x.map.channel),aoMapUv:ut&&g(x.aoMap.channel),lightMapUv:Lt&&g(x.lightMap.channel),bumpMapUv:Ot&&g(x.bumpMap.channel),normalMapUv:zt&&g(x.normalMap.channel),displacementMapUv:Zt&&g(x.displacementMap.channel),emissiveMapUv:Ee&&g(x.emissiveMap.channel),metalnessMapUv:ie&&g(x.metalnessMap.channel),roughnessMapUv:re&&g(x.roughnessMap.channel),anisotropyMapUv:nt&&g(x.anisotropyMap.channel),clearcoatMapUv:ft&&g(x.clearcoatMap.channel),clearcoatNormalMapUv:pt&&g(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:it&&g(x.clearcoatRoughnessMap.channel),iridescenceMapUv:rt&&g(x.iridescenceMap.channel),iridescenceThicknessMapUv:mt&&g(x.iridescenceThicknessMap.channel),sheenColorMapUv:Nt&&g(x.sheenColorMap.channel),sheenRoughnessMapUv:vt&&g(x.sheenRoughnessMap.channel),specularMapUv:gt&&g(x.specularMap.channel),specularColorMapUv:Ut&&g(x.specularColorMap.channel),specularIntensityMapUv:Gt&&g(x.specularIntensityMap.channel),transmissionMapUv:$t&&g(x.transmissionMap.channel),thicknessMapUv:V&&g(x.thicknessMap.channel),alphaMapUv:st&&g(x.alphaMap.channel),vertexTangents:!!B.attributes.tangent&&(zt||R),vertexNormals:!!B.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!B.attributes.uv&&(Tt||st),fog:!!I,useFog:x.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||B.attributes.normal===void 0&&zt===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:dt,skinning:U.isSkinnedMesh===!0,hasPositionAttribute:B.attributes.position!==void 0,morphTargets:B.morphAttributes.position!==void 0,morphNormals:B.morphAttributes.normal!==void 0,morphColors:B.morphAttributes.color!==void 0,morphTargetsCount:k,morphTextureStride:K,numSunLights:T.sun.length,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numSunLightShadows:T.sunShadowMap.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:F.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:x.dithering,shadowMapEnabled:i.shadowMap.enabled&&C.length>0,shadowMapType:i.shadowMap.type,toneMapping:Ft,decodeVideoTexture:Tt&&x.map.isVideoTexture===!0&&te.getTransfer(x.map.colorSpace)===ue,decodeVideoTextureEmissive:Ee&&x.emissiveMap.isVideoTexture===!0&&te.getTransfer(x.emissiveMap.colorSpace)===ue,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===Ne,flipSided:x.side===De,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ct&&x.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ct&&x.extensions.multiDraw===!0||ot)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Pt.vertexUv1s=l.has(1),Pt.vertexUv2s=l.has(2),Pt.vertexUv3s=l.has(3),l.clear(),Pt}function m(x){let T=[];if(x.shaderID?T.push(x.shaderID):(T.push(x.customVertexShaderID),T.push(x.customFragmentShaderID)),x.defines!==void 0)for(let C in x.defines)T.push(C),T.push(x.defines[C]);return x.isRawShaderMaterial===!1&&(p(T,x),b(T,x),T.push(i.outputColorSpace)),T.push(x.customProgramCacheKey),T.join()}function p(x,T){x.push(T.precision),x.push(T.outputColorSpace),x.push(T.envMapMode),x.push(T.envMapCubeUVHeight),x.push(T.mapUv),x.push(T.alphaMapUv),x.push(T.lightMapUv),x.push(T.aoMapUv),x.push(T.bumpMapUv),x.push(T.normalMapUv),x.push(T.displacementMapUv),x.push(T.emissiveMapUv),x.push(T.metalnessMapUv),x.push(T.roughnessMapUv),x.push(T.anisotropyMapUv),x.push(T.clearcoatMapUv),x.push(T.clearcoatNormalMapUv),x.push(T.clearcoatRoughnessMapUv),x.push(T.iridescenceMapUv),x.push(T.iridescenceThicknessMapUv),x.push(T.sheenColorMapUv),x.push(T.sheenRoughnessMapUv),x.push(T.specularMapUv),x.push(T.specularColorMapUv),x.push(T.specularIntensityMapUv),x.push(T.transmissionMapUv),x.push(T.thicknessMapUv),x.push(T.combine),x.push(T.fogExp2),x.push(T.sizeAttenuation),x.push(T.morphTargetsCount),x.push(T.morphAttributeCount),x.push(T.numSunLights),x.push(T.numDirLights),x.push(T.numPointLights),x.push(T.numSpotLights),x.push(T.numSpotLightMaps),x.push(T.numHemiLights),x.push(T.numRectAreaLights),x.push(T.numSunLightShadows),x.push(T.numDirLightShadows),x.push(T.numPointLightShadows),x.push(T.numSpotLightShadows),x.push(T.numSpotLightShadowsWithMaps),x.push(T.numLightProbes),x.push(T.shadowMapType),x.push(T.toneMapping),x.push(T.numClippingPlanes),x.push(T.numClipIntersection),x.push(T.depthPacking)}function b(x,T){o.disableAll(),T.instancing&&o.enable(0),T.instancingColor&&o.enable(1),T.instancingMorph&&o.enable(2),T.matcap&&o.enable(3),T.envMap&&o.enable(4),T.normalMapObjectSpace&&o.enable(5),T.normalMapTangentSpace&&o.enable(6),T.clearcoat&&o.enable(7),T.iridescence&&o.enable(8),T.alphaTest&&o.enable(9),T.vertexColors&&o.enable(10),T.vertexAlphas&&o.enable(11),T.vertexUv1s&&o.enable(12),T.vertexUv2s&&o.enable(13),T.vertexUv3s&&o.enable(14),T.vertexTangents&&o.enable(15),T.anisotropy&&o.enable(16),T.alphaHash&&o.enable(17),T.batching&&o.enable(18),T.dispersion&&o.enable(19),T.retroreflection&&o.enable(24),T.batchingColor&&o.enable(20),T.gradientMap&&o.enable(21),T.packedNormalMap&&o.enable(22),T.vertexNormals&&o.enable(23),x.push(o.mask),o.disableAll(),T.fog&&o.enable(0),T.useFog&&o.enable(1),T.flatShading&&o.enable(2),T.logarithmicDepthBuffer&&o.enable(3),T.reversedDepthBuffer&&o.enable(4),T.skinning&&o.enable(5),T.morphTargets&&o.enable(6),T.morphNormals&&o.enable(7),T.morphColors&&o.enable(8),T.premultipliedAlpha&&o.enable(9),T.shadowMapEnabled&&o.enable(10),T.doubleSided&&o.enable(11),T.flipSided&&o.enable(12),T.useDepthPacking&&o.enable(13),T.dithering&&o.enable(14),T.transmission&&o.enable(15),T.sheen&&o.enable(16),T.opaque&&o.enable(17),T.pointsUvs&&o.enable(18),T.decodeVideoTexture&&o.enable(19),T.decodeVideoTextureEmissive&&o.enable(20),T.alphaToCoverage&&o.enable(21),T.numLightProbeGrids>0&&o.enable(22),T.hasPositionAttribute&&o.enable(23),x.push(o.mask)}function E(x){let T=f[x.type],C;if(T){let D=Wn[T];C=vd.clone(D.uniforms)}else C=x.uniforms;return C}function v(x,T){let C=h.get(T);return C!==void 0?++C.usedTimes:(C=new tv(i,T,x,s),c.push(C),h.set(T,C)),C}function y(x){if(--x.usedTimes===0){let T=c.indexOf(x);c[T]=c[c.length-1],c.pop(),h.delete(x.cacheKey),x.destroy()}}function S(x){a.remove(x)}function A(){a.dispose()}return{getParameters:_,getProgramCacheKey:m,getUniforms:E,acquireProgram:v,releaseProgram:y,releaseShaderCache:S,programs:c,dispose:A}}function sv(){let i=new WeakMap;function t(o){return i.has(o)}function e(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,l){i.get(o)[a]=l}function r(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:r}}function rv(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.materialVariant!==t.materialVariant?i.materialVariant-t.materialVariant:i.z!==t.z?i.z-t.z:i.id-t.id}function zd(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function kd(){let i=[],t=0,e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function o(u){let f=0;return u.isInstancedMesh&&(f+=2),u.isSkinnedMesh&&(f+=1),f}function a(u,f,g,_,m,p){let b=i[t];return b===void 0?(b={id:u.id,object:u,geometry:f,material:g,materialVariant:o(u),groupOrder:_,renderOrder:u.renderOrder,z:m,group:p},i[t]=b):(b.id=u.id,b.object=u,b.geometry=f,b.material=g,b.materialVariant=o(u),b.groupOrder=_,b.renderOrder=u.renderOrder,b.z=m,b.group=p),t++,b}function l(u,f,g,_,m,p,b){b.reversedDepth===!0&&(m=-m);let E=a(u,f,g,_,m,p);g.transmission>0?n.push(E):g.transparent===!0?s.push(E):e.push(E)}function c(u,f,g,_,m,p){let b=a(u,f,g,_,m,p);g.transmission>0?n.unshift(b):g.transparent===!0?s.unshift(b):e.unshift(b)}function h(u,f){e.length>1&&e.sort(u||rv),n.length>1&&n.sort(f||zd),s.length>1&&s.sort(f||zd)}function d(){for(let u=t,f=i.length;u=r.length?(o=new kd,r.push(o)):o=r[s],o}function e(){i=new WeakMap}return{get:t,dispose:e}}function av(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"SunLight":case"DirectionalLight":e={direction:new L,color:new Vt};break;case"SpotLight":e={position:new L,direction:new L,color:new Vt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new L,color:new Vt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new L,skyColor:new Vt,groundColor:new Vt};break;case"RectAreaLight":e={color:new Vt,position:new L,halfWidth:new L,halfHeight:new L};break}return i[t.id]=e,e}}}function lv(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"SunLight":case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var cv=0;function hv(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function uv(i){let t=new av,e=lv(),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 c=0;c<9;c++)n.probe.push(new L);let s=new L,r=new Yt,o=new Yt;function a(c){let h=0,d=0,u=0;for(let U=0;U<9;U++)n.probe[U].set(0,0,0);let f=0,g=0,_=0,m=0,p=0,b=0,E=0,v=0,y=0,S=0,A=0,x=0,T=0,C=0;c.sort(hv);for(let U=0,F=c.length;U0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=yt.LTC_FLOAT_1,n.rectAreaLTC2=yt.LTC_FLOAT_2):(n.rectAreaLTC1=yt.LTC_HALF_1,n.rectAreaLTC2=yt.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let D=n.hash;(D.sunLength!==f||D.directionalLength!==m||D.pointLength!==p||D.spotLength!==b||D.rectAreaLength!==E||D.hemiLength!==v||D.numSunShadows!==g||D.numDirectionalShadows!==y||D.numPointShadows!==S||D.numSpotShadows!==A||D.numSpotMaps!==x||D.numLightProbes!==C)&&(n.sun.length=f,n.directional.length=m,n.spot.length=b,n.rectArea.length=E,n.point.length=p,n.hemi.length=v,n.sunShadow.length=g,n.sunShadowMap.length=g,n.sunShadowMatrix.length=_,n.sunShadowCascade.length=_,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.directionalShadowMatrix.length=y,n.pointShadow.length=S,n.pointShadowMap.length=S,n.pointShadowMatrix.length=S,n.spotShadow.length=A,n.spotShadowMap.length=A,n.spotLightMatrix.length=A+x-T,n.spotLightMap.length=x,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=C,D.sunLength=f,D.directionalLength=m,D.pointLength=p,D.spotLength=b,D.rectAreaLength=E,D.hemiLength=v,D.numSunShadows=g,D.numDirectionalShadows=y,D.numPointShadows=S,D.numSpotShadows=A,D.numSpotMaps=x,D.numLightProbes=C,n.version=cv++)}function l(c,h){let d=0,u=0,f=0,g=0,_=0,m=0,p=h.matrixWorldInverse;for(let b=0,E=c.length;b=o.length?(a=new Hd(i),o.push(a)):a=o[r],a}function n(){t=new WeakMap}return{get:e,dispose:n}}var fv=`void main() { gl_Position = vec4( position, 1.0 ); -}`,uv=`uniform sampler2D shadow_pass; +}`,pv=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; void main() { @@ -4193,12 +4193,12 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); -}`,dv=[new I(1,0,0),new I(-1,0,0),new I(0,1,0),new I(0,-1,0),new I(0,0,1),new I(0,0,-1)],fv=[new I(0,-1,0),new I(0,-1,0),new I(0,0,1),new I(0,0,-1),new I(0,-1,0),new I(0,-1,0)],kd=new Jt,Sr=new I,Zc=new I;function pv(i,t,e){let n=new Un,s=new $t,r=new $t,o=new ge,a=new zo,l=new ko,c={},h=e.maxTextureSize,d={[zn]:De,[De]:zn,[Ne]:Ne},u=new qe({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new $t},radius:{value:4}},vertexShader:hv,fragmentShader:uv}),f=u.clone();f.defines.HORIZONTAL_PASS=1;let g=new de;g.setAttribute("position",new Ae(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new _e(g,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=fr;let p=this.type;this.render=function(S,A,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===Uu&&(zt("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=fr);let T=i.getRenderTarget(),R=i.getActiveCubeFace(),D=i.getActiveMipmapLevel(),F=i.state;F.setBlending(kn),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 U=p!==this.type;U&&A.traverse(function(C){C.material&&(Array.isArray(C.material)?C.material.forEach(B=>B.needsUpdate=!0):C.material.needsUpdate=!0)});for(let C=0,B=S.length;Ch||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/O.x),s.x=r.x*O.x,q.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/O.y),s.y=r.y*O.y,q.mapSize.y=r.y));let L=i.state.buffers.depth.getReversed();if(q.camera._reversedDepth=L,q.map===null||U===!0){if(q.map!==null&&(q.map.depthTexture!==null&&(q.map.depthTexture.dispose(),q.map.depthTexture=null),q.map.dispose()),this.type===Ts){if(W.isPointLight){zt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}q.map=new He(s.x,s.y,{format:bi,type:Sn,minFilter:Xe,magFilter:Xe,generateMipmaps:!1}),q.map.texture.name=W.name+".shadowMap",q.map.depthTexture=new pi(s.x,s.y,Ye),q.map.depthTexture.name=W.name+".shadowMapDepth",q.map.depthTexture.format=Pn,q.map.depthTexture.compareFunction=null,q.map.depthTexture.minFilter=ze,q.map.depthTexture.magFilter=ze}else W.isPointLight?(q.map=new Ya(s.x),q.map.depthTexture=new Bo(s.x,bn)):(q.map=new He(s.x,s.y),q.map.depthTexture=new pi(s.x,s.y,bn)),q.map.depthTexture.name=W.name+".shadowMap",q.map.depthTexture.format=Pn,this.type===fr?(q.map.depthTexture.compareFunction=L?Ga:Va,q.map.depthTexture.minFilter=Xe,q.map.depthTexture.magFilter=Xe):(q.map.depthTexture.compareFunction=null,q.map.depthTexture.minFilter=ze,q.map.depthTexture.magFilter=ze);q.camera.updateProjectionMatrix()}q.map.isWebGLCubeRenderTarget!==!0&&(q.map.width!==s.x||q.map.height!==s.y)&&q.map.setSize(s.x,s.y);let H=q.map.isWebGLCubeRenderTarget?6:q.getViewportCount();W.isPointLight!==!0&&q.updateMatrices(W,x);for(let X=0;X0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let F=R.uuid,U=A.uuid,C=c[F];C===void 0&&(C={},c[F]=C);let B=C[U];B===void 0&&(B=R.clone(),C[U]=B,A.addEventListener("dispose",y)),R=B}if(R.visible=A.visible,R.wireframe=A.wireframe,T===Ts?R.side=A.shadowSide!==null?A.shadowSide:A.side:R.side=A.shadowSide!==null?A.shadowSide:d[A.side],R.alphaMap=A.alphaMap,R.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,R.map=A.map,R.clipShadows=A.clipShadows,R.clippingPlanes=A.clippingPlanes,R.clipIntersection=A.clipIntersection,R.displacementMap=A.displacementMap,R.displacementScale=A.displacementScale,R.displacementBias=A.displacementBias,R.wireframeLinewidth=A.wireframeLinewidth,R.linewidth=A.linewidth,x.isPointLight===!0&&R.isMeshDistanceMaterial===!0){let F=i.properties.get(R);F.light=x}return R}function v(S,A,x,T,R){if(S.visible===!1)return;if(S.layers.test(A.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&R===Ts)&&(!S.frustumCulled||S.intersectsFrustum(n))){S.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,S.matrixWorld);let U=t.update(S),C=S.material;if(Array.isArray(C)){let B=U.groups;for(let W=0,q=B.length;W=1):L.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),q=O>=2);let H=null,X={},z=i.getParameter(i.SCISSOR_BOX),Q=i.getParameter(i.VIEWPORT),lt=new ge().fromArray(z),ut=new ge().fromArray(Q);function ct(V,xt,st,vt){let Tt=new Uint8Array(4),ht=i.createTexture();i.bindTexture(V,ht),i.texParameteri(V,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(V,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Bt=0;Bt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new $t,h=new WeakMap,d=new Set,u,f=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(P,M){return g?new OffscreenCanvas(P,M):ps("canvas")}function m(P,M,Y){let K=1,nt=Xt(P);if((nt.width>Y||nt.height>Y)&&(K=Y/Math.max(nt.width,nt.height)),K<1)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap||typeof VideoFrame<"u"&&P instanceof VideoFrame){let pt=Math.floor(K*nt.width),mt=Math.floor(K*nt.height);u===void 0&&(u=_(pt,mt));let it=M?_(pt,mt):u;return it.width=pt,it.height=mt,it.getContext("2d").drawImage(P,0,0,pt,mt),zt("WebGLRenderer: Texture has been resized from ("+nt.width+"x"+nt.height+") to ("+pt+"x"+mt+")."),it}else return"data"in P&&zt("WebGLRenderer: Image in DataTexture is too big ("+nt.width+"x"+nt.height+")."),P;return P}function p(P){return P.generateMipmaps}function b(P){i.generateMipmap(P)}function w(P){return P.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:P.isWebGL3DRenderTarget?i.TEXTURE_3D:P.isWebGLArrayRenderTarget||P.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function v(P,M,Y,K,nt,pt=!1){if(P!==null){if(i[P]!==void 0)return i[P];zt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let mt;K&&(mt=t.get("EXT_texture_norm16"),mt||zt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let it=M;if(M===i.RED&&(Y===i.FLOAT&&(it=i.R32F),Y===i.HALF_FLOAT&&(it=i.R16F),Y===i.UNSIGNED_BYTE&&(it=i.R8),Y===i.UNSIGNED_SHORT&&mt&&(it=mt.R16_EXT),Y===i.SHORT&&mt&&(it=mt.R16_SNORM_EXT)),M===i.RED_INTEGER&&(Y===i.UNSIGNED_BYTE&&(it=i.R8UI),Y===i.UNSIGNED_SHORT&&(it=i.R16UI),Y===i.UNSIGNED_INT&&(it=i.R32UI),Y===i.BYTE&&(it=i.R8I),Y===i.SHORT&&(it=i.R16I),Y===i.INT&&(it=i.R32I)),M===i.RG&&(Y===i.FLOAT&&(it=i.RG32F),Y===i.HALF_FLOAT&&(it=i.RG16F),Y===i.UNSIGNED_BYTE&&(it=i.RG8),Y===i.UNSIGNED_SHORT&&mt&&(it=mt.RG16_EXT),Y===i.SHORT&&mt&&(it=mt.RG16_SNORM_EXT)),M===i.RG_INTEGER&&(Y===i.UNSIGNED_BYTE&&(it=i.RG8UI),Y===i.UNSIGNED_SHORT&&(it=i.RG16UI),Y===i.UNSIGNED_INT&&(it=i.RG32UI),Y===i.BYTE&&(it=i.RG8I),Y===i.SHORT&&(it=i.RG16I),Y===i.INT&&(it=i.RG32I)),M===i.RGB_INTEGER&&(Y===i.UNSIGNED_BYTE&&(it=i.RGB8UI),Y===i.UNSIGNED_SHORT&&(it=i.RGB16UI),Y===i.UNSIGNED_INT&&(it=i.RGB32UI),Y===i.BYTE&&(it=i.RGB8I),Y===i.SHORT&&(it=i.RGB16I),Y===i.INT&&(it=i.RGB32I)),M===i.RGBA_INTEGER&&(Y===i.UNSIGNED_BYTE&&(it=i.RGBA8UI),Y===i.UNSIGNED_SHORT&&(it=i.RGBA16UI),Y===i.UNSIGNED_INT&&(it=i.RGBA32UI),Y===i.BYTE&&(it=i.RGBA8I),Y===i.SHORT&&(it=i.RGBA16I),Y===i.INT&&(it=i.RGBA32I)),M===i.RGB&&(Y===i.UNSIGNED_SHORT&&mt&&(it=mt.RGB16_EXT),Y===i.SHORT&&mt&&(it=mt.RGB16_SNORM_EXT),Y===i.UNSIGNED_INT_5_9_9_9_REV&&(it=i.RGB9_E5),Y===i.UNSIGNED_INT_10F_11F_11F_REV&&(it=i.R11F_G11F_B10F)),M===i.RGBA){let ot=pt?Js:te.getTransfer(nt);Y===i.FLOAT&&(it=i.RGBA32F),Y===i.HALF_FLOAT&&(it=i.RGBA16F),Y===i.UNSIGNED_BYTE&&(it=ot===he?i.SRGB8_ALPHA8:i.RGBA8),Y===i.UNSIGNED_SHORT&&mt&&(it=mt.RGBA16_EXT),Y===i.SHORT&&mt&&(it=mt.RGBA16_SNORM_EXT),Y===i.UNSIGNED_SHORT_4_4_4_4&&(it=i.RGBA4),Y===i.UNSIGNED_SHORT_5_5_5_1&&(it=i.RGB5_A1)}return(it===i.R16F||it===i.R32F||it===i.RG16F||it===i.RG32F||it===i.RGBA16F||it===i.RGBA32F)&&t.get("EXT_color_buffer_float"),it}function y(P,M){let Y;return P?M===null||M===bn||M===Cs?Y=i.DEPTH24_STENCIL8:M===Ye?Y=i.DEPTH32F_STENCIL8:M===Rs&&(Y=i.DEPTH24_STENCIL8,zt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):M===null||M===bn||M===Cs?Y=i.DEPTH_COMPONENT24:M===Ye?Y=i.DEPTH_COMPONENT32F:M===Rs&&(Y=i.DEPTH_COMPONENT16),Y}function S(P,M){return p(P)===!0||P.isFramebufferTexture&&P.minFilter!==ze&&P.minFilter!==Xe?Math.log2(Math.max(M.width,M.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?M.mipmaps.length:1}function A(P){let M=P.target;M.removeEventListener("dispose",A),T(M),M.isVideoTexture&&h.delete(M),M.isHTMLTexture&&d.delete(M)}function x(P){let M=P.target;M.removeEventListener("dispose",x),D(M)}function T(P){let M=n.get(P);if(M.__webglInit===void 0)return;let Y=P.source,K=f.get(Y);if(K){let nt=K[M.__cacheKey];nt.usedTimes--,nt.usedTimes===0&&R(P),Object.keys(K).length===0&&f.delete(Y)}n.remove(P)}function R(P){let M=n.get(P);i.deleteTexture(M.__webglTexture);let Y=P.source,K=f.get(Y);delete K[M.__cacheKey],o.memory.textures--}function D(P){let M=n.get(P);if(P.depthTexture&&(P.depthTexture.dispose(),n.remove(P.depthTexture)),P.isWebGLCubeRenderTarget)for(let K=0;K<6;K++){if(Array.isArray(M.__webglFramebuffer[K]))for(let nt=0;nt=s.maxTextures&&zt("WebGLTextures: Trying to use "+(P+1)+" texture units while this GPU supports only "+s.maxTextures),F+=1,P}function q(P){let M=[];return M.push(P.wrapS),M.push(P.wrapT),M.push(P.wrapR||0),M.push(P.magFilter),M.push(P.minFilter),M.push(P.anisotropy),M.push(P.internalFormat),M.push(P.format),M.push(P.type),M.push(P.generateMipmaps),M.push(P.premultiplyAlpha),M.push(P.flipY),M.push(P.unpackAlignment),M.push(P.colorSpace),M.join()}function O(P,M){let Y=n.get(P);if(P.isVideoTexture&&N(P),P.isRenderTargetTexture===!1&&P.isExternalTexture!==!0&&P.version>0&&Y.__version!==P.version){let K=P.image;if(K===null)zt("WebGLRenderer: Texture marked for update but no image data found.");else if(K.complete===!1)zt("WebGLRenderer: Texture marked for update but image is incomplete");else{rt(Y,P,M);return}}else P.isExternalTexture&&(Y.__webglTexture=P.sourceTexture?P.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,Y.__webglTexture,i.TEXTURE0+M)}function L(P,M){let Y=n.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&Y.__version!==P.version){rt(Y,P,M);return}else P.isExternalTexture&&(Y.__webglTexture=P.sourceTexture?P.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,Y.__webglTexture,i.TEXTURE0+M)}function H(P,M){let Y=n.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&Y.__version!==P.version){rt(Y,P,M);return}e.bindTexture(i.TEXTURE_3D,Y.__webglTexture,i.TEXTURE0+M)}function X(P,M){let Y=n.get(P);if(P.isCubeDepthTexture!==!0&&P.version>0&&Y.__version!==P.version){yt(Y,P,M);return}e.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture,i.TEXTURE0+M)}let z={[ds]:i.REPEAT,[In]:i.CLAMP_TO_EDGE,[Co]:i.MIRRORED_REPEAT},Q={[ze]:i.NEAREST,[nd]:i.NEAREST_MIPMAP_NEAREST,[mr]:i.NEAREST_MIPMAP_LINEAR,[Xe]:i.LINEAR,[sa]:i.LINEAR_MIPMAP_NEAREST,[yi]:i.LINEAR_MIPMAP_LINEAR},lt={[od]:i.NEVER,[ud]:i.ALWAYS,[ad]:i.LESS,[Va]:i.LEQUAL,[ld]:i.EQUAL,[Ga]:i.GEQUAL,[cd]:i.GREATER,[hd]:i.NOTEQUAL};function ut(P,M){if(M.type===Ye&&t.has("OES_texture_float_linear")===!1&&(M.magFilter===Xe||M.magFilter===sa||M.magFilter===mr||M.magFilter===yi||M.minFilter===Xe||M.minFilter===sa||M.minFilter===mr||M.minFilter===yi)&&zt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(P,i.TEXTURE_WRAP_S,z[M.wrapS]),i.texParameteri(P,i.TEXTURE_WRAP_T,z[M.wrapT]),(P===i.TEXTURE_3D||P===i.TEXTURE_2D_ARRAY)&&i.texParameteri(P,i.TEXTURE_WRAP_R,z[M.wrapR]),i.texParameteri(P,i.TEXTURE_MAG_FILTER,Q[M.magFilter]),i.texParameteri(P,i.TEXTURE_MIN_FILTER,Q[M.minFilter]),M.compareFunction&&(i.texParameteri(P,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(P,i.TEXTURE_COMPARE_FUNC,lt[M.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===ze||M.minFilter!==mr&&M.minFilter!==yi||M.type===Ye&&t.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||n.get(M).__currentAnisotropy){let Y=t.get("EXT_texture_filter_anisotropic");i.texParameterf(P,Y.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,s.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy}}}function ct(P,M){let Y=!1;P.__webglInit===void 0&&(P.__webglInit=!0,M.addEventListener("dispose",A));let K=M.source,nt=f.get(K);nt===void 0&&(nt={},f.set(K,nt));let pt=q(M);if(pt!==P.__cacheKey){nt[pt]===void 0&&(nt[pt]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,Y=!0),nt[pt].usedTimes++;let mt=nt[P.__cacheKey];mt!==void 0&&(nt[P.__cacheKey].usedTimes--,mt.usedTimes===0&&R(M)),P.__cacheKey=pt,P.__webglTexture=nt[pt].texture}return Y}function G(P,M,Y){return Math.floor(Math.floor(P/Y)/M)}function tt(P,M,Y,K){let pt=P.updateRanges;if(pt.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,M.width,M.height,Y,K,M.data);else{pt.sort((Ut,bt)=>Ut.start-bt.start);let mt=0;for(let Ut=1;Ut0){kt&&Zt&&e.texStorage2D(i.TEXTURE_2D,xt,bt,Ft[0].width,Ft[0].height);for(let st=0,vt=Ft.length;st0){let Tt=Oc(_t.width,_t.height,M.format,M.type);for(let ht of M.layerUpdates){let Bt=_t.data.subarray(ht*Tt/_t.data.BYTES_PER_ELEMENT,(ht+1)*Tt/_t.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,st,0,0,ht,_t.width,_t.height,1,gt,Bt)}}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,st,0,0,0,_t.width,_t.height,ot.depth,gt,_t.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,st,bt,_t.width,_t.height,ot.depth,0,_t.data,0,0);else zt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else kt?V&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,st,0,0,0,_t.width,_t.height,ot.depth,gt,Ut,_t.data):e.texImage3D(i.TEXTURE_2D_ARRAY,st,bt,_t.width,_t.height,ot.depth,0,gt,Ut,_t.data);M.layerUpdates.size>0&&M.clearLayerUpdates()}else{kt&&Zt&&e.texStorage2D(i.TEXTURE_2D,xt,bt,Ft[0].width,Ft[0].height);for(let st=0,vt=Ft.length;st0){let st=Oc(ot.width,ot.height,M.format,M.type);for(let vt of M.layerUpdates){let Tt=ot.data.subarray(vt*st/ot.data.BYTES_PER_ELEMENT,(vt+1)*st/ot.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,vt,ot.width,ot.height,1,gt,Ut,Tt)}M.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,ot.width,ot.height,ot.depth,gt,Ut,ot.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,bt,ot.width,ot.height,ot.depth,0,gt,Ut,ot.data);else if(M.isData3DTexture)kt?(Zt&&e.texStorage3D(i.TEXTURE_3D,xt,bt,ot.width,ot.height,ot.depth),V&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,ot.width,ot.height,ot.depth,gt,Ut,ot.data)):e.texImage3D(i.TEXTURE_3D,0,bt,ot.width,ot.height,ot.depth,0,gt,Ut,ot.data);else if(M.isFramebufferTexture){if(Zt)if(kt)e.texStorage2D(i.TEXTURE_2D,xt,bt,ot.width,ot.height);else{let st=ot.width,vt=ot.height;for(let Tt=0;Tt>=1,vt>>=1}}else if(M.isHTMLTexture){if("texElementImage2D"in i){let st=i.canvas;if(st.hasAttribute("layoutsubtree")||st.setAttribute("layoutsubtree","true"),ot.parentNode!==st){st.appendChild(ot),d.add(M),st.onpaint=vt=>{let Tt=vt.changedElements;for(let ht of d)Tt.includes(ht.image)&&(ht.needsUpdate=!0)},st.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,ot);else{let Tt=i.RGBA,ht=i.RGBA,Bt=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,Tt,ht,Bt,ot)}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(Ft.length>0){if(kt&&Zt){let st=Xt(Ft[0]);e.texStorage2D(i.TEXTURE_2D,xt,bt,st.width,st.height)}for(let st=0,vt=Ft.length;st0&&vt++;let ht=Xt(bt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,vt,Zt,ht.width,ht.height)}for(let ht=0;ht<6;ht++)if(Ut){V?st&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ht,0,0,0,bt[ht].width,bt[ht].height,Ft,kt,bt[ht].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ht,0,Zt,bt[ht].width,bt[ht].height,0,Ft,kt,bt[ht].data);for(let Bt=0;Bt>pt),_t=Math.max(1,M.height>>pt);nt===i.TEXTURE_3D||nt===i.TEXTURE_2D_ARRAY?e.texImage3D(nt,pt,ot,bt,_t,M.depth,0,mt,it,null):e.texImage2D(nt,pt,ot,bt,_t,0,mt,it,null)}e.bindFramebuffer(i.FRAMEBUFFER,P),Mt(M)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,K,nt,Ut.__webglTexture,0,at(M)):(nt===i.TEXTURE_2D||nt>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&nt<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,K,nt,Ut.__webglTexture,pt),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Ot(P,M,Y){if(i.bindRenderbuffer(i.RENDERBUFFER,P),M.depthBuffer){let K=M.depthTexture,nt=K&&K.isDepthTexture?K.type:null,pt=y(M.stencilBuffer,nt),mt=M.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;Mt(M)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,at(M),pt,M.width,M.height):Y?i.renderbufferStorageMultisample(i.RENDERBUFFER,at(M),pt,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,pt,M.width,M.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,mt,i.RENDERBUFFER,P)}else{let K=M.textures;for(let nt=0;nt{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,K.removeEventListener("dispose",nt)};K.addEventListener("dispose",nt),M.__depthDisposeCallback=nt}M.__boundDepthTexture=K}if(P.depthTexture&&!M.__autoAllocateDepthBuffer)if(Y)for(let K=0;K<6;K++)ae(M.__webglFramebuffer[K],P,K);else{let K=P.texture.mipmaps;K&&K.length>0?ae(M.__webglFramebuffer[0],P,0):ae(M.__webglFramebuffer,P,0)}else if(Y){M.__webglDepthbuffer=[];for(let K=0;K<6;K++)if(e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[K]),M.__webglDepthbuffer[K]===void 0)M.__webglDepthbuffer[K]=i.createRenderbuffer(),Ot(M.__webglDepthbuffer[K],P,!1);else{let nt=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,pt=M.__webglDepthbuffer[K];i.bindRenderbuffer(i.RENDERBUFFER,pt),i.framebufferRenderbuffer(i.FRAMEBUFFER,nt,i.RENDERBUFFER,pt)}}else{let K=P.texture.mipmaps;if(K&&K.length>0?e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=i.createRenderbuffer(),Ot(M.__webglDepthbuffer,P,!1);else{let nt=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,pt=M.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,pt),i.framebufferRenderbuffer(i.FRAMEBUFFER,nt,i.RENDERBUFFER,pt)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function dt(P,M,Y){let K=n.get(P);M!==void 0&&ft(K.__webglFramebuffer,P,P.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),Y!==void 0&&Gt(P)}function Nt(P){let M=P.texture,Y=n.get(P),K=n.get(M);P.addEventListener("dispose",x);let nt=P.textures,pt=P.isWebGLCubeRenderTarget===!0,mt=nt.length>1;if(mt||(K.__webglTexture===void 0&&(K.__webglTexture=i.createTexture()),K.__version=M.version,o.memory.textures++),pt){Y.__webglFramebuffer=[];for(let it=0;it<6;it++)if(M.mipmaps&&M.mipmaps.length>0){Y.__webglFramebuffer[it]=[];for(let ot=0;ot0){Y.__webglFramebuffer=[];for(let it=0;it0&&Mt(P)===!1){Y.__webglMultisampledFramebuffer=i.createFramebuffer(),Y.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,Y.__webglMultisampledFramebuffer);for(let it=0;it0)for(let ot=0;ot0)for(let ot=0;ot0){if(Mt(P)===!1){let M=P.textures,Y=P.width,K=P.height,nt=i.COLOR_BUFFER_BIT,pt=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,mt=n.get(P),it=M.length>1;if(it)for(let gt=0;gt0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,mt.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,mt.__webglFramebuffer);for(let gt=0;gt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function N(P){let M=o.render.frame;h.get(P)!==M&&(h.set(P,M),P.update())}function Yt(P,M){let Y=P.colorSpace,K=P.format,nt=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||Y!==Zs&&Y!==ni&&(te.getTransfer(Y)===he?(K!==sn||nt!==nn)&&zt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ht("WebGLTextures: Unsupported texture color space:",Y)),M}function Xt(P){return typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement?(c.width=P.naturalWidth||P.width,c.height=P.naturalHeight||P.height):typeof VideoFrame<"u"&&P instanceof VideoFrame?(c.width=P.displayWidth,c.height=P.displayHeight):(c.width=P.width,c.height=P.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=U,this.getTextureUnits=C,this.setTextureUnits=B,this.setTexture2D=O,this.setTexture2DArray=L,this.setTexture3D=H,this.setTextureCube=X,this.rebindTextures=dt,this.setupRenderTarget=Nt,this.updateRenderTargetMipmap=Pt,this.updateMultisampleRenderTarget=Ee,this.setupDepthRenderbuffer=Gt,this.setupFrameBufferTexture=ft,this.useMultisampledRTT=Mt,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function _v(i,t){function e(n,s=ni){let r,o=te.getTransfer(s);if(n===nn)return i.UNSIGNED_BYTE;if(n===oa)return i.UNSIGNED_SHORT_4_4_4_4;if(n===aa)return i.UNSIGNED_SHORT_5_5_5_1;if(n===wc)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Ec)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===bc)return i.BYTE;if(n===Sc)return i.SHORT;if(n===Rs)return i.UNSIGNED_SHORT;if(n===ra)return i.INT;if(n===bn)return i.UNSIGNED_INT;if(n===Ye)return i.FLOAT;if(n===Sn)return i.HALF_FLOAT;if(n===Tc)return i.ALPHA;if(n===Ac)return i.RGB;if(n===sn)return i.RGBA;if(n===Pn)return i.DEPTH_COMPONENT;if(n===Mi)return i.DEPTH_STENCIL;if(n===Is)return i.RED;if(n===la)return i.RED_INTEGER;if(n===bi)return i.RG;if(n===ca)return i.RG_INTEGER;if(n===ha)return i.RGBA_INTEGER;if(n===gr||n===_r||n===xr||n===vr)if(o===he)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===gr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===_r)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===xr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===vr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===gr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===_r)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===xr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===vr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ua||n===da||n===fa||n===pa)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===ua)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===da)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===fa)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===pa)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ma||n===ga||n===_a||n===xa||n===va||n===yr||n===ya)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===ma||n===ga)return o===he?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===_a)return o===he?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===xa)return r.COMPRESSED_R11_EAC;if(n===va)return r.COMPRESSED_SIGNED_R11_EAC;if(n===yr)return r.COMPRESSED_RG11_EAC;if(n===ya)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Ma||n===ba||n===Sa||n===wa||n===Ea||n===Ta||n===Aa||n===Ra||n===Ca||n===Ia||n===Pa||n===La||n===Da||n===Na)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Ma)return o===he?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===ba)return o===he?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Sa)return o===he?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===wa)return o===he?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ea)return o===he?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ta)return o===he?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Aa)return o===he?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ra)return o===he?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Ca)return o===he?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Ia)return o===he?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Pa)return o===he?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===La)return o===he?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Da)return o===he?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Na)return o===he?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Ua||n===Fa||n===Ba)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===Ua)return o===he?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Fa)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Ba)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Oa||n===za||n===Mr||n===ka)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===Oa)return r.COMPRESSED_RED_RGTC1_EXT;if(n===za)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Mr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ka)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Cs?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}var xv=` +}`,mv=[new L(1,0,0),new L(-1,0,0),new L(0,1,0),new L(0,-1,0),new L(0,0,1),new L(0,0,-1)],gv=[new L(0,-1,0),new L(0,-1,0),new L(0,0,1),new L(0,0,-1),new L(0,-1,0),new L(0,-1,0)],Vd=new Yt,Rr=new L,Kc=new L;function _v(i,t,e){let n=new Fn,s=new Xt,r=new Xt,o=new ge,a=new Wo,l=new Xo,c={},h=e.maxTextureSize,d={[Hn]:De,[De]:Hn,[Ne]:Ne},u=new qe({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Xt},radius:{value:4}},vertexShader:fv,fragmentShader:pv}),f=u.clone();f.defines.HORIZONTAL_PASS=1;let g=new fe;g.setAttribute("position",new Ae(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new _e(g,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=mr;let p=this.type;this.render=function(S,A,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===Bu&&(Ht("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=mr);let T=i.getRenderTarget(),C=i.getActiveCubeFace(),D=i.getActiveMipmapLevel(),U=i.state;U.setBlending(Vn),U.buffers.depth.getReversed()===!0?U.buffers.color.setClear(0,0,0,0):U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);let F=p!==this.type;F&&A.traverse(function(I){I.material&&(Array.isArray(I.material)?I.material.forEach(B=>B.needsUpdate=!0):I.material.needsUpdate=!0)});for(let I=0,B=S.length;Ih||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/O.x),s.x=r.x*O.x,q.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/O.y),s.y=r.y*O.y,q.mapSize.y=r.y));let N=i.state.buffers.depth.getReversed();if(q.camera._reversedDepth=N,q.map===null||F===!0){if(q.map!==null&&(q.map.depthTexture!==null&&(q.map.depthTexture.dispose(),q.map.depthTexture=null),q.map.dispose()),this.type===Ts){if(G.isPointLight){Ht("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}q.map=new Ve(s.x,s.y,{format:wi,type:wn,minFilter:Xe,magFilter:Xe,generateMipmaps:!1}),q.map.texture.name=G.name+".shadowMap",q.map.depthTexture=new _i(s.x,s.y,Ye),q.map.depthTexture.name=G.name+".shadowMapDepth",q.map.depthTexture.format=Ln,q.map.depthTexture.compareFunction=null,q.map.depthTexture.minFilter=ke,q.map.depthTexture.magFilter=ke}else G.isPointLight?(q.map=new Ja(s.x),q.map.depthTexture=new Vo(s.x,Sn)):(q.map=new Ve(s.x,s.y),q.map.depthTexture=new _i(s.x,s.y,Sn)),q.map.depthTexture.name=G.name+".shadowMap",q.map.depthTexture.format=Ln,this.type===mr?(q.map.depthTexture.compareFunction=N?qa:Xa,q.map.depthTexture.minFilter=Xe,q.map.depthTexture.magFilter=Xe):(q.map.depthTexture.compareFunction=null,q.map.depthTexture.minFilter=ke,q.map.depthTexture.magFilter=ke);q.camera.updateProjectionMatrix()}q.map.isWebGLCubeRenderTarget!==!0&&(q.map.width!==s.x||q.map.height!==s.y)&&q.map.setSize(s.x,s.y);let z=q.map.isWebGLCubeRenderTarget?6:q.getViewportCount();G.isPointLight!==!0&&q.updateMatrices(G,x);for(let W=0;W0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let U=C.uuid,F=A.uuid,I=c[U];I===void 0&&(I={},c[U]=I);let B=I[F];B===void 0&&(B=C.clone(),I[F]=B,A.addEventListener("dispose",y)),C=B}if(C.visible=A.visible,C.wireframe=A.wireframe,T===Ts?C.side=A.shadowSide!==null?A.shadowSide:A.side:C.side=A.shadowSide!==null?A.shadowSide:d[A.side],C.alphaMap=A.alphaMap,C.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,C.map=A.map,C.clipShadows=A.clipShadows,C.clippingPlanes=A.clippingPlanes,C.clipIntersection=A.clipIntersection,C.displacementMap=A.displacementMap,C.displacementScale=A.displacementScale,C.displacementBias=A.displacementBias,C.wireframeLinewidth=A.wireframeLinewidth,C.linewidth=A.linewidth,x.isPointLight===!0&&C.isMeshDistanceMaterial===!0){let U=i.properties.get(C);U.light=x}return C}function v(S,A,x,T,C){if(S.visible===!1)return;if(S.layers.test(A.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&C===Ts)&&(!S.frustumCulled||S.intersectsFrustum(n))){S.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,S.matrixWorld);let F=t.update(S),I=S.material;if(Array.isArray(I)){let B=F.groups;for(let G=0,q=B.length;G=1):N.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(N)[1]),q=O>=2);let z=null,W={},k=i.getParameter(i.SCISSOR_BOX),K=i.getParameter(i.VIEWPORT),lt=new ge().fromArray(k),ht=new ge().fromArray(K);function at(V,_t,st,xt){let St=new Uint8Array(4),ct=i.createTexture();i.bindTexture(V,ct),i.texParameteri(V,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(V,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Ft=0;Ft"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Xt,h=new WeakMap,d=new Set,u,f=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(P,M){return g?new OffscreenCanvas(P,M):ms("canvas")}function m(P,M,X){let j=1,nt=kt(P);if((nt.width>X||nt.height>X)&&(j=X/Math.max(nt.width,nt.height)),j<1)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap||typeof VideoFrame<"u"&&P instanceof VideoFrame){let ft=Math.floor(j*nt.width),pt=Math.floor(j*nt.height);u===void 0&&(u=_(ft,pt));let it=M?_(ft,pt):u;return it.width=ft,it.height=pt,it.getContext("2d").drawImage(P,0,0,ft,pt),Ht("WebGLRenderer: Texture has been resized from ("+nt.width+"x"+nt.height+") to ("+ft+"x"+pt+")."),it}else return"data"in P&&Ht("WebGLRenderer: Image in DataTexture is too big ("+nt.width+"x"+nt.height+")."),P;return P}function p(P){return P.generateMipmaps}function b(P){i.generateMipmap(P)}function E(P){return P.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:P.isWebGL3DRenderTarget?i.TEXTURE_3D:P.isWebGLArrayRenderTarget||P.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function v(P,M,X,j,nt,ft=!1){if(P!==null){if(i[P]!==void 0)return i[P];Ht("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let pt;j&&(pt=t.get("EXT_texture_norm16"),pt||Ht("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let it=M;if(M===i.RED&&(X===i.FLOAT&&(it=i.R32F),X===i.HALF_FLOAT&&(it=i.R16F),X===i.UNSIGNED_BYTE&&(it=i.R8),X===i.UNSIGNED_SHORT&&pt&&(it=pt.R16_EXT),X===i.SHORT&&pt&&(it=pt.R16_SNORM_EXT)),M===i.RED_INTEGER&&(X===i.UNSIGNED_BYTE&&(it=i.R8UI),X===i.UNSIGNED_SHORT&&(it=i.R16UI),X===i.UNSIGNED_INT&&(it=i.R32UI),X===i.BYTE&&(it=i.R8I),X===i.SHORT&&(it=i.R16I),X===i.INT&&(it=i.R32I)),M===i.RG&&(X===i.FLOAT&&(it=i.RG32F),X===i.HALF_FLOAT&&(it=i.RG16F),X===i.UNSIGNED_BYTE&&(it=i.RG8),X===i.UNSIGNED_SHORT&&pt&&(it=pt.RG16_EXT),X===i.SHORT&&pt&&(it=pt.RG16_SNORM_EXT)),M===i.RG_INTEGER&&(X===i.UNSIGNED_BYTE&&(it=i.RG8UI),X===i.UNSIGNED_SHORT&&(it=i.RG16UI),X===i.UNSIGNED_INT&&(it=i.RG32UI),X===i.BYTE&&(it=i.RG8I),X===i.SHORT&&(it=i.RG16I),X===i.INT&&(it=i.RG32I)),M===i.RGB_INTEGER&&(X===i.UNSIGNED_BYTE&&(it=i.RGB8UI),X===i.UNSIGNED_SHORT&&(it=i.RGB16UI),X===i.UNSIGNED_INT&&(it=i.RGB32UI),X===i.BYTE&&(it=i.RGB8I),X===i.SHORT&&(it=i.RGB16I),X===i.INT&&(it=i.RGB32I)),M===i.RGBA_INTEGER&&(X===i.UNSIGNED_BYTE&&(it=i.RGBA8UI),X===i.UNSIGNED_SHORT&&(it=i.RGBA16UI),X===i.UNSIGNED_INT&&(it=i.RGBA32UI),X===i.BYTE&&(it=i.RGBA8I),X===i.SHORT&&(it=i.RGBA16I),X===i.INT&&(it=i.RGBA32I)),M===i.RGB&&(X===i.UNSIGNED_SHORT&&pt&&(it=pt.RGB16_EXT),X===i.SHORT&&pt&&(it=pt.RGB16_SNORM_EXT),X===i.UNSIGNED_INT_5_9_9_9_REV&&(it=i.RGB9_E5),X===i.UNSIGNED_INT_10F_11F_11F_REV&&(it=i.R11F_G11F_B10F)),M===i.RGBA){let rt=ft?Ks:te.getTransfer(nt);X===i.FLOAT&&(it=i.RGBA32F),X===i.HALF_FLOAT&&(it=i.RGBA16F),X===i.UNSIGNED_BYTE&&(it=rt===ue?i.SRGB8_ALPHA8:i.RGBA8),X===i.UNSIGNED_SHORT&&pt&&(it=pt.RGBA16_EXT),X===i.SHORT&&pt&&(it=pt.RGBA16_SNORM_EXT),X===i.UNSIGNED_SHORT_4_4_4_4&&(it=i.RGBA4),X===i.UNSIGNED_SHORT_5_5_5_1&&(it=i.RGB5_A1)}return(it===i.R16F||it===i.R32F||it===i.RG16F||it===i.RG32F||it===i.RGBA16F||it===i.RGBA32F)&&t.get("EXT_color_buffer_float"),it}function y(P,M){let X;return P?M===null||M===Sn||M===Cs?X=i.DEPTH24_STENCIL8:M===Ye?X=i.DEPTH32F_STENCIL8:M===Rs&&(X=i.DEPTH24_STENCIL8,Ht("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):M===null||M===Sn||M===Cs?X=i.DEPTH_COMPONENT24:M===Ye?X=i.DEPTH_COMPONENT32F:M===Rs&&(X=i.DEPTH_COMPONENT16),X}function S(P,M){return p(P)===!0||P.isFramebufferTexture&&P.minFilter!==ke&&P.minFilter!==Xe?Math.log2(Math.max(M.width,M.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?M.mipmaps.length:1}function A(P){let M=P.target;M.removeEventListener("dispose",A),T(M),M.isVideoTexture&&h.delete(M),M.isHTMLTexture&&d.delete(M)}function x(P){let M=P.target;M.removeEventListener("dispose",x),D(M)}function T(P){let M=n.get(P);if(M.__webglInit===void 0)return;let X=P.source,j=f.get(X);if(j){let nt=j[M.__cacheKey];nt.usedTimes--,nt.usedTimes===0&&C(P),Object.keys(j).length===0&&f.delete(X)}n.remove(P)}function C(P){let M=n.get(P);i.deleteTexture(M.__webglTexture);let X=P.source,j=f.get(X);delete j[M.__cacheKey],o.memory.textures--}function D(P){let M=n.get(P);if(P.depthTexture&&(P.depthTexture.dispose(),n.remove(P.depthTexture)),P.isWebGLCubeRenderTarget)for(let j=0;j<6;j++){if(Array.isArray(M.__webglFramebuffer[j]))for(let nt=0;nt=s.maxTextures&&Ht("WebGLTextures: Trying to use "+(P+1)+" texture units while this GPU supports only "+s.maxTextures),U+=1,P}function q(P){let M=[];return M.push(P.wrapS),M.push(P.wrapT),M.push(P.wrapR||0),M.push(P.magFilter),M.push(P.minFilter),M.push(P.anisotropy),M.push(P.internalFormat),M.push(P.format),M.push(P.type),M.push(P.generateMipmaps),M.push(P.premultiplyAlpha),M.push(P.flipY),M.push(P.unpackAlignment),M.push(P.colorSpace),M.join()}function O(P,M){let X=n.get(P);if(P.isVideoTexture&&R(P),P.isRenderTargetTexture===!1&&P.isExternalTexture!==!0&&P.version>0&&X.__version!==P.version){let j=P.image;if(j===null)Ht("WebGLRenderer: Texture marked for update but no image data found.");else if(j.complete===!1)Ht("WebGLRenderer: Texture marked for update but image is incomplete");else{dt(X,P,M);return}}else P.isExternalTexture&&(X.__webglTexture=P.sourceTexture?P.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,X.__webglTexture,i.TEXTURE0+M)}function N(P,M){let X=n.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&X.__version!==P.version){dt(X,P,M);return}else P.isExternalTexture&&(X.__webglTexture=P.sourceTexture?P.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,X.__webglTexture,i.TEXTURE0+M)}function z(P,M){let X=n.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&X.__version!==P.version){dt(X,P,M);return}e.bindTexture(i.TEXTURE_3D,X.__webglTexture,i.TEXTURE0+M)}function W(P,M){let X=n.get(P);if(P.isCubeDepthTexture!==!0&&P.version>0&&X.__version!==P.version){It(X,P,M);return}e.bindTexture(i.TEXTURE_CUBE_MAP,X.__webglTexture,i.TEXTURE0+M)}let k={[fs]:i.REPEAT,[Pn]:i.CLAMP_TO_EDGE,[No]:i.MIRRORED_REPEAT},K={[ke]:i.NEAREST,[sd]:i.NEAREST_MIPMAP_NEAREST,[xr]:i.NEAREST_MIPMAP_LINEAR,[Xe]:i.LINEAR,[la]:i.LINEAR_MIPMAP_NEAREST,[bi]:i.LINEAR_MIPMAP_LINEAR},lt={[ld]:i.NEVER,[fd]:i.ALWAYS,[cd]:i.LESS,[Xa]:i.LEQUAL,[hd]:i.EQUAL,[qa]:i.GEQUAL,[ud]:i.GREATER,[dd]:i.NOTEQUAL};function ht(P,M){if(M.type===Ye&&t.has("OES_texture_float_linear")===!1&&(M.magFilter===Xe||M.magFilter===la||M.magFilter===xr||M.magFilter===bi||M.minFilter===Xe||M.minFilter===la||M.minFilter===xr||M.minFilter===bi)&&Ht("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(P,i.TEXTURE_WRAP_S,k[M.wrapS]),i.texParameteri(P,i.TEXTURE_WRAP_T,k[M.wrapT]),(P===i.TEXTURE_3D||P===i.TEXTURE_2D_ARRAY)&&i.texParameteri(P,i.TEXTURE_WRAP_R,k[M.wrapR]),i.texParameteri(P,i.TEXTURE_MAG_FILTER,K[M.magFilter]),i.texParameteri(P,i.TEXTURE_MIN_FILTER,K[M.minFilter]),M.compareFunction&&(i.texParameteri(P,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(P,i.TEXTURE_COMPARE_FUNC,lt[M.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===ke||M.minFilter!==xr&&M.minFilter!==bi||M.type===Ye&&t.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||n.get(M).__currentAnisotropy){let X=t.get("EXT_texture_filter_anisotropic");i.texParameterf(P,X.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,s.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy}}}function at(P,M){let X=!1;P.__webglInit===void 0&&(P.__webglInit=!0,M.addEventListener("dispose",A));let j=M.source,nt=f.get(j);nt===void 0&&(nt={},f.set(j,nt));let ft=q(M);if(ft!==P.__cacheKey){nt[ft]===void 0&&(nt[ft]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,X=!0),nt[ft].usedTimes++;let pt=nt[P.__cacheKey];pt!==void 0&&(nt[P.__cacheKey].usedTimes--,pt.usedTimes===0&&C(M)),P.__cacheKey=ft,P.__webglTexture=nt[ft].texture}return X}function Y(P,M,X){return Math.floor(Math.floor(P/X)/M)}function tt(P,M,X,j){let ft=P.updateRanges;if(ft.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,M.width,M.height,X,j,M.data);else{ft.sort((Nt,vt)=>Nt.start-vt.start);let pt=0;for(let Nt=1;Nt0){Gt&&$t&&e.texStorage2D(i.TEXTURE_2D,_t,vt,Ut[0].width,Ut[0].height);for(let st=0,xt=Ut.length;st0){let St=kc(gt.width,gt.height,M.format,M.type);for(let ct of M.layerUpdates){let Ft=gt.data.subarray(ct*St/gt.data.BYTES_PER_ELEMENT,(ct+1)*St/gt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,st,0,0,ct,gt.width,gt.height,1,mt,Ft)}}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,st,0,0,0,gt.width,gt.height,rt.depth,mt,gt.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,st,vt,gt.width,gt.height,rt.depth,0,gt.data,0,0);else Ht("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Gt?V&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,st,0,0,0,gt.width,gt.height,rt.depth,mt,Nt,gt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,st,vt,gt.width,gt.height,rt.depth,0,mt,Nt,gt.data);M.layerUpdates.size>0&&M.clearLayerUpdates()}else{Gt&&$t&&e.texStorage2D(i.TEXTURE_2D,_t,vt,Ut[0].width,Ut[0].height);for(let st=0,xt=Ut.length;st0){let st=kc(rt.width,rt.height,M.format,M.type);for(let xt of M.layerUpdates){let St=rt.data.subarray(xt*st/rt.data.BYTES_PER_ELEMENT,(xt+1)*st/rt.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,xt,rt.width,rt.height,1,mt,Nt,St)}M.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,rt.width,rt.height,rt.depth,mt,Nt,rt.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,vt,rt.width,rt.height,rt.depth,0,mt,Nt,rt.data);else if(M.isData3DTexture)Gt?($t&&e.texStorage3D(i.TEXTURE_3D,_t,vt,rt.width,rt.height,rt.depth),V&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,rt.width,rt.height,rt.depth,mt,Nt,rt.data)):e.texImage3D(i.TEXTURE_3D,0,vt,rt.width,rt.height,rt.depth,0,mt,Nt,rt.data);else if(M.isFramebufferTexture){if($t)if(Gt)e.texStorage2D(i.TEXTURE_2D,_t,vt,rt.width,rt.height);else{let st=rt.width,xt=rt.height;for(let St=0;St<_t;St++)e.texImage2D(i.TEXTURE_2D,St,vt,st,xt,0,mt,Nt,null),st>>=1,xt>>=1}}else if(M.isHTMLTexture){if("texElementImage2D"in i){let st=i.canvas;if(st.hasAttribute("layoutsubtree")||st.setAttribute("layoutsubtree","true"),rt.parentNode!==st){st.appendChild(rt),d.add(M),st.onpaint=xt=>{let St=xt.changedElements;for(let ct of d)St.includes(ct.image)&&(ct.needsUpdate=!0)},st.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,rt);else{let St=i.RGBA,ct=i.RGBA,Ft=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,St,ct,Ft,rt)}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(Ut.length>0){if(Gt&&$t){let st=kt(Ut[0]);e.texStorage2D(i.TEXTURE_2D,_t,vt,st.width,st.height)}for(let st=0,xt=Ut.length;st0&&xt++;let ct=kt(vt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,xt,$t,ct.width,ct.height)}for(let ct=0;ct<6;ct++)if(Nt){V?st&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ct,0,0,0,vt[ct].width,vt[ct].height,Ut,Gt,vt[ct].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ct,0,$t,vt[ct].width,vt[ct].height,0,Ut,Gt,vt[ct].data);for(let Ft=0;Ft>ft),gt=Math.max(1,M.height>>ft);nt===i.TEXTURE_3D||nt===i.TEXTURE_2D_ARRAY?e.texImage3D(nt,ft,rt,vt,gt,M.depth,0,pt,it,null):e.texImage2D(nt,ft,rt,vt,gt,0,pt,it,null)}e.bindFramebuffer(i.FRAMEBUFFER,P),re(M)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,j,nt,Nt.__webglTexture,0,ie(M)):(nt===i.TEXTURE_2D||nt>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&nt<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,j,nt,Nt.__webglTexture,ft),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Tt(P,M,X){if(i.bindRenderbuffer(i.RENDERBUFFER,P),M.depthBuffer){let j=M.depthTexture,nt=j&&j.isDepthTexture?j.type:null,ft=y(M.stencilBuffer,nt),pt=M.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;re(M)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ie(M),ft,M.width,M.height):X?i.renderbufferStorageMultisample(i.RENDERBUFFER,ie(M),ft,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,ft,M.width,M.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,pt,i.RENDERBUFFER,P)}else{let j=M.textures;for(let nt=0;nt{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,j.removeEventListener("dispose",nt)};j.addEventListener("dispose",nt),M.__depthDisposeCallback=nt}M.__boundDepthTexture=j}if(P.depthTexture&&!M.__autoAllocateDepthBuffer)if(X)for(let j=0;j<6;j++)jt(M.__webglFramebuffer[j],P,j);else{let j=P.texture.mipmaps;j&&j.length>0?jt(M.__webglFramebuffer[0],P,0):jt(M.__webglFramebuffer,P,0)}else if(X){M.__webglDepthbuffer=[];for(let j=0;j<6;j++)if(e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[j]),M.__webglDepthbuffer[j]===void 0)M.__webglDepthbuffer[j]=i.createRenderbuffer(),Tt(M.__webglDepthbuffer[j],P,!1);else{let nt=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ft=M.__webglDepthbuffer[j];i.bindRenderbuffer(i.RENDERBUFFER,ft),i.framebufferRenderbuffer(i.FRAMEBUFFER,nt,i.RENDERBUFFER,ft)}}else{let j=P.texture.mipmaps;if(j&&j.length>0?e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=i.createRenderbuffer(),Tt(M.__webglDepthbuffer,P,!1);else{let nt=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ft=M.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,ft),i.framebufferRenderbuffer(i.FRAMEBUFFER,nt,i.RENDERBUFFER,ft)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function ut(P,M,X){let j=n.get(P);M!==void 0&&ot(j.__webglFramebuffer,P,P.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),X!==void 0&&Bt(P)}function Lt(P){let M=P.texture,X=n.get(P),j=n.get(M);P.addEventListener("dispose",x);let nt=P.textures,ft=P.isWebGLCubeRenderTarget===!0,pt=nt.length>1;if(pt||(j.__webglTexture===void 0&&(j.__webglTexture=i.createTexture()),j.__version=M.version,o.memory.textures++),ft){X.__webglFramebuffer=[];for(let it=0;it<6;it++)if(M.mipmaps&&M.mipmaps.length>0){X.__webglFramebuffer[it]=[];for(let rt=0;rt0){X.__webglFramebuffer=[];for(let it=0;it0&&re(P)===!1){X.__webglMultisampledFramebuffer=i.createFramebuffer(),X.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let it=0;it0)for(let rt=0;rt0)for(let rt=0;rt0){if(re(P)===!1){let M=P.textures,X=P.width,j=P.height,nt=i.COLOR_BUFFER_BIT,ft=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,pt=n.get(P),it=M.length>1;if(it)for(let mt=0;mt0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,pt.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,pt.__webglFramebuffer);for(let mt=0;mt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function R(P){let M=o.render.frame;h.get(P)!==M&&(h.set(P,M),P.update())}function wt(P,M){let X=P.colorSpace,j=P.format,nt=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||X!==Js&&X!==ii&&(te.getTransfer(X)===ue?(j!==sn||nt!==nn)&&Ht("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Wt("WebGLTextures: Unsupported texture color space:",X)),M}function kt(P){return typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement?(c.width=P.naturalWidth||P.width,c.height=P.naturalHeight||P.height):typeof VideoFrame<"u"&&P instanceof VideoFrame?(c.width=P.displayWidth,c.height=P.displayHeight):(c.width=P.width,c.height=P.height),c}this.allocateTextureUnit=G,this.resetTextureUnits=F,this.getTextureUnits=I,this.setTextureUnits=B,this.setTexture2D=O,this.setTexture2DArray=N,this.setTexture3D=z,this.setTextureCube=W,this.rebindTextures=ut,this.setupRenderTarget=Lt,this.updateRenderTargetMipmap=Ot,this.updateMultisampleRenderTarget=Ee,this.setupDepthRenderbuffer=Bt,this.setupFrameBufferTexture=ot,this.useMultisampledRTT=re,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function yv(i,t){function e(n,s=ii){let r,o=te.getTransfer(s);if(n===nn)return i.UNSIGNED_BYTE;if(n===ha)return i.UNSIGNED_SHORT_4_4_4_4;if(n===ua)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Ac)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Rc)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Ec)return i.BYTE;if(n===Tc)return i.SHORT;if(n===Rs)return i.UNSIGNED_SHORT;if(n===ca)return i.INT;if(n===Sn)return i.UNSIGNED_INT;if(n===Ye)return i.FLOAT;if(n===wn)return i.HALF_FLOAT;if(n===Cc)return i.ALPHA;if(n===Ic)return i.RGB;if(n===sn)return i.RGBA;if(n===Ln)return i.DEPTH_COMPONENT;if(n===Si)return i.DEPTH_STENCIL;if(n===Is)return i.RED;if(n===da)return i.RED_INTEGER;if(n===wi)return i.RG;if(n===fa)return i.RG_INTEGER;if(n===pa)return i.RGBA_INTEGER;if(n===vr||n===yr||n===Mr||n===br)if(o===ue)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===vr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===yr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Mr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===br)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===vr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===yr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Mr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===br)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ma||n===ga||n===_a||n===xa)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===ma)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ga)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===_a)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===xa)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===va||n===ya||n===Ma||n===ba||n===Sa||n===Sr||n===wa)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===va||n===ya)return o===ue?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ma)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===ba)return r.COMPRESSED_R11_EAC;if(n===Sa)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Sr)return r.COMPRESSED_RG11_EAC;if(n===wa)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Ea||n===Ta||n===Aa||n===Ra||n===Ca||n===Ia||n===Pa||n===La||n===Da||n===Na||n===Ua||n===Fa||n===Ba||n===Oa)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Ea)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ta)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Aa)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ra)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ca)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ia)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Pa)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===La)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Da)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Na)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Ua)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Fa)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ba)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Oa)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===za||n===ka||n===Ha)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===za)return o===ue?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ka)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Ha)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Va||n===Ga||n===wr||n===Wa)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===Va)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Ga)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===wr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Wa)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Cs?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}var Mv=` void main() { gl_Position = vec4( position, 1.0 ); -}`,vv=` +}`,bv=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; @@ -4217,7 +4217,7 @@ void main() { } -}`,ih=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){let n=new sr(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){let e=t.cameras[0].viewport,n=new qe({vertexShader:xv,fragmentShader:vv,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new _e(new yn(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},sh=class extends Ln{constructor(t,e){super();let n=this,s=null,r=1,o=null,a="local-floor",l=1,c=null,h=null,d=null,u=null,f=null,g=null,_=typeof XRWebGLBinding<"u",m=new ih,p={},b=e.getContextAttributes(),w=null,v=null,y=[],S=[],A=new $t,x=null,T=null,R=new Oe;R.viewport=new ge;let D=new Oe;D.viewport=new ge;let F=[R,D],U=new Qo,C=null,B=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(G){let tt=y[G];return tt===void 0&&(tt=new vs,y[G]=tt),tt.getTargetRaySpace()},this.getControllerGrip=function(G){let tt=y[G];return tt===void 0&&(tt=new vs,y[G]=tt),tt.getGripSpace()},this.getHand=function(G){let tt=y[G];return tt===void 0&&(tt=new vs,y[G]=tt),tt.getHandSpace()};function W(G){let tt=S.indexOf(G.inputSource);if(tt===-1)return;let rt=y[tt];rt!==void 0&&(rt.update(G.inputSource,G.frame,c||o),rt.dispatchEvent({type:G.type,data:G.inputSource}))}function q(){s.removeEventListener("select",W),s.removeEventListener("selectstart",W),s.removeEventListener("selectend",W),s.removeEventListener("squeeze",W),s.removeEventListener("squeezestart",W),s.removeEventListener("squeezeend",W),s.removeEventListener("end",q),s.removeEventListener("inputsourceschange",O);for(let G=0;G=0&&(S[yt]=null,y[yt].disconnect(rt))}for(let tt=0;tt=S.length){S.push(rt),yt=Ot;break}else if(S[Ot]===null){S[Ot]=rt,yt=Ot;break}if(yt===-1)break}let ft=y[yt];ft&&ft.connect(rt)}}let L=new I,H=new I;function X(G,tt,rt){L.setFromMatrixPosition(tt.matrixWorld),H.setFromMatrixPosition(rt.matrixWorld);let yt=L.distanceTo(H),ft=tt.projectionMatrix.elements,Ot=rt.projectionMatrix.elements,ae=ft[14]/(ft[10]-1),Gt=ft[14]/(ft[10]+1),dt=(ft[9]+1)/ft[5],Nt=(ft[9]-1)/ft[5],Pt=(ft[8]-1)/ft[0],Wt=(Ot[8]+1)/Ot[0],fe=ae*Pt,Ee=ae*Wt,at=yt/(-Pt+Wt),Mt=at*-Pt;if(tt.matrixWorld.decompose(G.position,G.quaternion,G.scale),G.translateX(Mt),G.translateZ(at),G.matrixWorld.compose(G.position,G.quaternion,G.scale),G.matrixWorldInverse.copy(G.matrixWorld).invert(),ft[10]===-1)G.projectionMatrix.copy(tt.projectionMatrix),G.projectionMatrixInverse.copy(tt.projectionMatrixInverse);else{let N=ae+at,Yt=Gt+at,Xt=fe-Mt,P=Ee+(yt-Mt),M=dt*Gt/Yt*N,Y=Nt*Gt/Yt*N;G.projectionMatrix.makePerspective(Xt,P,M,Y,N,Yt),G.projectionMatrixInverse.copy(G.projectionMatrix).invert()}}function z(G,tt){tt===null?G.matrixWorld.copy(G.matrix):G.matrixWorld.multiplyMatrices(tt.matrixWorld,G.matrix),G.matrixWorldInverse.copy(G.matrixWorld).invert()}this.updateCamera=function(G){if(s===null)return;let tt=G.near,rt=G.far;m.texture!==null&&(m.depthNear>0&&(tt=m.depthNear),m.depthFar>0&&(rt=m.depthFar)),U.near=D.near=R.near=tt,U.far=D.far=R.far=rt,(C!==U.near||B!==U.far)&&(s.updateRenderState({depthNear:U.near,depthFar:U.far}),C=U.near,B=U.far),U.layers.mask=G.layers.mask|6,R.layers.mask=U.layers.mask&-5,D.layers.mask=U.layers.mask&-3;let yt=G.parent,ft=U.cameras;z(U,yt);for(let Ot=0;Ot0&&(m.alphaTest.value=p.alphaTest);let b=t.get(p),w=b.envMap,v=b.envMapRotation;w&&(m.envMap.value=w,m.envMapRotation.value.setFromMatrix4(yv.makeRotationFromEuler(v)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Yd),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,e(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,e(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,e(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 l(m,p,b,w){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*b,m.scale.value=w*.5,p.map&&(m.map.value=p.map,e(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(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,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(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 d(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function u(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,b){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===De&&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.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,e(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,e(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function _(m,p){let b=t.get(p).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function bv(i,t,e,n){let s={},r={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(v,y){let S=y.program;n.uniformBlockBinding(v,S)}function c(v,y){let S=s[v.id];S===void 0&&(m(v),S=h(v),s[v.id]=S,v.addEventListener("dispose",b));let A=y.program;n.updateUBOMapping(v,A);let x=t.render.frame;r[v.id]!==x&&(u(v),r[v.id]=x)}function h(v){let y=d();v.__bindingPointIndex=y;let S=i.createBuffer(),A=v.__size,x=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,A,x),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,y,S),S}function d(){for(let v=0;v0&&(S+=A-x),v.__size=S,v.__cache={},this}function p(v){let y={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(y.boundary=4,y.storage=4):v.isVector2?(y.boundary=8,y.storage=8):v.isVector3||v.isColor?(y.boundary=16,y.storage=12):v.isVector4?(y.boundary=16,y.storage=16):v.isMatrix3?(y.boundary=48,y.storage=48):v.isMatrix4?(y.boundary=64,y.storage=64):v.isTexture?zt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(v)?(y.boundary=16,y.storage=v.byteLength):zt("WebGLRenderer: Unsupported uniform value type.",v),y}function b(v){let y=v.target;y.removeEventListener("dispose",b);let S=o.indexOf(y.__bindingPointIndex);o.splice(S,1),i.deleteBuffer(s[y.id]),delete s[y.id],delete r[y.id]}function w(){for(let v in s)i.deleteBuffer(s[v]);o=[],s={},r={}}return{bind:l,update:c,dispose:w}}var Sv=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]),Hn=null;function wv(){return Hn===null&&(Hn=new Nn(Sv,16,16,bi,Sn),Hn.name="DFG_LUT",Hn.minFilter=Xe,Hn.magFilter=Xe,Hn.wrapS=In,Hn.wrapT=In,Hn.generateMipmaps=!1,Hn.needsUpdate=!0),Hn}var Si=class{constructor(t={}){let{canvas:e=dd(),context:n=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:f=nn}=t;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=o;let _=f,m=new Set([ha,ca,la]),p=new Set([nn,bn,Rs,Cs,oa,aa]),b=new Uint32Array(4),w=new Int32Array(4),v=new I,y=null,S=null,A=[],x=[],T=null;this.domElement=e,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Mn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let R=this,D=!1,F=null,U=null,C=null,B=null;this._outputColorSpace=Te;let W=0,q=0,O=null,L=-1,H=null,X=new ge,z=new ge,Q=null,lt=new Vt(0),ut=0,ct=e.width,G=e.height,tt=1,rt=null,yt=null,ft=new ge(0,0,ct,G),Ot=new ge(0,0,ct,G),ae=!1,Gt=new Un,dt=!1,Nt=!1,Pt=new Jt,Wt=new I,fe=new ge,Ee={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},at=!1;function Mt(){return O===null?tt:1}let N=n;function Yt(E,k){return e.getContext(E,k)}let Xt,P,M,Y,K,nt,pt,mt,it,ot,gt,Ut,bt,_t,Ft,kt,Zt,V,xt,st,vt,Tt,ht;try{let E={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${"186"}`),e.addEventListener("webglcontextlost",xe,!1),e.addEventListener("webglcontextrestored",le,!1),e.addEventListener("webglcontextcreationerror",fn,!1),N===null){let k="webgl2";if(N=Yt(k,E),N===null)throw Yt(k)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Bt()}catch(E){throw e.removeEventListener("webglcontextlost",xe,!1),e.removeEventListener("webglcontextrestored",le,!1),e.removeEventListener("webglcontextcreationerror",fn,!1),Ht("WebGLRenderer: "+E.message),E}function Bt(){Xt=new P0(N),Xt.init(),vt=new _v(N,Xt),P=new M0(N,Xt,t,vt),M=new mv(N,Xt),P.reversedDepthBuffer&&u&&M.buffers.depth.setReversed(!0),U=N.createFramebuffer(),C=N.createFramebuffer(),B=N.createFramebuffer(),Y=new N0(N),K=new ev,nt=new gv(N,Xt,M,K,P,vt,Y),pt=new I0(R),mt=new Fm(N),Tt=new v0(N,mt),it=new L0(N,mt,Y,Tt),ot=new F0(N,it,mt,Tt,Y),V=new U0(N,P,nt),Ft=new b0(K),gt=new tv(R,pt,Xt,P,Tt,Ft),Ut=new Mv(R,K),bt=new iv,_t=new cv(Xt),Zt=new x0(R,pt,M,ot,g,l),kt=new pv(R,ot,P),ht=new bv(N,Y,P,M),xt=new y0(N,Xt,Y),st=new D0(N,Xt,Y),Y.programs=gt.programs,R.capabilities=P,R.extensions=Xt,R.properties=K,R.renderLists=bt,R.shadowMap=kt,R.state=M,R.info=Y}_!==nn&&(T=new O0(_,e.width,e.height,a,s,r));let Lt=new sh(R,N);this.xr=Lt,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let E=Xt.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){let E=Xt.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return tt},this.setPixelRatio=function(E){E!==void 0&&(tt=E,this.setSize(ct,G,!1))},this.getSize=function(E){return E.set(ct,G)},this.setSize=function(E,k,j=!0){if(Lt.isPresenting){zt("WebGLRenderer: Can't change size while VR device is presenting.");return}ct=E,G=k,e.width=Math.floor(E*tt),e.height=Math.floor(k*tt),j===!0&&(e.style.width=E+"px",e.style.height=k+"px"),T!==null&&T.setSize(e.width,e.height),this.setViewport(0,0,E,k)},this.getDrawingBufferSize=function(E){return E.set(ct*tt,G*tt).floor()},this.setDrawingBufferSize=function(E,k,j){ct=E,G=k,tt=j,e.width=Math.floor(E*j),e.height=Math.floor(k*j),this.setViewport(0,0,E,k)},this.setEffects=function(E){if(_===nn){Ht("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let k=0;k{function Et(){if(Z.forEach(function(Rt){let Ct=K.get(Rt).currentProgram;(Ct===void 0||Ct.isReady())&&Z.delete(Rt)}),Z.size===0){J(E);return}setTimeout(Et,10)}Xt.get("KHR_parallel_shader_compile")!==null?Et():setTimeout(Et,10)})};let Tl=null;function Dp(E){Tl&&Tl(E)}function Gh(){Ci.stop()}function Wh(){Ci.start()}let Ci=new Hd;Ci.setAnimationLoop(Dp),typeof self<"u"&&Ci.setContext(self),this.setAnimationLoop=function(E){Tl=E,Lt.setAnimationLoop(E),E===null?Ci.stop():Ci.start()},Lt.addEventListener("sessionstart",Gh),Lt.addEventListener("sessionend",Wh),this.render=function(E,k){if(k!==void 0&&k.isCamera!==!0){Ht("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;F!==null&&F.renderStart(E,k);let j=Lt.enabled===!0&&Lt.isPresenting===!0,Z=T!==null&&(O===null||j)&&T.begin(R,O);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),k.parent===null&&k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),Lt.enabled===!0&&Lt.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Lt.cameraAutoUpdate===!0&&Lt.updateCamera(k),k=Lt.getCamera()),E.isScene===!0&&E.onBeforeRender(R,E,k,O),S=_t.get(E,x.length),S.init(k),S.state.textureUnits=nt.getTextureUnits(),x.push(S),Pt.multiplyMatrices(k.projectionMatrix,k.matrixWorldInverse),Gt.setFromProjectionMatrix(Pt,xn,k.reversedDepth),Nt=this.localClippingEnabled,dt=Ft.init(this.clippingPlanes,Nt),y=bt.get(E,A.length),y.init(),A.push(y),Lt.enabled===!0&&Lt.isPresenting===!0){let Rt=R.xr.getDepthSensingMesh();Rt!==null&&Al(Rt,k,-1/0,R.sortObjects)}Al(E,k,0,R.sortObjects),y.finish(),F!==null&&F.updateLights(S.state.lightsArray),R.sortObjects===!0&&y.sort(rt,yt),at=Lt.enabled===!1||Lt.isPresenting===!1||Lt.hasDepthSensing()===!1,at&&Zt.addToRenderList(y,E),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),dt===!0&&Ft.beginShadows();let J=S.state.shadowsArray;if(kt.render(J,E,k),dt===!0&&Ft.endShadows(),(Z&&T.hasRenderPass())===!1){let Rt=y.opaque,wt=y.transmissive;if(S.setupLights(),k.isArrayCamera){let Ct=k.cameras;if(wt.length>0)for(let Dt=0,Kt=Ct.length;Dt0&&qh(Rt,wt,E,k),at&&Zt.render(E),Xh(y,E,k)}O!==null&&q===0&&(nt.updateMultisampleRenderTarget(O),nt.updateRenderTargetMipmap(O)),Z&&T.end(R),E.isScene===!0&&E.onAfterRender(R,E,k),Tt.resetDefaultState(),L=-1,H=null,x.pop(),x.length>0?(S=x[x.length-1],nt.setTextureUnits(S.state.textureUnits),dt===!0&&Ft.setGlobalState(R.clippingPlanes,S.state.camera)):S=null,A.pop(),A.length>0?y=A[A.length-1]:y=null,F!==null&&F.renderEnd()};function Al(E,k,j,Z){if(E.visible===!1)return;if(E.layers.test(k.layers)){if(E.isGroup)j=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(k);else if(E.isLightProbeGrid)S.pushLightProbeGrid(E);else if(E.isLight)S.pushLight(E),E.castShadow&&S.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||E.intersectsFrustum(Gt)){Z&&fe.setFromMatrixPosition(E.matrixWorld).applyMatrix4(Pt);let Rt=ot.update(E),wt=E.material;wt.visible&&y.push(E,Rt,wt,j,fe.z,null,k)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||E.intersectsFrustum(Gt))){let Rt=ot.update(E),wt=E.material;if(Z&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),fe.copy(E.boundingSphere.center)):(Rt.boundingSphere===null&&Rt.computeBoundingSphere(),fe.copy(Rt.boundingSphere.center)),fe.applyMatrix4(E.matrixWorld).applyMatrix4(Pt)),Array.isArray(wt)){let Ct=Rt.groups;for(let Dt=0,Kt=Ct.length;Dt0&&Vr(J,k,j),Et.length>0&&Vr(Et,k,j),Rt.length>0&&Vr(Rt,k,j),M.buffers.depth.setTest(!0),M.buffers.depth.setMask(!0),M.buffers.color.setMask(!0),M.setPolygonOffset(!1)}function qh(E,k,j,Z){if((j.isScene===!0?j.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[Z.id]===void 0){let It=Xt.has("EXT_color_buffer_half_float")||Xt.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[Z.id]=new He(1,1,{generateMipmaps:!0,type:It?Sn:nn,minFilter:yi,samples:Math.max(4,P.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:te.workingColorSpace})}let Et=S.state.transmissionRenderTarget[Z.id],Rt=Z.viewport||X;Et.setSize(Rt.z*R.transmissionResolutionScale,Rt.w*R.transmissionResolutionScale);let wt=R.getRenderTarget(),Ct=R.getActiveCubeFace(),Dt=R.getActiveMipmapLevel();R.setRenderTarget(Et),R.getClearColor(lt),ut=R.getClearAlpha(),ut<1&&R.setClearColor(16777215,.5),R.clear(),at&&Zt.render(j);let Kt=R.toneMapping;R.toneMapping=Mn;let Qt=Z.viewport;if(Z.viewport!==void 0&&(Z.viewport=void 0),S.setupLightsView(Z),dt===!0&&Ft.setGlobalState(R.clippingPlanes,Z),Vr(E,j,Z),nt.updateMultisampleRenderTarget(Et),nt.updateRenderTargetMipmap(Et),Xt.has("WEBGL_multisampled_render_to_texture")===!1){let It=!1;for(let ce=0,Ie=k.length;ce0,Z.currentProgram=Qt,Z.uniformsList=null,Qt}function $h(E){if(E.uniformsList===null){let k=E.currentProgram.getUniforms();E.uniformsList=Ds.seqWithValue(k.seq,E.uniforms)}return E.uniformsList}function Zh(E,k){let j=K.get(E);j.outputColorSpace=k.outputColorSpace,j.batching=k.batching,j.batchingColor=k.batchingColor,j.instancing=k.instancing,j.instancingColor=k.instancingColor,j.instancingMorph=k.instancingMorph,j.skinning=k.skinning,j.morphTargets=k.morphTargets,j.morphNormals=k.morphNormals,j.morphColors=k.morphColors,j.morphTargetsCount=k.morphTargetsCount,j.numClippingPlanes=k.numClippingPlanes,j.numIntersection=k.numClipIntersection,j.vertexAlphas=k.vertexAlphas,j.vertexTangents=k.vertexTangents,j.toneMapping=k.toneMapping}function Np(E,k){if(E.length===0)return null;if(E.length===1)return E[0].texture!==null?E[0]:null;v.setFromMatrixPosition(k.matrixWorld);for(let j=0,Z=E.length;j0),It=!!j.morphAttributes.position,ce=!!j.morphAttributes.normal,Ie=!!j.morphAttributes.color,be=Mn;Z.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(be=R.toneMapping);let me=j.morphAttributes.position||j.morphAttributes.normal||j.morphAttributes.color,$e=me!==void 0?me.length:0,At=K.get(Z),tn=S.state.lights;if(dt===!0&&(Nt===!0||E!==H)){let ve=E===H&&Z.id===L;Ft.setState(Z,E,ve)}let se=!1;Z.version===At.__version?(At.needsLights&&At.lightsStateVersion!==tn.state.version||At.outputColorSpace!==wt||J.isBatchedMesh&&At.batching===!1||!J.isBatchedMesh&&At.batching===!0||J.isBatchedMesh&&At.batchingColor===!0&&J._colorsTexture===null||J.isBatchedMesh&&At.batchingColor===!1&&J._colorsTexture!==null||J.isInstancedMesh&&At.instancing===!1||!J.isInstancedMesh&&At.instancing===!0||J.isSkinnedMesh&&At.skinning===!1||!J.isSkinnedMesh&&At.skinning===!0||J.isInstancedMesh&&At.instancingColor===!0&&J.instanceColor===null||J.isInstancedMesh&&At.instancingColor===!1&&J.instanceColor!==null||J.isInstancedMesh&&At.instancingMorph===!0&&J.morphTexture===null||J.isInstancedMesh&&At.instancingMorph===!1&&J.morphTexture!==null||At.envMap!==Dt||Z.fog===!0&&At.fog!==Et||At.numClippingPlanes!==void 0&&(At.numClippingPlanes!==Ft.numPlanes||At.numIntersection!==Ft.numIntersection)||At.vertexAlphas!==Kt||At.vertexTangents!==Qt||At.morphTargets!==It||At.morphNormals!==ce||At.morphColors!==Ie||At.toneMapping!==be||At.morphTargetsCount!==$e||!!At.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(se=!0):(se=!0,At.__version=Z.version);let hn=At.currentProgram;se===!0&&(hn=Gr(Z,k,J),F&&Z.isNodeMaterial&&F.onUpdateProgram(Z,hn,At));let Rn=!1,ri=!1,qi=!1,pe=hn.getUniforms(),Ce=At.uniforms;if(M.useProgram(hn.program)&&(Rn=!0,ri=!0,qi=!0),Z.id!==L&&(L=Z.id,ri=!0),At.needsLights){let ve=Np(S.state.lightProbeGridArray,J);At.lightProbeGrid!==ve&&(At.lightProbeGrid=ve,ri=!0)}if(Rn||H!==E){M.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),pe.setValue(N,"projectionMatrix",E.projectionMatrix),pe.setValue(N,"viewMatrix",E.matrixWorldInverse);let ai=pe.map.cameraPosition;ai!==void 0&&ai.setValue(N,Wt.setFromMatrixPosition(E.matrixWorld)),P.logarithmicDepthBuffer&&pe.setValue(N,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(Z.isMeshPhongMaterial||Z.isMeshToonMaterial||Z.isMeshLambertMaterial||Z.isMeshBasicMaterial||Z.isMeshStandardMaterial||Z.isShaderMaterial)&&pe.setValue(N,"isOrthographic",E.isOrthographicCamera===!0),H!==E&&(H=E,ri=!0,qi=!0)}if(At.needsLights&&(tn.state.sunShadowMap.length>0&&pe.setValue(N,"sunShadowMap",tn.state.sunShadowMap,nt),tn.state.directionalShadowMap.length>0&&pe.setValue(N,"directionalShadowMap",tn.state.directionalShadowMap,nt),tn.state.spotShadowMap.length>0&&pe.setValue(N,"spotShadowMap",tn.state.spotShadowMap,nt),tn.state.pointShadowMap.length>0&&pe.setValue(N,"pointShadowMap",tn.state.pointShadowMap,nt)),J.isSkinnedMesh){pe.setOptional(N,J,"bindMatrix"),pe.setOptional(N,J,"bindMatrixInverse");let ve=J.skeleton;ve&&(ve.boneTexture===null&&ve.computeBoneTexture(),pe.setValue(N,"boneTexture",ve.boneTexture,nt))}J.isBatchedMesh&&(pe.setOptional(N,J,"batchingTexture"),pe.setValue(N,"batchingTexture",J._matricesTexture,nt),pe.setOptional(N,J,"batchingIdTexture"),pe.setValue(N,"batchingIdTexture",J._indirectTexture,nt),pe.setOptional(N,J,"batchingColorTexture"),J._colorsTexture!==null&&pe.setValue(N,"batchingColorTexture",J._colorsTexture,nt));let oi=j.morphAttributes;if((oi.position!==void 0||oi.normal!==void 0||oi.color!==void 0)&&V.update(J,j,hn),(ri||At.receiveShadow!==J.receiveShadow)&&(At.receiveShadow=J.receiveShadow,pe.setValue(N,"receiveShadow",J.receiveShadow)),(Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial)&&Z.envMap===null&&k.environment!==null&&(Ce.envMapIntensity.value=k.environmentIntensity),Ce.dfgLUT!==void 0&&(Ce.dfgLUT.value=wv()),ri){if(pe.setValue(N,"toneMappingExposure",R.toneMappingExposure),At.needsLights&&Fp(Ce,qi),Et&&Z.fog===!0&&Ut.refreshFogUniforms(Ce,Et),Ut.refreshMaterialUniforms(Ce,Z,tt,G,S.state.transmissionRenderTarget[E.id]),At.needsLights&&At.lightProbeGrid){let ve=At.lightProbeGrid;Ce.probesSH.value=ve.texture,Ce.probesMin.value.copy(ve.boundingBox.min),Ce.probesMax.value.copy(ve.boundingBox.max),Ce.probesResolution.value.copy(ve.resolution)}Ds.upload(N,$h(At),Ce,nt)}if(Z.isShaderMaterial&&Z.uniformsNeedUpdate===!0&&(Ds.upload(N,$h(At),Ce,nt),Z.uniformsNeedUpdate=!1),Z.isSpriteMaterial&&pe.setValue(N,"center",J.center),pe.setValue(N,"modelViewMatrix",J.modelViewMatrix),pe.setValue(N,"normalMatrix",J.normalMatrix),pe.setValue(N,"modelMatrix",J.matrixWorld),Z.uniformsGroups!==void 0){let ve=Z.uniformsGroups;for(let ai=0,Yi=ve.length;ai0&&nt.useMultisampledRTT(E)===!1?Z=K.get(E).__webglMultisampledFramebuffer:Array.isArray(Dt)?Z=Dt[j]:Z=Dt,X.copy(E.viewport),z.copy(E.scissor),Q=E.scissorTest}else X.copy(ft).multiplyScalar(tt).floor(),z.copy(Ot).multiplyScalar(tt).floor(),Q=ae;if(j!==0&&(Z=U),M.bindFramebuffer(N.FRAMEBUFFER,Z)&&M.drawBuffers(E,Z),M.viewport(X),M.scissor(z),M.setScissorTest(Q),J){let wt=K.get(E.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+k,wt.__webglTexture,j)}else if(Et){let wt=k;for(let Ct=0;Ct1&&N.readBuffer(N.COLOR_ATTACHMENT0+wt);let It=Jh(Dt);if(It.__formatReadable===!1){Ht("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(It.__typeReadable===!1){Ht("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}k>=0&&k<=E.width-Z&&j>=0&&j<=E.height-J&&N.readPixels(k,j,Z,J,vt.convert(Kt),vt.convert(Qt),Et)}finally{let Dt=O!==null?K.get(O).__webglFramebuffer:null;M.bindFramebuffer(N.FRAMEBUFFER,Dt)}}},this.readRenderTargetPixelsAsync=async function(E,k,j,Z,J,Et,Rt,wt=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ct=K.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&Rt!==void 0&&(Ct=Ct[Rt]),Ct)if(k>=0&&k<=E.width-Z&&j>=0&&j<=E.height-J){M.bindFramebuffer(N.FRAMEBUFFER,Ct);let Dt=E.textures[wt],Kt=Dt.format,Qt=Dt.type;E.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+wt);let It=Jh(Dt);if(It.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(It.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let ce=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,ce),N.bufferData(N.PIXEL_PACK_BUFFER,Et.byteLength,N.STREAM_READ),N.readPixels(k,j,Z,J,vt.convert(Kt),vt.convert(Qt),0),N.bindBuffer(N.PIXEL_PACK_BUFFER,null);let Ie=O!==null?K.get(O).__webglFramebuffer:null;M.bindFramebuffer(N.FRAMEBUFFER,Ie);let be=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await pd(N,be,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,ce),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,Et),N.bindBuffer(N.PIXEL_PACK_BUFFER,null),N.deleteBuffer(ce),N.deleteSync(be),Et}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,k=null,j=0){let Z=Math.pow(2,-j),J=Math.floor(E.image.width*Z),Et=Math.floor(E.image.height*Z),Rt=k!==null?k.x:0,wt=k!==null?k.y:0;nt.setTexture2D(E,0),N.copyTexSubImage2D(N.TEXTURE_2D,j,0,0,Rt,wt,J,Et),M.unbindTexture()},this.copyTextureToTexture=function(E,k,j=null,Z=null,J=0,Et=0){let Rt,wt,Ct,Dt,Kt,Qt,It,ce,Ie,be=E.isCompressedTexture?E.mipmaps[Et]:E.image;if(j!==null)Rt=j.max.x-j.min.x,wt=j.max.y-j.min.y,Ct=j.isBox3?j.max.z-j.min.z:1,Dt=j.min.x,Kt=j.min.y,Qt=j.isBox3?j.min.z:0;else{let Ce=Math.pow(2,-J);Rt=Math.floor(be.width*Ce),wt=Math.floor(be.height*Ce),E.isDataArrayTexture?Ct=be.depth:E.isData3DTexture?Ct=Math.floor(be.depth*Ce):Ct=1,Dt=0,Kt=0,Qt=0}Z!==null?(It=Z.x,ce=Z.y,Ie=Z.z):(It=0,ce=0,Ie=0);let me=vt.convert(k.format),$e=vt.convert(k.type),At;k.isData3DTexture?(nt.setTexture3D(k,0),At=N.TEXTURE_3D):k.isDataArrayTexture||k.isCompressedArrayTexture?(nt.setTexture2DArray(k,0),At=N.TEXTURE_2D_ARRAY):(nt.setTexture2D(k,0),At=N.TEXTURE_2D),M.activeTexture(N.TEXTURE0),M.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,k.flipY),M.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),M.pixelStorei(N.UNPACK_ALIGNMENT,k.unpackAlignment);let tn=M.getParameter(N.UNPACK_ROW_LENGTH),se=M.getParameter(N.UNPACK_IMAGE_HEIGHT),hn=M.getParameter(N.UNPACK_SKIP_PIXELS),Rn=M.getParameter(N.UNPACK_SKIP_ROWS),ri=M.getParameter(N.UNPACK_SKIP_IMAGES);M.pixelStorei(N.UNPACK_ROW_LENGTH,be.width),M.pixelStorei(N.UNPACK_IMAGE_HEIGHT,be.height),M.pixelStorei(N.UNPACK_SKIP_PIXELS,Dt),M.pixelStorei(N.UNPACK_SKIP_ROWS,Kt),M.pixelStorei(N.UNPACK_SKIP_IMAGES,Qt);let qi=E.isDataArrayTexture||E.isData3DTexture,pe=k.isDataArrayTexture||k.isData3DTexture;if(E.isDepthTexture){let Ce=K.get(E),oi=K.get(k),ve=K.get(Ce.__renderTarget),ai=K.get(oi.__renderTarget);M.bindFramebuffer(N.READ_FRAMEBUFFER,ve.__webglFramebuffer),M.bindFramebuffer(N.DRAW_FRAMEBUFFER,ai.__webglFramebuffer);for(let Yi=0;Yi=c.length){s-=c.length;continue}let h=Math.min(o,c.length-s);if(a.push(c.substringData(s,h)),o-=h,s=0,!o)break}let l=new Uint8Array(Math.ceil((r+e)/3)*3);if(rh(l,0,a.join(""))i!==null&&typeof i=="object"&&!Array.isArray(i),ii=i=>Array.isArray(i)&&i.every(Gi),wi=i=>Array.isArray(i)&&i.length===3&&i.every(t=>typeof t=="number"),Qd=i=>Gi(i)&&wi(i.min)&&wi(i.max),Jd=i=>i==null||Gi(i)&&ii(i.planes)&&i.planes.every(t=>wi(t.normal)&&t.normal.every(Number.isFinite)&&t.normal.some(e=>e!==0)&&Number.isFinite(t.offset))&&(i.box==null||Qd(i.box)&&i.box.max.every(Number.isFinite)&&i.box.min.every((t,e)=>Number.isFinite(t)&&t<=i.box.max[e]));function Av(i){if(!Gi(i)||!ii(i.elements)||!ii(i.geometries)||!ii(i.materials)||!Gi(i.instances))throw new ie("META must describe elements, geometries, materials and instances.");if(i.title!=null&&typeof i.title!="string")throw new ie("Invalid META title.");let{instances:t}=i;if(!Number.isSafeInteger(t.count)||t.count<0)throw new ie("Invalid META instance count.");for(let[e,n,s]of[["geometry","u32",t.count],["material","u32",t.count],["element","i32",t.count],["matrix","f32",t.count*12]])if(t[e]?.t!==n||t[e].n!==s)throw new ie(`Invalid META instance ${e} view.`);for(let e of i.geometries){let n=e.q;if(!Qd(e.bbox)||!["u16","u32"].includes(e.indices?.t)||e.positions?.t!==(n?"u16":"f32")||n&&(!wi(n.o)||typeof n.s!="number")||e.normals!=null&&!["f32","i16"].includes(e.normals.t)||e.uvs!=null&&e.uvs.t!=="f32"||e.kind!=null&&e.kind!=="points"||e.colors!=null&&(e.kind!=="points"||e.colors.t!=="u8"||e.colors.n!==e.positions.n))throw new ie("Invalid META geometry.")}if(i.points!=null){let e=i.points;if(!Gi(e)||!Number.isSafeInteger(e.count)||e.count<0)throw new ie("Invalid META point count.");for(let[n,s,r]of[["geometry","u32",e.count],["material","u32",e.count],["element","i32",e.count],["matrix","f32",e.count*12]])if(e[n]?.t!==s||e[n].n!==r)throw new ie(`Invalid META point ${n} view.`)}if(i.panoramas!=null&&(!ii(i.panoramas)||i.panoramas.some(e=>!Number.isInteger(e.element)||e.element<0||e.element>=i.elements.length||e.name!=null&&typeof e.name!="string"||!wi(e.position)||!e.position.every(Number.isFinite)||!Number.isFinite(e.yaw)||e.image?.t!=="u8"||!Number.isSafeInteger(e.image.n)||e.image.n<4||e.image.n>16*1024*1024)))throw new ie("Invalid META panorama.");Rv(i);for(let e of i.materials){let n=e.texture;if(!wi(e.color)||typeof e.opacity!="number"||n!=null&&(!Number.isInteger(n)||n<0||n>=(i.textures?.length??0)))throw new ie("Invalid META material.")}}function Rv(i){if(!Gi(i)||!ii(i.elements)||i.title!=null&&typeof i.title!="string")throw new ie("Invalid review metadata.");for(let l of["textures","grids","viewpoints","bcfTopics","clashTests","linkedFiles","models"])if(i[l]!=null&&!ii(i[l]))throw new ie(`Invalid META ${l} list.`);if(i.models?.some(({id:l,name:c})=>!Number.isSafeInteger(l)||typeof c!="string")||i.elements.some(({modelId:l,levelId:c})=>l!=null&&!Number.isSafeInteger(l)||c!=null&&!Number.isSafeInteger(c)))throw new ie("Invalid META model or level identity.");let t=l=>l==null||Array.isArray(l)&&l.every(c=>Number.isInteger(c)&&c>=0&&cwi(l)&&l.every(Number.isFinite),n=l=>l==null||typeof l=="string",s=l=>e(l.camera?.position)&&e(l.camera?.target)&&Jd(l.sections)&&t(l.hiddenElements)&&t(l.visibleElements)&&t(l.selectedElements)&&(l.hiddenElements==null||l.visibleElements==null)&&(l.hiddenModelKeys==null||Array.isArray(l.hiddenModelKeys)&&l.hiddenModelKeys.every(c=>typeof c=="string")),r=l=>Number.isSafeInteger(l)&&l>=0,o=l=>s(l)&&e(l.camera.up)&&l.camera.up.some(c=>c!==0)&&(l.camera.projection==="orthographic"?Number.isFinite(l.camera.orthographicHeight)&&l.camera.orthographicHeight>0:l.camera.projection==="perspective"&&Number.isFinite(l.camera.fov)&&l.camera.fov>0&&l.camera.fov<180)&&r(l.missingComponents)&&r(l.ambiguousComponents),a=l=>{let c=Er(l);return Array.isArray(c)&&c.length>=2&&c.every(e)};if(i.grids?.some(l=>!a(l))||i.viewpoints?.some(l=>!s(l))||i.clashTests?.some(l=>!ii(l.clashes)||l.clashes.some(c=>!wi(c.point))))throw new ie("Invalid META grids, viewpoints or clashes.");if(i.bcfTopics?.some(l=>typeof l.title!="string"||!n(l.description)||!n(l.status)||!ii(l.viewpoints)||l.viewpoints.some(c=>!o(c))))throw new ie("Invalid META BCF topics.");if(i.linkedFiles?.some(l=>!t(l.members)))throw new ie("Invalid META linked file members.");if(!Jd(i.sections))throw new ie("Invalid META sections.")}function Cv(i){let t;try{t=JSON.parse(i)}catch(e){throw new ie(e.message,{cause:e})}return Av(t),t}function oh(i=document,t){t?.("metadataStart");let e;try{e=jd(i,"ioviewer-meta")}catch(s){throw s instanceof ie?s:new ie(s.message,{cause:s})}let n=Cv(e);return t?.("metadataEnd"),n}function Kd(i,t){let e=Ev[i?.t];if(!e)throw new ie(`Unknown view type '${i?.t}'.`);let n=e.BYTES_PER_ELEMENT;if(!(Number.isSafeInteger(i.o)&&Number.isSafeInteger(i.n)&&i.o>=0&&i.n>=0&&i.o%n===0&&i.o+i.n*n<=t))throw new ie(`View ${JSON.stringify(i)} is outside the ${t} bytes of binary data.`);return e}function tf(i=document,t,e=oh(i,t)){let n,s,r,o;try{if(t?.("binaryStart"),s=i.getElementById("ioviewer-bin"),!s)throw new Error("Data block 'ioviewer-bin' is missing.");({bytes:n,canonical:r}=Zd(s)),t?.("binaryEnd")}catch(c){throw new ie(c.message,{cause:c})}let a=n.length,l=null;return{meta:e,view(c){if(!n)throw new Error("The binary data has been released.");let h=Kd(c,a);return new h(n.buffer,c.o,c.n)},readView(c){let h=Kd(c,a);if(!c.n)return new h(0);!n&&!r&&(o??(o=Zd(s).bytes));let d=n??o;return d?new h(d.buffer,c.o,c.n):new h(Tv(s,c.o,c.n*h.BYTES_PER_ELEMENT))},releaseBinary(){n=null,o=null},props(c){return l??(l=JSON.parse(jd(i,"ioviewer-props"))),l[c]??null}}}var ef=new Jt,nf=new Un,ah=32;function lh(i,t=new Float64Array(24)){return ef.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),nf.setFromProjectionMatrix(ef,i.coordinateSystem,i.reversedDepth),nf.planes.forEach(({normal:e,constant:n},s)=>t.set([e.x,e.y,e.z,n],s*4)),t}function ch(i,t,e,n,s){for(let r=0;r<24;r+=4)if(i[r]*t+i[r+1]*e+i[r+2]*n+i[r+3]<-s)return!0;return!1}function sf(i,t,e,n,s){for(let r=0;r<24;r+=4)if(i[r]*t+i[r+1]*e+i[r+2]*n+i[r+3]=0;r--)if(i[r]!==0){if(n+=i[r],n>e)return s?r===0?0:2**(r/2-4):2**((r+1)/2-4);s=!1}return 0}var wn=.0009765625,uh=32767,Tr=i=>i<0?-1:1;function of(i){let t=Math.min(Math.max(i,-1),1)*uh;return Tr(t)*Math.round(Math.abs(t))}function Ar(i,t,e,n,s){let r=Math.abs(e)+Math.abs(n)+Math.abs(s);if(!(r>0)){i[t]=i[t+1]=0;return}let o=e/r,a=n/r;s<0&&([o,a]=[(1-Math.abs(a))*Tr(o),(1-Math.abs(o))*Tr(a)]),i[t]=of(o),i[t+1]=of(a)}function af(i,t,e,n){let s=Math.max(e/uh,-1),r=Math.max(n/uh,-1),o=1-Math.abs(s)-Math.abs(r);o<0&&([s,r]=[(1-Math.abs(r))*Tr(s),(1-Math.abs(s))*Tr(r)]);let a=Math.sqrt(s*s+r*r+o*o);i[t]=s/a,i[t+1]=r/a,i[t+2]=o/a}function Rr(i,t){let e=i.view(t.positions);if(!t.q){if(!(e instanceof Float32Array))throw new Error(`Geometry positions of type '${t.positions.t}' need a "q" origin and step.`);return e}if(!(e instanceof Uint16Array))throw new Error(`Quantized geometry positions must be u16, got '${t.positions.t}'.`);return e}function Ja(i,t){let e=Rr(i,t);if(!t.q)return e;let[n,s,r]=t.q.o,o=t.q.s,a=new Float32Array(e.length);for(let l=0;ls[d]&&(s[d]=u))}let r=0;for(let h=1;h<3;h++)s[h]-n[h]>s[r]-n[r]&&(r=h);let o=s[r]-n[r],a=2**20-1,l=new Float64Array(i.length);for(let h=0;h0&&Number.isFinite(u)?Math.round((u-n[r])/o*a):0;l[h]=f*2**32+d}let c=0;e<0?l.sort():c=Pv(l,e);for(let h=0;hr)return i.subarray(e,n+1).sort(),a+l*Math.ceil(Math.log2(l));a+=l,s=Math.imul(s,1664525)+1013904223>>>0;let c=i[e+s%(n-e+1)],h=e,d=n;for(;h<=d;){for(;i[h]c;)d--;if(h<=d){let u=i[h];i[h++]=i[d],i[d--]=u}}if(t<=d)n=d;else if(t>=h)e=h;else return a}return a}function pf(i,t,e,n=1/0){let s=[];s.scanned=0;let r=[Uint32Array.from(t)];for(;r.length;){let o=r.pop(),a=Math.ceil(o.length/e);if(o.length<=1||a<=1&&Lv(o,i)<=n){o.length&&s.push(o);continue}let l=a>1?Math.ceil(o.length*Math.floor(a/2)/a):Math.ceil(o.length/2);s.scanned+=ff(o,i,l),r.push(o.subarray(l),o.subarray(0,l))}return s}function Lv(i,t){let e=1/0,n=1/0,s=1/0,r=-1/0,o=-1/0,a=-1/0;for(let l of i){let c=t[l*3],h=t[l*3+1],d=t[l*3+2];cr&&(r=c),ho&&(o=h),da&&(a=d)}return Math.hypot(r-e,o-n,a-s)/2}function mf(i,t){let e=new Float64Array(6).fill(-1/0),n=new Float64Array(6).fill(-1/0),s=new Int32Array(6);for(let o=0;oe[a]?(n[a]=e[a],e[a]=c,s[a]=o):c>n[a]&&(n[a]=c)}if(e[0]===-1/0)return 0;let r=Math.hypot(e[0]+e[3],e[1]+e[4],e[2]+e[5]);if(n[0]===-1/0)return r;for(let o of s){let a=c=>s[c]===o?n[c]:e[c],l=Math.hypot(a(0)+a(3),a(1)+a(4),a(2)+a(5));r=Math.min(r,2*l)}return r}var fh=384*2**20;function gf(i,{cap:t=fh,minRepeats:e=16,perCell:n=1024,maxDraws:s=1024}={}){let r=new Uint8Array(i.length),o=0;for(let h of i)o+=h.k*h.bytes;if(o<=t)return r;let a=h=>(i[h].k-1)*i[h].bytes,l=[...i.keys()].filter(h=>i[h].k>=e);l.sort((h,d)=>a(d)-a(h)||i[d].k-i[h].k||h-d);let c=0;for(let h of l){let d=i[h].cells??Math.ceil(i[h].k/n);c+d>s||(r[h]=1,c+=d)}return r}function Ka(i,t){return i>65535?new Uint32Array(t):new Uint16Array(t)}function ph(i,t){return i.sort((e,n)=>t[n]-t[e]||e-n)}function _f(i,t,e,n){for(;t>>1;i[s]>=n?t=s+1:e=s}return t}function xf(i,t,e){let n=i[t];return[n,e>t?i[e]-n:0]}function vf(i,t,e,n){let s=i.subarray(t*12,t*12+12);if(s[0]===1&&s[1]===0&&s[2]===0&&s[3]===0&&s[4]===1&&s[5]===0&&s[6]===0&&s[7]===0&&s[8]===1&&e.q&&e.q.s===wn){for(let a=0;a<3;a++)n[a]=s[9+a]+e.q.o[a];return hf}let o=!0;for(let a=0;a<3;a++){let l=s[9+a],c=s[9+a];for(let h=0;h<3;h++){let d=s[h*3+a]*e.min[h],u=s[h*3+a]*e.max[h];l+=Math.min(d,u),c+=Math.max(d,u)}n[a]=Math.floor(l/wn)*wn,Math.ceil((c-n[a])/wn)<=uf||(o=!1)}return o||n.fill(0),o?Iv:Fs}function yf(i,t){let e=i.length,n=0,s=0;for(let m of i){let p=t.source(t.geometryOf[m]);n+=p.vertices,s+=p.indices.length}let r=t.kind[i[0]]===Fs,o=r?new Float32Array(n*4):new Uint16Array(n*4),a=new Int16Array(n*2),l=t.textured?new Float32Array(n*2):null,c=Ka(n,s),h=new Uint32Array(e+1),d=new Float32Array(e*3),u=new Float32Array(e),f=new Float64Array(3),g=0,_=0;for(let m=0;mMath.min(Math.max(Math.round(i/wn),0),uf);function Mf(i,t,e,n,s){let r=i.length/3,o=[1/0,1/0,1/0],a=[-1/0,-1/0,-1/0];for(let c=0;ca[h]&&(a[h]=d)}let l=e instanceof Int16Array?e:null;return{positions:i,q:t,oct:l,normals:l?null:e,indices:n,uvs:s,vertices:r,min:o,max:a}}function ja(i){if(!i.normals&&i.oct){i.normals=new Float32Array(i.vertices*3);for(let t=0;t=0&&(S[It]=null,y[It].disconnect(dt))}for(let tt=0;tt=S.length){S.push(dt),It=Tt;break}else if(S[Tt]===null){S[Tt]=dt,It=Tt;break}if(It===-1)break}let ot=y[It];ot&&ot.connect(dt)}}let N=new L,z=new L;function W(Y,tt,dt){N.setFromMatrixPosition(tt.matrixWorld),z.setFromMatrixPosition(dt.matrixWorld);let It=N.distanceTo(z),ot=tt.projectionMatrix.elements,Tt=dt.projectionMatrix.elements,jt=ot[14]/(ot[10]-1),Bt=ot[14]/(ot[10]+1),ut=(ot[9]+1)/ot[5],Lt=(ot[9]-1)/ot[5],Ot=(ot[8]-1)/ot[0],zt=(Tt[8]+1)/Tt[0],Zt=jt*Ot,Ee=jt*zt,ie=It/(-Ot+zt),re=ie*-Ot;if(tt.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(re),Y.translateZ(ie),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),ot[10]===-1)Y.projectionMatrix.copy(tt.projectionMatrix),Y.projectionMatrixInverse.copy(tt.projectionMatrixInverse);else{let R=jt+ie,wt=Bt+ie,kt=Zt-re,P=Ee+(It-re),M=ut*Bt/wt*R,X=Lt*Bt/wt*R;Y.projectionMatrix.makePerspective(kt,P,M,X,R,wt),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function k(Y,tt){tt===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(tt.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(s===null)return;let tt=Y.near,dt=Y.far;m.texture!==null&&(m.depthNear>0&&(tt=m.depthNear),m.depthFar>0&&(dt=m.depthFar)),F.near=D.near=C.near=tt,F.far=D.far=C.far=dt,(I!==F.near||B!==F.far)&&(s.updateRenderState({depthNear:F.near,depthFar:F.far}),I=F.near,B=F.far),F.layers.mask=Y.layers.mask|6,C.layers.mask=F.layers.mask&-5,D.layers.mask=F.layers.mask&-3;let It=Y.parent,ot=F.cameras;k(F,It);for(let Tt=0;Tt0&&(m.alphaTest.value=p.alphaTest);let b=t.get(p),E=b.envMap,v=b.envMapRotation;E&&(m.envMap.value=E,m.envMapRotation.value.setFromMatrix4(Sv.makeRotationFromEuler(v)).transpose(),E.isCubeTexture&&E.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Zd),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,e(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,e(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,e(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 l(m,p,b,E){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*b,m.scale.value=E*.5,p.map&&(m.map.value=p.map,e(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(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,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(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 d(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function u(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,b){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===De&&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.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,e(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,e(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function _(m,p){let b=t.get(p).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Ev(i,t,e,n){let s={},r={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(v,y){let S=y.program;n.uniformBlockBinding(v,S)}function c(v,y){let S=s[v.id];S===void 0&&(m(v),S=h(v),s[v.id]=S,v.addEventListener("dispose",b));let A=y.program;n.updateUBOMapping(v,A);let x=t.render.frame;r[v.id]!==x&&(u(v),r[v.id]=x)}function h(v){let y=d();v.__bindingPointIndex=y;let S=i.createBuffer(),A=v.__size,x=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,A,x),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,y,S),S}function d(){for(let v=0;v0&&(S+=A-x),v.__size=S,v.__cache={},this}function p(v){let y={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(y.boundary=4,y.storage=4):v.isVector2?(y.boundary=8,y.storage=8):v.isVector3||v.isColor?(y.boundary=16,y.storage=12):v.isVector4?(y.boundary=16,y.storage=16):v.isMatrix3?(y.boundary=48,y.storage=48):v.isMatrix4?(y.boundary=64,y.storage=64):v.isTexture?Ht("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(v)?(y.boundary=16,y.storage=v.byteLength):Ht("WebGLRenderer: Unsupported uniform value type.",v),y}function b(v){let y=v.target;y.removeEventListener("dispose",b);let S=o.indexOf(y.__bindingPointIndex);o.splice(S,1),i.deleteBuffer(s[y.id]),delete s[y.id],delete r[y.id]}function E(){for(let v in s)i.deleteBuffer(s[v]);o=[],s={},r={}}return{bind:l,update:c,dispose:E}}var Tv=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]),Gn=null;function Av(){return Gn===null&&(Gn=new Un(Tv,16,16,wi,wn),Gn.name="DFG_LUT",Gn.minFilter=Xe,Gn.magFilter=Xe,Gn.wrapS=Pn,Gn.wrapT=Pn,Gn.generateMipmaps=!1,Gn.needsUpdate=!0),Gn}var Ei=class{constructor(t={}){let{canvas:e=pd(),context:n=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:f=nn}=t;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=o;let _=f,m=new Set([pa,fa,da]),p=new Set([nn,Sn,Rs,Cs,ha,ua]),b=new Uint32Array(4),E=new Int32Array(4),v=new L,y=null,S=null,A=[],x=[],T=null;this.domElement=e,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=bn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let C=this,D=!1,U=null,F=null,I=null,B=null;this._outputColorSpace=Te;let G=0,q=0,O=null,N=-1,z=null,W=new ge,k=new ge,K=null,lt=new Vt(0),ht=0,at=e.width,Y=e.height,tt=1,dt=null,It=null,ot=new ge(0,0,at,Y),Tt=new ge(0,0,at,Y),jt=!1,Bt=new Fn,ut=!1,Lt=!1,Ot=new Yt,zt=new L,Zt=new ge,Ee={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},ie=!1;function re(){return O===null?tt:1}let R=n;function wt(w,H){return e.getContext(w,H)}let kt,P,M,X,j,nt,ft,pt,it,rt,mt,Nt,vt,gt,Ut,Gt,$t,V,_t,st,xt,St,ct;try{let w={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${"186"}`),e.addEventListener("webglcontextlost",xe,!1),e.addEventListener("webglcontextrestored",ce,!1),e.addEventListener("webglcontextcreationerror",fn,!1),R===null){let H="webgl2";if(R=wt(H,w),R===null)throw wt(H)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Ft()}catch(w){throw e.removeEventListener("webglcontextlost",xe,!1),e.removeEventListener("webglcontextrestored",ce,!1),e.removeEventListener("webglcontextcreationerror",fn,!1),Wt("WebGLRenderer: "+w.message),w}function Ft(){kt=new N0(R),kt.init(),xt=new yv(R,kt),P=new w0(R,kt,t,xt),M=new xv(R,kt),P.reversedDepthBuffer&&u&&M.buffers.depth.setReversed(!0),F=R.createFramebuffer(),I=R.createFramebuffer(),B=R.createFramebuffer(),X=new B0(R),j=new sv,nt=new vv(R,kt,M,j,P,xt,X),ft=new D0(C),pt=new zm(R),St=new b0(R,pt),it=new U0(R,pt,X,St),rt=new z0(R,it,pt,St,X),V=new O0(R,P,nt),Ut=new E0(j),mt=new iv(C,ft,kt,P,St,Ut),Nt=new wv(C,j),vt=new ov,gt=new dv(kt),$t=new M0(C,ft,M,rt,g,l),Gt=new _v(C,rt,P),ct=new Ev(R,X,P,M),_t=new S0(R,kt,X),st=new F0(R,kt,X),X.programs=mt.programs,C.capabilities=P,C.extensions=kt,C.properties=j,C.renderLists=vt,C.shadowMap=Gt,C.state=M,C.info=X}_!==nn&&(T=new H0(_,e.width,e.height,a,s,r));let Pt=new oh(C,R);this.xr=Pt,this.getContext=function(){return R},this.getContextAttributes=function(){return R.getContextAttributes()},this.forceContextLoss=function(){let w=kt.get("WEBGL_lose_context");w&&w.loseContext()},this.forceContextRestore=function(){let w=kt.get("WEBGL_lose_context");w&&w.restoreContext()},this.getPixelRatio=function(){return tt},this.setPixelRatio=function(w){w!==void 0&&(tt=w,this.setSize(at,Y,!1))},this.getSize=function(w){return w.set(at,Y)},this.setSize=function(w,H,Q=!0){if(Pt.isPresenting){Ht("WebGLRenderer: Can't change size while VR device is presenting.");return}at=w,Y=H,e.width=Math.floor(w*tt),e.height=Math.floor(H*tt),Q===!0&&(e.style.width=w+"px",e.style.height=H+"px"),T!==null&&T.setSize(e.width,e.height),this.setViewport(0,0,w,H)},this.getDrawingBufferSize=function(w){return w.set(at*tt,Y*tt).floor()},this.setDrawingBufferSize=function(w,H,Q){at=w,Y=H,tt=Q,e.width=Math.floor(w*Q),e.height=Math.floor(H*Q),this.setViewport(0,0,w,H)},this.setEffects=function(w){if(_===nn){Wt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(w){for(let H=0;H{function bt(){if(Z.forEach(function(At){let Rt=j.get(At).currentProgram;(Rt===void 0||Rt.isReady())&&Z.delete(At)}),Z.size===0){J(w);return}setTimeout(bt,10)}kt.get("KHR_parallel_shader_compile")!==null?bt():setTimeout(bt,10)})};let Cl=null;function Fp(w){Cl&&Cl(w)}function Xh(){Ii.stop()}function qh(){Ii.start()}let Ii=new Gd;Ii.setAnimationLoop(Fp),typeof self<"u"&&Ii.setContext(self),this.setAnimationLoop=function(w){Cl=w,Pt.setAnimationLoop(w),w===null?Ii.stop():Ii.start()},Pt.addEventListener("sessionstart",Xh),Pt.addEventListener("sessionend",qh),this.render=function(w,H){if(H!==void 0&&H.isCamera!==!0){Wt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;U!==null&&U.renderStart(w,H);let Q=Pt.enabled===!0&&Pt.isPresenting===!0,Z=T!==null&&(O===null||Q)&&T.begin(C,O);if(w.matrixWorldAutoUpdate===!0&&w.updateMatrixWorld(),H.parent===null&&H.matrixWorldAutoUpdate===!0&&H.updateMatrixWorld(),Pt.enabled===!0&&Pt.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Pt.cameraAutoUpdate===!0&&Pt.updateCamera(H),H=Pt.getCamera()),w.isScene===!0&&w.onBeforeRender(C,w,H,O),S=gt.get(w,x.length),S.init(H),S.state.textureUnits=nt.getTextureUnits(),x.push(S),Ot.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse),Bt.setFromProjectionMatrix(Ot,xn,H.reversedDepth),Lt=this.localClippingEnabled,ut=Ut.init(this.clippingPlanes,Lt),y=vt.get(w,A.length),y.init(),A.push(y),Pt.enabled===!0&&Pt.isPresenting===!0){let At=C.xr.getDepthSensingMesh();At!==null&&Il(At,H,-1/0,C.sortObjects)}Il(w,H,0,C.sortObjects),y.finish(),U!==null&&U.updateLights(S.state.lightsArray),C.sortObjects===!0&&y.sort(dt,It),ie=Pt.enabled===!1||Pt.isPresenting===!1||Pt.hasDepthSensing()===!1,ie&&$t.addToRenderList(y,w),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),ut===!0&&Ut.beginShadows();let J=S.state.shadowsArray;if(Gt.render(J,w,H),ut===!0&&Ut.endShadows(),(Z&&T.hasRenderPass())===!1){let At=y.opaque,Mt=y.transmissive;if(S.setupLights(),H.isArrayCamera){let Rt=H.cameras;if(Mt.length>0)for(let Dt=0,Jt=Rt.length;Dt0&&$h(At,Mt,w,H),ie&&$t.render(w),Yh(y,w,H)}O!==null&&q===0&&(nt.updateMultisampleRenderTarget(O),nt.updateRenderTargetMipmap(O)),Z&&T.end(C),w.isScene===!0&&w.onAfterRender(C,w,H),St.resetDefaultState(),N=-1,z=null,x.pop(),x.length>0?(S=x[x.length-1],nt.setTextureUnits(S.state.textureUnits),ut===!0&&Ut.setGlobalState(C.clippingPlanes,S.state.camera)):S=null,A.pop(),A.length>0?y=A[A.length-1]:y=null,U!==null&&U.renderEnd()};function Il(w,H,Q,Z){if(w.visible===!1)return;if(w.layers.test(H.layers)){if(w.isGroup)Q=w.renderOrder;else if(w.isLOD)w.autoUpdate===!0&&w.update(H);else if(w.isLightProbeGrid)S.pushLightProbeGrid(w);else if(w.isLight)S.pushLight(w),w.castShadow&&S.pushShadow(w);else if(w.isSprite){if(!w.frustumCulled||w.intersectsFrustum(Bt)){Z&&Zt.setFromMatrixPosition(w.matrixWorld).applyMatrix4(Ot);let At=rt.update(w),Mt=w.material;Mt.visible&&y.push(w,At,Mt,Q,Zt.z,null,H)}}else if((w.isMesh||w.isLine||w.isPoints)&&(!w.frustumCulled||w.intersectsFrustum(Bt))){let At=rt.update(w),Mt=w.material;if(Z&&(w.boundingSphere!==void 0?(w.boundingSphere===null&&w.computeBoundingSphere(),Zt.copy(w.boundingSphere.center)):(At.boundingSphere===null&&At.computeBoundingSphere(),Zt.copy(At.boundingSphere.center)),Zt.applyMatrix4(w.matrixWorld).applyMatrix4(Ot)),Array.isArray(Mt)){let Rt=At.groups;for(let Dt=0,Jt=Rt.length;Dt0&&Yr(J,H,Q),bt.length>0&&Yr(bt,H,Q),At.length>0&&Yr(At,H,Q),M.buffers.depth.setTest(!0),M.buffers.depth.setMask(!0),M.buffers.color.setMask(!0),M.setPolygonOffset(!1)}function $h(w,H,Q,Z){if((Q.isScene===!0?Q.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[Z.id]===void 0){let Ct=kt.has("EXT_color_buffer_half_float")||kt.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[Z.id]=new Ve(1,1,{generateMipmaps:!0,type:Ct?wn:nn,minFilter:bi,samples:Math.max(4,P.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:te.workingColorSpace})}let bt=S.state.transmissionRenderTarget[Z.id],At=Z.viewport||W;bt.setSize(At.z*C.transmissionResolutionScale,At.w*C.transmissionResolutionScale);let Mt=C.getRenderTarget(),Rt=C.getActiveCubeFace(),Dt=C.getActiveMipmapLevel();C.setRenderTarget(bt),C.getClearColor(lt),ht=C.getClearAlpha(),ht<1&&C.setClearColor(16777215,.5),C.clear(),ie&&$t.render(Q);let Jt=C.toneMapping;C.toneMapping=bn;let Qt=Z.viewport;if(Z.viewport!==void 0&&(Z.viewport=void 0),S.setupLightsView(Z),ut===!0&&Ut.setGlobalState(C.clippingPlanes,Z),Yr(w,Q,Z),nt.updateMultisampleRenderTarget(bt),nt.updateRenderTargetMipmap(bt),kt.has("WEBGL_multisampled_render_to_texture")===!1){let Ct=!1;for(let he=0,Ie=H.length;he0,Z.currentProgram=Qt,Z.uniformsList=null,Qt}function Jh(w){if(w.uniformsList===null){let H=w.currentProgram.getUniforms();w.uniformsList=Ds.seqWithValue(H.seq,w.uniforms)}return w.uniformsList}function Kh(w,H){let Q=j.get(w);Q.outputColorSpace=H.outputColorSpace,Q.batching=H.batching,Q.batchingColor=H.batchingColor,Q.instancing=H.instancing,Q.instancingColor=H.instancingColor,Q.instancingMorph=H.instancingMorph,Q.skinning=H.skinning,Q.morphTargets=H.morphTargets,Q.morphNormals=H.morphNormals,Q.morphColors=H.morphColors,Q.morphTargetsCount=H.morphTargetsCount,Q.numClippingPlanes=H.numClippingPlanes,Q.numIntersection=H.numClipIntersection,Q.vertexAlphas=H.vertexAlphas,Q.vertexTangents=H.vertexTangents,Q.toneMapping=H.toneMapping}function Bp(w,H){if(w.length===0)return null;if(w.length===1)return w[0].texture!==null?w[0]:null;v.setFromMatrixPosition(H.matrixWorld);for(let Q=0,Z=w.length;Q0),Ct=!!Q.morphAttributes.position,he=!!Q.morphAttributes.normal,Ie=!!Q.morphAttributes.color,be=bn;Z.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(be=C.toneMapping);let me=Q.morphAttributes.position||Q.morphAttributes.normal||Q.morphAttributes.color,$e=me!==void 0?me.length:0,Et=j.get(Z),tn=S.state.lights;if(ut===!0&&(Lt===!0||w!==z)){let ve=w===z&&Z.id===N;Ut.setState(Z,w,ve)}let oe=!1;Z.version===Et.__version?(Et.needsLights&&Et.lightsStateVersion!==tn.state.version||Et.outputColorSpace!==Mt||J.isBatchedMesh&&Et.batching===!1||!J.isBatchedMesh&&Et.batching===!0||J.isBatchedMesh&&Et.batchingColor===!0&&J._colorsTexture===null||J.isBatchedMesh&&Et.batchingColor===!1&&J._colorsTexture!==null||J.isInstancedMesh&&Et.instancing===!1||!J.isInstancedMesh&&Et.instancing===!0||J.isSkinnedMesh&&Et.skinning===!1||!J.isSkinnedMesh&&Et.skinning===!0||J.isInstancedMesh&&Et.instancingColor===!0&&J.instanceColor===null||J.isInstancedMesh&&Et.instancingColor===!1&&J.instanceColor!==null||J.isInstancedMesh&&Et.instancingMorph===!0&&J.morphTexture===null||J.isInstancedMesh&&Et.instancingMorph===!1&&J.morphTexture!==null||Et.envMap!==Dt||Z.fog===!0&&Et.fog!==bt||Et.numClippingPlanes!==void 0&&(Et.numClippingPlanes!==Ut.numPlanes||Et.numIntersection!==Ut.numIntersection)||Et.vertexAlphas!==Jt||Et.vertexTangents!==Qt||Et.morphTargets!==Ct||Et.morphNormals!==he||Et.morphColors!==Ie||Et.toneMapping!==be||Et.morphTargetsCount!==$e||!!Et.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(oe=!0):(oe=!0,Et.__version=Z.version);let hn=Et.currentProgram;oe===!0&&(hn=$r(Z,H,J),U&&Z.isNodeMaterial&&U.onUpdateProgram(Z,hn,Et));let Cn=!1,ai=!1,Yi=!1,pe=hn.getUniforms(),Ce=Et.uniforms;if(M.useProgram(hn.program)&&(Cn=!0,ai=!0,Yi=!0),Z.id!==N&&(N=Z.id,ai=!0),Et.needsLights){let ve=Bp(S.state.lightProbeGridArray,J);Et.lightProbeGrid!==ve&&(Et.lightProbeGrid=ve,ai=!0)}if(Cn||z!==w){M.buffers.depth.getReversed()&&w.reversedDepth!==!0&&(w._reversedDepth=!0,w.updateProjectionMatrix()),pe.setValue(R,"projectionMatrix",w.projectionMatrix),pe.setValue(R,"viewMatrix",w.matrixWorldInverse);let ci=pe.map.cameraPosition;ci!==void 0&&ci.setValue(R,zt.setFromMatrixPosition(w.matrixWorld)),P.logarithmicDepthBuffer&&pe.setValue(R,"logDepthBufFC",2/(Math.log(w.far+1)/Math.LN2)),(Z.isMeshPhongMaterial||Z.isMeshToonMaterial||Z.isMeshLambertMaterial||Z.isMeshBasicMaterial||Z.isMeshStandardMaterial||Z.isShaderMaterial)&&pe.setValue(R,"isOrthographic",w.isOrthographicCamera===!0),z!==w&&(z=w,ai=!0,Yi=!0)}if(Et.needsLights&&(tn.state.sunShadowMap.length>0&&pe.setValue(R,"sunShadowMap",tn.state.sunShadowMap,nt),tn.state.directionalShadowMap.length>0&&pe.setValue(R,"directionalShadowMap",tn.state.directionalShadowMap,nt),tn.state.spotShadowMap.length>0&&pe.setValue(R,"spotShadowMap",tn.state.spotShadowMap,nt),tn.state.pointShadowMap.length>0&&pe.setValue(R,"pointShadowMap",tn.state.pointShadowMap,nt)),J.isSkinnedMesh){pe.setOptional(R,J,"bindMatrix"),pe.setOptional(R,J,"bindMatrixInverse");let ve=J.skeleton;ve&&(ve.boneTexture===null&&ve.computeBoneTexture(),pe.setValue(R,"boneTexture",ve.boneTexture,nt))}J.isBatchedMesh&&(pe.setOptional(R,J,"batchingTexture"),pe.setValue(R,"batchingTexture",J._matricesTexture,nt),pe.setOptional(R,J,"batchingIdTexture"),pe.setValue(R,"batchingIdTexture",J._indirectTexture,nt),pe.setOptional(R,J,"batchingColorTexture"),J._colorsTexture!==null&&pe.setValue(R,"batchingColorTexture",J._colorsTexture,nt));let li=Q.morphAttributes;if((li.position!==void 0||li.normal!==void 0||li.color!==void 0)&&V.update(J,Q,hn),(ai||Et.receiveShadow!==J.receiveShadow)&&(Et.receiveShadow=J.receiveShadow,pe.setValue(R,"receiveShadow",J.receiveShadow)),(Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial)&&Z.envMap===null&&H.environment!==null&&(Ce.envMapIntensity.value=H.environmentIntensity),Ce.dfgLUT!==void 0&&(Ce.dfgLUT.value=Av()),ai){if(pe.setValue(R,"toneMappingExposure",C.toneMappingExposure),Et.needsLights&&zp(Ce,Yi),bt&&Z.fog===!0&&Nt.refreshFogUniforms(Ce,bt),Nt.refreshMaterialUniforms(Ce,Z,tt,Y,S.state.transmissionRenderTarget[w.id]),Et.needsLights&&Et.lightProbeGrid){let ve=Et.lightProbeGrid;Ce.probesSH.value=ve.texture,Ce.probesMin.value.copy(ve.boundingBox.min),Ce.probesMax.value.copy(ve.boundingBox.max),Ce.probesResolution.value.copy(ve.resolution)}Ds.upload(R,Jh(Et),Ce,nt)}if(Z.isShaderMaterial&&Z.uniformsNeedUpdate===!0&&(Ds.upload(R,Jh(Et),Ce,nt),Z.uniformsNeedUpdate=!1),Z.isSpriteMaterial&&pe.setValue(R,"center",J.center),pe.setValue(R,"modelViewMatrix",J.modelViewMatrix),pe.setValue(R,"normalMatrix",J.normalMatrix),pe.setValue(R,"modelMatrix",J.matrixWorld),Z.uniformsGroups!==void 0){let ve=Z.uniformsGroups;for(let ci=0,$i=ve.length;ci<$i;ci++){let Qh=ve[ci];ct.update(Qh,hn),ct.bind(Qh,hn)}}return hn}function zp(w,H){w.ambientLightColor.needsUpdate=H,w.lightProbe.needsUpdate=H,w.sunLights.needsUpdate=H,w.sunLightShadows.needsUpdate=H,w.directionalLights.needsUpdate=H,w.directionalLightShadows.needsUpdate=H,w.pointLights.needsUpdate=H,w.pointLightShadows.needsUpdate=H,w.spotLights.needsUpdate=H,w.spotLightShadows.needsUpdate=H,w.rectAreaLights.needsUpdate=H,w.hemisphereLights.needsUpdate=H}function kp(w){return w.isMeshLambertMaterial||w.isMeshToonMaterial||w.isMeshPhongMaterial||w.isMeshStandardMaterial||w.isShadowMaterial||w.isShaderMaterial&&w.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return q},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(w,H,Q){let Z=j.get(w);Z.__autoAllocateDepthBuffer=w.resolveDepthBuffer===!1,Z.__autoAllocateDepthBuffer===!1&&(Z.__useRenderToTexture=!1),j.get(w.texture).__webglTexture=H,j.get(w.depthTexture).__webglTexture=Z.__autoAllocateDepthBuffer?void 0:Q,Z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(w,H){let Q=j.get(w);Q.__webglFramebuffer=H,Q.__useDefaultFramebuffer=H===void 0},this.setRenderTarget=function(w,H=0,Q=0){O=w,G=H,q=Q;let Z=null,J=!1,bt=!1;if(w){let Mt=j.get(w);if(Mt.__useDefaultFramebuffer!==void 0){M.bindFramebuffer(R.FRAMEBUFFER,Mt.__webglFramebuffer),W.copy(w.viewport),k.copy(w.scissor),K=w.scissorTest,M.viewport(W),M.scissor(k),M.setScissorTest(K),N=-1;return}else if(Mt.__webglFramebuffer===void 0)nt.setupRenderTarget(w);else if(Mt.__hasExternalTextures)nt.rebindTextures(w,j.get(w.texture).__webglTexture,j.get(w.depthTexture).__webglTexture);else if(w.depthBuffer){let Jt=w.depthTexture;if(Mt.__boundDepthTexture!==Jt){if(Jt!==null&&j.has(Jt)&&(w.width!==Jt.image.width||w.height!==Jt.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");nt.setupDepthRenderbuffer(w)}}let Rt=w.texture;(Rt.isData3DTexture||Rt.isDataArrayTexture||Rt.isCompressedArrayTexture)&&(bt=!0);let Dt=j.get(w).__webglFramebuffer;w.isWebGLCubeRenderTarget?(Array.isArray(Dt[H])?Z=Dt[H][Q]:Z=Dt[H],J=!0):w.samples>0&&nt.useMultisampledRTT(w)===!1?Z=j.get(w).__webglMultisampledFramebuffer:Array.isArray(Dt)?Z=Dt[Q]:Z=Dt,W.copy(w.viewport),k.copy(w.scissor),K=w.scissorTest}else W.copy(ot).multiplyScalar(tt).floor(),k.copy(Tt).multiplyScalar(tt).floor(),K=jt;if(Q!==0&&(Z=F),M.bindFramebuffer(R.FRAMEBUFFER,Z)&&M.drawBuffers(w,Z),M.viewport(W),M.scissor(k),M.setScissorTest(K),J){let Mt=j.get(w.texture);R.framebufferTexture2D(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,R.TEXTURE_CUBE_MAP_POSITIVE_X+H,Mt.__webglTexture,Q)}else if(bt){let Mt=H;for(let Rt=0;Rt1&&R.readBuffer(R.COLOR_ATTACHMENT0+Mt);let Ct=jh(Dt);if(Ct.__formatReadable===!1){Wt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Ct.__typeReadable===!1){Wt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}H>=0&&H<=w.width-Z&&Q>=0&&Q<=w.height-J&&R.readPixels(H,Q,Z,J,xt.convert(Jt),xt.convert(Qt),bt)}finally{let Dt=O!==null?j.get(O).__webglFramebuffer:null;M.bindFramebuffer(R.FRAMEBUFFER,Dt)}}},this.readRenderTargetPixelsAsync=async function(w,H,Q,Z,J,bt,At,Mt=0){if(!(w&&w.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Rt=j.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&At!==void 0&&(Rt=Rt[At]),Rt)if(H>=0&&H<=w.width-Z&&Q>=0&&Q<=w.height-J){M.bindFramebuffer(R.FRAMEBUFFER,Rt);let Dt=w.textures[Mt],Jt=Dt.format,Qt=Dt.type;w.textures.length>1&&R.readBuffer(R.COLOR_ATTACHMENT0+Mt);let Ct=jh(Dt);if(Ct.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Ct.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let he=R.createBuffer();R.bindBuffer(R.PIXEL_PACK_BUFFER,he),R.bufferData(R.PIXEL_PACK_BUFFER,bt.byteLength,R.STREAM_READ),R.readPixels(H,Q,Z,J,xt.convert(Jt),xt.convert(Qt),0),R.bindBuffer(R.PIXEL_PACK_BUFFER,null);let Ie=O!==null?j.get(O).__webglFramebuffer:null;M.bindFramebuffer(R.FRAMEBUFFER,Ie);let be=R.fenceSync(R.SYNC_GPU_COMMANDS_COMPLETE,0);return R.flush(),await gd(R,be,4),R.bindBuffer(R.PIXEL_PACK_BUFFER,he),R.getBufferSubData(R.PIXEL_PACK_BUFFER,0,bt),R.bindBuffer(R.PIXEL_PACK_BUFFER,null),R.deleteBuffer(he),R.deleteSync(be),bt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(w,H=null,Q=0){let Z=Math.pow(2,-Q),J=Math.floor(w.image.width*Z),bt=Math.floor(w.image.height*Z),At=H!==null?H.x:0,Mt=H!==null?H.y:0;nt.setTexture2D(w,0),R.copyTexSubImage2D(R.TEXTURE_2D,Q,0,0,At,Mt,J,bt),M.unbindTexture()},this.copyTextureToTexture=function(w,H,Q=null,Z=null,J=0,bt=0){let At,Mt,Rt,Dt,Jt,Qt,Ct,he,Ie,be=w.isCompressedTexture?w.mipmaps[bt]:w.image;if(Q!==null)At=Q.max.x-Q.min.x,Mt=Q.max.y-Q.min.y,Rt=Q.isBox3?Q.max.z-Q.min.z:1,Dt=Q.min.x,Jt=Q.min.y,Qt=Q.isBox3?Q.min.z:0;else{let Ce=Math.pow(2,-J);At=Math.floor(be.width*Ce),Mt=Math.floor(be.height*Ce),w.isDataArrayTexture?Rt=be.depth:w.isData3DTexture?Rt=Math.floor(be.depth*Ce):Rt=1,Dt=0,Jt=0,Qt=0}Z!==null?(Ct=Z.x,he=Z.y,Ie=Z.z):(Ct=0,he=0,Ie=0);let me=xt.convert(H.format),$e=xt.convert(H.type),Et;H.isData3DTexture?(nt.setTexture3D(H,0),Et=R.TEXTURE_3D):H.isDataArrayTexture||H.isCompressedArrayTexture?(nt.setTexture2DArray(H,0),Et=R.TEXTURE_2D_ARRAY):(nt.setTexture2D(H,0),Et=R.TEXTURE_2D),M.activeTexture(R.TEXTURE0),M.pixelStorei(R.UNPACK_FLIP_Y_WEBGL,H.flipY),M.pixelStorei(R.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),M.pixelStorei(R.UNPACK_ALIGNMENT,H.unpackAlignment);let tn=M.getParameter(R.UNPACK_ROW_LENGTH),oe=M.getParameter(R.UNPACK_IMAGE_HEIGHT),hn=M.getParameter(R.UNPACK_SKIP_PIXELS),Cn=M.getParameter(R.UNPACK_SKIP_ROWS),ai=M.getParameter(R.UNPACK_SKIP_IMAGES);M.pixelStorei(R.UNPACK_ROW_LENGTH,be.width),M.pixelStorei(R.UNPACK_IMAGE_HEIGHT,be.height),M.pixelStorei(R.UNPACK_SKIP_PIXELS,Dt),M.pixelStorei(R.UNPACK_SKIP_ROWS,Jt),M.pixelStorei(R.UNPACK_SKIP_IMAGES,Qt);let Yi=w.isDataArrayTexture||w.isData3DTexture,pe=H.isDataArrayTexture||H.isData3DTexture;if(w.isDepthTexture){let Ce=j.get(w),li=j.get(H),ve=j.get(Ce.__renderTarget),ci=j.get(li.__renderTarget);M.bindFramebuffer(R.READ_FRAMEBUFFER,ve.__webglFramebuffer),M.bindFramebuffer(R.DRAW_FRAMEBUFFER,ci.__webglFramebuffer);for(let $i=0;$i=c.length){s-=c.length;continue}let h=Math.min(o,c.length-s);if(a.push(c.substringData(s,h)),o-=h,s=0,!o)break}let l=new Uint8Array(Math.ceil((r+e)/3)*3);if(ah(l,0,a.join(""))i!==null&&typeof i=="object"&&!Array.isArray(i),si=i=>Array.isArray(i)&&i.every(Wi),Ti=i=>Array.isArray(i)&&i.length===3&&i.every(t=>typeof t=="number"),ef=i=>Wi(i)&&Ti(i.min)&&Ti(i.max),jd=i=>i==null||Wi(i)&&si(i.planes)&&i.planes.every(t=>Ti(t.normal)&&t.normal.every(Number.isFinite)&&t.normal.some(e=>e!==0)&&Number.isFinite(t.offset))&&(i.box==null||ef(i.box)&&i.box.max.every(Number.isFinite)&&i.box.min.every((t,e)=>Number.isFinite(t)&&t<=i.box.max[e]));function Iv(i){if(!Wi(i)||!si(i.elements)||!si(i.geometries)||!si(i.materials)||!Wi(i.instances))throw new se("META must describe elements, geometries, materials and instances.");if(i.title!=null&&typeof i.title!="string")throw new se("Invalid META title.");let{instances:t}=i;if(!Number.isSafeInteger(t.count)||t.count<0)throw new se("Invalid META instance count.");for(let[e,n,s]of[["geometry","u32",t.count],["material","u32",t.count],["element","i32",t.count],["matrix","f32",t.count*12]])if(t[e]?.t!==n||t[e].n!==s)throw new se(`Invalid META instance ${e} view.`);for(let e of i.geometries){let n=e.q;if(!ef(e.bbox)||!["u16","u32"].includes(e.indices?.t)||e.positions?.t!==(n?"u16":"f32")||n&&(!Ti(n.o)||typeof n.s!="number")||e.normals!=null&&!["f32","i16"].includes(e.normals.t)||e.uvs!=null&&e.uvs.t!=="f32"||e.kind!=null&&e.kind!=="points"||e.colors!=null&&(e.kind!=="points"||e.colors.t!=="u8"||e.colors.n!==e.positions.n))throw new se("Invalid META geometry.")}if(i.points!=null){let e=i.points;if(!Wi(e)||!Number.isSafeInteger(e.count)||e.count<0)throw new se("Invalid META point count.");for(let[n,s,r]of[["geometry","u32",e.count],["material","u32",e.count],["element","i32",e.count],["matrix","f32",e.count*12]])if(e[n]?.t!==s||e[n].n!==r)throw new se(`Invalid META point ${n} view.`)}if(i.panoramas!=null&&(!si(i.panoramas)||i.panoramas.some(e=>!Number.isInteger(e.element)||e.element<0||e.element>=i.elements.length||e.name!=null&&typeof e.name!="string"||!Ti(e.position)||!e.position.every(Number.isFinite)||!Number.isFinite(e.yaw)||e.image?.t!=="u8"||!Number.isSafeInteger(e.image.n)||e.image.n<4||e.image.n>16*1024*1024)))throw new se("Invalid META panorama.");Pv(i);for(let e of i.materials){let n=e.texture;if(!Ti(e.color)||typeof e.opacity!="number"||n!=null&&(!Number.isInteger(n)||n<0||n>=(i.textures?.length??0)))throw new se("Invalid META material.")}}function Pv(i){if(!Wi(i)||!si(i.elements)||i.title!=null&&typeof i.title!="string")throw new se("Invalid review metadata.");for(let l of["textures","grids","viewpoints","bcfTopics","clashTests","linkedFiles","models"])if(i[l]!=null&&!si(i[l]))throw new se(`Invalid META ${l} list.`);if(i.models?.some(({id:l,name:c})=>!Number.isSafeInteger(l)||typeof c!="string")||i.elements.some(({modelId:l,levelId:c})=>l!=null&&!Number.isSafeInteger(l)||c!=null&&!Number.isSafeInteger(c)))throw new se("Invalid META model or level identity.");let t=l=>l==null||Array.isArray(l)&&l.every(c=>Number.isInteger(c)&&c>=0&&cTi(l)&&l.every(Number.isFinite),n=l=>l==null||typeof l=="string",s=l=>e(l.camera?.position)&&e(l.camera?.target)&&jd(l.sections)&&t(l.hiddenElements)&&t(l.visibleElements)&&t(l.selectedElements)&&(l.hiddenElements==null||l.visibleElements==null)&&(l.hiddenModelKeys==null||Array.isArray(l.hiddenModelKeys)&&l.hiddenModelKeys.every(c=>typeof c=="string")),r=l=>Number.isSafeInteger(l)&&l>=0,o=l=>s(l)&&e(l.camera.up)&&l.camera.up.some(c=>c!==0)&&(l.camera.projection==="orthographic"?Number.isFinite(l.camera.orthographicHeight)&&l.camera.orthographicHeight>0:l.camera.projection==="perspective"&&Number.isFinite(l.camera.fov)&&l.camera.fov>0&&l.camera.fov<180)&&r(l.missingComponents)&&r(l.ambiguousComponents),a=l=>{let c=Ir(l);return Array.isArray(c)&&c.length>=2&&c.every(e)};if(i.grids?.some(l=>!a(l))||i.viewpoints?.some(l=>!s(l))||i.clashTests?.some(l=>!si(l.clashes)||l.clashes.some(c=>!Ti(c.point))))throw new se("Invalid META grids, viewpoints or clashes.");if(i.bcfTopics?.some(l=>typeof l.title!="string"||!n(l.description)||!n(l.status)||!si(l.viewpoints)||l.viewpoints.some(c=>!o(c))))throw new se("Invalid META BCF topics.");if(i.linkedFiles?.some(l=>!t(l.members)))throw new se("Invalid META linked file members.");if(!jd(i.sections))throw new se("Invalid META sections.")}function Lv(i){let t;try{t=JSON.parse(i)}catch(e){throw new se(e.message,{cause:e})}return Iv(t),t}function lh(i=document,t){t?.("metadataStart");let e;try{e=tf(i,"ioviewer-meta")}catch(s){throw s instanceof se?s:new se(s.message,{cause:s})}let n=Lv(e);return t?.("metadataEnd"),n}function Qd(i,t){let e=Rv[i?.t];if(!e)throw new se(`Unknown view type '${i?.t}'.`);let n=e.BYTES_PER_ELEMENT;if(!(Number.isSafeInteger(i.o)&&Number.isSafeInteger(i.n)&&i.o>=0&&i.n>=0&&i.o%n===0&&i.o+i.n*n<=t))throw new se(`View ${JSON.stringify(i)} is outside the ${t} bytes of binary data.`);return e}function nf(i=document,t,e=lh(i,t)){let n,s,r,o;try{if(t?.("binaryStart"),s=i.getElementById("ioviewer-bin"),!s)throw new Error("Data block 'ioviewer-bin' is missing.");({bytes:n,canonical:r}=Kd(s)),t?.("binaryEnd")}catch(c){throw new se(c.message,{cause:c})}let a=n.length,l=null;return{meta:e,view(c){if(!n)throw new Error("The binary data has been released.");let h=Qd(c,a);return new h(n.buffer,c.o,c.n)},readView(c){let h=Qd(c,a);if(!c.n)return new h(0);!n&&!r&&(o??(o=Kd(s).bytes));let d=n??o;return d?new h(d.buffer,c.o,c.n):new h(Cv(s,c.o,c.n*h.BYTES_PER_ELEMENT))},releaseBinary(){n=null,o=null},props(c){return l??(l=JSON.parse(tf(i,"ioviewer-props"))),l[c]??null}}}var sf=new Yt,rf=new Fn,ch=32;function hh(i,t=new Float64Array(24)){return sf.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),rf.setFromProjectionMatrix(sf,i.coordinateSystem,i.reversedDepth),rf.planes.forEach(({normal:e,constant:n},s)=>t.set([e.x,e.y,e.z,n],s*4)),t}function uh(i,t,e,n,s){for(let r=0;r<24;r+=4)if(i[r]*t+i[r+1]*e+i[r+2]*n+i[r+3]<-s)return!0;return!1}function of(i,t,e,n,s){for(let r=0;r<24;r+=4)if(i[r]*t+i[r+1]*e+i[r+2]*n+i[r+3]=0;r--)if(i[r]!==0){if(n+=i[r],n>e)return s?r===0?0:2**(r/2-4):2**((r+1)/2-4);s=!1}return 0}var En=.0009765625,fh=32767,Pr=i=>i<0?-1:1;function lf(i){let t=Math.min(Math.max(i,-1),1)*fh;return Pr(t)*Math.round(Math.abs(t))}function Lr(i,t,e,n,s){let r=Math.abs(e)+Math.abs(n)+Math.abs(s);if(!(r>0)){i[t]=i[t+1]=0;return}let o=e/r,a=n/r;s<0&&([o,a]=[(1-Math.abs(a))*Pr(o),(1-Math.abs(o))*Pr(a)]),i[t]=lf(o),i[t+1]=lf(a)}function cf(i,t,e,n){let s=Math.max(e/fh,-1),r=Math.max(n/fh,-1),o=1-Math.abs(s)-Math.abs(r);o<0&&([s,r]=[(1-Math.abs(r))*Pr(s),(1-Math.abs(s))*Pr(r)]);let a=Math.sqrt(s*s+r*r+o*o);i[t]=s/a,i[t+1]=r/a,i[t+2]=o/a}function Dr(i,t){let e=i.view(t.positions);if(!t.q){if(!(e instanceof Float32Array))throw new Error(`Geometry positions of type '${t.positions.t}' need a "q" origin and step.`);return e}if(!(e instanceof Uint16Array))throw new Error(`Quantized geometry positions must be u16, got '${t.positions.t}'.`);return e}function Qa(i,t){let e=Dr(i,t);if(!t.q)return e;let[n,s,r]=t.q.o,o=t.q.s,a=new Float32Array(e.length);for(let l=0;ls[d]&&(s[d]=u))}let r=0;for(let h=1;h<3;h++)s[h]-n[h]>s[r]-n[r]&&(r=h);let o=s[r]-n[r],a=2**20-1,l=new Float64Array(i.length);for(let h=0;h0&&Number.isFinite(u)?Math.round((u-n[r])/o*a):0;l[h]=f*2**32+d}let c=0;e<0?l.sort():c=Nv(l,e);for(let h=0;hr)return i.subarray(e,n+1).sort(),a+l*Math.ceil(Math.log2(l));a+=l,s=Math.imul(s,1664525)+1013904223>>>0;let c=i[e+s%(n-e+1)],h=e,d=n;for(;h<=d;){for(;i[h]c;)d--;if(h<=d){let u=i[h];i[h++]=i[d],i[d--]=u}}if(t<=d)n=d;else if(t>=h)e=h;else return a}return a}function gf(i,t,e,n=1/0){let s=[];s.scanned=0;let r=[Uint32Array.from(t)];for(;r.length;){let o=r.pop(),a=Math.ceil(o.length/e);if(o.length<=1||a<=1&&Uv(o,i)<=n){o.length&&s.push(o);continue}let l=a>1?Math.ceil(o.length*Math.floor(a/2)/a):Math.ceil(o.length/2);s.scanned+=mf(o,i,l),r.push(o.subarray(l),o.subarray(0,l))}return s}function Uv(i,t){let e=1/0,n=1/0,s=1/0,r=-1/0,o=-1/0,a=-1/0;for(let l of i){let c=t[l*3],h=t[l*3+1],d=t[l*3+2];cr&&(r=c),ho&&(o=h),da&&(a=d)}return Math.hypot(r-e,o-n,a-s)/2}function _f(i,t){let e=new Float64Array(6).fill(-1/0),n=new Float64Array(6).fill(-1/0),s=new Int32Array(6);for(let o=0;oe[a]?(n[a]=e[a],e[a]=c,s[a]=o):c>n[a]&&(n[a]=c)}if(e[0]===-1/0)return 0;let r=Math.hypot(e[0]+e[3],e[1]+e[4],e[2]+e[5]);if(n[0]===-1/0)return r;for(let o of s){let a=c=>s[c]===o?n[c]:e[c],l=Math.hypot(a(0)+a(3),a(1)+a(4),a(2)+a(5));r=Math.min(r,2*l)}return r}var mh=384*2**20;function xf(i,{cap:t=mh,minRepeats:e=16,perCell:n=1024,maxDraws:s=1024}={}){let r=new Uint8Array(i.length),o=0;for(let h of i)o+=h.k*h.bytes;if(o<=t)return r;let a=h=>(i[h].k-1)*i[h].bytes,l=[...i.keys()].filter(h=>i[h].k>=e);l.sort((h,d)=>a(d)-a(h)||i[d].k-i[h].k||h-d);let c=0;for(let h of l){let d=i[h].cells??Math.ceil(i[h].k/n);c+d>s||(r[h]=1,c+=d)}return r}function tl(i,t){return i>65535?new Uint32Array(t):new Uint16Array(t)}function gh(i,t){return i.sort((e,n)=>t[n]-t[e]||e-n)}function vf(i,t,e,n){for(;t>>1;i[s]>=n?t=s+1:e=s}return t}function yf(i,t,e){let n=i[t];return[n,e>t?i[e]-n:0]}function Mf(i,t,e,n){let s=i.subarray(t*12,t*12+12);if(s[0]===1&&s[1]===0&&s[2]===0&&s[3]===0&&s[4]===1&&s[5]===0&&s[6]===0&&s[7]===0&&s[8]===1&&e.q&&e.q.s===En){for(let a=0;a<3;a++)n[a]=s[9+a]+e.q.o[a];return df}let o=!0;for(let a=0;a<3;a++){let l=s[9+a],c=s[9+a];for(let h=0;h<3;h++){let d=s[h*3+a]*e.min[h],u=s[h*3+a]*e.max[h];l+=Math.min(d,u),c+=Math.max(d,u)}n[a]=Math.floor(l/En)*En,Math.ceil((c-n[a])/En)<=ff||(o=!1)}return o||n.fill(0),o?Dv:Fs}function bf(i,t){let e=i.length,n=0,s=0;for(let m of i){let p=t.source(t.geometryOf[m]);n+=p.vertices,s+=p.indices.length}let r=t.kind[i[0]]===Fs,o=r?new Float32Array(n*4):new Uint16Array(n*4),a=new Int16Array(n*2),l=t.textured?new Float32Array(n*2):null,c=tl(n,s),h=new Uint32Array(e+1),d=new Float32Array(e*3),u=new Float32Array(e),f=new Float64Array(3),g=0,_=0;for(let m=0;mMath.min(Math.max(Math.round(i/En),0),ff);function Sf(i,t,e,n,s){let r=i.length/3,o=[1/0,1/0,1/0],a=[-1/0,-1/0,-1/0];for(let c=0;ca[h]&&(a[h]=d)}let l=e instanceof Int16Array?e:null;return{positions:i,q:t,oct:l,normals:l?null:e,indices:n,uvs:s,vertices:r,min:o,max:a}}function el(i){if(!i.normals&&i.oct){i.normals=new Float32Array(i.vertices*3);for(let t=0;t= 0.0 ? - t : t, n.y >= 0.0 ? - t : t ); return n; -}`,Ir=` +}`,Ur=` int slot = int( slotBase ) + int( q.w ); ivec2 st = ivec2( slot & 2047, slot >> 11 ); vec4 info = texelFetch( slotInfo, st, 0 ); vec4 state = texelFetch( slotState, st, 0 ); -vec3 slotPosition = info.xyz + q.xyz * info.w;`,mh=` +vec3 slotPosition = info.xyz + q.xyz * info.w;`,_h=` #ifndef IO_NO_HIDE_BRANCH if ( state.a < 0.5 ) gl_Position = vec4( 0.0, 0.0, 2.0, 1.0 ); -#endif`,Fv=` +#endif`,zv=` vec3 transformedNormal = objectNormal; #ifdef USE_INSTANCING mat3 im = mat3( instanceMatrix ); @@ -4248,13 +4248,13 @@ transformedNormal = mat3( cross( im[ 1 ], im[ 2 ] ), cross( im[ 2 ], im[ 0 ] ), transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; -#endif`;function Ei(i,t,e){let n=i.indexOf(t);if(n<0||i.indexOf(t,n+1)>=0)throw new Error(`The shader must contain '${t}' exactly once.`);return i.slice(0,n)+e+i.slice(n+t.length)}function Bv(i){Object.assign(i.uniforms,this.userData.slotUniforms);let t=Ei(i.vertexShader,"#include ",`#include -${Cr}`);t=Ei(t,"#include ",`${Ir} -vTint = state.rgb;`),t=Ei(t,"#include ","vec3 objectNormal = ioOct( normal.xy );"),t=Ei(t,"#include ",Fv),t=Ei(t,"#include ","vec3 transformed = slotPosition;"),t=Ei(t,"#include ",`#include -${mh}`),i.vertexShader=t;let e=Ei(i.fragmentShader,"#include ",`#include -varying vec3 vTint;`);e=Ei(e,"#include ","diffuseColor.rgb *= vTint;"),i.fragmentShader=e}function gh(i,t,e=!1){return i.userData.slotUniforms=t,i.onBeforeCompile=Bv,i.index0AttributeName="q",e&&(i.defines={IO_NO_HIDE_BRANCH:""}),i}var yh=["materials","textures","white","wireframe"],Ov=[245,158,11],zv=[235,235,237],Pr=4294967295,Wi=2048,_h=256,kv=16,xh=1024,Hv=.1,Vv=8192,Gv=1.4,tl=2**-20,Qa=17;function Wv(i,t){let[e,n,s,r,o,a,l,c,h]=i.subarray(t*12,t*12+9);return e*(o*h-a*c)-r*(n*h-s*c)+l*(n*a-s*o)<0}function Xv(){this.array=null}function En(i,t,e=!1,n=Ae){return new n(i,t,e).onUpload(Xv)}var Lr=class extends RangeError{constructor(t,e){super(`${t} drawable instances exceed the limit of ${e}.`),this.name="ModelTooLargeError",this.count=t,this.limit=e}},bf=(i,t)=>{for(let e=t*6;e=0?3:0)]+o*t[e+(o>=0?4:1)]+a*t[e+(a>=0?5:2)]+l<-(n+tl*Math.abs(l)))return!0}return!1}function Sf(i,t,{min:e,max:n},s){let r=t*12,o=t*6;if(e[0]>n[0]||e[1]>n[1]||e[2]>n[2]){s.set(e,o),s.set(n,o+3);return}for(let a=0;a<3;a++){let l=i[r+a],c=i[r+a+3],h=i[r+a+6],d=i[r+a+9],u=l*e[0],f=l*n[0],g=c*e[1],_=c*n[1],m=h*e[2],p=h*n[2];s[o+a]=Math.min(u,f)+Math.min(g,_)+Math.min(m,p)+d,s[o+a+3]=Math.max(u,f)+Math.max(g,_)+Math.max(m,p)+d}}var Yv=i=>{let t=i.getHex(Te);return[t>>16&255,t>>8&255,t&255]},Dr=class{constructor(t,e={}){let{meta:n}=t,s=n.instances,r=s.count,o=t.view(s.geometry),a=t.view(s.material),l=t.view(s.matrix),c=n.points,h=c?.count??0,d=r+h;this.root=new Re,this.elementCount=n.elements.length,this._elements=n.elements,this._meta=n,this._mode="materials",this._opacity=1,this._picking=!1,this._pickBounds=!0,this._instanceDetail=!0,this._pickFrustum=null,this._textures=new Map,this._elementOf=new Int32Array(d),this._elementOf.set(t.view(s.element)),this._bucketOf=new Uint32Array(r),this._visible=new Uint8Array(d).fill(1),this._layers=new Map,this._layerHides=new Uint8Array(d),this._highlight=new Uint8Array(d),this._highlighted=[],this._tint=new Map,this._boxes=new Float32Array(d*6),this._minPixels=0,this._viewHeight=1,this.visibleCost=0;let u=!!e.noHideBranch;if(this.slotUniforms={slotInfo:{value:null},slotState:{value:null}},this._buckets=this._createBuckets(n,a,u),h){this._elementOf.set(t.view(c.element),r),this._pointMaterials=t.view(c.material).slice();let g=t.view(c.geometry),_=t.view(c.matrix),m=this._boxes.subarray(r*6);for(let p=0;pthis._shown(e)?1:0)}instancesOf(t){return this._checkElement(t),this._elementInstances.subarray(this._elementStart[t],this._elementStart[t+1])}isVisible(t){this._checkElement(t);for(let e=this._elementStart[t];ethis._chunkCount){this._pickFrustum=lh(n,this._planes);let{x:r,y:o,z:a}=n.position;this._pickViewPadding=tl*(Math.abs(r)+Math.abs(o)+Math.abs(a))}for(let r of this._units)r.mesh.material=t,s?(r.mesh.visible=(r.mesh.visible||!!r.lines?.visible)&&r.bucket.material.opacity>0,r.lines&&(r.lines.visible=!1)):this._showUnit(r);if(!s)for(let r of this._compactCells)this._cellAttributes(r,!1);try{return e()}finally{this._picking=!1,this._pickFrustum=null;for(let r of this._units)r.mesh.material=r.bucket.material,this._showUnit(r);for(let r of this._cut)r.mesh.visible=!1,r.lines&&(r.lines.visible=!1);if(!s)for(let r of this._compactCells)this._cellAttributes(r,!0)}}elementBox(t,e=new oe){this._checkElement(t),e.makeEmpty();for(let n=this._elementStart[t];n=0&&t<=1))throw new RangeError(`Opacity must be within 0..1, got ${t}.`);this._opacity=t;for(let e of this._buckets)this._applyOpacity(e);this._changed("appearance")}get opacity(){return this._opacity}setDetail(t,e=1){this._minPixels=t,this._viewHeight=e;for(let s of this._cut)this._showUnit(s);this._cut.length=0;for(let s of this._detailCells)s.detailCount=null;this._detailCells.length=0;for(let s of this._compactCells)this._cellAttributes(s,!1);this._compactCells.length=0;let n=this._unitScale;this._unitScale=null,!(!(t>0)||!n)&&(this._cutInView=0,this._cutFrame=null,this._units.forEach((s,r)=>{if(!(!(n[r]>=0)||s.shown===0)){if(s.dirty&&this._span(s),s.cell&&this._detailUsesInstances){if(s.detailHigh>=t&&this._detailCell(s,t))return}else if(this._slotRadius[s.slotBase+s.first]*n[r]>=t)return;s.mesh.visible=!1,s.lines&&(s.lines.visible=!1),this._cut.push(s),this._cutInView+=vh(s,s.first,s.last+1)}}))}_detailCell(t,e){if(t.detailLow>=e)return t.detailCount=Math.min(t.detailEnd,t.last+1),this._detailCells.push(t),!0;let{slotBase:n,last:s}=t,r=this._detailIndices,o=0,a=!1,l=!1;for(let u=0;u<=s;u++){let f=this._pixels[n+u];f<0||(fc.count;for(let u=0;u0?o[6]/m:1/0:o[6];d[f]=p;let b=g.cell&&this._detailUsesInstances,w=b&&!sf(r,_[0],_[1],_[2],_[3]+g.pickPadding),v=g.slotBase+g.n,y=-1;if(b){let R=this._slotRadius[g.slotBase],D=this._slotRadius[v-1],F=m+_[3],U=Math.abs(o[3])*_[4]+Math.abs(o[4])*_[5]+Math.abs(o[5])*_[6],C=F-U-R,B=F+U-D,W=Math.fround(o[7]?C>0?R*o[6]/C:1/0:R*p),q=Math.fround(o[7]?B>0?D*o[6]/B:1/0:D*p);Us(q)===Us(W)&&(y=W)}if(y>=0&&!w){g.detailLow=g.detailHigh=y,g.detailEnd=g.n;let R=this._slotCost[g.slotBase]*g.shown;l[Us(y)]+=R,u+=R;continue}let S=0,A=1/0,x=-1,T=0;for(let R=g.slotBase;R=0){S++;continue}let L=(W-o[0])*o[3]+(q-o[1])*o[4]+(O-o[2])*o[5]-D;F=o[7]?L>0?o[6]/L:1/0:o[6]}let U=F===1/0?1/0:Math.fround(D*F);b&&(a[R]=U,A=Math.min(A,U),x=Math.max(x,U));let C=this._slotCost[R];l[Us(U)]+=C,u+=C}if(b){if(S){A=x=y;let R=S*this._slotCost[g.slotBase];l[Us(y)]+=R,u+=R}g.detailLow=A,g.detailHigh=x,g.detailEnd=T}}return this.visibleCost=u,rf(l,u,n)}drawStats(){let t=-1/0;for(let r of this._units)t=Math.max(t,r.lastFrame);let e=0,n=this._cutFrame===t?this._cutInView:0,s=0;for(let r of this._units)r.lastFrame===t&&(n+=vh(r,r.first,Math.max(r.last+1,r.first)),e+=vh(r,r.first,Math.max(r.end,r.first)),s++);return{drawn:e,inView:n,draws:s}}drawnInstances(t){t.updateMatrixWorld();let e=new Un().setFromProjectionMatrix(new Jt().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),n={info:{render:{frame:-1}}},s=new Ge,r=[];for(let o of this._units){let a=this._mode==="wireframe"&&!this._picking?o.lines:o.mesh;if(!(!a?.visible||!e.intersectsSphere(s.set(s.center.fromArray(o.sphere),o.sphere[3])))){a.onBeforeRender(n,null,t,a.geometry,a.material,null);for(let l=o.first;lo-a)}memory(){let t=this._units[this._chunkCount]?.slotBase??this._slotInstance.length;return{gpuBytes:this._mergedBytes+this._instancedBytes+this._lineBytes+this._stateBytes+this._detailBytes,mergedBytes:this._mergedBytes,instancedBytes:this._instancedBytes,stateBytes:this._stateBytes,lineBytes:this._lineBytes,detailBytes:this._detailBytes,detailSourceBytes:(this._slotInstance.length-t)*48,chunks:this._chunkCount,cells:this._units.length-this._chunkCount,mergedInstances:t,instancedInstances:this._slotInstance.length-t,triangles:this._triangles}}setClipping(t,e){for(let n of this._buckets)for(let s of[n.material,n.wire])s.clippingPlanes=t.length>0?t:null,s.clipIntersection=e,s.needsUpdate=!0;this._changed("clipping")}_build(t,e,n,s,r){let o=e.length,a=this._meta,l=new Map,c=O=>{let L=l.get(O);if(!L){let H=a.geometries[O],X=t.view(H.indices),z=H.uvs?t.view(H.uvs):null;L=Mf(Rr(t,H),H.q??null,lf(t,H),X,z),L.drawable=L.indices.length>=3&&L.min.every(Number.isFinite)&&L.max.every(Number.isFinite),l.set(O,L)}return L},h=new Uint8Array(o),d=new Float64Array(o*3),u=new Float32Array(o*3),f=new Uint32Array(o),g=new Float32Array(o),_=new Uint8Array(o),m=new Map,p=this._boxes;for(let O=0;OO-L).map(O=>{let L=m.get(O),H=c(e[L[0]]),X=this._buckets[this._bucketOf[L[0]]].texture!==null,z=[0,1,2].every(lt=>(H.max[lt]-H.min[lt])/wn<=65535),Q=H.vertices*((z?12:20)+(X?8:0))+H.indices.length*(H.vertices>65535?4:2);return{k:L.length,bytes:Q,members:L,textured:X}}),v=s.mergedCap??fh,y=s.minRepeats??kv;if(w.reduce((O,L)=>O+L.k*L.bytes,0)>v){let O=s.cellExtent==null?mf(p,f)*Hv:this.visibleBox().getSize(new I).length()*s.cellExtent;for(let L of w)L.k{if(S[L]){for(let H of O.leaves)T.push({shape:O,members:ph(H,g)});return}for(let H of O.members){x[e[H]]++;let X=this._bucketOf[H]*2+(h[H]===Fs?1:0),z=A.get(X);z||A.set(X,z=[]),z.push(H)}});let R=[];for(let O of[...A.keys()].sort((L,H)=>L-H))for(let L of df(u,f,A.get(O),s.chunkVertices??cf))R.push(ph(L,g));let D=[...R,...T.map(O=>O.members)].reduce((O,L)=>O+L.length,0);if(D>r)throw new Lr(D,r);let F=Math.max(1,Math.ceil(D/Wi)),U=new Float32Array(Wi*F*4);this._state=new Nn(new Uint8Array(Wi*F*4),Wi,F),this._state.colorSpace=Te,this._state.onUpdate=()=>{this._fullPending=!1,this._pendingRanges=0},this._fullPending=!0,this._pendingRanges=0,this._dirty=new Uint32Array(_h),this._dirtyCount=0;let C=new Nn(U,Wi,F,sn,Ye);C.needsUpdate=!0,C.onUpdate=()=>C.image.data=null,this.slotUniforms.slotInfo.value=C,this.slotUniforms.slotState.value=this._state,this._stateBytes=Wi*F*20,this._slotOf=new Uint32Array(this._visible.length).fill(Pr),this._slotInstance=new Uint32Array(D),this._slotUnit=new Uint32Array(D),this._slotRadius=new Float32Array(D),this._slotCost=new Float32Array(D),this._pixels=new Float32Array(D),this._planes=new Float64Array(24),this._detailView=new Float64Array(8),this._frameView=new Float64Array(8),this._frameViewAt=NaN,this._units=[],this._cut=[],this._detailCells=[],this._compactCells=[],this._detailIndices=new Uint16Array(xh),this._detailBins=new Float64Array(ah),this._detailBytes=0,this._unitScale=null,this._cutInView=0,this._cutFrame=-1,this._mergedBytes=0,this._instancedBytes=0,this._lineBytes=0;let B={matrices:n,geometryOf:e,mirrored:_,kind:h,origins:d,source:c,textured:!1};this._lineSources=new Map;let W=0;for(let O of R){let L=this._buckets[this._bucketOf[O[0]]];B.textured=L.texture!==null;let H=yf(O,B);for(let X=0;XO+L,0);let q=new Map;for(let{shape:O,members:L}of T){let H=L[0],X=c(e[H]),z=q.get(O);if(!z){let Q=a.geometries[e[H]].bbox;z=this._shape(X,_[H]===1,O.textured);let lt=ct=>Math.max(...ct.map(Math.abs)),ut=Math.max(lt(X.min),lt(X.max));z.pickExtent=ut,z.pickPadding=Math.max(0,...X.min.map((ct,G)=>Q.min[G]-ct),...X.max.map((ct,G)=>ct-Q.max[G]))+(X.q?tl*(lt(X.q.o)+65535*Math.abs(X.q.s)):0),q.set(O,z)}for(let Q=0;QO+L,0)}_shape(t,e,n){let s=t.vertices,r=t.q?new Uint16Array(s*4):new Float32Array(s*4);for(let h=0;hn+p),1,!1,ti);a.setAttribute("slotBase",l),a.setIndex(s.index);let c=Ef(this._boxes,e),h=new Ge(new I(c[0],c[1],c[2]),c[3]);a.boundingSphere=h;let d=new Ms(a,t.material,0),u=new Float32Array(o*16),f=new Float32Array(o*12),g=0;for(let m=0;mthis._range(_,m,b,d),d.visible=!1,this.root.add(d),_}_chunk(t,e,n,s,r,o){let a=new Es;a.instanceCount=1,a.setAttribute("q",En(s.q,4)),a.setAttribute("normal",En(s.o,2,!0)),s.uv&&a.setAttribute("uv",En(s.uv,2)),a.setAttribute("slotBase",En(new Float32Array([n]),1,!1,ti)),a.setIndex(En(s.index,1));let l=Ef(this._boxes,e);a.boundingSphere=new Ge(new I(l[0],l[1],l[2]),l[3]),this._mergedBytes+=s.q.byteLength+s.o.byteLength+(s.uv?.byteLength??0)+s.index.byteLength;let c=new _e(a,t.material),h={bucket:t,mesh:c,lines:null,slotBase:n,n:e.length,sphere:l,shown:0,first:0,last:-1,end:0,dirty:!1,cell:!1,starts:s.indexStart,vertices:s.q.length/4,f32:s.q instanceof Float32Array,members:e.slice(),lastFrame:-1/0};return c.onBeforeRender=(d,u,f)=>this._range(h,d,f,c),c.visible=!1,this.root.add(c),h}_buildLines(){if(!this._lineSources)return;let{mirrored:t,geometryOf:e}=this._lineMembers;for(let n of this._units){if(n.cell){let h=n.mesh.geometry.index;n.lines=new Ms(n.mesh.geometry,n.bucket.wire,0),n.lines.instanceMatrix=n.mesh.instanceMatrix,n.lines.boundingSphere=n.mesh.boundingSphere,n.lines.onBeforeRender=(d,u,f)=>this._range(n,d,f,n.lines),this._lineBytes+=h.count*2*h.array.BYTES_PER_ELEMENT,this.root.add(n.lines);continue}let s=n.starts[n.n],r=Ka(n.vertices,s*2),o=0,a=0;for(let h of n.members){let d=this._lineSources.get(e[h]),u=t[h]===1;for(let f=0;fthis._range(n,h,u,n.lines),this.root.add(n.lines),n.members=null}this._lineSources=null,this._lineMembers=null}_range(t,e,n,s){t.dirty&&this._span(t);let r=t.last+1;if(this._picking){if(t.cell&&this._pickFrustum){let o=this._state.image.data,a=t.pickPadding+this._pickViewPadding;for(;r>0;){let l=t.slotBase+r-1;if(o[l*4+3]&&!qv(this._pickFrustum,this._boxes,this._slotInstance[l]*6,a))break;r--}}}else if(t.cell&&t.detailCount!==null)r=t.detailCount;else if(this._minPixels>0&&r>t.first){let o=e.info.render.frame;o!==this._frameViewAt&&(hh(n,this._viewHeight,this._frameView),this._frameViewAt=o);let a=this._frameView,l=wf(a,t.sphere),c=a[7]?l>0?this._minPixels*l/a[6]:0:this._minPixels/a[6];r=Math.min(r,_f(this._slotRadius,t.slotBase+t.first,t.slotBase+r,c)-t.slotBase)}if(t.cell)s.count=Math.max(r,0);else{let o=s.isLineSegments?2:1,[a,l]=xf(t.starts,t.first,r);s.geometry.setDrawRange(a*o,l*o)}this._picking||(t.end=r,t.lastFrame=e.info.render.frame,this._cutFrame===null&&this._minPixels>0&&(this._cutFrame=t.lastFrame))}_span(t){let e=this._state.image.data,n=0;for(;n=n&&e[(t.slotBase+s)*4+3]===0;)s--;t.first=n0&&!e,t.lines&&(t.lines.visible=t.shown>0&&e)}_createBuckets(t,e,n){let s=new Map,r=[];for(let o=0;oMath.round(h*255)),opacity:c.opacity,texture:c.texture??null,material:gh(new Ss({side:Ne}),this.slotUniforms,n),wire:gh(new Ss({side:Ne,wireframe:!0}),this.slotUniforms,n)},this._applyOpacity(l),s.set(a,l),r.push(l)}this._bucketOf[o]=l.index}return r}_indexElements(){let t=new Uint32Array(this.elementCount+1);for(let s of this._elementOf)s>=0&&t[s+1]++;for(let s=0;s{s>=0&&(e[n[s]++]=r)}),this._elementStart=t,this._elementInstances=e}_texture(t){let e=this._textures.get(t);if(!e){let n=this._meta.textures[t],s=new Image;e=new ke(s),e.colorSpace=Te,e.wrapS=e.wrapT=ds,e.repeat.set(1/n.sx,1/n.sy),s.onload=()=>{e.needsUpdate=!0,this._changed("appearance")},s.src=`data:${n.mime};base64,${n.data}`,this._textures.set(t,e)}return e}_applyOpacity(t){let e=t.opacity*this._opacity,n=e<1;for(let s of[t.material,t.wire])s.transparent!==n&&(s.needsUpdate=!0),s.opacity=e,s.transparent=n,s.depthWrite=!n}_colorOf(t){if(t>=this._bucketOf.length){let e=this._pointMaterials[t-this._bucketOf.length];return this._meta.materials[e].color.map(n=>Math.round(n*255))}return this._highlight[t]?Ov:this._tint.get(t)??(this._mode==="white"?zv:this._buckets[this._bucketOf[t]].bytes)}_applyColor(t){let e=this._slotOf[t];e!==Pr&&(this._state.image.data.set(this._colorOf(t),e*4),this._markDirty(e))}_setInstanceVisible(t,e){this._visible[t]=e?1:0,this._draw(t)}_setLayerFlag(t,e,n){t[e]!==(n?1:0)&&(t[e]=n?1:0,this._layerHides[e]+=n?1:-1,this._draw(e))}_shown(t){return this._visible[t]===1&&this._layerHides[t]===0}_draw(t){let e=this._slotOf[t];if(e===Pr)return;let n=this._shown(t)?255:0,s=this._state.image.data;if(s[e*4+3]===n)return;s[e*4+3]=n,this._markDirty(e);let r=this._units[this._slotUnit[e]];r.shown+=n?1:-1,r.dirty=!0,this._showUnit(r)}_markDirty(t){this._dirtyCount<_h&&(this._dirty[this._dirtyCount]=t),this._dirtyCount++}_flush(){let t=this._dirtyCount;if(t===0)return;this._dirtyCount=0;let e=this._state;if(this._fullPending||this._pendingRanges+t>_h)e.clearUpdateRanges(),this._fullPending=!0;else{for(let n=0;n=this.elementCount)throw new RangeError(`Element index ${t} is out of range 0..${this.elementCount-1}.`)}_expandBox(t,e){if(!bf(this._boxes,e))return;let n=this._boxes,s=e*6;t.min.set(Math.min(t.min.x,n[s]),Math.min(t.min.y,n[s+1]),Math.min(t.min.z,n[s+2])),t.max.set(Math.max(t.max.x,n[s+3]),Math.max(t.max.y,n[s+4]),Math.max(t.max.z,n[s+5]))}_changed(t){this._flush(),this.root.dispatchEvent({type:"change",detail:{kind:t}})}};function vh(i,t,e){return e<=t?0:i.cell?(e-t)*i.triangles:(i.starts[e]-i.starts[t])/3}function wf(i,t){return(t[0]-i[0])*i[3]+(t[1]-i[1])*i[4]+(t[2]-i[2])*i[5]-t[3]}function Ef(i,t){let e=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(let a of t)for(let l=0;l<3;l++)e[l]=Math.min(e[l],i[a*6+l]),n[l]=Math.max(n[l],i[a*6+3+l]);let s=(n[0]-e[0])/2,r=(n[1]-e[1])/2,o=(n[2]-e[2])/2;return Float64Array.of((e[0]+n[0])/2,(e[1]+n[1])/2,(e[2]+n[2])/2,Math.hypot(s,r,o),s,r,o)}var el=class{constructor(t){this.root=new Re,this._objects=[];let e=t.meta.points;if(this.count=e?.count??0,!this.count)return;let n=t.view(e.geometry),s=t.view(e.material),r=t.view(e.matrix);for(let o=0;o0?t:null}setOpacity(t){for(let e of this._objects)e.material.opacity=t,e.material.transparent=t<1}};function $v(i,t){let e=t*12;return[i[e],i[e+1],i[e+2],0,i[e+3],i[e+4],i[e+5],0,i[e+6],i[e+7],i[e+8],0,i[e+9],i[e+10],i[e+11],1]}var Zv={ru:{elements:"\u042D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",noGeometry:"\u041D\u0435\u0442 \u0433\u0435\u043E\u043C\u0435\u0442\u0440\u0438\u0438",contextLost:"\u0412\u0438\u0434\u0435\u043E\u043A\u0430\u0440\u0442\u0430 \u0441\u0431\u0440\u043E\u0448\u0435\u043D\u0430 \u2014 \u043F\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0443",noWebGL:"\u041D\u0443\u0436\u0435\u043D \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0441 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u043A\u043E\u0439 WebGL 2",badData:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C \u0434\u0430\u043D\u043D\u044B\u0435 \u043C\u043E\u0434\u0435\u043B\u0438",tooLarge:"\u041C\u043E\u0434\u0435\u043B\u044C \u0441\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u0430\u044F \u0434\u043B\u044F \u044D\u0442\u043E\u0433\u043E \u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0449\u0438\u043A\u0430: \u043E\u0431\u044A\u0435\u043A\u0442\u043E\u0432 \u0441 \u0433\u0435\u043E\u043C\u0435\u0442\u0440\u0438\u0435\u0439 \u2014 {count}, \u043F\u0440\u0435\u0434\u0435\u043B \u2014 {limit}",selected:"\u0412\u044B\u0431\u0440\u0430\u043D\u043E",close:"\u0417\u0430\u043A\u0440\u044B\u0442\u044C","scanMap.title":"\u041C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u0430","scanMap.plan":"\u041F\u043B\u0430\u043D \u043E\u0431\u043B\u0430\u043A\u0430 \u0442\u043E\u0447\u0435\u043A","scanMap.metres":"\u043C","scanMap.choosePhoto":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0444\u043E\u0442\u043E\u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0443\u2026","scanMap.photo":"\u0424\u043E\u0442\u043E\u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0430","scanMap.goToStation":"\u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u043A \u0441\u0442\u0430\u043D\u0446\u0438\u0438 {name}","scanMap.photoControls":"\u0424\u043E\u0442\u043E\u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0430. \u0421\u0442\u0440\u0435\u043B\u043A\u0438 \u043F\u043E\u0432\u043E\u0440\u0430\u0447\u0438\u0432\u0430\u044E\u0442 \u043A\u0430\u043C\u0435\u0440\u0443, \u043A\u043E\u043B\u0435\u0441\u043E \u043C\u0435\u043D\u044F\u0435\u0442 \u043C\u0430\u0441\u0448\u0442\u0430\u0431.","scanMap.loading":"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 \u0444\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u0438\u2026","scanMap.photoError":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0442\u043A\u0440\u044B\u0442\u044C \u0441\u0444\u0435\u0440\u0438\u0447\u0435\u0441\u043A\u0443\u044E \u0444\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u044E.","scanMap.enlargePhoto":"\u0423\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C","scanMap.shrinkPhoto":"\u0423\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C","scanMap.size":"\u0420\u0430\u0437\u043C\u0435\u0440 \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u044B","scanMap.small":"\u041C\u0430\u043B\u0430\u044F","scanMap.medium":"\u0421\u0440\u0435\u0434\u043D\u044F\u044F","scanMap.large":"\u0411\u043E\u043B\u044C\u0448\u0430\u044F","scanMap.zoomIn":"\u041F\u0440\u0438\u0431\u043B\u0438\u0437\u0438\u0442\u044C \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u0443","scanMap.zoomOut":"\u041E\u0442\u0434\u0430\u043B\u0438\u0442\u044C \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u0443","scanMap.reset":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0432\u0435\u0441\u044C \u043F\u043B\u0430\u043D","scanMap.levels":"\u0423\u0440\u043E\u0432\u043D\u0438 \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u044B","scanMap.allLevels":"\u0412\u0441\u0435 \u0432\u044B\u0441\u043E\u0442\u044B","scanMap.level":"\u0423\u0440\u043E\u0432\u0435\u043D\u044C {n}","scanMap.addLevel":"\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0443\u0440\u043E\u0432\u0435\u043D\u044C \u043F\u043E \u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0435","scanMap.removeLevel":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u044B\u0439 \u0443\u0440\u043E\u0432\u0435\u043D\u044C","scanMap.autoButton":"\u0410\u0432\u0442\u043E","scanMap.autoLevels":"\u041E\u043F\u0440\u0435\u0434\u0435\u043B\u0438\u0442\u044C \u0443\u0440\u043E\u0432\u043D\u0438 \u043F\u043E \u0432\u044B\u0441\u043E\u0442\u0430\u043C \u0441\u0442\u0430\u043D\u0446\u0438\u0439","scanMap.noLevels":"\u041D\u0435\u0442 \u044F\u0432\u043D\u043E \u0440\u0430\u0437\u0434\u0435\u043B\u0451\u043D\u043D\u044B\u0445 \u0433\u0440\u0443\u043F\u043F \u0441\u0442\u0430\u043D\u0446\u0438\u0439 \u043F\u043E \u0432\u044B\u0441\u043E\u0442\u0435.","scanMap.levelsAdded":"\u0423\u0440\u043E\u0432\u043D\u0438 \u043F\u043E \u0432\u044B\u0441\u043E\u0442\u0430\u043C \u0441\u0442\u0430\u043D\u0446\u0438\u0439 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u044B.","scanMap.levelsExist":"\u042D\u0442\u0438 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u044B \u0443\u0436\u0435 \u043E\u0445\u0432\u0430\u0447\u0435\u043D\u044B \u0443\u0440\u043E\u0432\u043D\u044F\u043C\u0438.","scanMap.levelAdded":"\u0423\u0440\u043E\u0432\u0435\u043D\u044C \u0441\u043E\u0437\u0434\u0430\u043D.","scanMap.levelTemporary":"\u0423\u0440\u043E\u0432\u043D\u0438 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B \u0434\u043E \u0437\u0430\u043A\u0440\u044B\u0442\u0438\u044F \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B.","scanMap.cancel":"\u041E\u0442\u043C\u0435\u043D\u0430","scanMap.pickLower":"\u0429\u0451\u043B\u043A\u043D\u0438\u0442\u0435 \u043F\u043E \u043D\u0438\u0436\u043D\u0435\u0439 \u043E\u0442\u043C\u0435\u0442\u043A\u0435 \u0443\u0440\u043E\u0432\u043D\u044F.","scanMap.pickUpper":"\u041D\u0438\u0437 {z}. \u0422\u0435\u043F\u0435\u0440\u044C \u0449\u0451\u043B\u043A\u043D\u0438\u0442\u0435 \u043F\u043E \u0432\u0435\u0440\u0445\u043D\u0435\u0439 \u043E\u0442\u043C\u0435\u0442\u043A\u0435.","scanMap.noLowerHit":"\u041D\u0430 \u043B\u0443\u0447\u0435 \u043D\u0435\u0442 \u0442\u043E\u0447\u0435\u043A \u043E\u0431\u043B\u0430\u043A\u0430. \u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043D\u0438\u0436\u043D\u044E\u044E \u043E\u0442\u043C\u0435\u0442\u043A\u0443 \u0440\u044F\u0434\u043E\u043C.","scanMap.noUpperHit":"\u041D\u0430 \u043B\u0443\u0447\u0435 \u043D\u0435\u0442 \u0442\u043E\u0447\u0435\u043A \u043E\u0431\u043B\u0430\u043A\u0430. \u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0435\u0440\u0445\u043D\u044E\u044E \u043E\u0442\u043C\u0435\u0442\u043A\u0443 \u0440\u044F\u0434\u043E\u043C.","scanMap.upperAboveLower":"\u0412\u0435\u0440\u0445\u043D\u044F\u044F \u043E\u0442\u043C\u0435\u0442\u043A\u0430 \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0432\u044B\u0448\u0435 {z}.",elementGroup:"\u042D\u043B\u0435\u043C\u0435\u043D\u0442",id:"Id",category:"\u041A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F",type:"\u0422\u0438\u043F",level:"\u0423\u0440\u043E\u0432\u0435\u043D\u044C",sourceId:"ID \u0438\u0441\u0442\u043E\u0447\u043D\u0438\u043A\u0430",link:"\u0421\u0432\u044F\u0437\u0430\u043D\u043D\u044B\u0439 \u0444\u0430\u0439\u043B",panels:"\u041F\u0430\u043D\u0435\u043B\u0438","panel.model":"\u041C\u043E\u0434\u0435\u043B\u044C","panel.views":"\u0412\u0438\u0434\u044B","panel.sections":"\u0421\u0435\u0447\u0435\u043D\u0438\u044F","panel.clashes":"\u041A\u043E\u043B\u043B\u0438\u0437\u0438\u0438","panel.bcf":"\u0422\u0435\u043C\u044B BCF","bcf.noView":"\u041D\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E\u0433\u043E \u0432\u0438\u0434\u0430","bcf.viewpoint":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432\u0438\u0434 {index}","bcf.components":"\u041D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E \u043A\u043E\u043C\u043F\u043E\u043D\u0435\u043D\u0442\u043E\u0432 \u2014 {missing}, \u043D\u0435\u043E\u0434\u043D\u043E\u0437\u043D\u0430\u0447\u043D\u044B\u0445 \u2014 {ambiguous}","panel.timeliner":"4D-\u0433\u0440\u0430\u0444\u0438\u043A","panel.links":"\u0421\u0432\u044F\u0437\u0430\u043D\u043D\u044B\u0435 \u0444\u0430\u0439\u043B\u044B","group.navigation":"\u041D\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044F","group.sections":"\u0421\u0435\u0447\u0435\u043D\u0438\u044F","group.measure":"\u0418\u0437\u043C\u0435\u0440\u0435\u043D\u0438\u044F","group.display":"\u041E\u0442\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435","group.view":"\u0412\u0438\u0434","tool.orbit":"\u0412\u0440\u0430\u0449\u0435\u043D\u0438\u0435","tool.pan":"\u041F\u0430\u043D\u043E\u0440\u0430\u043C\u0430","tool.fit":"\u0412\u043F\u0438\u0441\u0430\u0442\u044C \u0432\u0441\u0451","tool.projection":"\u041F\u0435\u0440\u0441\u043F\u0435\u043A\u0442\u0438\u0432\u0430 / \u043E\u0440\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u044F","tool.plane":"\u041F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u044C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","tool.box":"\u0411\u043E\u043A\u0441 \u0441\u0435\u0447\u0435\u043D\u0438\u044F","tool.resetSections":"\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","tool.distance":"\u0420\u0430\u0441\u0441\u0442\u043E\u044F\u043D\u0438\u0435","tool.displayMode":"\u0420\u0435\u0436\u0438\u043C \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F","tool.grids":"\u041E\u0441\u0438","tool.opacity":"\u041F\u0440\u043E\u0437\u0440\u0430\u0447\u043D\u043E\u0441\u0442\u044C","tool.fullscreen":"\u041F\u043E\u043B\u043D\u044B\u0439 \u044D\u043A\u0440\u0430\u043D",contextMenu:"\u041A\u043E\u043D\u0442\u0435\u043A\u0441\u0442\u043D\u043E\u0435 \u043C\u0435\u043D\u044E","menu.properties":"\u0421\u0432\u043E\u0439\u0441\u0442\u0432\u0430","menu.hide":"\u0421\u043A\u0440\u044B\u0442\u044C","menu.isolate":"\u0418\u0437\u043E\u043B\u0438\u0440\u043E\u0432\u0430\u0442\u044C","menu.showAll":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0432\u0441\u0451","menu.zoomTo":"\u041F\u0440\u0438\u0431\u043B\u0438\u0437\u0438\u0442\u044C \u043A \u043E\u0431\u044A\u0435\u043A\u0442\u0443","menu.sectionBox":"\u0411\u043E\u043A\u0441 \u0441\u0435\u0447\u0435\u043D\u0438\u044F \u043F\u043E \u043E\u0431\u044A\u0435\u043A\u0442\u0443","menu.copyId":"\u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C Id","menu.fitAll":"\u0412\u043F\u0438\u0441\u0430\u0442\u044C \u0432\u0441\u0451","menu.resetSections":"\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","menu.unavailable":"\u041D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E \u0434\u043B\u044F \u044D\u0442\u043E\u0439 \u043C\u043E\u0434\u0435\u043B\u0438",searchPlaceholder:"\u041F\u043E\u0438\u0441\u043A \u043F\u043E \u0438\u043C\u0435\u043D\u0438, \u0442\u0438\u043F\u0443, Id\u2026",noCategory:"\u0411\u0435\u0437 \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u0438",noMatches:"\u041D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E","filters.title":"\u0424\u0438\u043B\u044C\u0442\u0440\u044B","filters.model":"\u041C\u043E\u0434\u0435\u043B\u044C-\u0438\u0441\u0442\u043E\u0447\u043D\u0438\u043A","filters.noLevel":"\u0411\u0435\u0437 \u0443\u0440\u043E\u0432\u043D\u044F","filters.all":"\u0412\u0441\u0435","filters.clear":"\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C","filters.isolate":"\u0418\u0437\u043E\u043B\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u043E\u0432\u043F\u0430\u0434\u0435\u043D\u0438\u044F",idCopied:"Id \u0441\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D",copyFailed:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0441\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C Id",fullscreenUnavailable:"\u041F\u043E\u043B\u043D\u043E\u044D\u043A\u0440\u0430\u043D\u043D\u044B\u0439 \u0440\u0435\u0436\u0438\u043C \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D","face.front":"\u0421\u043F\u0435\u0440\u0435\u0434\u0438","face.back":"\u0421\u0437\u0430\u0434\u0438","face.left":"\u0421\u043B\u0435\u0432\u0430","face.right":"\u0421\u043F\u0440\u0430\u0432\u0430","face.top":"\u0421\u0432\u0435\u0440\u0445\u0443","face.bottom":"\u0421\u043D\u0438\u0437\u0443","cube.title":"\u041A\u0443\u0431 \u0432\u0438\u0434\u0430","cube.up":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u0432\u0435\u0440\u0445","cube.down":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u043D\u0438\u0437","cube.left":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u043B\u0435\u0432\u043E","cube.right":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u043F\u0440\u0430\u0432\u043E","cube.home":"\u0418\u0441\u0445\u043E\u0434\u043D\u044B\u0439 \u0432\u0438\u0434","sections.mode":"\u0420\u0435\u0436\u0438\u043C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","sections.planes":"\u041F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0438","sections.box":"\u0411\u043E\u043A\u0441","sections.off":"\u0412\u044B\u043A\u043B","sections.axis":"\u041E\u0441\u044C","sections.addPlane":"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u044C","sections.noPlanes":"\u041F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0435\u0439 \u043D\u0435\u0442","sections.rotated":"\u043F\u043E\u0432\u0451\u0440\u043D\u0443\u0442\u0430","sections.custom":"\u041F\u0440\u043E\u0438\u0437\u0432\u043E\u043B\u044C\u043D\u0430\u044F","sections.position":"\u041F\u043E\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0438","sections.flip":"\u0421\u043C\u0435\u043D\u0438\u0442\u044C \u0441\u0442\u043E\u0440\u043E\u043D\u0443","sections.enabled":"\u0412\u043A\u043B","sections.delete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u044C","sections.keepInside":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0432\u043D\u0443\u0442\u0440\u0438","sections.cutInside":"\u0412\u044B\u0440\u0435\u0437\u0430\u0442\u044C \u0432\u043D\u0443\u0442\u0440\u0438","sections.fitSelection":"\u041F\u043E \u0432\u044B\u0434\u0435\u043B\u0435\u043D\u043D\u043E\u043C\u0443","sections.showGizmo":"\u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u043C\u0430\u043D\u0438\u043F\u0443\u043B\u044F\u0442\u043E\u0440","sections.boxYaw":"\u041F\u043E\u0432\u043E\u0440\u043E\u0442 \u0432\u043E\u043A\u0440\u0443\u0433 Z","sections.fill":"\u0417\u0430\u043B\u0438\u0432\u043A\u0430 \u0441\u0440\u0435\u0437\u043E\u0432","sections.fillUnavailable":"\u0417\u0430\u043B\u0438\u0432\u043A\u0430 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0430 \u0431\u0435\u0437 \u0431\u0443\u0444\u0435\u0440\u0430 \u0442\u0440\u0430\u0444\u0430\u0440\u0435\u0442\u0430 WebGL","sections.maxPlanes":"\u041D\u0435 \u0431\u043E\u043B\u044C\u0448\u0435 6 \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0435\u0439","unit.m":"\u043C","display.materials":"\u041C\u0430\u0442\u0435\u0440\u0438\u0430\u043B\u044B","display.textures":"\u0422\u0435\u043A\u0441\u0442\u0443\u0440\u044B","display.white":"\u0411\u0435\u043B\u044B\u0439","display.wireframe":"\u041A\u0430\u0440\u043A\u0430\u0441","display.background":"\u0426\u0432\u0435\u0442 \u0444\u043E\u043D\u0430","display.backgroundReset":"\u0424\u043E\u043D \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E","opacity.label":"\u041D\u0435\u043F\u0440\u043E\u0437\u0440\u0430\u0447\u043D\u043E\u0441\u0442\u044C","opacity.value":"{value} %","views.tour":"\u0422\u0443\u0440 \u043F\u043E \u0432\u0438\u0434\u0430\u043C","views.stop":"\u041E\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u0442\u0443\u0440","clash.New":"\u041D\u043E\u0432\u0430\u044F","clash.Active":"\u0410\u043A\u0442\u0438\u0432\u043D\u0430\u044F","clash.Reviewed":"\u041F\u0440\u043E\u0432\u0435\u0440\u0435\u043D\u0430","clash.Approved":"\u0423\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u0430","clash.Resolved":"\u0423\u0441\u0442\u0440\u0430\u043D\u0435\u043D\u0430","task.construct":"\u0421\u0442\u0440\u043E\u0438\u0442\u0435\u043B\u044C\u0441\u0442\u0432\u043E","task.demolish":"\u0421\u043D\u043E\u0441","task.temporary":"\u0412\u0440\u0435\u043C\u0435\u043D\u043D\u043E\u0435","player.title":"4D-\u043F\u0440\u043E\u0438\u0433\u0440\u044B\u0432\u0430\u0442\u0435\u043B\u044C","player.play":"\u0412\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u0441\u0442\u0438","player.pause":"\u041F\u0430\u0443\u0437\u0430","player.date":"\u0414\u0430\u0442\u0430 \u0433\u0440\u0430\u0444\u0438\u043A\u0430","player.speed":"\u0421\u043A\u043E\u0440\u043E\u0441\u0442\u044C",truncated:"\u041F\u043E\u043A\u0430\u0437\u0430\u043D\u043E {meshes} \u0438\u0437 {total} \u043C\u0435\u0448\u0435\u0439: \u043C\u043E\u0434\u0435\u043B\u044C \u043E\u0431\u0440\u0435\u0437\u0430\u043D\u0430 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u043E\u0439 MaxMeshVertices"},en:{elements:"Elements",noGeometry:"No geometry",contextLost:"The graphics context was lost \u2014 reload the page",noWebGL:"This page needs a browser with WebGL 2",badData:"The model data could not be read",tooLarge:"The model is too large for this viewer: {count} objects with geometry, the limit is {limit}",selected:"Selected",close:"Close","scanMap.title":"Minimap","scanMap.plan":"Point cloud floor plan","scanMap.metres":"m","scanMap.choosePhoto":"Open photo panorama\u2026","scanMap.photo":"Photo panorama","scanMap.goToStation":"Move to station {name}","scanMap.photoControls":"Photo panorama. Arrow keys turn the camera, the wheel zooms.","scanMap.loading":"Loading photograph\u2026","scanMap.photoError":"Could not open the spherical photograph.","scanMap.enlargePhoto":"Enlarge","scanMap.shrinkPhoto":"Restore size","scanMap.size":"Minimap size","scanMap.small":"Small","scanMap.medium":"Medium","scanMap.large":"Large","scanMap.zoomIn":"Zoom in on minimap","scanMap.zoomOut":"Zoom out on minimap","scanMap.reset":"Fit the whole plan","scanMap.levels":"Minimap levels","scanMap.allLevels":"All heights","scanMap.level":"Level {n}","scanMap.addLevel":"Create level from panorama","scanMap.removeLevel":"Remove selected level","scanMap.autoButton":"Auto","scanMap.autoLevels":"Detect levels by station height","scanMap.noLevels":"Station heights have no clear groups.","scanMap.levelsAdded":"Levels added from station heights.","scanMap.levelsExist":"Existing levels already cover these height ranges.","scanMap.levelAdded":"Level created.","scanMap.levelTemporary":"Levels will stay available until you close this page.","scanMap.cancel":"Cancel","scanMap.pickLower":"Click the lower level elevation.","scanMap.pickUpper":"Lower elevation {z}. Now click the upper elevation.","scanMap.noLowerHit":"No scan points along that ray. Choose a nearby lower elevation.","scanMap.noUpperHit":"No scan points along that ray. Choose a nearby upper elevation.","scanMap.upperAboveLower":"The upper elevation must be above {z}.",elementGroup:"Element",id:"Id",category:"Category",type:"Type",level:"Level",sourceId:"Source ID",link:"Link",panels:"Panels","panel.model":"Model","panel.views":"Views","panel.sections":"Sections","panel.clashes":"Clashes","panel.bcf":"BCF topics","bcf.noView":"No view available","bcf.viewpoint":"Open viewpoint {index}","bcf.components":"Components missing \u2014 {missing}, ambiguous \u2014 {ambiguous}","panel.timeliner":"4D schedule","panel.links":"Linked files","group.navigation":"Navigation","group.sections":"Sections","group.measure":"Measure","group.display":"Display","group.view":"View","tool.orbit":"Orbit","tool.pan":"Pan","tool.fit":"Fit all","tool.projection":"Perspective / orthographic","tool.plane":"Section plane","tool.box":"Section box","tool.resetSections":"Reset sections","tool.distance":"Distance","tool.displayMode":"Display mode","tool.grids":"Grids","tool.opacity":"Transparency","tool.fullscreen":"Full screen",contextMenu:"Context menu","menu.properties":"Properties","menu.hide":"Hide","menu.isolate":"Isolate","menu.showAll":"Show all","menu.zoomTo":"Zoom to object","menu.sectionBox":"Section box around object","menu.copyId":"Copy Id","menu.fitAll":"Fit all","menu.resetSections":"Reset sections","menu.unavailable":"Unavailable for this model",searchPlaceholder:"Search by name, type, Id\u2026",noCategory:"No category",noMatches:"No matches","filters.title":"Filters","filters.model":"Source model","filters.noLevel":"No level","filters.all":"All","filters.clear":"Clear","filters.isolate":"Isolate matches",idCopied:"Id copied",copyFailed:"Could not copy Id",fullscreenUnavailable:"Fullscreen is not available","face.front":"Front","face.back":"Back","face.left":"Left","face.right":"Right","face.top":"Top","face.bottom":"Bottom","cube.title":"View cube","cube.up":"Rotate up","cube.down":"Rotate down","cube.left":"Rotate left","cube.right":"Rotate right","cube.home":"Home view","sections.mode":"Section mode","sections.planes":"Planes","sections.box":"Box","sections.off":"Off","sections.axis":"Axis","sections.addPlane":"Add plane","sections.noPlanes":"No planes","sections.rotated":"rotated","sections.custom":"Custom","sections.position":"Plane position","sections.flip":"Flip side","sections.enabled":"On","sections.delete":"Delete plane","sections.keepInside":"Show inside","sections.cutInside":"Cut inside","sections.fitSelection":"Fit to selection","sections.showGizmo":"Show gizmo","sections.boxYaw":"Rotation around Z","sections.fill":"Fill cut faces","sections.fillUnavailable":"Section fill requires a WebGL stencil buffer","sections.maxPlanes":"At most 6 planes","unit.m":"m","display.materials":"Materials","display.textures":"Textures","display.white":"White","display.wireframe":"Wireframe","display.background":"Background color","display.backgroundReset":"Reset background","opacity.label":"Opacity","opacity.value":"{value}%","views.tour":"Play tour","views.stop":"Stop tour","clash.New":"New","clash.Active":"Active","clash.Reviewed":"Reviewed","clash.Approved":"Approved","clash.Resolved":"Resolved","task.construct":"Construct","task.demolish":"Demolish","task.temporary":"Temporary","player.title":"4D player","player.play":"Play","player.pause":"Pause","player.date":"Schedule date","player.speed":"Speed",truncated:"Showing {meshes} of {total} meshes: the model was truncated by the MaxMeshVertices setting"}},si=(globalThis.navigator?.language??"").toLowerCase().startsWith("ru")?"ru":"en",Nr=new Intl.NumberFormat(si).format;function $(i,t=si){let e=Zv[t][i];if(e===void 0)throw new Error(`Missing UI string '${i}'.`);return e}var Tf=new I(0,0,1),nl=Math.PI/2-.01;function Rf(i,t,e=4){return Math.hypot(t.x-i.x,t.y-i.y)<=e}function Cf(i,t,e,n,s,r){let o=i.clone().sub(e),a=t.clone().sub(e),l=d=>(o.applyQuaternion(d),a.applyQuaternion(d));l(new Le().setFromAxisAngle(Tf,-n*r));let c=a.clone().sub(o).normalize(),h=c.clone().cross(Tf);if(h.lengthSq()>1e-12){let d=Math.asin(re.clamp(c.z,-1,1)),u=re.clamp(s*r,d-nl,d+nl);l(new Le().setFromAxisAngle(h.normalize(),-u))}return{position:o.add(e),target:a.add(e)}}function If(i,t,e,n){let s=r=>r.clone().sub(e).multiplyScalar(n).add(e);return{position:s(i),target:s(t)}}var Jv=.85,Kv=100/3;function Pf(i,t,e){let n=i*(t===1?Kv:t===2?e:1);return re.clamp(Jv**(-n/100),.5,2)}var Mh=(i,t)=>t>=i?"window":"crossing";function Lf(i,t,e){let n=Af(i.position,i.target),s=Af(t.position,t.target),r=n.azimuth??s.azimuth??0,o=s.azimuth??r,a=re.euclideanModulo(o-r+Math.PI,2*Math.PI)-Math.PI,l=(_,m)=>_+(m-_)*e,c=r+a*e,h=re.clamp(l(n.elevation,s.elevation),-nl,nl),d=l(n.distance,s.distance),u=i.target.clone().lerp(t.target,e),f=Math.cos(h)*d;return{position:u.clone().add(new I(f*Math.cos(c),f*Math.sin(c),Math.sin(h)*d)),target:u}}function Df(i,t,e,n){let s=i.position.clone().sub(i.target),r=t.position.clone().sub(t.target),o=s.length(),a=r.length();s.normalize(),r.normalize();let l=new Le().setFromUnitVectors(s,r),c=e.clone().applyQuaternion(l),h=new I().setFromMatrixColumn(new Jt().lookAt(t.position,t.target,n),1),d=r.dot(new I().crossVectors(c,h)),u=Math.atan2(Math.abs(d)<1e-9?0:d,c.dot(h)),f=new Le;return g=>{f.identity().slerp(l,g);let _=s.clone().applyQuaternion(f),m=i.target.clone().lerp(t.target,g),p=_.clone().multiplyScalar(re.lerp(o,a,g)).add(m),b=e.clone().applyQuaternion(f).applyAxisAngle(_,u*g);return{position:p,target:m,up:b}}}function Af(i,t){let e=i.clone().sub(t),n=e.length(),s=Math.hypot(e.x,e.y);return{distance:n,elevation:n>1e-12?Math.asin(re.clamp(e.z/n,-1,1)):0,azimuth:s>1e-9*Math.max(n,1e-12)?Math.atan2(e.y,e.x):null}}var jv=.005,Qv=new I(1,-1,.8).normalize(),Sh=.01,Nf=1e-6,ty=64,Uf=1.05,ey=5e3,bh=(i,t)=>new CustomEvent(i,{detail:t});function Ff({bbox:i,grids:t}){let e=r=>Array.isArray(r)&&r.length===3&&r.every(Number.isFinite);if(!e(i?.min)||!e(i?.max))return!0;let n=new oe(new I(...i.min),new I(...i.max));if(n.isEmpty())return!0;let s=new I;for(let r of t??[])for(let o of Er(r)){if(!e(o))return!0;n.expandByPoint(s.fromArray(o))}return n.getSize(s).length()*Uf>Sh*ey}var il=class extends EventTarget{constructor(t,e,{pick:n=()=>null,visibleBox:s=()=>new oe}={}){super(),this.dom=e,this.pick=n,this.visibleBox=s,this.target=new I,this.leftButtonMode="orbit",this._perspective=t,this._defaultFov=t.fov,this._orthographic=new Bn(-1,1,1,-1),this.camera=t,this._drag=null,this._wheelPick=null,this._animation=0,this._overlay=null,this._bounds=null,this._extraBounds=new Map,e.style.touchAction="none",e.addEventListener("pointerdown",r=>this._down(r)),e.addEventListener("pointermove",r=>this._move(r)),e.addEventListener("pointerup",r=>this._up(r)),e.addEventListener("pointercancel",()=>this._end()),e.addEventListener("lostpointercapture",r=>this._lostCapture(r)),window.addEventListener("blur",()=>this._end()),e.addEventListener("wheel",r=>this._wheel(r),{passive:!1}),e.addEventListener("contextmenu",r=>r.preventDefault())}setLeftButtonMode(t){if(t!=="orbit"&&t!=="pan")throw new RangeError(`Unknown left button mode: ${t}`);this.leftButtonMode=t}setProjection(t){if(t!=="perspective"&&t!=="orthographic")throw new RangeError(`Unknown projection: ${t}`);let e=t==="perspective"?this._perspective:this._orthographic,n=this.camera;if(e!==n){this._stopAnimation(),e.position.copy(n.position),n.isOrthographicCamera&&e.position.sub(this.target).divideScalar(n.zoom).add(this.target),e.zoom=1,e.quaternion.copy(n.quaternion),e.up.copy(n.up),n.parent?.add(e),n.parent?.remove(n);for(let s of[...n.children])e.add(s);this.camera=e,this.resize()}}resize(){let t=this.camera,e=this.dom.clientWidth/Math.max(this.dom.clientHeight,1),n=Math.max(t.position.distanceTo(this.target),1e-6);if(t.isPerspectiveCamera)t.aspect=e;else{let r=n*Math.tan(re.degToRad(this._perspective.fov/2));Object.assign(t,{top:r,bottom:-r,left:-r*e,right:r*e})}let s=this._rangeSphere();if(s){let r=s.center.clone().sub(t.position),o=new I(0,0,-1).applyQuaternion(t.quaternion);t.far=Math.max(1e-6,(r.length()+s.radius)*Uf);let a=r.dot(o)-s.radius;t.near=Math.max(a*.95,Math.min(Sh,t.far/2))}t.updateProjectionMatrix(),this.dispatchEvent(new Event("change"))}setExtraBounds(t,e){e&&!e.isEmpty()?this._extraBounds.set(t,e.clone()):this._extraBounds.delete(t),this.resize()}_rangeSphere(){let t=this._visibleBounds()?.sphere??null;if(this._extraBounds.size===0)return t;let e=t?this._bounds.box.clone():new oe;for(let n of this._extraBounds.values())e.union(n);return e.getBoundingSphere(new Ge)}invalidateBounds(){this._bounds=null}_visibleBounds(){if(!this._bounds){let t=this.visibleBox();this._bounds={box:t,sphere:t.isEmpty()?null:t.getBoundingSphere(new Ge)}}return this._bounds.sphere&&this._bounds}fitBox(t,e=!0){if(t.isEmpty())return;let n=t.getBoundingSphere(new Ge),s=Math.max(n.radius,.001),r=re.degToRad(this._perspective.fov/2),o=this.dom.clientWidth/Math.max(this.dom.clientHeight,1),a=s/Math.sin(Math.min(r,Math.atan(Math.tan(r)*o))),l=this.camera.position.clone().sub(this.target);l.lengthSq()<1e-12&&l.copy(Qv);let c=l.normalize().multiplyScalar(a).add(n.center);e?this.animateTo({position:c,target:n.center}):(this.camera.zoom=1,this._set(c,n.center))}zoomToBox(t){this.fitBox(t,!0)}resetCameraStyle(){this._perspective.fov=this._defaultFov,this.camera.up.set(0,0,1)}restoreViewCamera({position:t,target:e,up:n,fov:s,orthographicHeight:r}){let o=new I(...t),a=new I(...e);if(this.resetCameraStyle(),!n){this.animateTo({position:o,target:a});return}this._stopAnimation(),this.camera.up.fromArray(n),this._perspective.fov=s??this._defaultFov;let l=Math.max(o.distanceTo(a),1e-6);this.camera.zoom=r==null?1:2*l*Math.tan(re.degToRad(this._perspective.fov/2))/r,this._set(o,a)}animateTo({position:t,target:e,zoom:n=1,overPole:s=!1},r=400){this._stopAnimation();let o={position:this.camera.position.clone(),target:this.target.clone()},a={position:t??o.position,target:e??o.target},l=this.camera.zoom,c=s?Df(o,a,new I(0,1,0).applyQuaternion(this.camera.quaternion),this.camera.up):u=>Lf(o,a,u),h=performance.now(),d=u=>{let f=Math.min((u-h)/r,1),g=f*f*(3-2*f),_=c(g);this.camera.isOrthographicCamera&&(this.camera.zoom=re.lerp(l,n,g)),this._set(_.position,_.target,_.up),this._animation=f<1?requestAnimationFrame(d):0};this._animation=requestAnimationFrame(d)}get animating(){return this._animation!==0}_stopAnimation(){cancelAnimationFrame(this._animation),this._animation=0}_set(t,e,n){if(this.camera.position.copy(t),this.target.copy(e),n){let s=this.camera.up.clone();this.camera.up.copy(n),this.camera.lookAt(e),this.camera.up.copy(s)}else this.camera.lookAt(e);this.resize()}_down(t){this._end(),this._stopAnimation(),this.dom.setPointerCapture(t.pointerId),t.preventDefault();let e=t.button===0&&t.shiftKey?"box":t.button===0&&this.leftButtonMode==="orbit"?"orbit":"pan",n={x:t.clientX,y:t.clientY},s=null;e==="orbit"&&(s=this.pick(n.x,n.y),s||(s=this._visibleBounds()?.sphere.center.clone()??this.target.clone())),this._drag={id:t.pointerId,button:t.button,mode:e,pivot:s,down:n,last:n,moved:!1}}_anchor(t,e){let n=this.pick(t,e);if(n)return n;let s=this.dom.getBoundingClientRect(),r=s.left+s.width/2,o=s.top+s.height/2;return t===r&&e===o?null:this.pick(r,o)}_gestureDepth(t,e){let n=this.camera,s=t?t.clone().sub(n.position).dot(e):0;return Math.max(Nf,n.position.distanceTo(this.target),s)}_move(t){let e=this._drag;if(!e||t.pointerId!==e.id)return;if(t.buttons===0)return this._end();let n={x:t.clientX,y:t.clientY};if(!e.moved&&Rf(e.down,n))return;e.moved=!0;let s=n.x-e.last.x,r=n.y-e.last.y;if(e.last=n,e.mode==="box")this._drawRect(e.down,n);else if(e.mode==="orbit"){let o=Cf(this.camera.position,this.target,e.pivot,s,r,jv);this._set(o.position,o.target)}else this._pan(s,r)}_pan(t,e){let n=this.camera,s=Math.max(this.dom.clientHeight,1);if(n.isPerspectiveCamera&&this._drag.depth===void 0){let{x:c,y:h}=this._drag.down;this._drag.depth=this._gestureDepth(this._anchor(c,h),n.getWorldDirection(new I))}let r=n.isPerspectiveCamera?2*this._drag.depth*Math.tan(re.degToRad(n.fov/2))/(s*n.zoom):(n.top-n.bottom)/n.zoom/s,o=new I(1,0,0).applyQuaternion(n.quaternion),a=new I(0,1,0).applyQuaternion(n.quaternion),l=o.multiplyScalar(-t*r).addScaledVector(a,e*r);this._set(n.position.clone().add(l),this.target.clone().add(l))}_up(t){let e=this._drag;if(!e||t.pointerId!==e.id||t.button!==e.button)return;let n={x:t.clientX,y:t.clientY};if(this._end(),e.mode==="box"&&e.moved){let s={x:Math.min(e.down.x,n.x),y:Math.min(e.down.y,n.y),width:Math.abs(n.x-e.down.x),height:Math.abs(n.y-e.down.y)},r=Mh(e.down.x,n.x);this.dispatchEvent(bh("boxselect",{rect:s,mode:r,ctrl:t.ctrlKey,shift:t.shiftKey}))}else!e.moved&&e.button===0?this.dispatchEvent(bh("click",{x:n.x,y:n.y,button:0,ctrl:t.ctrlKey,shift:t.shiftKey})):!e.moved&&e.button===2&&this.dispatchEvent(bh("contextmenu",{x:n.x,y:n.y}))}_lostCapture(t){this._drag&&t.buttons?this.dom.setPointerCapture(this._drag.id):this._end()}_end(){this._drag=null,this._overlay?.remove(),this._overlay=null}_drawRect(t,e){this._overlay||(this._overlay=document.createElement("div"),Object.assign(this._overlay.style,{position:"fixed",pointerEvents:"none",border:"1px solid #2563eb",background:"rgba(37,99,235,0.12)"}),(this.dom.parentElement??document.body).appendChild(this._overlay)),Object.assign(this._overlay.style,{borderStyle:Mh(t.x,e.x)==="window"?"solid":"dashed",left:`${Math.min(t.x,e.x)}px`,top:`${Math.min(t.y,e.y)}px`,width:`${Math.abs(e.x-t.x)}px`,height:`${Math.abs(e.y-t.y)}px`})}_wheel(t){if(t.preventDefault(),t.deltaY===0)return;this._stopAnimation();let e=Pf(t.deltaY,t.deltaMode,this.dom.clientHeight),n=this.camera,s=n.position.distanceTo(this.target),r=this._visibleBounds()?.sphere.radius??0,o=ty*Math.max(r,.001);if(n.isOrthographicCamera){let{left:_,top:m,width:p,height:b}=this.dom.getBoundingClientRect();if(!p||!b)return;let w=re.clamp(n.zoom/e,Math.max(1e-6,Math.min(n.zoom,s/o)),1e6);if(w===n.zoom)return;let v=new I((2*(t.clientX-_)/p-1)*n.right,(1-2*(t.clientY-m)/b)*n.top,0).multiplyScalar(1/n.zoom-1/w).applyQuaternion(n.quaternion);n.zoom=w,this._set(n.position.clone().add(v),this.target.clone().add(v));return}this._wheelPick||(this._wheelPick={point:this._anchor(t.clientX,t.clientY)},requestAnimationFrame(()=>this._wheelPick=null));let a=n.getWorldDirection(new I),l=this._gestureDepth(this._wheelPick.point,a);if(!Number.isFinite(l))return;let c=Math.min(Sh,Math.max(Nf,r)),h=re.clamp(l*e,c,Math.max(l,o))/l;if(h===1)return;let d=n.position.clone().addScaledVector(a,l),u=this._wheelPick.point,f=u&&u.clone().sub(n.position).dot(a)>=c?u:d,g=If(n.position,d,f,h);this._set(g.position,g.target)}};function et(i,t,e){let n=document.createElement(i);return t&&(n.className=t),e!==void 0&&(n.textContent=e),n}function Qe(i,t,e){let n=et("button",i);return n.type="button",n.innerHTML=t,n.title=e,n.setAttribute("aria-label",e),n}function Bs(i){i.preventDefault(),i.stopPropagation()}function sl(i){Bs(i);let t=i.button===2,e=()=>{window.removeEventListener("pointerup",n,!0),setTimeout(()=>{window.removeEventListener("click",Bs,!0),t&&window.removeEventListener("contextmenu",Bs,!0)})},n=s=>{Bs(s),e()};window.addEventListener("pointerup",n,!0),window.addEventListener("click",Bs,!0),t&&window.addEventListener("contextmenu",Bs,!0)}function Ur(i,t,e,n){let s=t.clone().applyMatrix4(e.matrixWorldInverse).z<0,r=t.clone().project(e);i.hidden=!(s&&Math.abs(r.x)<=1&&Math.abs(r.y)<=1),!i.hidden&&(i.style.left=`${n.left+(r.x+1)/2*n.width}px`,i.style.top=`${n.top+(1-r.y)/2*n.height}px`)}var Me=i=>``,Bf='',ne={model:Me(''),views:Me(''),sections:Me(''),clashes:Me(''),bcf:Me(''),timeliner:Me(''),links:Me(''),orbit:Me(''),pan:Me(''),fit:Me(''),projection:Me(Bf),plane:Me(''),box:Me(`${Bf}`),resetSections:Me(''),distance:Me(''),displayMode:Me(''),grids:Me(''),opacity:Me(''),fullscreen:Me(''),close:Me(''),chevron:Me(''),flip:Me(''),remove:Me(''),play:Me(''),pause:Me(''),home:Me('')};var Fr=new I(0,0,1),cn={right:new I(1,0,0),left:new I(-1,0,0),back:new I(0,1,0),front:new I(0,-1,0),top:new I(0,0,1),bottom:new I(0,0,-1)},ny={right:Fr,left:Fr,back:Fr,front:Fr,top:cn.back,bottom:cn.front},Xi=.7,iy=re.degToRad(1),Of=.01,zf=96,rl=1.75;function kf(i){let t=i.split("-"),e=new I;for(let n of t){if(!Object.hasOwn(cn,n))throw new RangeError(`Unknown view cube region: ${i}`);e.add(cn[n])}if(new Set(t).size!==t.length||e.lengthSq()!==t.length)throw new RangeError(`Unknown view cube region: ${i}`);return e.normalize()}function sy(i){let t=[];return Math.abs(i.z)>=Xi&&t.push(i.z>0?"top":"bottom"),Math.abs(i.y)>=Xi&&t.push(i.y>0?"back":"front"),Math.abs(i.x)>=Xi&&t.push(i.x>0?"right":"left"),t.join("-")}function wh(i,t=iy){let e=i.clone().normalize(),n=Math.cos(t);return Object.keys(cn).find(s=>e.dot(cn[s])>=n)??null}function Hf(i){let t=new I(i.x,i.y,0);if(t.lengthSq()<1e-24)return"front";t.normalize();let e=["front","right","back","left"],n=Math.max(...e.map(s=>t.dot(cn[s])));return e.find(s=>t.dot(cn[s])>=n-1e-9)}function Eh(i,t){return cn[Hf(t)].clone().multiplyScalar(Math.sin(Of)).addScaledVector(cn[i],Math.cos(Of))}function ry(i,t){let e=wh(i);if(!e)return null;let n=e==="top"||e==="bottom";if(t==="left"||t==="right")return(n?Eh(e,i):kf(e)).applyAxisAngle(Fr,t==="right"?Math.PI/2:-Math.PI/2);if(t!=="up"&&t!=="down")throw new RangeError(`Unknown arrow: ${t}`);if(!n)return Eh(t==="up"?"top":"bottom",i);let s=cn[Hf(i)];return t==="up"==(e==="top")?s.clone().negate():s.clone()}function oy(i,t){let e=document.createElement("canvas");e.width=e.height=128;let n=e.getContext("2d");n.fillStyle="#2a2f38",n.fillRect(0,0,128,128),n.fillStyle="#cbd5e1",n.textAlign="center",n.textBaseline="middle",n.font=`600 26px ${t}`;let s=n.measureText(i).width;s>112&&(n.font=`600 ${Math.floor(2912/s)}px ${t}`),n.fillText(i,64,64);let r=new ir(e);return r.colorSpace=Te,r}var ol=class{constructor(t,e,n){this.controls=n,this.home={position:e.position.clone(),target:n.target.clone()},this.element=et("div","ioviewer-viewcube"),this.canvas=et("canvas","ioviewer-viewcube-canvas"),this.canvas.title=$("cube.title"),this.canvas.setAttribute("aria-label",$("cube.title")),this.element.append(this.canvas),this.error=null,this.renderer=this._createRenderer(),this.scene=new Qn,this.camera=new Bn(-rl,rl,rl,-rl,.1,10),this.faces=new Re;let s=getComputedStyle(t).fontFamily;for(let[l,c]of Object.entries(cn)){let h=$(`face.${l}`),d=new _e(new yn(2,2),new Ke({map:oy(h,s)})),u=ny[l];d.quaternion.setFromRotationMatrix(new Jt().makeBasis(u.clone().cross(c),u,c)),d.position.copy(c),d.name=l,d.userData.label=h,this.faces.add(d)}let r=new vn(new Oi(new dn(2,2,2)),new an({color:"#5b6575"}));this.highlight=new _e(new dn(1,1,1),new Ke({color:"#2563eb",transparent:!0,opacity:.6})),this.highlight.visible=!1,this.scene.add(this.faces,r,this.highlight),this._raycaster=new On,this.hovered=null,this._pointer=null,this.element.addEventListener("contextmenu",l=>l.preventDefault());let o=l=>{this._pointer=[l.clientX,l.clientY],this._hover(this.regionAtClient(...this._pointer))&&this._render()};this.canvas.addEventListener("pointerenter",o),this.canvas.addEventListener("pointermove",o),this.canvas.addEventListener("pointerleave",()=>{this._pointer=null,this._hover(null)&&this._render()}),this.canvas.addEventListener("click",l=>{let c=this.regionAtClient(l.clientX,l.clientY);if(!c)return;let h=c==="top"||c==="bottom";this._look(h?Eh(c,n.camera.position.clone().sub(n.target)):kf(c))}),this.arrows=["up","down","left","right"].map(l=>{let c=Qe("ioviewer-viewcube-arrow",ne.chevron,$(`cube.${l}`));return c.dataset.arrow=l,c.addEventListener("click",h=>{h.detail&&c.blur(),this._arrow(l)}),c});let a=Qe("ioviewer-viewcube-home",ne.home,$("cube.home"));a.addEventListener("click",l=>{l.detail&&a.blur(),n.resetCameraStyle(),n.animateTo({position:this.home.position.clone(),target:this.home.target.clone()})}),this.element.append(...this.arrows,a),t.append(this.element),this.update()}_createRenderer(){this.canvas.addEventListener("webglcontextlost",e=>{e.stopImmediatePropagation(),this._fail(new Error("The view cube lost its WebGL context."))});let t=this.canvas.getContext("webgl2",{alpha:!0,antialias:!0});if(!t)return this._fail(new Error("WebGL 2 is not available for the view cube."));try{let e=new Si({canvas:this.canvas,context:t,alpha:!0,antialias:!0});return e.setPixelRatio(window.devicePixelRatio),e.setSize(zf,zf),e}catch(e){return this._fail(e)}}_fail(t){return this.error=t,this.renderer=null,this.element.hidden=!0,null}_render(){if(this.renderer)try{this.renderer.render(this.scene,this.camera)}catch(t){this._fail(t)}}update(){if(!this.renderer)return;let t=this.controls.camera,e=!this.camera.quaternion.equals(t.quaternion);this.camera.quaternion.copy(t.quaternion),this.camera.position.set(0,0,5).applyQuaternion(t.quaternion),this.camera.updateMatrixWorld();let n=wh(t.position.clone().sub(this.controls.target))!==null;for(let s of this.arrows)s.hidden=!n;e&&this._pointer&&this._hover(this.regionAtClient(...this._pointer)),this._render()}regionAtClient(t,e){let n=this.canvas.getBoundingClientRect(),s=new $t((t-n.left)/n.width*2-1,1-(e-n.top)/n.height*2);this._raycaster.setFromCamera(s,this.camera);let r=this._raycaster.intersectObjects(this.faces.children)[0];return r?sy(r.point):null}_hover(t){if(t===this.hovered)return!1;if(this.hovered=t,this.highlight.visible=!!t,t){let e=t.split("-").reduce((a,l)=>a.add(cn[l]),new I),n=a=>a===0?[-Xi,Xi]:a>0?[Xi,1.02]:[-1.02,-Xi],[s,r,o]=e.toArray().map(n);this.highlight.scale.set(s[1]-s[0],r[1]-r[0],o[1]-o[0]),this.highlight.position.set((s[0]+s[1])/2,(r[0]+r[1])/2,(o[0]+o[1])/2)}return!0}_arrow(t){let n=this.controls.camera.position.clone().sub(this.controls.target),s=ry(n,t);if(!s)return;let r=wh(n),o=r==="top"&&t==="up"||r==="bottom"&&t==="down";this._look(s,o)}_look(t,e=!1){let{controls:n}=this,s=n.camera.position.distanceTo(n.target);n.animateTo({position:t.clone().multiplyScalar(s).add(n.target),target:n.target.clone(),zoom:n.camera.zoom,overPole:e})}};var ay=` +#endif`;function Ai(i,t,e){let n=i.indexOf(t);if(n<0||i.indexOf(t,n+1)>=0)throw new Error(`The shader must contain '${t}' exactly once.`);return i.slice(0,n)+e+i.slice(n+t.length)}function kv(i){Object.assign(i.uniforms,this.userData.slotUniforms);let t=Ai(i.vertexShader,"#include ",`#include +${Nr}`);t=Ai(t,"#include ",`${Ur} +vTint = state.rgb;`),t=Ai(t,"#include ","vec3 objectNormal = ioOct( normal.xy );"),t=Ai(t,"#include ",zv),t=Ai(t,"#include ","vec3 transformed = slotPosition;"),t=Ai(t,"#include ",`#include +${_h}`),i.vertexShader=t;let e=Ai(i.fragmentShader,"#include ",`#include +varying vec3 vTint;`);e=Ai(e,"#include ","diffuseColor.rgb *= vTint;"),i.fragmentShader=e}function xh(i,t,e=!1){return i.userData.slotUniforms=t,i.onBeforeCompile=kv,i.index0AttributeName="q",e&&(i.defines={IO_NO_HIDE_BRANCH:""}),i}var bh=["materials","textures","white","wireframe"],Hv=[245,158,11],Vv=[235,235,237],Fr=4294967295,Xi=2048,vh=256,Gv=16,yh=1024,Wv=.1,Xv=8192,qv=1.4,il=2**-20,nl=17;function Yv(i,t){let[e,n,s,r,o,a,l,c,h]=i.subarray(t*12,t*12+9);return e*(o*h-a*c)-r*(n*h-s*c)+l*(n*a-s*o)<0}function $v(){this.array=null}function Tn(i,t,e=!1,n=Ae){return new n(i,t,e).onUpload($v)}var Br=class extends RangeError{constructor(t,e){super(`${t} drawable instances exceed the limit of ${e}.`),this.name="ModelTooLargeError",this.count=t,this.limit=e}},wf=(i,t)=>{for(let e=t*6;e=0?3:0)]+o*t[e+(o>=0?4:1)]+a*t[e+(a>=0?5:2)]+l<-(n+il*Math.abs(l)))return!0}return!1}function Ef(i,t,{min:e,max:n},s){let r=t*12,o=t*6;if(e[0]>n[0]||e[1]>n[1]||e[2]>n[2]){s.set(e,o),s.set(n,o+3);return}for(let a=0;a<3;a++){let l=i[r+a],c=i[r+a+3],h=i[r+a+6],d=i[r+a+9],u=l*e[0],f=l*n[0],g=c*e[1],_=c*n[1],m=h*e[2],p=h*n[2];s[o+a]=Math.min(u,f)+Math.min(g,_)+Math.min(m,p)+d,s[o+a+3]=Math.max(u,f)+Math.max(g,_)+Math.max(m,p)+d}}var Jv=i=>{let t=i.getHex(Te);return[t>>16&255,t>>8&255,t&255]},Or=class{constructor(t,e={}){let{meta:n}=t,s=n.instances,r=s.count,o=t.view(s.geometry),a=t.view(s.material),l=t.view(s.matrix),c=n.points,h=c?.count??0,d=r+h;this.root=new Re,this.elementCount=n.elements.length,this._elements=n.elements,this._meta=n,this._mode="materials",this._opacity=1,this._picking=!1,this._pickBounds=!0,this._instanceDetail=!0,this._pickFrustum=null,this._textures=new Map,this._elementOf=new Int32Array(d),this._elementOf.set(t.view(s.element)),this._bucketOf=new Uint32Array(r),this._visible=new Uint8Array(d).fill(1),this._layers=new Map,this._layerHides=new Uint8Array(d),this._highlight=new Uint8Array(d),this._highlighted=[],this._tint=new Map,this._boxes=new Float32Array(d*6),this._minPixels=0,this._viewHeight=1,this.visibleCost=0;let u=!!e.noHideBranch;if(this.slotUniforms={slotInfo:{value:null},slotState:{value:null}},this._buckets=this._createBuckets(n,a,u),h){this._elementOf.set(t.view(c.element),r),this._pointMaterials=t.view(c.material).slice();let g=t.view(c.geometry),_=t.view(c.matrix),m=this._boxes.subarray(r*6);for(let p=0;pthis._shown(e)?1:0)}instancesOf(t){return this._checkElement(t),this._elementInstances.subarray(this._elementStart[t],this._elementStart[t+1])}isVisible(t){this._checkElement(t);for(let e=this._elementStart[t];ethis._chunkCount){this._pickFrustum=hh(n,this._planes);let{x:r,y:o,z:a}=n.position;this._pickViewPadding=il*(Math.abs(r)+Math.abs(o)+Math.abs(a))}for(let r of this._units)r.mesh.material=t,s?(r.mesh.visible=(r.mesh.visible||!!r.lines?.visible)&&r.bucket.material.opacity>0,r.lines&&(r.lines.visible=!1)):this._showUnit(r);if(!s)for(let r of this._compactCells)this._cellAttributes(r,!1);try{return e()}finally{this._picking=!1,this._pickFrustum=null;for(let r of this._units)r.mesh.material=r.bucket.material,this._showUnit(r);for(let r of this._cut)r.mesh.visible=!1,r.lines&&(r.lines.visible=!1);if(!s)for(let r of this._compactCells)this._cellAttributes(r,!0)}}elementBox(t,e=new le){this._checkElement(t),e.makeEmpty();for(let n=this._elementStart[t];n=0&&t<=1))throw new RangeError(`Opacity must be within 0..1, got ${t}.`);this._opacity=t;for(let e of this._buckets)this._applyOpacity(e);this._changed("appearance")}get opacity(){return this._opacity}setDetail(t,e=1){this._minPixels=t,this._viewHeight=e;for(let s of this._cut)this._showUnit(s);this._cut.length=0;for(let s of this._detailCells)s.detailCount=null;this._detailCells.length=0;for(let s of this._compactCells)this._cellAttributes(s,!1);this._compactCells.length=0;let n=this._unitScale;this._unitScale=null,!(!(t>0)||!n)&&(this._cutInView=0,this._cutFrame=null,this._units.forEach((s,r)=>{if(!(!(n[r]>=0)||s.shown===0)){if(s.dirty&&this._span(s),s.cell&&this._detailUsesInstances){if(s.detailHigh>=t&&this._detailCell(s,t))return}else if(this._slotRadius[s.slotBase+s.first]*n[r]>=t)return;s.mesh.visible=!1,s.lines&&(s.lines.visible=!1),this._cut.push(s),this._cutInView+=Mh(s,s.first,s.last+1)}}))}_detailCell(t,e){if(t.detailLow>=e)return t.detailCount=Math.min(t.detailEnd,t.last+1),this._detailCells.push(t),!0;let{slotBase:n,last:s}=t,r=this._detailIndices,o=0,a=!1,l=!1;for(let u=0;u<=s;u++){let f=this._pixels[n+u];f<0||(fc.count;for(let u=0;u0?o[6]/m:1/0:o[6];d[f]=p;let b=g.cell&&this._detailUsesInstances,E=b&&!of(r,_[0],_[1],_[2],_[3]+g.pickPadding),v=g.slotBase+g.n,y=-1;if(b){let C=this._slotRadius[g.slotBase],D=this._slotRadius[v-1],U=m+_[3],F=Math.abs(o[3])*_[4]+Math.abs(o[4])*_[5]+Math.abs(o[5])*_[6],I=U-F-C,B=U+F-D,G=Math.fround(o[7]?I>0?C*o[6]/I:1/0:C*p),q=Math.fround(o[7]?B>0?D*o[6]/B:1/0:D*p);Us(q)===Us(G)&&(y=G)}if(y>=0&&!E){g.detailLow=g.detailHigh=y,g.detailEnd=g.n;let C=this._slotCost[g.slotBase]*g.shown;l[Us(y)]+=C,u+=C;continue}let S=0,A=1/0,x=-1,T=0;for(let C=g.slotBase;C=0){S++;continue}let N=(G-o[0])*o[3]+(q-o[1])*o[4]+(O-o[2])*o[5]-D;U=o[7]?N>0?o[6]/N:1/0:o[6]}let F=U===1/0?1/0:Math.fround(D*U);b&&(a[C]=F,A=Math.min(A,F),x=Math.max(x,F));let I=this._slotCost[C];l[Us(F)]+=I,u+=I}if(b){if(S){A=x=y;let C=S*this._slotCost[g.slotBase];l[Us(y)]+=C,u+=C}g.detailLow=A,g.detailHigh=x,g.detailEnd=T}}return this.visibleCost=u,af(l,u,n)}drawStats(){let t=-1/0;for(let r of this._units)t=Math.max(t,r.lastFrame);let e=0,n=this._cutFrame===t?this._cutInView:0,s=0;for(let r of this._units)r.lastFrame===t&&(n+=Mh(r,r.first,Math.max(r.last+1,r.first)),e+=Mh(r,r.first,Math.max(r.end,r.first)),s++);return{drawn:e,inView:n,draws:s}}drawnInstances(t){t.updateMatrixWorld();let e=new Fn().setFromProjectionMatrix(new Yt().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),n={info:{render:{frame:-1}}},s=new We,r=[];for(let o of this._units){let a=this._mode==="wireframe"&&!this._picking?o.lines:o.mesh;if(!(!a?.visible||!e.intersectsSphere(s.set(s.center.fromArray(o.sphere),o.sphere[3])))){a.onBeforeRender(n,null,t,a.geometry,a.material,null);for(let l=o.first;lo-a)}memory(){let t=this._units[this._chunkCount]?.slotBase??this._slotInstance.length;return{gpuBytes:this._mergedBytes+this._instancedBytes+this._lineBytes+this._stateBytes+this._detailBytes,mergedBytes:this._mergedBytes,instancedBytes:this._instancedBytes,stateBytes:this._stateBytes,lineBytes:this._lineBytes,detailBytes:this._detailBytes,detailSourceBytes:(this._slotInstance.length-t)*48,chunks:this._chunkCount,cells:this._units.length-this._chunkCount,mergedInstances:t,instancedInstances:this._slotInstance.length-t,triangles:this._triangles}}setClipping(t,e){for(let n of this._buckets)for(let s of[n.material,n.wire])s.clippingPlanes=t.length>0?t:null,s.clipIntersection=e,s.needsUpdate=!0;this._changed("clipping")}_build(t,e,n,s,r){let o=e.length,a=this._meta,l=new Map,c=O=>{let N=l.get(O);if(!N){let z=a.geometries[O],W=t.view(z.indices),k=z.uvs?t.view(z.uvs):null;N=Sf(Dr(t,z),z.q??null,hf(t,z),W,k),N.drawable=N.indices.length>=3&&N.min.every(Number.isFinite)&&N.max.every(Number.isFinite),l.set(O,N)}return N},h=new Uint8Array(o),d=new Float64Array(o*3),u=new Float32Array(o*3),f=new Uint32Array(o),g=new Float32Array(o),_=new Uint8Array(o),m=new Map,p=this._boxes;for(let O=0;OO-N).map(O=>{let N=m.get(O),z=c(e[N[0]]),W=this._buckets[this._bucketOf[N[0]]].texture!==null,k=[0,1,2].every(lt=>(z.max[lt]-z.min[lt])/En<=65535),K=z.vertices*((k?12:20)+(W?8:0))+z.indices.length*(z.vertices>65535?4:2);return{k:N.length,bytes:K,members:N,textured:W}}),v=s.mergedCap??mh,y=s.minRepeats??Gv;if(E.reduce((O,N)=>O+N.k*N.bytes,0)>v){let O=s.cellExtent==null?_f(p,f)*Wv:this.visibleBox().getSize(new L).length()*s.cellExtent;for(let N of E)N.k{if(S[N]){for(let z of O.leaves)T.push({shape:O,members:gh(z,g)});return}for(let z of O.members){x[e[z]]++;let W=this._bucketOf[z]*2+(h[z]===Fs?1:0),k=A.get(W);k||A.set(W,k=[]),k.push(z)}});let C=[];for(let O of[...A.keys()].sort((N,z)=>N-z))for(let N of pf(u,f,A.get(O),s.chunkVertices??uf))C.push(gh(N,g));let D=[...C,...T.map(O=>O.members)].reduce((O,N)=>O+N.length,0);if(D>r)throw new Br(D,r);let U=Math.max(1,Math.ceil(D/Xi)),F=new Float32Array(Xi*U*4);this._state=new Un(new Uint8Array(Xi*U*4),Xi,U),this._state.colorSpace=Te,this._state.onUpdate=()=>{this._fullPending=!1,this._pendingRanges=0},this._fullPending=!0,this._pendingRanges=0,this._dirty=new Uint32Array(vh),this._dirtyCount=0;let I=new Un(F,Xi,U,sn,Ye);I.needsUpdate=!0,I.onUpdate=()=>I.image.data=null,this.slotUniforms.slotInfo.value=I,this.slotUniforms.slotState.value=this._state,this._stateBytes=Xi*U*20,this._slotOf=new Uint32Array(this._visible.length).fill(Fr),this._slotInstance=new Uint32Array(D),this._slotUnit=new Uint32Array(D),this._slotRadius=new Float32Array(D),this._slotCost=new Float32Array(D),this._pixels=new Float32Array(D),this._planes=new Float64Array(24),this._detailView=new Float64Array(8),this._frameView=new Float64Array(8),this._frameViewAt=NaN,this._units=[],this._cut=[],this._detailCells=[],this._compactCells=[],this._detailIndices=new Uint16Array(yh),this._detailBins=new Float64Array(ch),this._detailBytes=0,this._unitScale=null,this._cutInView=0,this._cutFrame=-1,this._mergedBytes=0,this._instancedBytes=0,this._lineBytes=0;let B={matrices:n,geometryOf:e,mirrored:_,kind:h,origins:d,source:c,textured:!1};this._lineSources=new Map;let G=0;for(let O of C){let N=this._buckets[this._bucketOf[O[0]]];B.textured=N.texture!==null;let z=bf(O,B);for(let W=0;WO+N,0);let q=new Map;for(let{shape:O,members:N}of T){let z=N[0],W=c(e[z]),k=q.get(O);if(!k){let K=a.geometries[e[z]].bbox;k=this._shape(W,_[z]===1,O.textured);let lt=at=>Math.max(...at.map(Math.abs)),ht=Math.max(lt(W.min),lt(W.max));k.pickExtent=ht,k.pickPadding=Math.max(0,...W.min.map((at,Y)=>K.min[Y]-at),...W.max.map((at,Y)=>at-K.max[Y]))+(W.q?il*(lt(W.q.o)+65535*Math.abs(W.q.s)):0),q.set(O,k)}for(let K=0;KO+N,0)}_shape(t,e,n){let s=t.vertices,r=t.q?new Uint16Array(s*4):new Float32Array(s*4);for(let h=0;hn+p),1,!1,ei);a.setAttribute("slotBase",l),a.setIndex(s.index);let c=Af(this._boxes,e),h=new We(new L(c[0],c[1],c[2]),c[3]);a.boundingSphere=h;let d=new gi(a,t.material,0),u=new Float32Array(o*16),f=new Float32Array(o*12),g=0;for(let m=0;mthis._range(_,m,b,d),d.visible=!1,this.root.add(d),_}_chunk(t,e,n,s,r,o){let a=new Es;a.instanceCount=1,a.setAttribute("q",Tn(s.q,4)),a.setAttribute("normal",Tn(s.o,2,!0)),s.uv&&a.setAttribute("uv",Tn(s.uv,2)),a.setAttribute("slotBase",Tn(new Float32Array([n]),1,!1,ei)),a.setIndex(Tn(s.index,1));let l=Af(this._boxes,e);a.boundingSphere=new We(new L(l[0],l[1],l[2]),l[3]),this._mergedBytes+=s.q.byteLength+s.o.byteLength+(s.uv?.byteLength??0)+s.index.byteLength;let c=new _e(a,t.material),h={bucket:t,mesh:c,lines:null,slotBase:n,n:e.length,sphere:l,shown:0,first:0,last:-1,end:0,dirty:!1,cell:!1,starts:s.indexStart,vertices:s.q.length/4,f32:s.q instanceof Float32Array,members:e.slice(),lastFrame:-1/0};return c.onBeforeRender=(d,u,f)=>this._range(h,d,f,c),c.visible=!1,this.root.add(c),h}_buildLines(){if(!this._lineSources)return;let{mirrored:t,geometryOf:e}=this._lineMembers;for(let n of this._units){if(n.cell){let h=n.mesh.geometry.index;n.lines=new gi(n.mesh.geometry,n.bucket.wire,0),n.lines.instanceMatrix=n.mesh.instanceMatrix,n.lines.boundingSphere=n.mesh.boundingSphere,n.lines.onBeforeRender=(d,u,f)=>this._range(n,d,f,n.lines),this._lineBytes+=h.count*2*h.array.BYTES_PER_ELEMENT,this.root.add(n.lines);continue}let s=n.starts[n.n],r=tl(n.vertices,s*2),o=0,a=0;for(let h of n.members){let d=this._lineSources.get(e[h]),u=t[h]===1;for(let f=0;fthis._range(n,h,u,n.lines),this.root.add(n.lines),n.members=null}this._lineSources=null,this._lineMembers=null}_range(t,e,n,s){t.dirty&&this._span(t);let r=t.last+1;if(this._picking){if(t.cell&&this._pickFrustum){let o=this._state.image.data,a=t.pickPadding+this._pickViewPadding;for(;r>0;){let l=t.slotBase+r-1;if(o[l*4+3]&&!Zv(this._pickFrustum,this._boxes,this._slotInstance[l]*6,a))break;r--}}}else if(t.cell&&t.detailCount!==null)r=t.detailCount;else if(this._minPixels>0&&r>t.first){let o=e.info.render.frame;o!==this._frameViewAt&&(dh(n,this._viewHeight,this._frameView),this._frameViewAt=o);let a=this._frameView,l=Tf(a,t.sphere),c=a[7]?l>0?this._minPixels*l/a[6]:0:this._minPixels/a[6];r=Math.min(r,vf(this._slotRadius,t.slotBase+t.first,t.slotBase+r,c)-t.slotBase)}if(t.cell)s.count=Math.max(r,0);else{let o=s.isLineSegments?2:1,[a,l]=yf(t.starts,t.first,r);s.geometry.setDrawRange(a*o,l*o)}this._picking||(t.end=r,t.lastFrame=e.info.render.frame,this._cutFrame===null&&this._minPixels>0&&(this._cutFrame=t.lastFrame))}_span(t){let e=this._state.image.data,n=0;for(;n=n&&e[(t.slotBase+s)*4+3]===0;)s--;t.first=n0&&!e,t.lines&&(t.lines.visible=t.shown>0&&e)}_createBuckets(t,e,n){let s=new Map,r=[];for(let o=0;oMath.round(h*255)),opacity:c.opacity,texture:c.texture??null,material:xh(new Ss({side:Ne}),this.slotUniforms,n),wire:xh(new Ss({side:Ne,wireframe:!0}),this.slotUniforms,n)},this._applyOpacity(l),s.set(a,l),r.push(l)}this._bucketOf[o]=l.index}return r}_indexElements(){let t=new Uint32Array(this.elementCount+1);for(let s of this._elementOf)s>=0&&t[s+1]++;for(let s=0;s{s>=0&&(e[n[s]++]=r)}),this._elementStart=t,this._elementInstances=e}_texture(t){let e=this._textures.get(t);if(!e){let n=this._meta.textures[t],s=new Image;e=new He(s),e.colorSpace=Te,e.wrapS=e.wrapT=fs,e.repeat.set(1/n.sx,1/n.sy),s.onload=()=>{e.needsUpdate=!0,this._changed("appearance")},s.src=`data:${n.mime};base64,${n.data}`,this._textures.set(t,e)}return e}_applyOpacity(t){let e=t.opacity*this._opacity,n=e<1;for(let s of[t.material,t.wire])s.transparent!==n&&(s.needsUpdate=!0),s.opacity=e,s.transparent=n,s.depthWrite=!n}_colorOf(t){if(t>=this._bucketOf.length){let e=this._pointMaterials[t-this._bucketOf.length];return this._meta.materials[e].color.map(n=>Math.round(n*255))}return this._highlight[t]?Hv:this._tint.get(t)??(this._mode==="white"?Vv:this._buckets[this._bucketOf[t]].bytes)}_applyColor(t){let e=this._slotOf[t];e!==Fr&&(this._state.image.data.set(this._colorOf(t),e*4),this._markDirty(e))}_setInstanceVisible(t,e){this._visible[t]=e?1:0,this._draw(t)}_setLayerFlag(t,e,n){t[e]!==(n?1:0)&&(t[e]=n?1:0,this._layerHides[e]+=n?1:-1,this._draw(e))}_shown(t){return this._visible[t]===1&&this._layerHides[t]===0}_draw(t){let e=this._slotOf[t];if(e===Fr)return;let n=this._shown(t)?255:0,s=this._state.image.data;if(s[e*4+3]===n)return;s[e*4+3]=n,this._markDirty(e);let r=this._units[this._slotUnit[e]];r.shown+=n?1:-1,r.dirty=!0,this._showUnit(r)}_markDirty(t){this._dirtyCountvh)e.clearUpdateRanges(),this._fullPending=!0;else{for(let n=0;n=this.elementCount)throw new RangeError(`Element index ${t} is out of range 0..${this.elementCount-1}.`)}_expandBox(t,e){if(!wf(this._boxes,e))return;let n=this._boxes,s=e*6;t.min.set(Math.min(t.min.x,n[s]),Math.min(t.min.y,n[s+1]),Math.min(t.min.z,n[s+2])),t.max.set(Math.max(t.max.x,n[s+3]),Math.max(t.max.y,n[s+4]),Math.max(t.max.z,n[s+5]))}_changed(t){this._flush(),this.root.dispatchEvent({type:"change",detail:{kind:t}})}};function Mh(i,t,e){return e<=t?0:i.cell?(e-t)*i.triangles:(i.starts[e]-i.starts[t])/3}function Tf(i,t){return(t[0]-i[0])*i[3]+(t[1]-i[1])*i[4]+(t[2]-i[2])*i[5]-t[3]}function Af(i,t){let e=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(let a of t)for(let l=0;l<3;l++)e[l]=Math.min(e[l],i[a*6+l]),n[l]=Math.max(n[l],i[a*6+3+l]);let s=(n[0]-e[0])/2,r=(n[1]-e[1])/2,o=(n[2]-e[2])/2;return Float64Array.of((e[0]+n[0])/2,(e[1]+n[1])/2,(e[2]+n[2])/2,Math.hypot(s,r,o),s,r,o)}var sl=class{constructor(t){this.root=new Re,this._objects=[];let e=t.meta.points;if(this.count=e?.count??0,!this.count)return;let n=t.view(e.geometry),s=t.view(e.material),r=t.view(e.matrix);for(let o=0;o0?t:null}setOpacity(t){for(let e of this._objects)e.material.opacity=t,e.material.transparent=t<1}};function Kv(i,t){let e=t*12;return[i[e],i[e+1],i[e+2],0,i[e+3],i[e+4],i[e+5],0,i[e+6],i[e+7],i[e+8],0,i[e+9],i[e+10],i[e+11],1]}var jv={ru:{elements:"\u042D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",noGeometry:"\u041D\u0435\u0442 \u0433\u0435\u043E\u043C\u0435\u0442\u0440\u0438\u0438",contextLost:"\u0412\u0438\u0434\u0435\u043E\u043A\u0430\u0440\u0442\u0430 \u0441\u0431\u0440\u043E\u0448\u0435\u043D\u0430 \u2014 \u043F\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0443",noWebGL:"\u041D\u0443\u0436\u0435\u043D \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0441 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u043A\u043E\u0439 WebGL 2",badData:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C \u0434\u0430\u043D\u043D\u044B\u0435 \u043C\u043E\u0434\u0435\u043B\u0438",tooLarge:"\u041C\u043E\u0434\u0435\u043B\u044C \u0441\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u0430\u044F \u0434\u043B\u044F \u044D\u0442\u043E\u0433\u043E \u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0449\u0438\u043A\u0430: \u043E\u0431\u044A\u0435\u043A\u0442\u043E\u0432 \u0441 \u0433\u0435\u043E\u043C\u0435\u0442\u0440\u0438\u0435\u0439 \u2014 {count}, \u043F\u0440\u0435\u0434\u0435\u043B \u2014 {limit}",selected:"\u0412\u044B\u0431\u0440\u0430\u043D\u043E",close:"\u0417\u0430\u043A\u0440\u044B\u0442\u044C","scanMap.title":"\u041C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u0430","scanMap.plan":"\u041F\u043B\u0430\u043D \u043E\u0431\u043B\u0430\u043A\u0430 \u0442\u043E\u0447\u0435\u043A","scanMap.metres":"\u043C","scanMap.choosePhoto":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0444\u043E\u0442\u043E\u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0443\u2026","scanMap.spheres":"\u0421\u0444\u0435\u0440\u044B \u043F\u0430\u043D\u043E\u0440\u0430\u043C \u0432 3D","scanMap.photo":"\u0424\u043E\u0442\u043E\u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0430","scanMap.goToStation":"\u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u043A \u0441\u0442\u0430\u043D\u0446\u0438\u0438 {name}","scanMap.photoControls":"\u0424\u043E\u0442\u043E\u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0430. \u0421\u0442\u0440\u0435\u043B\u043A\u0438 \u043F\u043E\u0432\u043E\u0440\u0430\u0447\u0438\u0432\u0430\u044E\u0442 \u043A\u0430\u043C\u0435\u0440\u0443, \u043A\u043E\u043B\u0435\u0441\u043E \u043C\u0435\u043D\u044F\u0435\u0442 \u043C\u0430\u0441\u0448\u0442\u0430\u0431.","scanMap.loading":"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 \u0444\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u0438\u2026","scanMap.photoError":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0442\u043A\u0440\u044B\u0442\u044C \u0441\u0444\u0435\u0440\u0438\u0447\u0435\u0441\u043A\u0443\u044E \u0444\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u044E.","scanMap.enlargePhoto":"\u0423\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C","scanMap.shrinkPhoto":"\u0423\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C","scanMap.size":"\u0420\u0430\u0437\u043C\u0435\u0440 \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u044B","scanMap.small":"\u041C\u0430\u043B\u0430\u044F","scanMap.medium":"\u0421\u0440\u0435\u0434\u043D\u044F\u044F","scanMap.large":"\u0411\u043E\u043B\u044C\u0448\u0430\u044F","scanMap.zoomIn":"\u041F\u0440\u0438\u0431\u043B\u0438\u0437\u0438\u0442\u044C \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u0443","scanMap.zoomOut":"\u041E\u0442\u0434\u0430\u043B\u0438\u0442\u044C \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u0443","scanMap.reset":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0432\u0435\u0441\u044C \u043F\u043B\u0430\u043D","scanMap.levels":"\u0423\u0440\u043E\u0432\u043D\u0438 \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u044B","scanMap.allLevels":"\u0412\u0441\u0435 \u0432\u044B\u0441\u043E\u0442\u044B","scanMap.level":"\u0423\u0440\u043E\u0432\u0435\u043D\u044C {n}","scanMap.addLevel":"\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0443\u0440\u043E\u0432\u0435\u043D\u044C \u043F\u043E \u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0435","scanMap.removeLevel":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u044B\u0439 \u0443\u0440\u043E\u0432\u0435\u043D\u044C","scanMap.autoButton":"\u0410\u0432\u0442\u043E","scanMap.autoLevels":"\u041E\u043F\u0440\u0435\u0434\u0435\u043B\u0438\u0442\u044C \u0443\u0440\u043E\u0432\u043D\u0438 \u043F\u043E \u0432\u044B\u0441\u043E\u0442\u0430\u043C \u0441\u0442\u0430\u043D\u0446\u0438\u0439","scanMap.noLevels":"\u041D\u0435\u0442 \u044F\u0432\u043D\u043E \u0440\u0430\u0437\u0434\u0435\u043B\u0451\u043D\u043D\u044B\u0445 \u0433\u0440\u0443\u043F\u043F \u0441\u0442\u0430\u043D\u0446\u0438\u0439 \u043F\u043E \u0432\u044B\u0441\u043E\u0442\u0435.","scanMap.levelsAdded":"\u0423\u0440\u043E\u0432\u043D\u0438 \u043F\u043E \u0432\u044B\u0441\u043E\u0442\u0430\u043C \u0441\u0442\u0430\u043D\u0446\u0438\u0439 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u044B.","scanMap.levelsExist":"\u042D\u0442\u0438 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u044B \u0443\u0436\u0435 \u043E\u0445\u0432\u0430\u0447\u0435\u043D\u044B \u0443\u0440\u043E\u0432\u043D\u044F\u043C\u0438.","scanMap.levelAdded":"\u0423\u0440\u043E\u0432\u0435\u043D\u044C \u0441\u043E\u0437\u0434\u0430\u043D.","scanMap.levelTemporary":"\u0423\u0440\u043E\u0432\u043D\u0438 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B \u0434\u043E \u0437\u0430\u043A\u0440\u044B\u0442\u0438\u044F \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B.","scanMap.cancel":"\u041E\u0442\u043C\u0435\u043D\u0430","scanMap.pickLower":"\u0429\u0451\u043B\u043A\u043D\u0438\u0442\u0435 \u043F\u043E \u043D\u0438\u0436\u043D\u0435\u0439 \u043E\u0442\u043C\u0435\u0442\u043A\u0435 \u0443\u0440\u043E\u0432\u043D\u044F.","scanMap.pickUpper":"\u041D\u0438\u0437 {z}. \u0422\u0435\u043F\u0435\u0440\u044C \u0449\u0451\u043B\u043A\u043D\u0438\u0442\u0435 \u043F\u043E \u0432\u0435\u0440\u0445\u043D\u0435\u0439 \u043E\u0442\u043C\u0435\u0442\u043A\u0435.","scanMap.noLowerHit":"\u041D\u0430 \u043B\u0443\u0447\u0435 \u043D\u0435\u0442 \u0442\u043E\u0447\u0435\u043A \u043E\u0431\u043B\u0430\u043A\u0430. \u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043D\u0438\u0436\u043D\u044E\u044E \u043E\u0442\u043C\u0435\u0442\u043A\u0443 \u0440\u044F\u0434\u043E\u043C.","scanMap.noUpperHit":"\u041D\u0430 \u043B\u0443\u0447\u0435 \u043D\u0435\u0442 \u0442\u043E\u0447\u0435\u043A \u043E\u0431\u043B\u0430\u043A\u0430. \u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0435\u0440\u0445\u043D\u044E\u044E \u043E\u0442\u043C\u0435\u0442\u043A\u0443 \u0440\u044F\u0434\u043E\u043C.","scanMap.upperAboveLower":"\u0412\u0435\u0440\u0445\u043D\u044F\u044F \u043E\u0442\u043C\u0435\u0442\u043A\u0430 \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0432\u044B\u0448\u0435 {z}.",elementGroup:"\u042D\u043B\u0435\u043C\u0435\u043D\u0442",id:"Id",category:"\u041A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F",type:"\u0422\u0438\u043F",level:"\u0423\u0440\u043E\u0432\u0435\u043D\u044C",sourceId:"ID \u0438\u0441\u0442\u043E\u0447\u043D\u0438\u043A\u0430",link:"\u0421\u0432\u044F\u0437\u0430\u043D\u043D\u044B\u0439 \u0444\u0430\u0439\u043B",panels:"\u041F\u0430\u043D\u0435\u043B\u0438","panel.model":"\u041C\u043E\u0434\u0435\u043B\u044C","panel.views":"\u0412\u0438\u0434\u044B","panel.sections":"\u0421\u0435\u0447\u0435\u043D\u0438\u044F","panel.clashes":"\u041A\u043E\u043B\u043B\u0438\u0437\u0438\u0438","panel.bcf":"\u0422\u0435\u043C\u044B BCF","bcf.noView":"\u041D\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E\u0433\u043E \u0432\u0438\u0434\u0430","bcf.viewpoint":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432\u0438\u0434 {index}","bcf.components":"\u041D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E \u043A\u043E\u043C\u043F\u043E\u043D\u0435\u043D\u0442\u043E\u0432 \u2014 {missing}, \u043D\u0435\u043E\u0434\u043D\u043E\u0437\u043D\u0430\u0447\u043D\u044B\u0445 \u2014 {ambiguous}","panel.timeliner":"4D-\u0433\u0440\u0430\u0444\u0438\u043A","panel.links":"\u0421\u0432\u044F\u0437\u0430\u043D\u043D\u044B\u0435 \u0444\u0430\u0439\u043B\u044B","group.navigation":"\u041D\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044F","group.sections":"\u0421\u0435\u0447\u0435\u043D\u0438\u044F","group.measure":"\u0418\u0437\u043C\u0435\u0440\u0435\u043D\u0438\u044F","group.display":"\u041E\u0442\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435","group.view":"\u0412\u0438\u0434","tool.orbit":"\u0412\u0440\u0430\u0449\u0435\u043D\u0438\u0435","tool.pan":"\u041F\u0430\u043D\u043E\u0440\u0430\u043C\u0430","tool.fit":"\u0412\u043F\u0438\u0441\u0430\u0442\u044C \u0432\u0441\u0451","tool.projection":"\u041F\u0435\u0440\u0441\u043F\u0435\u043A\u0442\u0438\u0432\u0430 / \u043E\u0440\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u044F","tool.plane":"\u041F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u044C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","tool.box":"\u0411\u043E\u043A\u0441 \u0441\u0435\u0447\u0435\u043D\u0438\u044F","tool.resetSections":"\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","tool.distance":"\u0420\u0430\u0441\u0441\u0442\u043E\u044F\u043D\u0438\u0435","tool.displayMode":"\u0420\u0435\u0436\u0438\u043C \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F","tool.grids":"\u041E\u0441\u0438","tool.opacity":"\u041F\u0440\u043E\u0437\u0440\u0430\u0447\u043D\u043E\u0441\u0442\u044C","tool.fullscreen":"\u041F\u043E\u043B\u043D\u044B\u0439 \u044D\u043A\u0440\u0430\u043D",contextMenu:"\u041A\u043E\u043D\u0442\u0435\u043A\u0441\u0442\u043D\u043E\u0435 \u043C\u0435\u043D\u044E","menu.properties":"\u0421\u0432\u043E\u0439\u0441\u0442\u0432\u0430","menu.hide":"\u0421\u043A\u0440\u044B\u0442\u044C","menu.isolate":"\u0418\u0437\u043E\u043B\u0438\u0440\u043E\u0432\u0430\u0442\u044C","menu.showAll":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0432\u0441\u0451","menu.zoomTo":"\u041F\u0440\u0438\u0431\u043B\u0438\u0437\u0438\u0442\u044C \u043A \u043E\u0431\u044A\u0435\u043A\u0442\u0443","menu.sectionBox":"\u0411\u043E\u043A\u0441 \u0441\u0435\u0447\u0435\u043D\u0438\u044F \u043F\u043E \u043E\u0431\u044A\u0435\u043A\u0442\u0443","menu.copyId":"\u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C Id","menu.fitAll":"\u0412\u043F\u0438\u0441\u0430\u0442\u044C \u0432\u0441\u0451","menu.resetSections":"\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","menu.unavailable":"\u041D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E \u0434\u043B\u044F \u044D\u0442\u043E\u0439 \u043C\u043E\u0434\u0435\u043B\u0438",searchPlaceholder:"\u041F\u043E\u0438\u0441\u043A \u043F\u043E \u0438\u043C\u0435\u043D\u0438, \u0442\u0438\u043F\u0443, Id\u2026",noCategory:"\u0411\u0435\u0437 \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u0438",noMatches:"\u041D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E","filters.title":"\u0424\u0438\u043B\u044C\u0442\u0440\u044B","filters.model":"\u041C\u043E\u0434\u0435\u043B\u044C-\u0438\u0441\u0442\u043E\u0447\u043D\u0438\u043A","filters.noLevel":"\u0411\u0435\u0437 \u0443\u0440\u043E\u0432\u043D\u044F","filters.all":"\u0412\u0441\u0435","filters.clear":"\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C","filters.isolate":"\u0418\u0437\u043E\u043B\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u043E\u0432\u043F\u0430\u0434\u0435\u043D\u0438\u044F",idCopied:"Id \u0441\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D",copyFailed:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0441\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C Id",fullscreenUnavailable:"\u041F\u043E\u043B\u043D\u043E\u044D\u043A\u0440\u0430\u043D\u043D\u044B\u0439 \u0440\u0435\u0436\u0438\u043C \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D","face.front":"\u0421\u043F\u0435\u0440\u0435\u0434\u0438","face.back":"\u0421\u0437\u0430\u0434\u0438","face.left":"\u0421\u043B\u0435\u0432\u0430","face.right":"\u0421\u043F\u0440\u0430\u0432\u0430","face.top":"\u0421\u0432\u0435\u0440\u0445\u0443","face.bottom":"\u0421\u043D\u0438\u0437\u0443","cube.title":"\u041A\u0443\u0431 \u0432\u0438\u0434\u0430","cube.up":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u0432\u0435\u0440\u0445","cube.down":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u043D\u0438\u0437","cube.left":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u043B\u0435\u0432\u043E","cube.right":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u043F\u0440\u0430\u0432\u043E","cube.home":"\u0418\u0441\u0445\u043E\u0434\u043D\u044B\u0439 \u0432\u0438\u0434","sections.mode":"\u0420\u0435\u0436\u0438\u043C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","sections.planes":"\u041F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0438","sections.box":"\u0411\u043E\u043A\u0441","sections.off":"\u0412\u044B\u043A\u043B","sections.axis":"\u041E\u0441\u044C","sections.addPlane":"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u044C","sections.noPlanes":"\u041F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0435\u0439 \u043D\u0435\u0442","sections.rotated":"\u043F\u043E\u0432\u0451\u0440\u043D\u0443\u0442\u0430","sections.custom":"\u041F\u0440\u043E\u0438\u0437\u0432\u043E\u043B\u044C\u043D\u0430\u044F","sections.position":"\u041F\u043E\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0438","sections.flip":"\u0421\u043C\u0435\u043D\u0438\u0442\u044C \u0441\u0442\u043E\u0440\u043E\u043D\u0443","sections.enabled":"\u0412\u043A\u043B","sections.delete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u044C","sections.keepInside":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0432\u043D\u0443\u0442\u0440\u0438","sections.cutInside":"\u0412\u044B\u0440\u0435\u0437\u0430\u0442\u044C \u0432\u043D\u0443\u0442\u0440\u0438","sections.fitSelection":"\u041F\u043E \u0432\u044B\u0434\u0435\u043B\u0435\u043D\u043D\u043E\u043C\u0443","sections.showGizmo":"\u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u043C\u0430\u043D\u0438\u043F\u0443\u043B\u044F\u0442\u043E\u0440","sections.boxYaw":"\u041F\u043E\u0432\u043E\u0440\u043E\u0442 \u0432\u043E\u043A\u0440\u0443\u0433 Z","sections.fill":"\u0417\u0430\u043B\u0438\u0432\u043A\u0430 \u0441\u0440\u0435\u0437\u043E\u0432","sections.fillUnavailable":"\u0417\u0430\u043B\u0438\u0432\u043A\u0430 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0430 \u0431\u0435\u0437 \u0431\u0443\u0444\u0435\u0440\u0430 \u0442\u0440\u0430\u0444\u0430\u0440\u0435\u0442\u0430 WebGL","sections.maxPlanes":"\u041D\u0435 \u0431\u043E\u043B\u044C\u0448\u0435 6 \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0435\u0439","unit.m":"\u043C","display.materials":"\u041C\u0430\u0442\u0435\u0440\u0438\u0430\u043B\u044B","display.textures":"\u0422\u0435\u043A\u0441\u0442\u0443\u0440\u044B","display.white":"\u0411\u0435\u043B\u044B\u0439","display.wireframe":"\u041A\u0430\u0440\u043A\u0430\u0441","display.background":"\u0426\u0432\u0435\u0442 \u0444\u043E\u043D\u0430","display.backgroundReset":"\u0424\u043E\u043D \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E","opacity.label":"\u041D\u0435\u043F\u0440\u043E\u0437\u0440\u0430\u0447\u043D\u043E\u0441\u0442\u044C","opacity.value":"{value} %","views.tour":"\u0422\u0443\u0440 \u043F\u043E \u0432\u0438\u0434\u0430\u043C","views.stop":"\u041E\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u0442\u0443\u0440","clash.New":"\u041D\u043E\u0432\u0430\u044F","clash.Active":"\u0410\u043A\u0442\u0438\u0432\u043D\u0430\u044F","clash.Reviewed":"\u041F\u0440\u043E\u0432\u0435\u0440\u0435\u043D\u0430","clash.Approved":"\u0423\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u0430","clash.Resolved":"\u0423\u0441\u0442\u0440\u0430\u043D\u0435\u043D\u0430","task.construct":"\u0421\u0442\u0440\u043E\u0438\u0442\u0435\u043B\u044C\u0441\u0442\u0432\u043E","task.demolish":"\u0421\u043D\u043E\u0441","task.temporary":"\u0412\u0440\u0435\u043C\u0435\u043D\u043D\u043E\u0435","player.title":"4D-\u043F\u0440\u043E\u0438\u0433\u0440\u044B\u0432\u0430\u0442\u0435\u043B\u044C","player.play":"\u0412\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u0441\u0442\u0438","player.pause":"\u041F\u0430\u0443\u0437\u0430","player.date":"\u0414\u0430\u0442\u0430 \u0433\u0440\u0430\u0444\u0438\u043A\u0430","player.speed":"\u0421\u043A\u043E\u0440\u043E\u0441\u0442\u044C",truncated:"\u041F\u043E\u043A\u0430\u0437\u0430\u043D\u043E {meshes} \u0438\u0437 {total} \u043C\u0435\u0448\u0435\u0439: \u043C\u043E\u0434\u0435\u043B\u044C \u043E\u0431\u0440\u0435\u0437\u0430\u043D\u0430 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u043E\u0439 MaxMeshVertices"},en:{elements:"Elements",noGeometry:"No geometry",contextLost:"The graphics context was lost \u2014 reload the page",noWebGL:"This page needs a browser with WebGL 2",badData:"The model data could not be read",tooLarge:"The model is too large for this viewer: {count} objects with geometry, the limit is {limit}",selected:"Selected",close:"Close","scanMap.title":"Minimap","scanMap.plan":"Point cloud floor plan","scanMap.metres":"m","scanMap.choosePhoto":"Open photo panorama\u2026","scanMap.spheres":"Panorama spheres in 3D","scanMap.photo":"Photo panorama","scanMap.goToStation":"Move to station {name}","scanMap.photoControls":"Photo panorama. Arrow keys turn the camera, the wheel zooms.","scanMap.loading":"Loading photograph\u2026","scanMap.photoError":"Could not open the spherical photograph.","scanMap.enlargePhoto":"Enlarge","scanMap.shrinkPhoto":"Restore size","scanMap.size":"Minimap size","scanMap.small":"Small","scanMap.medium":"Medium","scanMap.large":"Large","scanMap.zoomIn":"Zoom in on minimap","scanMap.zoomOut":"Zoom out on minimap","scanMap.reset":"Fit the whole plan","scanMap.levels":"Minimap levels","scanMap.allLevels":"All heights","scanMap.level":"Level {n}","scanMap.addLevel":"Create level from panorama","scanMap.removeLevel":"Remove selected level","scanMap.autoButton":"Auto","scanMap.autoLevels":"Detect levels by station height","scanMap.noLevels":"Station heights have no clear groups.","scanMap.levelsAdded":"Levels added from station heights.","scanMap.levelsExist":"Existing levels already cover these height ranges.","scanMap.levelAdded":"Level created.","scanMap.levelTemporary":"Levels will stay available until you close this page.","scanMap.cancel":"Cancel","scanMap.pickLower":"Click the lower level elevation.","scanMap.pickUpper":"Lower elevation {z}. Now click the upper elevation.","scanMap.noLowerHit":"No scan points along that ray. Choose a nearby lower elevation.","scanMap.noUpperHit":"No scan points along that ray. Choose a nearby upper elevation.","scanMap.upperAboveLower":"The upper elevation must be above {z}.",elementGroup:"Element",id:"Id",category:"Category",type:"Type",level:"Level",sourceId:"Source ID",link:"Link",panels:"Panels","panel.model":"Model","panel.views":"Views","panel.sections":"Sections","panel.clashes":"Clashes","panel.bcf":"BCF topics","bcf.noView":"No view available","bcf.viewpoint":"Open viewpoint {index}","bcf.components":"Components missing \u2014 {missing}, ambiguous \u2014 {ambiguous}","panel.timeliner":"4D schedule","panel.links":"Linked files","group.navigation":"Navigation","group.sections":"Sections","group.measure":"Measure","group.display":"Display","group.view":"View","tool.orbit":"Orbit","tool.pan":"Pan","tool.fit":"Fit all","tool.projection":"Perspective / orthographic","tool.plane":"Section plane","tool.box":"Section box","tool.resetSections":"Reset sections","tool.distance":"Distance","tool.displayMode":"Display mode","tool.grids":"Grids","tool.opacity":"Transparency","tool.fullscreen":"Full screen",contextMenu:"Context menu","menu.properties":"Properties","menu.hide":"Hide","menu.isolate":"Isolate","menu.showAll":"Show all","menu.zoomTo":"Zoom to object","menu.sectionBox":"Section box around object","menu.copyId":"Copy Id","menu.fitAll":"Fit all","menu.resetSections":"Reset sections","menu.unavailable":"Unavailable for this model",searchPlaceholder:"Search by name, type, Id\u2026",noCategory:"No category",noMatches:"No matches","filters.title":"Filters","filters.model":"Source model","filters.noLevel":"No level","filters.all":"All","filters.clear":"Clear","filters.isolate":"Isolate matches",idCopied:"Id copied",copyFailed:"Could not copy Id",fullscreenUnavailable:"Fullscreen is not available","face.front":"Front","face.back":"Back","face.left":"Left","face.right":"Right","face.top":"Top","face.bottom":"Bottom","cube.title":"View cube","cube.up":"Rotate up","cube.down":"Rotate down","cube.left":"Rotate left","cube.right":"Rotate right","cube.home":"Home view","sections.mode":"Section mode","sections.planes":"Planes","sections.box":"Box","sections.off":"Off","sections.axis":"Axis","sections.addPlane":"Add plane","sections.noPlanes":"No planes","sections.rotated":"rotated","sections.custom":"Custom","sections.position":"Plane position","sections.flip":"Flip side","sections.enabled":"On","sections.delete":"Delete plane","sections.keepInside":"Show inside","sections.cutInside":"Cut inside","sections.fitSelection":"Fit to selection","sections.showGizmo":"Show gizmo","sections.boxYaw":"Rotation around Z","sections.fill":"Fill cut faces","sections.fillUnavailable":"Section fill requires a WebGL stencil buffer","sections.maxPlanes":"At most 6 planes","unit.m":"m","display.materials":"Materials","display.textures":"Textures","display.white":"White","display.wireframe":"Wireframe","display.background":"Background color","display.backgroundReset":"Reset background","opacity.label":"Opacity","opacity.value":"{value}%","views.tour":"Play tour","views.stop":"Stop tour","clash.New":"New","clash.Active":"Active","clash.Reviewed":"Reviewed","clash.Approved":"Approved","clash.Resolved":"Resolved","task.construct":"Construct","task.demolish":"Demolish","task.temporary":"Temporary","player.title":"4D player","player.play":"Play","player.pause":"Pause","player.date":"Schedule date","player.speed":"Speed",truncated:"Showing {meshes} of {total} meshes: the model was truncated by the MaxMeshVertices setting"}},ri=(globalThis.navigator?.language??"").toLowerCase().startsWith("ru")?"ru":"en",zr=new Intl.NumberFormat(ri).format;function $(i,t=ri){let e=jv[t][i];if(e===void 0)throw new Error(`Missing UI string '${i}'.`);return e}var Rf=new L(0,0,1),rl=Math.PI/2-.01;function If(i,t,e=4){return Math.hypot(t.x-i.x,t.y-i.y)<=e}function Pf(i,t,e,n,s,r){let o=i.clone().sub(e),a=t.clone().sub(e),l=d=>(o.applyQuaternion(d),a.applyQuaternion(d));l(new Le().setFromAxisAngle(Rf,-n*r));let c=a.clone().sub(o).normalize(),h=c.clone().cross(Rf);if(h.lengthSq()>1e-12){let d=Math.asin(ae.clamp(c.z,-1,1)),u=ae.clamp(s*r,d-rl,d+rl);l(new Le().setFromAxisAngle(h.normalize(),-u))}return{position:o.add(e),target:a.add(e)}}function Lf(i,t,e,n){let s=r=>r.clone().sub(e).multiplyScalar(n).add(e);return{position:s(i),target:s(t)}}var Qv=.85,ty=100/3;function Df(i,t,e){let n=i*(t===1?ty:t===2?e:1);return ae.clamp(Qv**(-n/100),.5,2)}var Sh=(i,t)=>t>=i?"window":"crossing";function Nf(i,t,e){let n=Cf(i.position,i.target),s=Cf(t.position,t.target),r=n.azimuth??s.azimuth??0,o=s.azimuth??r,a=ae.euclideanModulo(o-r+Math.PI,2*Math.PI)-Math.PI,l=(_,m)=>_+(m-_)*e,c=r+a*e,h=ae.clamp(l(n.elevation,s.elevation),-rl,rl),d=l(n.distance,s.distance),u=i.target.clone().lerp(t.target,e),f=Math.cos(h)*d;return{position:u.clone().add(new L(f*Math.cos(c),f*Math.sin(c),Math.sin(h)*d)),target:u}}function Uf(i,t,e,n){let s=i.position.clone().sub(i.target),r=t.position.clone().sub(t.target),o=s.length(),a=r.length();s.normalize(),r.normalize();let l=new Le().setFromUnitVectors(s,r),c=e.clone().applyQuaternion(l),h=new L().setFromMatrixColumn(new Yt().lookAt(t.position,t.target,n),1),d=r.dot(new L().crossVectors(c,h)),u=Math.atan2(Math.abs(d)<1e-9?0:d,c.dot(h)),f=new Le;return g=>{f.identity().slerp(l,g);let _=s.clone().applyQuaternion(f),m=i.target.clone().lerp(t.target,g),p=_.clone().multiplyScalar(ae.lerp(o,a,g)).add(m),b=e.clone().applyQuaternion(f).applyAxisAngle(_,u*g);return{position:p,target:m,up:b}}}function Cf(i,t){let e=i.clone().sub(t),n=e.length(),s=Math.hypot(e.x,e.y);return{distance:n,elevation:n>1e-12?Math.asin(ae.clamp(e.z/n,-1,1)):0,azimuth:s>1e-9*Math.max(n,1e-12)?Math.atan2(e.y,e.x):null}}var ey=.005,ny=new L(1,-1,.8).normalize(),Eh=.01,Ff=1e-6,iy=64,Bf=1.05,sy=5e3,wh=(i,t)=>new CustomEvent(i,{detail:t});function Of({bbox:i,grids:t}){let e=r=>Array.isArray(r)&&r.length===3&&r.every(Number.isFinite);if(!e(i?.min)||!e(i?.max))return!0;let n=new le(new L(...i.min),new L(...i.max));if(n.isEmpty())return!0;let s=new L;for(let r of t??[])for(let o of Ir(r)){if(!e(o))return!0;n.expandByPoint(s.fromArray(o))}return n.getSize(s).length()*Bf>Eh*sy}var ol=class extends EventTarget{constructor(t,e,{pick:n=()=>null,visibleBox:s=()=>new le}={}){super(),this.dom=e,this.pick=n,this.visibleBox=s,this.target=new L,this.leftButtonMode="orbit",this._perspective=t,this._defaultFov=t.fov,this._orthographic=new zn(-1,1,1,-1),this.camera=t,this._drag=null,this._wheelPick=null,this._animation=0,this._overlay=null,this._bounds=null,this._extraBounds=new Map,e.style.touchAction="none",e.addEventListener("pointerdown",r=>this._down(r)),e.addEventListener("pointermove",r=>this._move(r)),e.addEventListener("pointerup",r=>this._up(r)),e.addEventListener("pointercancel",()=>this._end()),e.addEventListener("lostpointercapture",r=>this._lostCapture(r)),window.addEventListener("blur",()=>this._end()),e.addEventListener("wheel",r=>this._wheel(r),{passive:!1}),e.addEventListener("contextmenu",r=>r.preventDefault())}setLeftButtonMode(t){if(t!=="orbit"&&t!=="pan")throw new RangeError(`Unknown left button mode: ${t}`);this.leftButtonMode=t}setProjection(t){if(t!=="perspective"&&t!=="orthographic")throw new RangeError(`Unknown projection: ${t}`);let e=t==="perspective"?this._perspective:this._orthographic,n=this.camera;if(e!==n){this._stopAnimation(),e.position.copy(n.position),n.isOrthographicCamera&&e.position.sub(this.target).divideScalar(n.zoom).add(this.target),e.zoom=1,e.quaternion.copy(n.quaternion),e.up.copy(n.up),n.parent?.add(e),n.parent?.remove(n);for(let s of[...n.children])e.add(s);this.camera=e,this.resize()}}resize(){let t=this.camera,e=this.dom.clientWidth/Math.max(this.dom.clientHeight,1),n=Math.max(t.position.distanceTo(this.target),1e-6);if(t.isPerspectiveCamera)t.aspect=e;else{let r=n*Math.tan(ae.degToRad(this._perspective.fov/2));Object.assign(t,{top:r,bottom:-r,left:-r*e,right:r*e})}let s=this._rangeSphere();if(s){let r=s.center.clone().sub(t.position),o=new L(0,0,-1).applyQuaternion(t.quaternion);t.far=Math.max(1e-6,(r.length()+s.radius)*Bf);let a=r.dot(o)-s.radius;t.near=Math.max(a*.95,Math.min(Eh,t.far/2))}t.updateProjectionMatrix(),this.dispatchEvent(new Event("change"))}setExtraBounds(t,e){e&&!e.isEmpty()?this._extraBounds.set(t,e.clone()):this._extraBounds.delete(t),this.resize()}_rangeSphere(){let t=this._visibleBounds()?.sphere??null;if(this._extraBounds.size===0)return t;let e=t?this._bounds.box.clone():new le;for(let n of this._extraBounds.values())e.union(n);return e.getBoundingSphere(new We)}invalidateBounds(){this._bounds=null}_visibleBounds(){if(!this._bounds){let t=this.visibleBox();this._bounds={box:t,sphere:t.isEmpty()?null:t.getBoundingSphere(new We)}}return this._bounds.sphere&&this._bounds}fitBox(t,e=!0){if(t.isEmpty())return;let n=t.getBoundingSphere(new We),s=Math.max(n.radius,.001),r=ae.degToRad(this._perspective.fov/2),o=this.dom.clientWidth/Math.max(this.dom.clientHeight,1),a=s/Math.sin(Math.min(r,Math.atan(Math.tan(r)*o))),l=this.camera.position.clone().sub(this.target);l.lengthSq()<1e-12&&l.copy(ny);let c=l.normalize().multiplyScalar(a).add(n.center);e?this.animateTo({position:c,target:n.center}):(this.camera.zoom=1,this._set(c,n.center))}zoomToBox(t){this.fitBox(t,!0)}resetCameraStyle(){this._perspective.fov=this._defaultFov,this.camera.up.set(0,0,1)}restoreViewCamera({position:t,target:e,up:n,fov:s,orthographicHeight:r}){let o=new L(...t),a=new L(...e);if(this.resetCameraStyle(),!n){this.animateTo({position:o,target:a});return}this._stopAnimation(),this.camera.up.fromArray(n),this._perspective.fov=s??this._defaultFov;let l=Math.max(o.distanceTo(a),1e-6);this.camera.zoom=r==null?1:2*l*Math.tan(ae.degToRad(this._perspective.fov/2))/r,this._set(o,a)}animateTo({position:t,target:e,zoom:n=1,overPole:s=!1},r=400){this._stopAnimation();let o={position:this.camera.position.clone(),target:this.target.clone()},a={position:t??o.position,target:e??o.target},l=this.camera.zoom,c=s?Uf(o,a,new L(0,1,0).applyQuaternion(this.camera.quaternion),this.camera.up):u=>Nf(o,a,u),h=performance.now(),d=u=>{let f=Math.min((u-h)/r,1),g=f*f*(3-2*f),_=c(g);this.camera.isOrthographicCamera&&(this.camera.zoom=ae.lerp(l,n,g)),this._set(_.position,_.target,_.up),this._animation=f<1?requestAnimationFrame(d):0};this._animation=requestAnimationFrame(d)}get animating(){return this._animation!==0}_stopAnimation(){cancelAnimationFrame(this._animation),this._animation=0}_set(t,e,n){if(this.camera.position.copy(t),this.target.copy(e),n){let s=this.camera.up.clone();this.camera.up.copy(n),this.camera.lookAt(e),this.camera.up.copy(s)}else this.camera.lookAt(e);this.resize()}_down(t){this._end(),this._stopAnimation(),this.dom.setPointerCapture(t.pointerId),t.preventDefault();let e=t.button===0&&t.shiftKey?"box":t.button===0&&this.leftButtonMode==="orbit"?"orbit":"pan",n={x:t.clientX,y:t.clientY},s=null;e==="orbit"&&(s=this.pick(n.x,n.y),s||(s=this._visibleBounds()?.sphere.center.clone()??this.target.clone())),this._drag={id:t.pointerId,button:t.button,mode:e,pivot:s,down:n,last:n,moved:!1}}_anchor(t,e){let n=this.pick(t,e);if(n)return n;let s=this.dom.getBoundingClientRect(),r=s.left+s.width/2,o=s.top+s.height/2;return t===r&&e===o?null:this.pick(r,o)}_gestureDepth(t,e){let n=this.camera,s=t?t.clone().sub(n.position).dot(e):0;return Math.max(Ff,n.position.distanceTo(this.target),s)}_move(t){let e=this._drag;if(!e||t.pointerId!==e.id)return;if(t.buttons===0)return this._end();let n={x:t.clientX,y:t.clientY};if(!e.moved&&If(e.down,n))return;e.moved=!0;let s=n.x-e.last.x,r=n.y-e.last.y;if(e.last=n,e.mode==="box")this._drawRect(e.down,n);else if(e.mode==="orbit"){let o=Pf(this.camera.position,this.target,e.pivot,s,r,ey);this._set(o.position,o.target)}else this._pan(s,r)}_pan(t,e){let n=this.camera,s=Math.max(this.dom.clientHeight,1);if(n.isPerspectiveCamera&&this._drag.depth===void 0){let{x:c,y:h}=this._drag.down;this._drag.depth=this._gestureDepth(this._anchor(c,h),n.getWorldDirection(new L))}let r=n.isPerspectiveCamera?2*this._drag.depth*Math.tan(ae.degToRad(n.fov/2))/(s*n.zoom):(n.top-n.bottom)/n.zoom/s,o=new L(1,0,0).applyQuaternion(n.quaternion),a=new L(0,1,0).applyQuaternion(n.quaternion),l=o.multiplyScalar(-t*r).addScaledVector(a,e*r);this._set(n.position.clone().add(l),this.target.clone().add(l))}_up(t){let e=this._drag;if(!e||t.pointerId!==e.id||t.button!==e.button)return;let n={x:t.clientX,y:t.clientY};if(this._end(),e.mode==="box"&&e.moved){let s={x:Math.min(e.down.x,n.x),y:Math.min(e.down.y,n.y),width:Math.abs(n.x-e.down.x),height:Math.abs(n.y-e.down.y)},r=Sh(e.down.x,n.x);this.dispatchEvent(wh("boxselect",{rect:s,mode:r,ctrl:t.ctrlKey,shift:t.shiftKey}))}else!e.moved&&e.button===0?this.dispatchEvent(wh("click",{x:n.x,y:n.y,button:0,ctrl:t.ctrlKey,shift:t.shiftKey})):!e.moved&&e.button===2&&this.dispatchEvent(wh("contextmenu",{x:n.x,y:n.y}))}_lostCapture(t){this._drag&&t.buttons?this.dom.setPointerCapture(this._drag.id):this._end()}_end(){this._drag=null,this._overlay?.remove(),this._overlay=null}_drawRect(t,e){this._overlay||(this._overlay=document.createElement("div"),Object.assign(this._overlay.style,{position:"fixed",pointerEvents:"none",border:"1px solid #2563eb",background:"rgba(37,99,235,0.12)"}),(this.dom.parentElement??document.body).appendChild(this._overlay)),Object.assign(this._overlay.style,{borderStyle:Sh(t.x,e.x)==="window"?"solid":"dashed",left:`${Math.min(t.x,e.x)}px`,top:`${Math.min(t.y,e.y)}px`,width:`${Math.abs(e.x-t.x)}px`,height:`${Math.abs(e.y-t.y)}px`})}_wheel(t){if(t.preventDefault(),t.deltaY===0)return;this._stopAnimation();let e=Df(t.deltaY,t.deltaMode,this.dom.clientHeight),n=this.camera,s=n.position.distanceTo(this.target),r=this._visibleBounds()?.sphere.radius??0,o=iy*Math.max(r,.001);if(n.isOrthographicCamera){let{left:_,top:m,width:p,height:b}=this.dom.getBoundingClientRect();if(!p||!b)return;let E=ae.clamp(n.zoom/e,Math.max(1e-6,Math.min(n.zoom,s/o)),1e6);if(E===n.zoom)return;let v=new L((2*(t.clientX-_)/p-1)*n.right,(1-2*(t.clientY-m)/b)*n.top,0).multiplyScalar(1/n.zoom-1/E).applyQuaternion(n.quaternion);n.zoom=E,this._set(n.position.clone().add(v),this.target.clone().add(v));return}this._wheelPick||(this._wheelPick={point:this._anchor(t.clientX,t.clientY)},requestAnimationFrame(()=>this._wheelPick=null));let a=n.getWorldDirection(new L),l=this._gestureDepth(this._wheelPick.point,a);if(!Number.isFinite(l))return;let c=Math.min(Eh,Math.max(Ff,r)),h=ae.clamp(l*e,c,Math.max(l,o))/l;if(h===1)return;let d=n.position.clone().addScaledVector(a,l),u=this._wheelPick.point,f=u&&u.clone().sub(n.position).dot(a)>=c?u:d,g=Lf(n.position,d,f,h);this._set(g.position,g.target)}};function et(i,t,e){let n=document.createElement(i);return t&&(n.className=t),e!==void 0&&(n.textContent=e),n}function Qe(i,t,e){let n=et("button",i);return n.type="button",n.innerHTML=t,n.title=e,n.setAttribute("aria-label",e),n}function Bs(i){i.preventDefault(),i.stopPropagation()}function al(i){Bs(i);let t=i.button===2,e=()=>{window.removeEventListener("pointerup",n,!0),setTimeout(()=>{window.removeEventListener("click",Bs,!0),t&&window.removeEventListener("contextmenu",Bs,!0)})},n=s=>{Bs(s),e()};window.addEventListener("pointerup",n,!0),window.addEventListener("click",Bs,!0),t&&window.addEventListener("contextmenu",Bs,!0)}function kr(i,t,e,n){let s=t.clone().applyMatrix4(e.matrixWorldInverse).z<0,r=t.clone().project(e);i.hidden=!(s&&Math.abs(r.x)<=1&&Math.abs(r.y)<=1),!i.hidden&&(i.style.left=`${n.left+(r.x+1)/2*n.width}px`,i.style.top=`${n.top+(1-r.y)/2*n.height}px`)}var Me=i=>``,zf='',ne={model:Me(''),views:Me(''),sections:Me(''),clashes:Me(''),bcf:Me(''),timeliner:Me(''),links:Me(''),orbit:Me(''),pan:Me(''),fit:Me(''),projection:Me(zf),plane:Me(''),box:Me(`${zf}`),resetSections:Me(''),distance:Me(''),displayMode:Me(''),grids:Me(''),opacity:Me(''),fullscreen:Me(''),close:Me(''),chevron:Me(''),flip:Me(''),remove:Me(''),play:Me(''),pause:Me(''),home:Me('')};var Hr=new L(0,0,1),cn={right:new L(1,0,0),left:new L(-1,0,0),back:new L(0,1,0),front:new L(0,-1,0),top:new L(0,0,1),bottom:new L(0,0,-1)},ry={right:Hr,left:Hr,back:Hr,front:Hr,top:cn.back,bottom:cn.front},qi=.7,oy=ae.degToRad(1),kf=.01,Hf=96,ll=1.75;function Vf(i){let t=i.split("-"),e=new L;for(let n of t){if(!Object.hasOwn(cn,n))throw new RangeError(`Unknown view cube region: ${i}`);e.add(cn[n])}if(new Set(t).size!==t.length||e.lengthSq()!==t.length)throw new RangeError(`Unknown view cube region: ${i}`);return e.normalize()}function ay(i){let t=[];return Math.abs(i.z)>=qi&&t.push(i.z>0?"top":"bottom"),Math.abs(i.y)>=qi&&t.push(i.y>0?"back":"front"),Math.abs(i.x)>=qi&&t.push(i.x>0?"right":"left"),t.join("-")}function Th(i,t=oy){let e=i.clone().normalize(),n=Math.cos(t);return Object.keys(cn).find(s=>e.dot(cn[s])>=n)??null}function Gf(i){let t=new L(i.x,i.y,0);if(t.lengthSq()<1e-24)return"front";t.normalize();let e=["front","right","back","left"],n=Math.max(...e.map(s=>t.dot(cn[s])));return e.find(s=>t.dot(cn[s])>=n-1e-9)}function Ah(i,t){return cn[Gf(t)].clone().multiplyScalar(Math.sin(kf)).addScaledVector(cn[i],Math.cos(kf))}function ly(i,t){let e=Th(i);if(!e)return null;let n=e==="top"||e==="bottom";if(t==="left"||t==="right")return(n?Ah(e,i):Vf(e)).applyAxisAngle(Hr,t==="right"?Math.PI/2:-Math.PI/2);if(t!=="up"&&t!=="down")throw new RangeError(`Unknown arrow: ${t}`);if(!n)return Ah(t==="up"?"top":"bottom",i);let s=cn[Gf(i)];return t==="up"==(e==="top")?s.clone().negate():s.clone()}function cy(i,t){let e=document.createElement("canvas");e.width=e.height=128;let n=e.getContext("2d");n.fillStyle="#2a2f38",n.fillRect(0,0,128,128),n.fillStyle="#cbd5e1",n.textAlign="center",n.textBaseline="middle",n.font=`600 26px ${t}`;let s=n.measureText(i).width;s>112&&(n.font=`600 ${Math.floor(2912/s)}px ${t}`),n.fillText(i,64,64);let r=new sr(e);return r.colorSpace=Te,r}var cl=class{constructor(t,e,n){this.controls=n,this.home={position:e.position.clone(),target:n.target.clone()},this.element=et("div","ioviewer-viewcube"),this.canvas=et("canvas","ioviewer-viewcube-canvas"),this.canvas.title=$("cube.title"),this.canvas.setAttribute("aria-label",$("cube.title")),this.element.append(this.canvas),this.error=null,this.renderer=this._createRenderer(),this.scene=new ti,this.camera=new zn(-ll,ll,ll,-ll,.1,10),this.faces=new Re;let s=getComputedStyle(t).fontFamily;for(let[l,c]of Object.entries(cn)){let h=$(`face.${l}`),d=new _e(new Mn(2,2),new Ke({map:cy(h,s)})),u=ry[l];d.quaternion.setFromRotationMatrix(new Yt().makeBasis(u.clone().cross(c),u,c)),d.position.copy(c),d.name=l,d.userData.label=h,this.faces.add(d)}let r=new yn(new zi(new dn(2,2,2)),new an({color:"#5b6575"}));this.highlight=new _e(new dn(1,1,1),new Ke({color:"#2563eb",transparent:!0,opacity:.6})),this.highlight.visible=!1,this.scene.add(this.faces,r,this.highlight),this._raycaster=new kn,this.hovered=null,this._pointer=null,this.element.addEventListener("contextmenu",l=>l.preventDefault());let o=l=>{this._pointer=[l.clientX,l.clientY],this._hover(this.regionAtClient(...this._pointer))&&this._render()};this.canvas.addEventListener("pointerenter",o),this.canvas.addEventListener("pointermove",o),this.canvas.addEventListener("pointerleave",()=>{this._pointer=null,this._hover(null)&&this._render()}),this.canvas.addEventListener("click",l=>{let c=this.regionAtClient(l.clientX,l.clientY);if(!c)return;let h=c==="top"||c==="bottom";this._look(h?Ah(c,n.camera.position.clone().sub(n.target)):Vf(c))}),this.arrows=["up","down","left","right"].map(l=>{let c=Qe("ioviewer-viewcube-arrow",ne.chevron,$(`cube.${l}`));return c.dataset.arrow=l,c.addEventListener("click",h=>{h.detail&&c.blur(),this._arrow(l)}),c});let a=Qe("ioviewer-viewcube-home",ne.home,$("cube.home"));a.addEventListener("click",l=>{l.detail&&a.blur(),n.resetCameraStyle(),n.animateTo({position:this.home.position.clone(),target:this.home.target.clone()})}),this.element.append(...this.arrows,a),t.append(this.element),this.update()}_createRenderer(){this.canvas.addEventListener("webglcontextlost",e=>{e.stopImmediatePropagation(),this._fail(new Error("The view cube lost its WebGL context."))});let t=this.canvas.getContext("webgl2",{alpha:!0,antialias:!0});if(!t)return this._fail(new Error("WebGL 2 is not available for the view cube."));try{let e=new Ei({canvas:this.canvas,context:t,alpha:!0,antialias:!0});return e.setPixelRatio(window.devicePixelRatio),e.setSize(Hf,Hf),e}catch(e){return this._fail(e)}}_fail(t){return this.error=t,this.renderer=null,this.element.hidden=!0,null}_render(){if(this.renderer)try{this.renderer.render(this.scene,this.camera)}catch(t){this._fail(t)}}update(){if(!this.renderer)return;let t=this.controls.camera,e=!this.camera.quaternion.equals(t.quaternion);this.camera.quaternion.copy(t.quaternion),this.camera.position.set(0,0,5).applyQuaternion(t.quaternion),this.camera.updateMatrixWorld();let n=Th(t.position.clone().sub(this.controls.target))!==null;for(let s of this.arrows)s.hidden=!n;e&&this._pointer&&this._hover(this.regionAtClient(...this._pointer)),this._render()}regionAtClient(t,e){let n=this.canvas.getBoundingClientRect(),s=new Xt((t-n.left)/n.width*2-1,1-(e-n.top)/n.height*2);this._raycaster.setFromCamera(s,this.camera);let r=this._raycaster.intersectObjects(this.faces.children)[0];return r?ay(r.point):null}_hover(t){if(t===this.hovered)return!1;if(this.hovered=t,this.highlight.visible=!!t,t){let e=t.split("-").reduce((a,l)=>a.add(cn[l]),new L),n=a=>a===0?[-qi,qi]:a>0?[qi,1.02]:[-1.02,-qi],[s,r,o]=e.toArray().map(n);this.highlight.scale.set(s[1]-s[0],r[1]-r[0],o[1]-o[0]),this.highlight.position.set((s[0]+s[1])/2,(r[0]+r[1])/2,(o[0]+o[1])/2)}return!0}_arrow(t){let n=this.controls.camera.position.clone().sub(this.controls.target),s=ly(n,t);if(!s)return;let r=Th(n),o=r==="top"&&t==="up"||r==="bottom"&&t==="down";this._look(s,o)}_look(t,e=!1){let{controls:n}=this,s=n.camera.position.distanceTo(n.target);n.animateTo({position:t.clone().multiplyScalar(s).add(n.target),target:n.target.clone(),zoom:n.camera.zoom,overPole:e})}};var hy=` #include -${Cr} +${Nr} #include #include varying vec3 vPos; @@ -4263,7 +4263,7 @@ varying vec2 vSlot; varying float vViewDepth; #endif void main() { - ${Ir} + ${Ur} vec3 transformed = slotPosition; #include #include @@ -4278,7 +4278,7 @@ void main() { vPos = ( modelMatrix * wp ).xyz; vSlot = vec2( float( slot >> 12 ), float( slot & 4095 ) ); if ( state.a < 0.5 ) gl_Position = vec4( 0.0, 0.0, 2.0, 1.0 ); -}`,ly=` +}`,uy=` #include #include #include @@ -4300,27 +4300,27 @@ void main() { #else gl_FragColor = vec4( vPos, id ); #endif -}`,Vf=i=>i&&{element:i.element,point:i.point.clone()};function Th(i,t){let e=new qe({vertexShader:ay,fragmentShader:ly,uniforms:i,defines:t?{[t]:""}:{},side:Ne,clipping:!0});return e.index0AttributeName="q",e}var al=class{constructor(t,e,n,s={}){this.renderer=t,this.scene=e,this.camera=n,this._lost=!1,t.domElement.addEventListener("webglcontextlost",()=>this._lost=!0),this._last=null,this._lastTile=null,this._key=new Float64Array(36),e.root.addEventListener("change",o=>{o.detail.kind!=="appearance"&&(this._last=this._lastTile=null)});let r=e.slotUniforms;this._float=s.pickFloat!==!1&&t.extensions.has("EXT_color_buffer_float"),this._float?(this._material=Th(r,null),this._target=new He(1,1,{type:Ye}),this._pixel=new Float32Array(4)):(this._material=Th(r,"IO_PICK_RGBA8"),this._depthMaterial=Th(r,"IO_PICK_DEPTH"),this._target=new He(1,1),this._pixel=new Uint8Array(4))}pick(t,e){let n=this.renderer.domElement.getBoundingClientRect(),s=Math.floor(t-n.left),r=Math.floor(e-n.top);if(this._lost||!(s>=0&&r>=0&&sh===o[d]))return Vf(l.hit);let c=this._pick(s,r,n);return this._last={camera:a,key:o.slice(),hit:c},Vf(c)}_sampleKey(t,e,n){this.camera.updateMatrixWorld();let s=this._key;return s.set([t,e,n.width,n.height]),s.set(this.camera.matrixWorld.elements,4),s.set(this.camera.projectionMatrix.elements,20),s}measureTile(t,e,n){let s=this.renderer.domElement.getBoundingClientRect(),r=Math.floor(t-s.left),o=Math.floor(e-s.top);if(this._lost||!(r>=0&&o>=0&&ry===a[S]))return c.tile;let h=n*2+1;(!this._measure||this._measure.target.width!==h)&&(this._measure?.target.dispose(),this._measure={target:new He(h,h,this._float?{type:Ye}:{}),ids:this._float?new Float32Array(h*h*4):new Uint8Array(h*h*4),depths:this._float?null:new Uint8Array(h*h*4)});let{target:d,ids:u,depths:f}=this._measure,g=r-n,_=o-n;this._render(this._material,g,_,s,d,u);let m=(y,S)=>{let A=Math.floor(y)-g,x=Math.floor(S)-_;return A>=0&&A=0&&x(this._float?Math.round(u[y*4+3]):p.getUint32(y*4,!0))-1,w=b(m(r,o)),v=null;if(w>=0){f&&this._render(this._depthMaterial,g,_,s,d,f);let y=f&&new DataView(f.buffer),S=l.matrixWorldInverse.elements.slice(),A=U=>{if(y)return y.getFloat32(U*4,!0);let C=U*4;return-(S[2]*u[C]+S[6]*u[C+1]+S[10]*u[C+2]+S[14])},x=m(r,o),T=this._float?new I().fromArray(u,x*4):this._depthPoint(r,o,s,A(x)),R=new Set([w]),D=this.scene.slotElement(w);if(D>=0)for(let U=0;U=0&&!R.has(C)&&this.scene.slotElement(C)===D&&R.add(C)}let F=l.isPerspectiveCamera;v={rect:s,point:T,element:D,slots:R,depthAt(U,C,B){let W=m(U,C),q=W<0?-1:b(W);if(q<0)return 1/0;if(q!==B)return A(W);let O=z=>F?1/A(z):A(z),L=O(W);function H(z,Q,lt){let ut=Math.sign(lt),ct=m(U+ut*z,C+ut*Q);if(ct>=0&&b(ct)===q)return(O(ct)-L)*Math.abs(lt);let G=m(U-ut*z,C-ut*Q);return G>=0&&b(G)===q?(L-O(G))*Math.abs(lt):0}let X=L+H(1,0,U-Math.floor(U)-.5)+H(0,1,C-Math.floor(C)-.5);return X>0?F?1/X:X:A(W)}}}return this._lastTile={camera:l,key:a.slice(),radius:n,tile:v},this._last={camera:l,key:this._lastTile.key,hit:v},v}_pick(t,e,n){let s=this._render(this._material,t,e,n),r=(this._float?Math.round(s[3]):new Uint32Array(s.buffer)[0])-1;if(r<0)return null;let o=this.scene.slotElement(r);if(this._float)return{element:o,point:new I(s[0],s[1],s[2])};let a=this._render(this._depthMaterial,t,e,n);return{element:o,point:this._depthPoint(t,e,n,new DataView(a.buffer).getFloat32(0,!0))}}_depthPoint(t,e,n,s){let r=this.camera,o=new I((t+.5)/n.width*2-1,1-(e+.5)/n.height*2,-1).applyMatrix4(r.projectionMatrixInverse);return r.isPerspectiveCamera?o.multiplyScalar(-s/o.z):o.z=-s,o.applyMatrix4(r.matrixWorld)}_render(t,e,n,s,r=this._target,o=this._pixel){let{renderer:a,camera:l}=this,c={target:a.getRenderTarget(),color:a.getClearColor(new Vt),alpha:a.getClearAlpha()},h=this.scene._buckets[0]?.material;t.clippingPlanes=h?.clippingPlanes??null,t.clipIntersection=h?.clipIntersection??!1,l.updateMatrixWorld(),l.setViewOffset(s.width,s.height,e,n,r.width,r.height);try{a.setRenderTarget(r),a.setClearColor(0,0),this.scene.withMaterial(t,()=>a.render(this.scene.root,l),{pickCamera:l}),a.readRenderTargetPixels(r,0,0,r.width,r.height,o)}finally{a.setRenderTarget(c.target),a.setClearColor(c.color,c.alpha),l.clearViewOffset()}return o}};var ll=33.333333333333336,cy=200,Gf=1e6,hy=20,cl=class{constructor(t,e,n=1e7){this.scene=t,this.budget=n,this.minPixels=0,this._requestRender=e,this._last=new Float64Array(32),this._seen=!1,this._requestedAt=null,this._frame=null,this._cost=0,this._fastFrames=0,this._refine=!1,this._settle=0}requested(t){this._requestedAt??(this._requestedAt=t)}begin(t,e,n){t.updateMatrixWorld();let s=this._requestedAt===null?0:Math.max(n-this._requestedAt,0);this._requestedAt=null;let r=this._moved(t);this._frame=r?{start:n,waited:s}:null,this.minPixels=r?this.scene.detailThreshold(t,e,this.budget,this._refine):0,r||(this._fastFrames=0),this.scene.setDetail(this.minPixels,e),r&&(clearTimeout(this._settle),this.minPixels>0&&(this._settle=setTimeout(this._requestRender,cy)))}end(t){this.scene.setDetail(0),this._frame&&this._adapt(this._frame.waited+(t-this._frame.start)),this._frame=null}_adapt(t){this._cost=this._cost?this._cost*.8+t*.2:t,t>ll*1.1?(this._refine=!1,this._fastFrames=0):this._refine||(this._fastFrames=this.minPixels>0&&t=hy),this._cost>ll*1.1?this.budget=Math.max(this.budget*.9,Gf):this._cost0&&(this.budget=Math.max(Math.min(this.budget*1.05,this.scene.visibleCost),Gf))}_moved(t){let e=this._last,n=[...t.matrixWorld.elements,...t.projectionMatrix.elements],s=(o,a)=>a!==26&&a!==30&&Math.abs(o-e[a])>1e-9*Math.max(1,Math.abs(o)),r=this._seen&&n.some(s);return this._seen=!0,e.set(n),r}};var Tn,Os,hl,ul=class extends EventTarget{constructor(){super(...arguments);Cl(this,Os);Cl(this,Tn,new Set)}get size(){return li(this,Tn).size}has(e){return li(this,Tn).has(e)}values(){return li(this,Tn).values()}set(e){Qh(this,Tn,new Set(e)),Wr(this,Os,hl).call(this)}toggle(e){li(this,Tn).delete(e)||li(this,Tn).add(e),Wr(this,Os,hl).call(this)}clear(){li(this,Tn).size!==0&&(li(this,Tn).clear(),Wr(this,Os,hl).call(this))}};Tn=new WeakMap,Os=new WeakSet,hl=function(){this.dispatchEvent(new Event("change"))};function Wf(i,t,e){if(t!=="window"&&t!=="crossing")throw new RangeError(`Unknown box select mode: ${t}`);let n=i.x+i.width,s=i.y+i.height,r=t==="window"?o=>o.minX>=i.x&&o.maxX<=n&&o.minY>=i.y&&o.maxY<=s:o=>o.maxX>=i.x&&o.minX<=n&&o.maxY>=i.y&&o.minY<=s;return e.filter(r).map(o=>o.index)}function Xf(i,t,e){let n=new Jt().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse).elements,{left:s,top:r,width:o,height:a}=e,l=new oe,c=[];for(let h=0;hn===l?r(l):o(l));let m=[...t.children].find(y=>qf.indexOf(y.dataset.panel)>g);t.insertBefore(_,m??null);let p=et("section","ioviewer-side-panel ioviewer-floating");p.dataset.panel=l,p.hidden=!0,p.setAttribute("aria-label",h);let b=Qe("ioviewer-panel-close",ne.close,$("close"));b.addEventListener("click",()=>r(l));let w=et("header","ioviewer-panel-header");w.append(et("h2","",h),b);let v=et("div","ioviewer-panel-body");p.append(w,v),i.append(p),e.set(l,{button:_,panel:p,onClose:f}),d(v)}return{rail:t,openPanel:o,closePanel:r,registerPanel:a}}var $f=[{id:"navigation",items:["orbit","pan","fit","projection"]},{id:"sections",items:["plane","box","resetSections"]},{id:"measure",items:["distance"]},{id:"display",items:["displayMode","grids","opacity"]},{id:"view",items:["fullscreen"]}];function Zf(i,t){let e=et("div","ioviewer-toolbar ioviewer-floating");e.setAttribute("role","toolbar");let n=new Map;for(let a of t){let l=et("div","ioviewer-toolbar-group");l.setAttribute("role","group"),l.setAttribute("aria-label",$(`group.${a.id}`));let c=et("div","ioviewer-toolbar-row");for(let h of a.items){let d=Qe("ioviewer-tool",ne[h],$(`tool.${h}`));d.dataset.tool=h,d.setAttribute("aria-disabled","true");let u={button:d,handler:null};d.addEventListener("click",()=>{d.getAttribute("aria-disabled")!=="true"&&u.handler?.()}),n.set(h,u),c.append(d)}l.append(c,et("div","ioviewer-toolbar-label",$(`group.${a.id}`))),e.append(l)}i.append(e),new ResizeObserver(()=>i.style.setProperty("--toolbar-height",`${e.offsetHeight}px`)).observe(e);function r(a){let l=n.get(a);if(!l)throw new RangeError(`Unknown tool: ${a}`);return l}function o(a,l){r(a).button.setAttribute("aria-disabled",String(!l))}return{element:e,setHandler(a,l){r(a).handler=l,o(a,!0)},setEnabled:o,setActive(a,l){let{button:c}=r(a);c.classList.toggle("active",l),c.setAttribute("aria-pressed",String(l))}}}var uy="input, textarea, select, [contenteditable]";function Ah(i){return i.key==="ContextMenu"||i.code==="ContextMenu"||i.shiftKey&&(i.key==="F10"||i.code==="F10")}function Jf(i){if(i.ctrlKey||i.altKey||i.metaKey||i.repeat||i.target?.closest?.(uy))return null;if(Ah(i))return"contextMenu";switch(i.code){case"KeyH":return i.shiftKey?"showAll":"hide";case"KeyI":return i.shiftKey?null:"isolate";case"KeyF":return i.shiftKey?null:"zoomTo";case"Escape":return"escape";default:return null}}function Kf(i,t,e,n,s){let r=et("details","ioviewer-tree-filters");r.hidden=i.length===0;let o=et("summary","",$("filters.title")),a=et("div","ioviewer-filter-fields"),l=new Map(t.map(({id:y,name:S})=>[y,S||`#${y}`])),c=y=>y.modelId??t[0]?.id??null,h=y=>y.levelId??(y.level||null),d=y=>y.category??"",u=[{name:$("filters.model"),key:c,labels:new Map},{name:$("level"),key:h,labels:new Map},{name:$("category"),key:d,labels:new Map}],[f,g,_]=u,m=et("div","ioviewer-filter-actions"),p=et("button","ioviewer-text-button",$("filters.clear"));p.type="button",p.addEventListener("click",()=>{for(let y of u)y.select&&(y.select.selectedIndex=0);e.value="",n(),e.focus()});let b=et("button","ioviewer-text-button",$("filters.isolate"));b.type="button",b.addEventListener("click",s),m.append(p,b),r.append(o,a,m);function w(){if(r.open){r.removeEventListener("toggle",w);for(let y of i){let S=c(y),A=l.get(S)??(S==null?"":`#${S}`);S!=null&&f.labels.set(S,A);let x=h(y);if(!g.labels.has(x)){let R=y.level||(x==null?$("filters.noLevel"):`#${x}`);g.labels.set(x,x!=null&&t.length>1&&A?`${R} \xB7 ${A}`:R)}let T=d(y);_.labels.set(T,T||$("noCategory"))}for(let y of u){if(!y.labels.size)continue;let S=new Map;for(let R of y.labels.values())S.set(R,(S.get(R)??0)+1);let A=[...y.labels].map(([R,D])=>[R,S.get(D)>1?`${D} (#${R})`:D]);A.sort((R,D)=>R[1].localeCompare(D[1])),y.keys=A.map(([R])=>R);let x=y.select=et("select");x.append(new Option($("filters.all"),""));for(let[R,[,D]]of A.entries())x.append(new Option(D,String(R+1)));x.addEventListener("change",n);let T=et("label","ioviewer-filter-field");T.append(et("span","",y.name),x),a.append(T)}}}r.addEventListener("toggle",w);function v(){return u.filter(y=>y.select?.selectedIndex>0)}return{element:r,predicate(){let y=v().map(({select:S,keys:A,key:x})=>({key:x,value:A[S.selectedIndex-1]}));return y.length?S=>y.every(({key:A,value:x})=>A(S)===x):null},update(y,S){let A=v().length;o.textContent=A?`${$("filters.title")} (${A})`:$("filters.title"),p.disabled=!A&&!y,b.disabled=!S}}}var Ti=24,dy=8;function Rh(i,t,e,n,s){let r=Math.min(n,Math.max(0,Math.floor(i/t)-s)),o=Math.min(n,Math.ceil((i+e)/t)+s);return{start:r,end:Math.max(r,o)}}function fy(i){let t=null;return e=>{let n=e.trim().toLowerCase();t??(t=i.map(r=>`${r.name??""} +}`,Wf=i=>i&&{element:i.element,point:i.point.clone()};function Rh(i,t){let e=new qe({vertexShader:hy,fragmentShader:uy,uniforms:i,defines:t?{[t]:""}:{},side:Ne,clipping:!0});return e.index0AttributeName="q",e}var hl=class{constructor(t,e,n,s={}){this.renderer=t,this.scene=e,this.camera=n,this._lost=!1,t.domElement.addEventListener("webglcontextlost",()=>this._lost=!0),this._last=null,this._lastTile=null,this._key=new Float64Array(36),e.root.addEventListener("change",o=>{o.detail.kind!=="appearance"&&(this._last=this._lastTile=null)});let r=e.slotUniforms;this._float=s.pickFloat!==!1&&t.extensions.has("EXT_color_buffer_float"),this._float?(this._material=Rh(r,null),this._target=new Ve(1,1,{type:Ye}),this._pixel=new Float32Array(4)):(this._material=Rh(r,"IO_PICK_RGBA8"),this._depthMaterial=Rh(r,"IO_PICK_DEPTH"),this._target=new Ve(1,1),this._pixel=new Uint8Array(4))}pick(t,e){let n=this.renderer.domElement.getBoundingClientRect(),s=Math.floor(t-n.left),r=Math.floor(e-n.top);if(this._lost||!(s>=0&&r>=0&&sh===o[d]))return Wf(l.hit);let c=this._pick(s,r,n);return this._last={camera:a,key:o.slice(),hit:c},Wf(c)}_sampleKey(t,e,n){this.camera.updateMatrixWorld();let s=this._key;return s.set([t,e,n.width,n.height]),s.set(this.camera.matrixWorld.elements,4),s.set(this.camera.projectionMatrix.elements,20),s}measureTile(t,e,n){let s=this.renderer.domElement.getBoundingClientRect(),r=Math.floor(t-s.left),o=Math.floor(e-s.top);if(this._lost||!(r>=0&&o>=0&&ry===a[S]))return c.tile;let h=n*2+1;(!this._measure||this._measure.target.width!==h)&&(this._measure?.target.dispose(),this._measure={target:new Ve(h,h,this._float?{type:Ye}:{}),ids:this._float?new Float32Array(h*h*4):new Uint8Array(h*h*4),depths:this._float?null:new Uint8Array(h*h*4)});let{target:d,ids:u,depths:f}=this._measure,g=r-n,_=o-n;this._render(this._material,g,_,s,d,u);let m=(y,S)=>{let A=Math.floor(y)-g,x=Math.floor(S)-_;return A>=0&&A=0&&x(this._float?Math.round(u[y*4+3]):p.getUint32(y*4,!0))-1,E=b(m(r,o)),v=null;if(E>=0){f&&this._render(this._depthMaterial,g,_,s,d,f);let y=f&&new DataView(f.buffer),S=l.matrixWorldInverse.elements.slice(),A=F=>{if(y)return y.getFloat32(F*4,!0);let I=F*4;return-(S[2]*u[I]+S[6]*u[I+1]+S[10]*u[I+2]+S[14])},x=m(r,o),T=this._float?new L().fromArray(u,x*4):this._depthPoint(r,o,s,A(x)),C=new Set([E]),D=this.scene.slotElement(E);if(D>=0)for(let F=0;F=0&&!C.has(I)&&this.scene.slotElement(I)===D&&C.add(I)}let U=l.isPerspectiveCamera;v={rect:s,point:T,element:D,slots:C,depthAt(F,I,B){let G=m(F,I),q=G<0?-1:b(G);if(q<0)return 1/0;if(q!==B)return A(G);let O=k=>U?1/A(k):A(k),N=O(G);function z(k,K,lt){let ht=Math.sign(lt),at=m(F+ht*k,I+ht*K);if(at>=0&&b(at)===q)return(O(at)-N)*Math.abs(lt);let Y=m(F-ht*k,I-ht*K);return Y>=0&&b(Y)===q?(N-O(Y))*Math.abs(lt):0}let W=N+z(1,0,F-Math.floor(F)-.5)+z(0,1,I-Math.floor(I)-.5);return W>0?U?1/W:W:A(G)}}}return this._lastTile={camera:l,key:a.slice(),radius:n,tile:v},this._last={camera:l,key:this._lastTile.key,hit:v},v}_pick(t,e,n){let s=this._render(this._material,t,e,n),r=(this._float?Math.round(s[3]):new Uint32Array(s.buffer)[0])-1;if(r<0)return null;let o=this.scene.slotElement(r);if(this._float)return{element:o,point:new L(s[0],s[1],s[2])};let a=this._render(this._depthMaterial,t,e,n);return{element:o,point:this._depthPoint(t,e,n,new DataView(a.buffer).getFloat32(0,!0))}}_depthPoint(t,e,n,s){let r=this.camera,o=new L((t+.5)/n.width*2-1,1-(e+.5)/n.height*2,-1).applyMatrix4(r.projectionMatrixInverse);return r.isPerspectiveCamera?o.multiplyScalar(-s/o.z):o.z=-s,o.applyMatrix4(r.matrixWorld)}_render(t,e,n,s,r=this._target,o=this._pixel){let{renderer:a,camera:l}=this,c={target:a.getRenderTarget(),color:a.getClearColor(new Vt),alpha:a.getClearAlpha()},h=this.scene._buckets[0]?.material;t.clippingPlanes=h?.clippingPlanes??null,t.clipIntersection=h?.clipIntersection??!1,l.updateMatrixWorld(),l.setViewOffset(s.width,s.height,e,n,r.width,r.height);try{a.setRenderTarget(r),a.setClearColor(0,0),this.scene.withMaterial(t,()=>a.render(this.scene.root,l),{pickCamera:l}),a.readRenderTargetPixels(r,0,0,r.width,r.height,o)}finally{a.setRenderTarget(c.target),a.setClearColor(c.color,c.alpha),l.clearViewOffset()}return o}};var ul=33.333333333333336,dy=200,Xf=1e6,fy=20,dl=class{constructor(t,e,n=1e7){this.scene=t,this.budget=n,this.minPixels=0,this._requestRender=e,this._last=new Float64Array(32),this._seen=!1,this._requestedAt=null,this._frame=null,this._cost=0,this._fastFrames=0,this._refine=!1,this._settle=0}requested(t){this._requestedAt??(this._requestedAt=t)}begin(t,e,n){t.updateMatrixWorld();let s=this._requestedAt===null?0:Math.max(n-this._requestedAt,0);this._requestedAt=null;let r=this._moved(t);this._frame=r?{start:n,waited:s}:null,this.minPixels=r?this.scene.detailThreshold(t,e,this.budget,this._refine):0,r||(this._fastFrames=0),this.scene.setDetail(this.minPixels,e),r&&(clearTimeout(this._settle),this.minPixels>0&&(this._settle=setTimeout(this._requestRender,dy)))}end(t){this.scene.setDetail(0),this._frame&&this._adapt(this._frame.waited+(t-this._frame.start)),this._frame=null}_adapt(t){this._cost=this._cost?this._cost*.8+t*.2:t,t>ul*1.1?(this._refine=!1,this._fastFrames=0):this._refine||(this._fastFrames=this.minPixels>0&&t=fy),this._cost>ul*1.1?this.budget=Math.max(this.budget*.9,Xf):this._cost0&&(this.budget=Math.max(Math.min(this.budget*1.05,this.scene.visibleCost),Xf))}_moved(t){let e=this._last,n=[...t.matrixWorld.elements,...t.projectionMatrix.elements],s=(o,a)=>a!==26&&a!==30&&Math.abs(o-e[a])>1e-9*Math.max(1,Math.abs(o)),r=this._seen&&n.some(s);return this._seen=!0,e.set(n),r}};var An,Os,fl,pl=class extends EventTarget{constructor(){super(...arguments);Ll(this,Os);Ll(this,An,new Set)}get size(){return hi(this,An).size}has(e){return hi(this,An).has(e)}values(){return hi(this,An).values()}set(e){eu(this,An,new Set(e)),Zr(this,Os,fl).call(this)}toggle(e){hi(this,An).delete(e)||hi(this,An).add(e),Zr(this,Os,fl).call(this)}clear(){hi(this,An).size!==0&&(hi(this,An).clear(),Zr(this,Os,fl).call(this))}};An=new WeakMap,Os=new WeakSet,fl=function(){this.dispatchEvent(new Event("change"))};function qf(i,t,e){if(t!=="window"&&t!=="crossing")throw new RangeError(`Unknown box select mode: ${t}`);let n=i.x+i.width,s=i.y+i.height,r=t==="window"?o=>o.minX>=i.x&&o.maxX<=n&&o.minY>=i.y&&o.maxY<=s:o=>o.maxX>=i.x&&o.minX<=n&&o.maxY>=i.y&&o.minY<=s;return e.filter(r).map(o=>o.index)}function Yf(i,t,e){let n=new Yt().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse).elements,{left:s,top:r,width:o,height:a}=e,l=new le,c=[];for(let h=0;hn===l?r(l):o(l));let m=[...t.children].find(y=>$f.indexOf(y.dataset.panel)>g);t.insertBefore(_,m??null);let p=et("section","ioviewer-side-panel ioviewer-floating");p.dataset.panel=l,p.hidden=!0,p.setAttribute("aria-label",h);let b=Qe("ioviewer-panel-close",ne.close,$("close"));b.addEventListener("click",()=>r(l));let E=et("header","ioviewer-panel-header");E.append(et("h2","",h),b);let v=et("div","ioviewer-panel-body");p.append(E,v),i.append(p),e.set(l,{button:_,panel:p,onClose:f}),d(v)}return{rail:t,openPanel:o,closePanel:r,registerPanel:a}}var Jf=[{id:"navigation",items:["orbit","pan","fit","projection"]},{id:"sections",items:["plane","box","resetSections"]},{id:"measure",items:["distance"]},{id:"display",items:["displayMode","grids","opacity"]},{id:"view",items:["fullscreen"]}];function Kf(i,t){let e=et("div","ioviewer-toolbar ioviewer-floating");e.setAttribute("role","toolbar");let n=new Map;for(let a of t){let l=et("div","ioviewer-toolbar-group");l.setAttribute("role","group"),l.setAttribute("aria-label",$(`group.${a.id}`));let c=et("div","ioviewer-toolbar-row");for(let h of a.items){let d=Qe("ioviewer-tool",ne[h],$(`tool.${h}`));d.dataset.tool=h,d.setAttribute("aria-disabled","true");let u={button:d,handler:null};d.addEventListener("click",()=>{d.getAttribute("aria-disabled")!=="true"&&u.handler?.()}),n.set(h,u),c.append(d)}l.append(c,et("div","ioviewer-toolbar-label",$(`group.${a.id}`))),e.append(l)}i.append(e),new ResizeObserver(()=>i.style.setProperty("--toolbar-height",`${e.offsetHeight}px`)).observe(e);function r(a){let l=n.get(a);if(!l)throw new RangeError(`Unknown tool: ${a}`);return l}function o(a,l){r(a).button.setAttribute("aria-disabled",String(!l))}return{element:e,setHandler(a,l){r(a).handler=l,o(a,!0)},setEnabled:o,setActive(a,l){let{button:c}=r(a);c.classList.toggle("active",l),c.setAttribute("aria-pressed",String(l))}}}var py="input, textarea, select, [contenteditable]";function Ch(i){return i.key==="ContextMenu"||i.code==="ContextMenu"||i.shiftKey&&(i.key==="F10"||i.code==="F10")}function jf(i){if(i.ctrlKey||i.altKey||i.metaKey||i.repeat||i.target?.closest?.(py))return null;if(Ch(i))return"contextMenu";switch(i.code){case"KeyH":return i.shiftKey?"showAll":"hide";case"KeyI":return i.shiftKey?null:"isolate";case"KeyF":return i.shiftKey?null:"zoomTo";case"Escape":return"escape";default:return null}}function Qf(i,t,e,n,s){let r=et("details","ioviewer-tree-filters");r.hidden=i.length===0;let o=et("summary","",$("filters.title")),a=et("div","ioviewer-filter-fields"),l=new Map(t.map(({id:y,name:S})=>[y,S||`#${y}`])),c=y=>y.modelId??t[0]?.id??null,h=y=>y.levelId??(y.level||null),d=y=>y.category??"",u=[{name:$("filters.model"),key:c,labels:new Map},{name:$("level"),key:h,labels:new Map},{name:$("category"),key:d,labels:new Map}],[f,g,_]=u,m=et("div","ioviewer-filter-actions"),p=et("button","ioviewer-text-button",$("filters.clear"));p.type="button",p.addEventListener("click",()=>{for(let y of u)y.select&&(y.select.selectedIndex=0);e.value="",n(),e.focus()});let b=et("button","ioviewer-text-button",$("filters.isolate"));b.type="button",b.addEventListener("click",s),m.append(p,b),r.append(o,a,m);function E(){if(r.open){r.removeEventListener("toggle",E);for(let y of i){let S=c(y),A=l.get(S)??(S==null?"":`#${S}`);S!=null&&f.labels.set(S,A);let x=h(y);if(!g.labels.has(x)){let C=y.level||(x==null?$("filters.noLevel"):`#${x}`);g.labels.set(x,x!=null&&t.length>1&&A?`${C} \xB7 ${A}`:C)}let T=d(y);_.labels.set(T,T||$("noCategory"))}for(let y of u){if(!y.labels.size)continue;let S=new Map;for(let C of y.labels.values())S.set(C,(S.get(C)??0)+1);let A=[...y.labels].map(([C,D])=>[C,S.get(D)>1?`${D} (#${C})`:D]);A.sort((C,D)=>C[1].localeCompare(D[1])),y.keys=A.map(([C])=>C);let x=y.select=et("select");x.append(new Option($("filters.all"),""));for(let[C,[,D]]of A.entries())x.append(new Option(D,String(C+1)));x.addEventListener("change",n);let T=et("label","ioviewer-filter-field");T.append(et("span","",y.name),x),a.append(T)}}}r.addEventListener("toggle",E);function v(){return u.filter(y=>y.select?.selectedIndex>0)}return{element:r,predicate(){let y=v().map(({select:S,keys:A,key:x})=>({key:x,value:A[S.selectedIndex-1]}));return y.length?S=>y.every(({key:A,value:x})=>A(S)===x):null},update(y,S){let A=v().length;o.textContent=A?`${$("filters.title")} (${A})`:$("filters.title"),p.disabled=!A&&!y,b.disabled=!S}}}var Ri=24,my=8;function Ih(i,t,e,n,s){let r=Math.min(n,Math.max(0,Math.floor(i/t)-s)),o=Math.min(n,Math.ceil((i+e)/t)+s);return{start:r,end:Math.max(r,o)}}function gy(i){let t=null;return e=>{let n=e.trim().toLowerCase();t??(t=i.map(r=>`${r.name??""} ${r.type??""} ${r.id} -${r.sourceId??""}`.toLowerCase()));let s=[];for(let r=0;r{let s=e.category??"";t.has(s)||t.set(s,[]),t.get(s).push(n)}),[...t].map(([e,n])=>({name:e,indices:n})).sort((e,n)=>e.name.localeCompare(n.name))}function jf(i,{elements:t,models:e,selection:n,scene:s,zoomToElement:r,openContextMenu:o}){let a=py(t),l=new Int32Array(t.length);a.forEach((z,Q)=>z.indices.forEach(lt=>l[lt]=Q));let c=new Uint8Array(a.length),h=new Int32Array(a.length),d=new Uint32Array(a.length),u=fy(t),f="",g=!1,_=new Int32Array(0),m=0,p=-1,b=null,w=!1,v=et("input","ioviewer-tree-search");v.type="search",v.placeholder=$("searchPlaceholder"),v.setAttribute("aria-label",$("searchPlaceholder"));let y=et("div","ioviewer-tree");y.setAttribute("role","tree"),y.setAttribute("aria-label",$("panel.model")),y.setAttribute("aria-multiselectable","true"),y.tabIndex=-1;let S=et("div","ioviewer-tree-spacer");S.setAttribute("role","presentation"),y.append(S);let A=et("div","ioviewer-tree-empty",$("noMatches")),x=Kf(t,e,v,L,()=>s.isolate(_));i.append(x.element,v,y,A);function T(){let z=_[m],Q=x.predicate();if(g=!!(f||Q),g){let ut=f?u(f):t.keys();if(Q){let ct=[];for(let G of ut)Q(t[G])&&ct.push(G);_=Int32Array.from(ct)}else _=Int32Array.from(ut)}else{let ut=a.length;a.forEach((G,tt)=>c[tt]&&(ut+=G.indices.length)),_=new Int32Array(ut);let ct=0;a.forEach((G,tt)=>{if(h[tt]=ct,_[ct++]=-(tt+1),c[tt])for(let rt of G.indices)_[ct++]=rt})}let lt=_.indexOf(z);m=lt>=0?lt:0,S.style.height=`${_.length*Ti}px`,A.hidden=_.length>0||!g,x.update(f,!!s.isolate&&g&&_.some(ut=>s.instancesOf(ut).length>0)),R()}function R(z=y.contains(document.activeElement)){let Q=y.clientHeight;if(Q===0||_.length===0){S.replaceChildren();return}let lt=y.scrollTop,{start:ut,end:ct}=Rh(lt,Ti,Q,_.length,dy);!z&&(m=ct)&&(m=Math.min(_.length-1,Math.floor(lt/Ti)));let G=[];m=ct&&G.push(D(m)),S.replaceChildren(...G),z&&S.querySelector('[tabindex="0"]')?.focus({preventScroll:!0})}function D(z){let Q=_[z],lt=Q<0?-Q-1:l[Q],ut=Q<0?d[lt]===a[lt].indices.length:n.has(Q),ct=et("div","tree-row");if(ct.style.top=`${z*Ti}px`,ct.style.height=`${Ti}px`,ct.dataset.row=z,ct.tabIndex=z===m?0:-1,ct.setAttribute("role","treeitem"),ct.classList.toggle("selected",ut),ct.setAttribute("aria-selected",String(ut)),Q<0){ct.classList.add("tree-category"),ct.setAttribute("aria-level","1"),ct.setAttribute("aria-posinset",String(lt+1)),ct.setAttribute("aria-setsize",String(a.length)),ct.setAttribute("aria-expanded",String(!!c[lt]));let G=et("span","tree-chevron");G.innerHTML=ne.chevron;let{name:tt,indices:rt}=a[lt];ct.append(G,et("span","tree-name",tt||$("noCategory")),et("span","tree-count",Nr(rt.length)))}else{let G=t[Q];ct.classList.add("tree-element"),ct.setAttribute("aria-level",g?"1":"2"),ct.setAttribute("aria-posinset",String(g?z+1:z-h[lt])),ct.setAttribute("aria-setsize",String(g?_.length:a[lt].indices.length)),ct.classList.toggle("tree-child",!g),ct.classList.toggle("tree-hidden",s.isVisible?.(Q)===!1),ct.append(et("span","tree-name",G.name||`#${G.id}`),et("span","tree-type",G.type??""))}return ct}function F(z){let Q=y.clientHeight;if(Q===0){p=z;return}let lt=z*Ti;lty.scrollTop+Q&&(y.scrollTop=lt+Ti-Q)}function U(z){m=z,F(z),R(!0)}function C(z){let Q=l[z];!g&&!c[Q]&&(c[Q]=1,T());let lt=_.indexOf(z);lt>=0&&(y.contains(document.activeElement)||(m=lt),F(lt)),R()}function B(z){w=!0;try{n.set(z)}finally{w=!1}}function W(z,Q){let lt=_.indexOf(b);lt<0&&(lt=z,b=_[z]);let ut=_.subarray(Math.min(lt,z),Math.max(lt,z)+1).filter(ct=>ct>=0);ut.length>0&&B(Q?[...n.values(),...ut]:ut)}function q(z){b=z;let Q=-z-1,lt=z<0?a[Q].indices:[z],ut=z<0?d[Q]===lt.length:n.has(z),ct=new Set(n.values());for(let G of lt)ut?ct.delete(G):ct.add(G);B(ct)}function O(z,Q,lt){z>=0&&!n.has(z)&&(b=z,B([z]));let ut=z>=0?z:n.values().next().value??null;o(Q,lt,ut,()=>{let ct=_.indexOf(z);ct>=0?U(ct):v.focus()})}v.addEventListener("focus",()=>{S.firstElementChild||X()});function L(){f=v.value.trim(),y.scrollTop=0,p=-1,m=-1,T()}v.addEventListener("input",L),y.addEventListener("scroll",()=>R()),y.addEventListener("focusin",z=>{let Q=z.target.closest(".tree-row");!Q||Q.tabIndex===0||(S.querySelector('[tabindex="0"]')?.setAttribute("tabindex","-1"),m=Number(Q.dataset.row),Q.tabIndex=0)}),y.addEventListener("keydown",z=>{let Q=z.target.closest(".tree-row");if(!Q||z.ctrlKey||z.altKey||z.metaKey)return;let lt=Number(Q.dataset.row),ut=_[lt];if(Ah(z)){if(z.preventDefault(),!z.repeat){let{left:G,bottom:tt}=Q.getBoundingClientRect();O(ut,G,tt)}return}if(z.key===" "){z.preventDefault(),z.repeat||(z.shiftKey?W(lt,!1):q(ut));return}if(z.shiftKey)return;let ct=lt;switch(z.key){case"ArrowUp":ct=Math.max(0,lt-1);break;case"ArrowDown":ct=Math.min(_.length-1,lt+1);break;case"Home":ct=0;break;case"End":ct=_.length-1;break;case"ArrowRight":ut<0&&(c[-ut-1]?ct=lt+1:(c[-ut-1]=1,T()));break;case"ArrowLeft":ut>=0&&!g?ct=h[l[ut]]:ut<0&&c[-ut-1]&&(c[-ut-1]=0,T());break;case"Enter":z.repeat||H(ut);break;default:return}z.preventDefault(),ct!==lt&&U(ct)});function H(z){if(z>=0){b=z,B([z]),r(z);return}c[-z-1]^=1,T()}y.addEventListener("click",z=>{let Q=z.target.closest(".tree-row");if(!Q)return;let lt=Number(Q.dataset.row),ut=z.ctrlKey||z.metaKey;z.shiftKey?W(lt,ut):ut?q(_[lt]):H(_[lt])}),y.addEventListener("contextmenu",z=>{let Q=z.target.closest(".tree-row");Q&&(z.preventDefault(),O(_[Number(Q.dataset.row)],z.clientX,z.clientY))});function X(){p>=0&&y.clientHeight>0&&(F(p),p=-1),R()}new ResizeObserver(X).observe(y),n.addEventListener("change",()=>{let z=-1;d.fill(0);for(let Q of n.values())d[l[Q]]++,z=Q;if(w){R();return}b=null,z>=0?C(z):R()}),s.root?.addEventListener("change",z=>z.detail.kind==="visibility"&&R()),T()}var Qf={element:["properties","hide","isolate","showAll","-","zoomTo","sectionBox","-","copyId"],empty:["showAll","fitAll","resetSections"]},my={hide:"H",isolate:"I",showAll:"Shift+H",zoomTo:"F"},dl=4;function tp(i){let t=et("div","ioviewer-context-menu");t.setAttribute("role","menu"),t.setAttribute("aria-label",$("contextMenu")),t.hidden=!0,i.append(t);let e=new Map(Object.values(Qf).flat().filter(c=>c!=="-").map(c=>[c,{enabled:!1,handler:null}])),n=null;function s(){if(t.hidden)return;let c=t.contains(document.activeElement)?n:null;n=null,t.hidden=!0,t.replaceChildren(),window.removeEventListener("pointerdown",o,!0),window.removeEventListener("wheel",s,!0),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",s),c?.()}function r(c){i.contains(c.target)||s()}function o(c){t.contains(c.target)||(s(),sl(c))}function a(c,h,d,u,f=null){let g=Qf[c];if(!g)throw new RangeError(`Unknown menu: ${c}`);s(),n=f;for(let p of g){if(p==="-"){let v=et("div","ioviewer-menu-separator");v.setAttribute("role","separator"),t.append(v);continue}let b=e.get(p),w=et("button","ioviewer-menu-item");w.type="button",w.tabIndex=-1,w.dataset.item=p,w.setAttribute("role","menuitem"),w.setAttribute("aria-disabled",String(!b.enabled)),b.enabled||(w.title=$("menu.unavailable")),w.append(et("span","",$(`menu.${p}`)),et("kbd","",my[p]??"")),w.addEventListener("click",()=>{b.enabled&&(s(),b.handler(u))}),t.append(w)}t.hidden=!1;let{width:_,height:m}=t.getBoundingClientRect();t.style.left=`${Math.max(dl,Math.min(h,innerWidth-_-dl))}px`,t.style.top=`${Math.max(dl,Math.min(d,innerHeight-m-dl))}px`,window.addEventListener("pointerdown",o,!0),window.addEventListener("wheel",s,!0),window.addEventListener("scroll",r,!0),window.addEventListener("resize",s),f&&t.querySelector("button")?.focus({preventScroll:!0})}t.addEventListener("keydown",c=>{if(c.key==="Tab"){s();return}if(c.key==="Escape"){c.preventDefault(),s();return}let h=[...t.querySelectorAll("button")],d=h.indexOf(document.activeElement),u;switch(c.key){case"ArrowDown":u=(d+1)%h.length;break;case"ArrowUp":u=(d+h.length-1)%h.length;break;case"Home":u=0;break;case"End":u=h.length-1;break;default:return}c.preventDefault(),h[u]?.focus({preventScroll:!0})});function l(c,{enabled:h=!0,handler:d}){let u=e.get(c);if(!u)throw new RangeError(`Unknown menu item: ${c}`);d&&(u.handler=d),u.enabled=h&&!!u.handler}return{element:t,open:a,close:s,setItem:l,get isOpen(){return!t.hidden}}}var gy=1600;function ep(i,t,e){let n=()=>i.textContent=`${$("selected")}: ${Nr(t.size)} \xB7 ${$("elements")}: ${Nr(e)}`;t.addEventListener("change",n),n()}function np(i,t){if(!t)return;let e=et("div","ioviewer-banner ioviewer-floating");e.setAttribute("role","status");let n=$("truncated").replace("{meshes}",t.meshes).replace("{total}",t.totalMeshes),s=Qe("ioviewer-panel-close",ne.close,$("close")),r=new ResizeObserver(()=>i.style.setProperty("--banner-height",`${e.offsetHeight}px`));s.addEventListener("click",()=>{r.disconnect(),i.style.removeProperty("--banner-height"),e.remove()}),e.append(et("span","",n),s),i.append(e),r.observe(e)}function zs(i,t){let e=et("div","ioviewer-toast",t);e.setAttribute("role","status"),i.append(e),setTimeout(()=>e.remove(),gy)}function ip(i,t){let e=et("table");for(let[s,r]of t)e.insertRow().append(et("th","",s),et("td","",String(r??"")));let n=et("section");return n.append(et("h3","",i),e),n}function sp(i,t,e){let n=et("h2","ioviewer-properties-title"),s=et("button","ioviewer-properties-close","\xD7");s.type="button",s.title=$("close"),s.setAttribute("aria-label",$("close")),s.addEventListener("click",()=>t.clear());let r=et("header");r.append(n,s);let o=et("div","ioviewer-properties-body");i.replaceChildren(r,o),i.hidden=!0;let a=h=>{let d=[[$("id"),h.id],[$("category"),h.category],[$("type"),h.type],[$("level"),h.level]];return h.sourceId&&d.push([$("sourceId"),h.sourceId]),h.link&&d.push([$("link"),h.link]),ip($("elementGroup"),d)},l=h=>{for(let[d,u]of Object.entries(h??{}))o.append(ip(d,Object.entries(u)))},c;t.addEventListener("change",()=>{if(c?.abort(),c=void 0,o.removeAttribute("aria-busy"),i.hidden=t.size===0,o.replaceChildren(),t.size!==1){n.textContent=`${$("selected")}: ${t.size}`;return}let[h]=t.values(),d=e.meta.elements[h];if(n.textContent=d.name||`#${d.id}`,o.append(a(d)),!e.loadProperties){l(e.props(d.id));return}let u=new AbortController;c=u,o.setAttribute("aria-busy","true"),e.loadProperties(h,u.signal).then(f=>{u.signal.aborted||!f||(n.textContent=f.name||d.name||`#${d.id}`,o.replaceChildren(a({...d,...f})),l(f.properties))}).catch(()=>{u.signal.aborted||o.append(et("p","",$("badData")))}).finally(()=>{c===u&&o.removeAttribute("aria-busy")})})}async function _y(i){if(await navigator.clipboard?.writeText(i).then(()=>!0,()=>!1))return!0;let t=document.createElement("textarea");t.value=i,t.setAttribute("readonly",""),t.className="ioviewer-offscreen",document.body.append(t),t.select();try{return document.execCommand("copy")}finally{t.remove()}}function rp({root:i,data:t,scene:e,controls:n,picker:s,selection:r,measure:o}){let{meta:a}=t,l=()=>n.fitBox(e.visibleBox()),c={hide:e.setVisible&&(()=>r.size&&e.setVisible([...r.values()],!1)),isolate:e.isolate&&(()=>r.size&&e.isolate([...r.values()])),showAll:e.showAll&&(()=>e.showAll()),zoomTo:()=>{if(!r.size)return l();let[b,...w]=r.values(),v=e.elementBox(b);for(let y of w)v.union(e.elementBox(y));n.zoomToBox(v)},fitAll:l},h=Yf(i);h.registerPanel("model",{icon:ne.model,title:$("panel.model"),visible:a.elements.length>0||!!e.setVisible,render:b=>jf(b,{elements:a.elements,models:a.models??[],selection:r,scene:e,openContextMenu:_,zoomToElement:w=>n.zoomToBox(e.elementBox(w))})});let d=document.createElement("aside");d.id="ioviewer-properties",d.className="ioviewer-floating",i.append(d),sp(d,r,t);let u=Zf(i,$f),f=b=>{n.setLeftButtonMode(b),u.setActive("orbit",b==="orbit"),u.setActive("pan",b==="pan")};u.setHandler("orbit",()=>f("orbit")),u.setHandler("pan",()=>f("pan")),f(n.leftButtonMode),u.setHandler("fit",l),u.setHandler("projection",()=>{let b=!n.camera.isOrthographicCamera;n.setProjection(b?"orthographic":"perspective"),u.setActive("projection",b)}),u.setActive("projection",!1),document.fullscreenEnabled&&(u.setHandler("fullscreen",()=>{(document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()).catch(()=>{u.setActive("fullscreen",!!document.fullscreenElement),zs(i,$("fullscreenUnavailable"))})}),document.addEventListener("fullscreenchange",()=>u.setActive("fullscreen",!!document.fullscreenElement)));let g=tp(i);function _(b,w,v,y){g.open(v===null?"empty":"element",b,w,v,y)}function m(b){if(g.isOpen)return;let w=b===document.body,v=(w?n.dom:b).getBoundingClientRect(),y=w?v.left+v.width/2:v.left,S=w?v.top+v.height/2:v.bottom;_(y,S,r.values().next().value??null,()=>b.focus({preventScroll:!0}))}g.setItem("properties",{handler:b=>r.set([b])});for(let b of["hide","isolate","showAll","zoomTo","fitAll"])g.setItem(b,{handler:c[b]});g.setItem("copyId",{handler:b=>_y(String(a.elements[b].id)).then(w=>zs(i,$(w?"idCopied":"copyFailed")),()=>zs(i,$("copyFailed")))}),n.addEventListener("contextmenu",async b=>{let{x:w,y:v}=b.detail;if(o?.active)return _(w,v,r.values().next().value??null);let y=s.pick(w,v),S=y?.then?await y:y;if(S!==void 0){if(!S||S.element<0)return _(w,v,null);r.has(S.element)||r.set([S.element]),_(w,v,S.element)}});let p=[];return window.addEventListener("keydown",b=>{if(b.defaultPrevented)return;let w=Jf(b);if(w){if(b.preventDefault(),w==="contextMenu")return m(document.activeElement??document.body);if(w==="escape"&&!g.isOpen){p.some(v=>v())||r.clear();return}g.close(),w!=="escape"&&c[w]?.()}}),ep(document.getElementById("ioviewer-status"),r,e.elementCount),np(i,a.truncated),{shell:h,toolbar:u,contextMenu:g,onEscape:b=>p.push(b)}}var Ch={x:new I(1,0,0),y:new I(0,1,0),z:new I(0,0,1)};function Ih(i){let t=Ch[i];if(!t)throw new RangeError(`Unknown axis: ${i}`);return t.clone()}function op(i,t,e){if(t.length===0)return!1;let n=s=>s.distanceToPoint(i)<0;return e?t.every(n):t.some(n)}function ap(i,t,e,n){let s=i.clone().normalize(),r=s.dot(t)+e;return n?new we(s,-r):new we(s.negate(),r)}function lp(i,t,e=0){if(t!=="keepInside"&&t!=="cutInside")throw new RangeError(`Unknown box mode: ${t}`);let{min:n,max:s}=i,r=[new we(new I(1,0,0),-n.x),new we(new I(-1,0,0),s.x),new we(new I(0,1,0),-n.y),new we(new I(0,-1,0),s.y),new we(new I(0,0,1),-n.z),new we(new I(0,0,-1),s.z)];if(e!==0){let o=i.getCenter(new I);for(let a of r){let l=a.distanceToPoint(o);a.normal.applyAxisAngle(Ch.z,e),a.constant=l-a.normal.dot(o)}}return t==="keepInside"?{planes:r,intersection:!1}:{planes:r.map(o=>o.negate()),intersection:!0}}function cp(i,t,e,n,s,r){let o=i.clone();if(n>0?o.max[e]=Math.max(i.max[e]+s,i.min[e]+r):o.min[e]=Math.min(i.min[e]-s,i.max[e]-r),t!==0){let a=o.getCenter(new I).sub(i.getCenter(new I));o.translate(a.clone().applyAxisAngle(Ch.z,t).sub(a))}return o}function hp(i){let{min:t,max:e}=i;return Array.from({length:8},(n,s)=>new I(s&1?e.x:t.x,s&2?e.y:t.y,s&4?e.z:t.z))}function up(i,t,e){if(t.length===0||i.isEmpty())return!1;let n=hp(i),s=r=>n.every(o=>r.distanceToPoint(o)<0);return e?t.every(s):t.some(s)}function fl(i,t){let e=i.getSize(new I).multiplyScalar(.5);return Math.abs(t.x)*e.x+Math.abs(t.y)*e.y+Math.abs(t.z)*e.z}function Br(i,t,e){let n=t.clone().sub(i.origin),s=e.dot(i.direction),r=1-s*s;return r<.03?null:(s*i.direction.dot(n)-e.dot(n))/r}function pl(i,t,e){let n=new I(1,0,0).applyQuaternion(t),s=new I(0,1,0).applyQuaternion(t),[r,o,a,l]=[1/0,-1/0,1/0,-1/0];for(let h of hp(i)){h.sub(e);let d=h.dot(n),u=h.dot(s);[r,o,a,l]=[Math.min(r,d),Math.max(o,d),Math.min(a,u),Math.max(l,u)]}return{center:e.clone().addScaledVector(n,(r+o)/2).addScaledVector(s,(a+l)/2),width:(o-r)*1.1,height:(l-a)*1.1}}var Or=6,xy=["off","planes","box"],vy=.05,Ph=new I(0,0,1),ml=class extends EventTarget{constructor(t,e,n){super(),this.scene=t,this.modelBox=e.clone(),this.center=e.getCenter(new I),this.planes=[],this.active=-1,this.box=null,this.boxYaw=0,this.boxMode="keepInside",this.fill=!1,this.gizmoVisible=!0,this._mode="off",n&&this.restore(n)}restore({planes:t,box:e,cutInside:n}){this.modelBox.isEmpty()||(this.planes=t.map(({axis:s,normal:r,offset:o,flipped:a})=>{let l=new I().fromArray(r),c=new Le().setFromUnitVectors(Ph,l);return{axis:s,quaternion:c,offset:o-l.dot(this.center),flipped:a,enabled:!0,rotated:!1}}),this.active=this.planes.length?0:-1,this.box=e?new oe(new I().fromArray(e.min),new I().fromArray(e.max)):null,this.boxYaw=0,this.boxMode=n?"cutInside":"keepInside",this.gizmoVisible=!1,this.setMode(this.box?"box":this.planes.length?"planes":"off"))}get mode(){return this._mode}setMode(t){if(!xy.includes(t))throw new RangeError(`Unknown section mode: ${t}`);t==="box"&&!this.box&&this.fitBoxToShown()||(this._mode=t,this._changed(!0))}addPlane(t){let e=Ih(t);if(this.planes.length>=Or||this.modelBox.isEmpty())return null;let n=new Le().setFromUnitVectors(Ph,e);return this.planes.push({axis:t,quaternion:n,offset:0,flipped:!1,enabled:!0,rotated:!1}),this.active=this.planes.length-1,this._mode="planes",this._changed(!0),this.active}removePlane(t){this._plane(t),this.planes.splice(t,1),(this.active>=this.planes.length||this.active>t)&&this.active--,this._changed(!0)}updatePlane(t,{offset:e,flipped:n,enabled:s,quaternion:r}){let o=this._plane(t);if(e!==void 0){if(!Number.isFinite(e))throw new RangeError(`Offset must be a finite number, got ${e}.`);o.offset=e}n!==void 0&&(o.flipped=!!n),s!==void 0&&(o.enabled=!!s),r&&(o.quaternion.copy(r).normalize(),o.rotated=o.axis!=="custom"&&this.normal(t).angleTo(Ih(o.axis))>1e-6),this._changed(!0)}setActivePlane(t){this._plane(t),this.active=t,this._changed(!1)}normal(t){return Ph.clone().applyQuaternion(this._plane(t).quaternion)}extent(t){return fl(this.modelBox,this.normal(t))}origin(t){return this.center.clone().addScaledVector(this.normal(t),this._plane(t).offset)}clipPlane(t){let e=this._plane(t);return ap(this.normal(t),this.center,e.offset,e.flipped)}setBox(t,e=0){if(t.isEmpty())throw new RangeError("The section box is empty.");e=dp(e),this.box=t.clone(),this.boxYaw=e,this._mode="box",this._changed(!0)}setBoxYaw(t){this.box&&(this.boxYaw=dp(t),this._changed(this.mode==="box"))}setBoxMode(t){if(t!=="keepInside"&&t!=="cutInside")throw new RangeError(`Unknown box mode: ${t}`);this.boxMode=t,this._changed(!0)}fitBoxToElements(t){let e=new oe;for(let s of t)e.union(this.scene.elementBox(s));if(e.isEmpty())return!1;let n=e.getSize(new I);return this.setBox(e.expandByScalar(vy*Math.max(n.x,n.y,n.z))),!0}fitBoxToShown(){let t=this.scene.visibleBox();if(t.isEmpty())return!1;let e=t.getSize(new I);return this.setBox(t.expandByScalar(.001*Math.max(e.x,e.y,e.z))),!0}setGizmoVisible(t){this.gizmoVisible=!!t,this._changed(!1)}setFill(t){this.fill=!!t,this._changed(!1)}reset(){this.planes=[],this.active=-1,this.box=null,this.boxYaw=0,this._mode="off",this._changed(!0)}clipping(){if(this._mode==="planes")return{planes:this.planes.flatMap((e,n)=>e.enabled?[this.clipPlane(n)]:[]),intersection:!1};if(this._mode==="box"&&this.box){let t=lp(this.box,this.boxMode,this.boxYaw);if(!t.intersection&&this.boxYaw!==0){let e=this.box.getCenter(new I),n=this.box.getSize(new I).multiplyScalar(.5),s=Math.abs(Math.cos(this.boxYaw)),r=Math.abs(Math.sin(this.boxYaw));n.set(s*n.x+r*n.y,r*n.x+s*n.y,n.z),t.bounds=new oe(e.clone().sub(n),e.add(n))}return t}return{planes:[],intersection:!1}}isCut(t,{planes:e,intersection:n,bounds:s}=this.clipping()){return s&&!t.isEmpty()&&!s.intersectsBox(t)||up(t,e,n)}_plane(t){let e=this.planes[t];if(!Number.isInteger(t)||!e)throw new RangeError(`Plane index ${t} is out of range 0..${this.planes.length-1}.`);return e}_changed(t){if(t){let{planes:e,intersection:n}=this.clipping();this.scene.setClipping(e,n)}this.dispatchEvent(new Event("change"))}};function dp(i){if(!Number.isFinite(i))throw new RangeError("The section box angle must be finite.");return i>=-Math.PI&&i<=Math.PI?i:re.euclideanModulo(i+Math.PI,2*Math.PI)-Math.PI}var Lh=80,yy=8,Uh=.8,My=Math.sin(re.degToRad(12)),Ai={x:"#ef4444",y:"#22c55e",z:"#3b82f6",centre:"#e2e8f0",hover:"#facc15",frame:"#93c5fd",fill:"#60a5fa"},Dh=["x","y","z"],by=Math.cos(re.degToRad(12)),gl=new I(0,0,1),Sy=i=>new Ke({color:i,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.9}),wy=new Ke({visible:!1});function _l(i,t,e,n){let s=new Re,r=Sy(t);for(let a of e)s.add(new _e(a,r));let o=new _e(n,wy);return o.userData.handle=s,s.add(o),s.userData={kind:i,color:t,material:r,proxy:o},s.traverse(a=>a.renderOrder=1e3),s}function Nh(i,t,e=n=>n){let n=_l("rotate",Ai[t],[e(new bs(Uh,.018,8,64))],e(new bs(Uh,.09,8,48)));return n.name=i,n.userData.axis=t,n}var xl=class extends EventTarget{constructor(t,e){super(),this.sections=t,this.dom=e,this.camera=null,this.group=new Re,this.group.name="sections",this._raycaster=new On,this._drag=null,this._hovered=null,this._buildPlanes(),this._buildPlaneGizmo(),this._buildBox(),t.addEventListener("change",()=>this._sync()),(e.parentElement??e).addEventListener("pointerdown",n=>this._down(n),!0),e.addEventListener("pointermove",n=>this._move(n)),e.addEventListener("pointerup",n=>this._up(n)),e.addEventListener("pointercancel",()=>this._end()),e.addEventListener("lostpointercapture",()=>this._end()),this._sync()}get dragging(){return this._drag!==null}update(t){this.camera=t;let e=this.planeGizmo;e.visible&&(e.scale.setScalar(this._worldPerPixel(e.position)*Lh),this.arrow.visible=this._across(gl.clone().applyQuaternion(e.quaternion),e.position));for(let s of this.boxHandles){let{shown:r,normal:o}=s.userData;s.visible=r&&(!o||this._across(o,s.position)),s.visible&&s.scale.setScalar(this._worldPerPixel(s.position)*yy)}let n=this.boxRing;n.visible&&n.scale.setScalar(this._worldPerPixel(n.position)*Lh)}_across(t,e){let n=this.camera,s=n.isOrthographicCamera?n.getWorldDirection(new I):e.clone().sub(n.position).normalize();return Math.abs(t.dot(s))new I(r/2,o/2,0))),n=new Ke({color:Ai.fill,transparent:!0,opacity:.12,side:Ne,depthWrite:!1}),s=new an({color:Ai.frame});this.planeVisuals=Array.from({length:Or},()=>{let r=new Re;return r.add(new _e(t,n),new er(e,s)),this.group.add(r),r})}_buildPlaneGizmo(){let t=(n,s)=>n.rotateX(Math.PI/2).translate(0,0,s),e=_l("move",Ai.z,[t(new Bi(.025,.025,1),.5),t(new rr(.08,.25),1.125)],t(new Bi(.12,.12,1.25),.625));e.name="arrow",this.arrow=e,this.planeGizmo=new Re,this.planeGizmo.add(e,Nh("ringX","x",n=>n.rotateY(Math.PI/2)),Nh("ringY","y",n=>n.rotateX(Math.PI/2))),this.group.add(this.planeGizmo)}_buildBox(){this.boxWire=new vn(new Oi(new dn(1,1,1)),new an({color:Ai.frame})),this.group.add(this.boxWire);let t=new mi(1,16,12),e=new mi(1.6,8,6);this.boxHandles=[];for(let s of Dh)for(let r of[-1,1]){let o=_l("face",Ai[s],[t],e);o.name=`face${r>0?"+":"-"}${s}`,Object.assign(o.userData,{axis:s,sign:r,normal:new I}),this.boxHandles.push(o)}let n=_l("centre",Ai.centre,[new dn(1.4,1.4,1.4)],e);n.name="centre",this.boxHandles.push(n),this.boxRing=Nh("boxRing","z"),this.group.add(...this.boxHandles,this.boxRing)}_sync(){let t=this.sections,e=t.mode==="planes";this.planeVisuals.forEach((r,o)=>{let a=t.planes[o];if(r.visible=e&&!!a?.enabled,!r.visible)return;r.children[0].visible=!t.fill;let l=pl(t.modelBox,a.quaternion,t.origin(o));r.position.copy(l.center),r.quaternion.copy(a.quaternion),r.scale.set(l.width,l.height,1)});let n=t.planes[t.active];this.planeGizmo.visible=e&&t.gizmoVisible&&!!n?.enabled,this.planeGizmo.visible&&(this.planeGizmo.position.copy(t.origin(t.active)),this.planeGizmo.quaternion.copy(n.quaternion));let s=t.mode==="box"?t.box:null;this.boxWire.visible=!!s,this.boxRing.visible=!!s&&t.gizmoVisible;for(let r of this.boxHandles)r.visible=r.userData.shown=!!s&&t.gizmoVisible;if(s){let r=s.getCenter(new I),o=s.getSize(new I);this.boxWire.position.copy(r),this.boxWire.scale.copy(o).max(new I(1e-6,1e-6,1e-6)),this.boxWire.rotation.z=t.boxYaw,this.boxRing.position.copy(r);for(let a of this.boxHandles){let{axis:l,sign:c,normal:h}=a.userData;h?(h.set(0,0,0).setComponent(Dh.indexOf(l),c).applyAxisAngle(gl,t.boxYaw),a.position.copy(r).addScaledVector(h,o[l]/2)):a.position.copy(r)}}}_worldPerPixel(t){let e=this.camera,n=Math.max(this.dom.clientHeight,1);if(e.isOrthographicCamera)return(e.top-e.bottom)/e.zoom/n;let s=t.clone().sub(e.position).dot(e.getWorldDirection(new I));return 2*Math.max(s,e.near)*Math.tan(re.degToRad(e.fov/2))/n}_ray(t){let e=this.dom.getBoundingClientRect(),n=new $t((t.clientX-e.left)/e.width*2-1,1-(t.clientY-e.top)/e.height*2);return this.camera.updateMatrixWorld(),this._raycaster.setFromCamera(n,this.camera),this._raycaster.ray.clone()}_hit(t){if(!this.camera)return null;this.update(this.camera),this.group.updateMatrixWorld(!0);let e=r=>{for(;r&&r!==this.group;r=r.parent)if(!r.visible)return!1;return!0},n=[];this.group.traverse(r=>r.userData.handle&&e(r)&&n.push(r)),this._ray(t);let s=this._raycaster.intersectObjects(n,!1);return(this.sections.mode==="box"?s.find(r=>r.object.userData.handle!==this.boxRing):null)??s[0]??null}_down(t){if(t.target!==this.dom||t.button!==0)return;let e=this._hit(t);if(!e)return;let n=e.object.userData.handle,s=this._start(n,this._raycaster.ray,e.point,t);s&&(t.stopPropagation(),t.preventDefault(),this.dom.setPointerCapture(t.pointerId),this._drag={id:t.pointerId,handle:n,...s},this._highlight(n))}_start(t,e,n,s){let r=this.sections,{kind:o}=t.userData;if(o==="move"){let u=r.active,f=r.origin(u),g=r.normal(u),_=Br(e,f,g);return _===null?null:{index:u,origin:f,normal:g,offset:r.planes[u].offset,s0:_}}if(o==="rotate"){let u=r.active,f=t===this.boxRing,g=f?t.position.clone():r.origin(u),_=f?null:r.planes[u].quaternion.clone(),m=f?gl:new I().setComponent(Dh.indexOf(t.userData.axis),1).applyQuaternion(_),p={index:u,origin:g,quaternion:_,axis:m,yaw:f?r.boxYaw:null};if(Math.abs(m.dot(e.direction))0&&r===0}function Ry(i,t){let{instances:e,geometries:n}=t.meta,s=t.readView(e.geometry),{width:r,height:o}=i.slotUniforms.slotState.value.image,a=new Uint8Array(r*o),l=new Map;for(let h=0;h{let s=e.category??"";t.has(s)||t.set(s,[]),t.get(s).push(n)}),[...t].map(([e,n])=>({name:e,indices:n})).sort((e,n)=>e.name.localeCompare(n.name))}function tp(i,{elements:t,models:e,selection:n,scene:s,zoomToElement:r,openContextMenu:o}){let a=_y(t),l=new Int32Array(t.length);a.forEach((k,K)=>k.indices.forEach(lt=>l[lt]=K));let c=new Uint8Array(a.length),h=new Int32Array(a.length),d=new Uint32Array(a.length),u=gy(t),f="",g=!1,_=new Int32Array(0),m=0,p=-1,b=null,E=!1,v=et("input","ioviewer-tree-search");v.type="search",v.placeholder=$("searchPlaceholder"),v.setAttribute("aria-label",$("searchPlaceholder"));let y=et("div","ioviewer-tree");y.setAttribute("role","tree"),y.setAttribute("aria-label",$("panel.model")),y.setAttribute("aria-multiselectable","true"),y.tabIndex=-1;let S=et("div","ioviewer-tree-spacer");S.setAttribute("role","presentation"),y.append(S);let A=et("div","ioviewer-tree-empty",$("noMatches")),x=Qf(t,e,v,N,()=>s.isolate(_));i.append(x.element,v,y,A);function T(){let k=_[m],K=x.predicate();if(g=!!(f||K),g){let ht=f?u(f):t.keys();if(K){let at=[];for(let Y of ht)K(t[Y])&&at.push(Y);_=Int32Array.from(at)}else _=Int32Array.from(ht)}else{let ht=a.length;a.forEach((Y,tt)=>c[tt]&&(ht+=Y.indices.length)),_=new Int32Array(ht);let at=0;a.forEach((Y,tt)=>{if(h[tt]=at,_[at++]=-(tt+1),c[tt])for(let dt of Y.indices)_[at++]=dt})}let lt=_.indexOf(k);m=lt>=0?lt:0,S.style.height=`${_.length*Ri}px`,A.hidden=_.length>0||!g,x.update(f,!!s.isolate&&g&&_.some(ht=>s.instancesOf(ht).length>0)),C()}function C(k=y.contains(document.activeElement)){let K=y.clientHeight;if(K===0||_.length===0){S.replaceChildren();return}let lt=y.scrollTop,{start:ht,end:at}=Ih(lt,Ri,K,_.length,my);!k&&(m=at)&&(m=Math.min(_.length-1,Math.floor(lt/Ri)));let Y=[];m=at&&Y.push(D(m)),S.replaceChildren(...Y),k&&S.querySelector('[tabindex="0"]')?.focus({preventScroll:!0})}function D(k){let K=_[k],lt=K<0?-K-1:l[K],ht=K<0?d[lt]===a[lt].indices.length:n.has(K),at=et("div","tree-row");if(at.style.top=`${k*Ri}px`,at.style.height=`${Ri}px`,at.dataset.row=k,at.tabIndex=k===m?0:-1,at.setAttribute("role","treeitem"),at.classList.toggle("selected",ht),at.setAttribute("aria-selected",String(ht)),K<0){at.classList.add("tree-category"),at.setAttribute("aria-level","1"),at.setAttribute("aria-posinset",String(lt+1)),at.setAttribute("aria-setsize",String(a.length)),at.setAttribute("aria-expanded",String(!!c[lt]));let Y=et("span","tree-chevron");Y.innerHTML=ne.chevron;let{name:tt,indices:dt}=a[lt];at.append(Y,et("span","tree-name",tt||$("noCategory")),et("span","tree-count",zr(dt.length)))}else{let Y=t[K];at.classList.add("tree-element"),at.setAttribute("aria-level",g?"1":"2"),at.setAttribute("aria-posinset",String(g?k+1:k-h[lt])),at.setAttribute("aria-setsize",String(g?_.length:a[lt].indices.length)),at.classList.toggle("tree-child",!g),at.classList.toggle("tree-hidden",s.isVisible?.(K)===!1),at.append(et("span","tree-name",Y.name||`#${Y.id}`),et("span","tree-type",Y.type??""))}return at}function U(k){let K=y.clientHeight;if(K===0){p=k;return}let lt=k*Ri;lty.scrollTop+K&&(y.scrollTop=lt+Ri-K)}function F(k){m=k,U(k),C(!0)}function I(k){let K=l[k];!g&&!c[K]&&(c[K]=1,T());let lt=_.indexOf(k);lt>=0&&(y.contains(document.activeElement)||(m=lt),U(lt)),C()}function B(k){E=!0;try{n.set(k)}finally{E=!1}}function G(k,K){let lt=_.indexOf(b);lt<0&&(lt=k,b=_[k]);let ht=_.subarray(Math.min(lt,k),Math.max(lt,k)+1).filter(at=>at>=0);ht.length>0&&B(K?[...n.values(),...ht]:ht)}function q(k){b=k;let K=-k-1,lt=k<0?a[K].indices:[k],ht=k<0?d[K]===lt.length:n.has(k),at=new Set(n.values());for(let Y of lt)ht?at.delete(Y):at.add(Y);B(at)}function O(k,K,lt){k>=0&&!n.has(k)&&(b=k,B([k]));let ht=k>=0?k:n.values().next().value??null;o(K,lt,ht,()=>{let at=_.indexOf(k);at>=0?F(at):v.focus()})}v.addEventListener("focus",()=>{S.firstElementChild||W()});function N(){f=v.value.trim(),y.scrollTop=0,p=-1,m=-1,T()}v.addEventListener("input",N),y.addEventListener("scroll",()=>C()),y.addEventListener("focusin",k=>{let K=k.target.closest(".tree-row");!K||K.tabIndex===0||(S.querySelector('[tabindex="0"]')?.setAttribute("tabindex","-1"),m=Number(K.dataset.row),K.tabIndex=0)}),y.addEventListener("keydown",k=>{let K=k.target.closest(".tree-row");if(!K||k.ctrlKey||k.altKey||k.metaKey)return;let lt=Number(K.dataset.row),ht=_[lt];if(Ch(k)){if(k.preventDefault(),!k.repeat){let{left:Y,bottom:tt}=K.getBoundingClientRect();O(ht,Y,tt)}return}if(k.key===" "){k.preventDefault(),k.repeat||(k.shiftKey?G(lt,!1):q(ht));return}if(k.shiftKey)return;let at=lt;switch(k.key){case"ArrowUp":at=Math.max(0,lt-1);break;case"ArrowDown":at=Math.min(_.length-1,lt+1);break;case"Home":at=0;break;case"End":at=_.length-1;break;case"ArrowRight":ht<0&&(c[-ht-1]?at=lt+1:(c[-ht-1]=1,T()));break;case"ArrowLeft":ht>=0&&!g?at=h[l[ht]]:ht<0&&c[-ht-1]&&(c[-ht-1]=0,T());break;case"Enter":k.repeat||z(ht);break;default:return}k.preventDefault(),at!==lt&&F(at)});function z(k){if(k>=0){b=k,B([k]),r(k);return}c[-k-1]^=1,T()}y.addEventListener("click",k=>{let K=k.target.closest(".tree-row");if(!K)return;let lt=Number(K.dataset.row),ht=k.ctrlKey||k.metaKey;k.shiftKey?G(lt,ht):ht?q(_[lt]):z(_[lt])}),y.addEventListener("contextmenu",k=>{let K=k.target.closest(".tree-row");K&&(k.preventDefault(),O(_[Number(K.dataset.row)],k.clientX,k.clientY))});function W(){p>=0&&y.clientHeight>0&&(U(p),p=-1),C()}new ResizeObserver(W).observe(y),n.addEventListener("change",()=>{let k=-1;d.fill(0);for(let K of n.values())d[l[K]]++,k=K;if(E){C();return}b=null,k>=0?I(k):C()}),s.root?.addEventListener("change",k=>k.detail.kind==="visibility"&&C()),T()}var ep={element:["properties","hide","isolate","showAll","-","zoomTo","sectionBox","-","copyId"],empty:["showAll","fitAll","resetSections"]},xy={hide:"H",isolate:"I",showAll:"Shift+H",zoomTo:"F"},ml=4;function np(i){let t=et("div","ioviewer-context-menu");t.setAttribute("role","menu"),t.setAttribute("aria-label",$("contextMenu")),t.hidden=!0,i.append(t);let e=new Map(Object.values(ep).flat().filter(c=>c!=="-").map(c=>[c,{enabled:!1,handler:null}])),n=null;function s(){if(t.hidden)return;let c=t.contains(document.activeElement)?n:null;n=null,t.hidden=!0,t.replaceChildren(),window.removeEventListener("pointerdown",o,!0),window.removeEventListener("wheel",s,!0),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",s),c?.()}function r(c){i.contains(c.target)||s()}function o(c){t.contains(c.target)||(s(),al(c))}function a(c,h,d,u,f=null){let g=ep[c];if(!g)throw new RangeError(`Unknown menu: ${c}`);s(),n=f;for(let p of g){if(p==="-"){let v=et("div","ioviewer-menu-separator");v.setAttribute("role","separator"),t.append(v);continue}let b=e.get(p),E=et("button","ioviewer-menu-item");E.type="button",E.tabIndex=-1,E.dataset.item=p,E.setAttribute("role","menuitem"),E.setAttribute("aria-disabled",String(!b.enabled)),b.enabled||(E.title=$("menu.unavailable")),E.append(et("span","",$(`menu.${p}`)),et("kbd","",xy[p]??"")),E.addEventListener("click",()=>{b.enabled&&(s(),b.handler(u))}),t.append(E)}t.hidden=!1;let{width:_,height:m}=t.getBoundingClientRect();t.style.left=`${Math.max(ml,Math.min(h,innerWidth-_-ml))}px`,t.style.top=`${Math.max(ml,Math.min(d,innerHeight-m-ml))}px`,window.addEventListener("pointerdown",o,!0),window.addEventListener("wheel",s,!0),window.addEventListener("scroll",r,!0),window.addEventListener("resize",s),f&&t.querySelector("button")?.focus({preventScroll:!0})}t.addEventListener("keydown",c=>{if(c.key==="Tab"){s();return}if(c.key==="Escape"){c.preventDefault(),s();return}let h=[...t.querySelectorAll("button")],d=h.indexOf(document.activeElement),u;switch(c.key){case"ArrowDown":u=(d+1)%h.length;break;case"ArrowUp":u=(d+h.length-1)%h.length;break;case"Home":u=0;break;case"End":u=h.length-1;break;default:return}c.preventDefault(),h[u]?.focus({preventScroll:!0})});function l(c,{enabled:h=!0,handler:d}){let u=e.get(c);if(!u)throw new RangeError(`Unknown menu item: ${c}`);d&&(u.handler=d),u.enabled=h&&!!u.handler}return{element:t,open:a,close:s,setItem:l,get isOpen(){return!t.hidden}}}var vy=1600;function ip(i,t,e){let n=()=>i.textContent=`${$("selected")}: ${zr(t.size)} \xB7 ${$("elements")}: ${zr(e)}`;t.addEventListener("change",n),n()}function sp(i,t){if(!t)return;let e=et("div","ioviewer-banner ioviewer-floating");e.setAttribute("role","status");let n=$("truncated").replace("{meshes}",t.meshes).replace("{total}",t.totalMeshes),s=Qe("ioviewer-panel-close",ne.close,$("close")),r=new ResizeObserver(()=>i.style.setProperty("--banner-height",`${e.offsetHeight}px`));s.addEventListener("click",()=>{r.disconnect(),i.style.removeProperty("--banner-height"),e.remove()}),e.append(et("span","",n),s),i.append(e),r.observe(e)}function zs(i,t){let e=et("div","ioviewer-toast",t);e.setAttribute("role","status"),i.append(e),setTimeout(()=>e.remove(),vy)}function rp(i,t){let e=et("table");for(let[s,r]of t)e.insertRow().append(et("th","",s),et("td","",String(r??"")));let n=et("section");return n.append(et("h3","",i),e),n}function op(i,t,e){let n=et("h2","ioviewer-properties-title"),s=et("button","ioviewer-properties-close","\xD7");s.type="button",s.title=$("close"),s.setAttribute("aria-label",$("close")),s.addEventListener("click",()=>t.clear());let r=et("header");r.append(n,s);let o=et("div","ioviewer-properties-body");i.replaceChildren(r,o),i.hidden=!0;let a=h=>{let d=[[$("id"),h.id],[$("category"),h.category],[$("type"),h.type],[$("level"),h.level]];return h.sourceId&&d.push([$("sourceId"),h.sourceId]),h.link&&d.push([$("link"),h.link]),rp($("elementGroup"),d)},l=h=>{for(let[d,u]of Object.entries(h??{}))o.append(rp(d,Object.entries(u)))},c;t.addEventListener("change",()=>{if(c?.abort(),c=void 0,o.removeAttribute("aria-busy"),i.hidden=t.size===0,o.replaceChildren(),t.size!==1){n.textContent=`${$("selected")}: ${t.size}`;return}let[h]=t.values(),d=e.meta.elements[h];if(n.textContent=d.name||`#${d.id}`,o.append(a(d)),!e.loadProperties){l(e.props(d.id));return}let u=new AbortController;c=u,o.setAttribute("aria-busy","true"),e.loadProperties(h,u.signal).then(f=>{u.signal.aborted||!f||(n.textContent=f.name||d.name||`#${d.id}`,o.replaceChildren(a({...d,...f})),l(f.properties))}).catch(()=>{u.signal.aborted||o.append(et("p","",$("badData")))}).finally(()=>{c===u&&o.removeAttribute("aria-busy")})})}async function yy(i){if(await navigator.clipboard?.writeText(i).then(()=>!0,()=>!1))return!0;let t=document.createElement("textarea");t.value=i,t.setAttribute("readonly",""),t.className="ioviewer-offscreen",document.body.append(t),t.select();try{return document.execCommand("copy")}finally{t.remove()}}function ap({root:i,data:t,scene:e,controls:n,picker:s,selection:r,measure:o}){let{meta:a}=t,l=()=>n.fitBox(e.visibleBox()),c={hide:e.setVisible&&(()=>r.size&&e.setVisible([...r.values()],!1)),isolate:e.isolate&&(()=>r.size&&e.isolate([...r.values()])),showAll:e.showAll&&(()=>e.showAll()),zoomTo:()=>{if(!r.size)return l();let[b,...E]=r.values(),v=e.elementBox(b);for(let y of E)v.union(e.elementBox(y));n.zoomToBox(v)},fitAll:l},h=Zf(i);h.registerPanel("model",{icon:ne.model,title:$("panel.model"),visible:a.elements.length>0||!!e.setVisible,render:b=>tp(b,{elements:a.elements,models:a.models??[],selection:r,scene:e,openContextMenu:_,zoomToElement:E=>n.zoomToBox(e.elementBox(E))})});let d=document.createElement("aside");d.id="ioviewer-properties",d.className="ioviewer-floating",i.append(d),op(d,r,t);let u=Kf(i,Jf),f=b=>{n.setLeftButtonMode(b),u.setActive("orbit",b==="orbit"),u.setActive("pan",b==="pan")};u.setHandler("orbit",()=>f("orbit")),u.setHandler("pan",()=>f("pan")),f(n.leftButtonMode),u.setHandler("fit",l),u.setHandler("projection",()=>{let b=!n.camera.isOrthographicCamera;n.setProjection(b?"orthographic":"perspective"),u.setActive("projection",b)}),u.setActive("projection",!1),document.fullscreenEnabled&&(u.setHandler("fullscreen",()=>{(document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()).catch(()=>{u.setActive("fullscreen",!!document.fullscreenElement),zs(i,$("fullscreenUnavailable"))})}),document.addEventListener("fullscreenchange",()=>u.setActive("fullscreen",!!document.fullscreenElement)));let g=np(i);function _(b,E,v,y){g.open(v===null?"empty":"element",b,E,v,y)}function m(b){if(g.isOpen)return;let E=b===document.body,v=(E?n.dom:b).getBoundingClientRect(),y=E?v.left+v.width/2:v.left,S=E?v.top+v.height/2:v.bottom;_(y,S,r.values().next().value??null,()=>b.focus({preventScroll:!0}))}g.setItem("properties",{handler:b=>r.set([b])});for(let b of["hide","isolate","showAll","zoomTo","fitAll"])g.setItem(b,{handler:c[b]});g.setItem("copyId",{handler:b=>yy(String(a.elements[b].id)).then(E=>zs(i,$(E?"idCopied":"copyFailed")),()=>zs(i,$("copyFailed")))}),n.addEventListener("contextmenu",async b=>{let{x:E,y:v}=b.detail;if(o?.active)return _(E,v,r.values().next().value??null);let y=s.pick(E,v),S=y?.then?await y:y;if(S!==void 0){if(!S||S.element<0)return _(E,v,null);r.has(S.element)||r.set([S.element]),_(E,v,S.element)}});let p=[];return window.addEventListener("keydown",b=>{if(b.defaultPrevented)return;let E=jf(b);if(E){if(b.preventDefault(),E==="contextMenu")return m(document.activeElement??document.body);if(E==="escape"&&!g.isOpen){p.some(v=>v())||r.clear();return}g.close(),E!=="escape"&&c[E]?.()}}),ip(document.getElementById("ioviewer-status"),r,e.elementCount),sp(i,a.truncated),{shell:h,toolbar:u,contextMenu:g,onEscape:b=>p.push(b)}}var Ph={x:new L(1,0,0),y:new L(0,1,0),z:new L(0,0,1)};function Lh(i){let t=Ph[i];if(!t)throw new RangeError(`Unknown axis: ${i}`);return t.clone()}function lp(i,t,e){if(t.length===0)return!1;let n=s=>s.distanceToPoint(i)<0;return e?t.every(n):t.some(n)}function cp(i,t,e,n){let s=i.clone().normalize(),r=s.dot(t)+e;return n?new we(s,-r):new we(s.negate(),r)}function hp(i,t,e=0){if(t!=="keepInside"&&t!=="cutInside")throw new RangeError(`Unknown box mode: ${t}`);let{min:n,max:s}=i,r=[new we(new L(1,0,0),-n.x),new we(new L(-1,0,0),s.x),new we(new L(0,1,0),-n.y),new we(new L(0,-1,0),s.y),new we(new L(0,0,1),-n.z),new we(new L(0,0,-1),s.z)];if(e!==0){let o=i.getCenter(new L);for(let a of r){let l=a.distanceToPoint(o);a.normal.applyAxisAngle(Ph.z,e),a.constant=l-a.normal.dot(o)}}return t==="keepInside"?{planes:r,intersection:!1}:{planes:r.map(o=>o.negate()),intersection:!0}}function up(i,t,e,n,s,r){let o=i.clone();if(n>0?o.max[e]=Math.max(i.max[e]+s,i.min[e]+r):o.min[e]=Math.min(i.min[e]-s,i.max[e]-r),t!==0){let a=o.getCenter(new L).sub(i.getCenter(new L));o.translate(a.clone().applyAxisAngle(Ph.z,t).sub(a))}return o}function dp(i){let{min:t,max:e}=i;return Array.from({length:8},(n,s)=>new L(s&1?e.x:t.x,s&2?e.y:t.y,s&4?e.z:t.z))}function fp(i,t,e){if(t.length===0||i.isEmpty())return!1;let n=dp(i),s=r=>n.every(o=>r.distanceToPoint(o)<0);return e?t.every(s):t.some(s)}function gl(i,t){let e=i.getSize(new L).multiplyScalar(.5);return Math.abs(t.x)*e.x+Math.abs(t.y)*e.y+Math.abs(t.z)*e.z}function Vr(i,t,e){let n=t.clone().sub(i.origin),s=e.dot(i.direction),r=1-s*s;return r<.03?null:(s*i.direction.dot(n)-e.dot(n))/r}function _l(i,t,e){let n=new L(1,0,0).applyQuaternion(t),s=new L(0,1,0).applyQuaternion(t),[r,o,a,l]=[1/0,-1/0,1/0,-1/0];for(let h of dp(i)){h.sub(e);let d=h.dot(n),u=h.dot(s);[r,o,a,l]=[Math.min(r,d),Math.max(o,d),Math.min(a,u),Math.max(l,u)]}return{center:e.clone().addScaledVector(n,(r+o)/2).addScaledVector(s,(a+l)/2),width:(o-r)*1.1,height:(l-a)*1.1}}var Gr=6,My=["off","planes","box"],by=.05,Dh=new L(0,0,1),xl=class extends EventTarget{constructor(t,e,n){super(),this.scene=t,this.modelBox=e.clone(),this.center=e.getCenter(new L),this.planes=[],this.active=-1,this.box=null,this.boxYaw=0,this.boxMode="keepInside",this.fill=!1,this.gizmoVisible=!0,this._mode="off",n&&this.restore(n)}restore({planes:t,box:e,cutInside:n}){this.modelBox.isEmpty()||(this.planes=t.map(({axis:s,normal:r,offset:o,flipped:a})=>{let l=new L().fromArray(r),c=new Le().setFromUnitVectors(Dh,l);return{axis:s,quaternion:c,offset:o-l.dot(this.center),flipped:a,enabled:!0,rotated:!1}}),this.active=this.planes.length?0:-1,this.box=e?new le(new L().fromArray(e.min),new L().fromArray(e.max)):null,this.boxYaw=0,this.boxMode=n?"cutInside":"keepInside",this.gizmoVisible=!1,this.setMode(this.box?"box":this.planes.length?"planes":"off"))}get mode(){return this._mode}setMode(t){if(!My.includes(t))throw new RangeError(`Unknown section mode: ${t}`);t==="box"&&!this.box&&this.fitBoxToShown()||(this._mode=t,this._changed(!0))}addPlane(t){let e=Lh(t);if(this.planes.length>=Gr||this.modelBox.isEmpty())return null;let n=new Le().setFromUnitVectors(Dh,e);return this.planes.push({axis:t,quaternion:n,offset:0,flipped:!1,enabled:!0,rotated:!1}),this.active=this.planes.length-1,this._mode="planes",this._changed(!0),this.active}removePlane(t){this._plane(t),this.planes.splice(t,1),(this.active>=this.planes.length||this.active>t)&&this.active--,this._changed(!0)}updatePlane(t,{offset:e,flipped:n,enabled:s,quaternion:r}){let o=this._plane(t);if(e!==void 0){if(!Number.isFinite(e))throw new RangeError(`Offset must be a finite number, got ${e}.`);o.offset=e}n!==void 0&&(o.flipped=!!n),s!==void 0&&(o.enabled=!!s),r&&(o.quaternion.copy(r).normalize(),o.rotated=o.axis!=="custom"&&this.normal(t).angleTo(Lh(o.axis))>1e-6),this._changed(!0)}setActivePlane(t){this._plane(t),this.active=t,this._changed(!1)}normal(t){return Dh.clone().applyQuaternion(this._plane(t).quaternion)}extent(t){return gl(this.modelBox,this.normal(t))}origin(t){return this.center.clone().addScaledVector(this.normal(t),this._plane(t).offset)}clipPlane(t){let e=this._plane(t);return cp(this.normal(t),this.center,e.offset,e.flipped)}setBox(t,e=0){if(t.isEmpty())throw new RangeError("The section box is empty.");e=pp(e),this.box=t.clone(),this.boxYaw=e,this._mode="box",this._changed(!0)}setBoxYaw(t){this.box&&(this.boxYaw=pp(t),this._changed(this.mode==="box"))}setBoxMode(t){if(t!=="keepInside"&&t!=="cutInside")throw new RangeError(`Unknown box mode: ${t}`);this.boxMode=t,this._changed(!0)}fitBoxToElements(t){let e=new le;for(let s of t)e.union(this.scene.elementBox(s));if(e.isEmpty())return!1;let n=e.getSize(new L);return this.setBox(e.expandByScalar(by*Math.max(n.x,n.y,n.z))),!0}fitBoxToShown(){let t=this.scene.visibleBox();if(t.isEmpty())return!1;let e=t.getSize(new L);return this.setBox(t.expandByScalar(.001*Math.max(e.x,e.y,e.z))),!0}setGizmoVisible(t){this.gizmoVisible=!!t,this._changed(!1)}setFill(t){this.fill=!!t,this._changed(!1)}reset(){this.planes=[],this.active=-1,this.box=null,this.boxYaw=0,this._mode="off",this._changed(!0)}clipping(){if(this._mode==="planes")return{planes:this.planes.flatMap((e,n)=>e.enabled?[this.clipPlane(n)]:[]),intersection:!1};if(this._mode==="box"&&this.box){let t=hp(this.box,this.boxMode,this.boxYaw);if(!t.intersection&&this.boxYaw!==0){let e=this.box.getCenter(new L),n=this.box.getSize(new L).multiplyScalar(.5),s=Math.abs(Math.cos(this.boxYaw)),r=Math.abs(Math.sin(this.boxYaw));n.set(s*n.x+r*n.y,r*n.x+s*n.y,n.z),t.bounds=new le(e.clone().sub(n),e.add(n))}return t}return{planes:[],intersection:!1}}isCut(t,{planes:e,intersection:n,bounds:s}=this.clipping()){return s&&!t.isEmpty()&&!s.intersectsBox(t)||fp(t,e,n)}_plane(t){let e=this.planes[t];if(!Number.isInteger(t)||!e)throw new RangeError(`Plane index ${t} is out of range 0..${this.planes.length-1}.`);return e}_changed(t){if(t){let{planes:e,intersection:n}=this.clipping();this.scene.setClipping(e,n)}this.dispatchEvent(new Event("change"))}};function pp(i){if(!Number.isFinite(i))throw new RangeError("The section box angle must be finite.");return i>=-Math.PI&&i<=Math.PI?i:ae.euclideanModulo(i+Math.PI,2*Math.PI)-Math.PI}var Nh=80,Sy=8,Bh=.8,wy=Math.sin(ae.degToRad(12)),Ci={x:"#ef4444",y:"#22c55e",z:"#3b82f6",centre:"#e2e8f0",hover:"#facc15",frame:"#93c5fd",fill:"#60a5fa"},Uh=["x","y","z"],Ey=Math.cos(ae.degToRad(12)),vl=new L(0,0,1),Ty=i=>new Ke({color:i,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.9}),Ay=new Ke({visible:!1});function yl(i,t,e,n){let s=new Re,r=Ty(t);for(let a of e)s.add(new _e(a,r));let o=new _e(n,Ay);return o.userData.handle=s,s.add(o),s.userData={kind:i,color:t,material:r,proxy:o},s.traverse(a=>a.renderOrder=1e3),s}function Fh(i,t,e=n=>n){let n=yl("rotate",Ci[t],[e(new bs(Bh,.018,8,64))],e(new bs(Bh,.09,8,48)));return n.name=i,n.userData.axis=t,n}var Ml=class extends EventTarget{constructor(t,e){super(),this.sections=t,this.dom=e,this.camera=null,this.group=new Re,this.group.name="sections",this._raycaster=new kn,this._drag=null,this._hovered=null,this._buildPlanes(),this._buildPlaneGizmo(),this._buildBox(),t.addEventListener("change",()=>this._sync()),(e.parentElement??e).addEventListener("pointerdown",n=>this._down(n),!0),e.addEventListener("pointermove",n=>this._move(n)),e.addEventListener("pointerup",n=>this._up(n)),e.addEventListener("pointercancel",()=>this._end()),e.addEventListener("lostpointercapture",()=>this._end()),this._sync()}get dragging(){return this._drag!==null}update(t){this.camera=t;let e=this.planeGizmo;e.visible&&(e.scale.setScalar(this._worldPerPixel(e.position)*Nh),this.arrow.visible=this._across(vl.clone().applyQuaternion(e.quaternion),e.position));for(let s of this.boxHandles){let{shown:r,normal:o}=s.userData;s.visible=r&&(!o||this._across(o,s.position)),s.visible&&s.scale.setScalar(this._worldPerPixel(s.position)*Sy)}let n=this.boxRing;n.visible&&n.scale.setScalar(this._worldPerPixel(n.position)*Nh)}_across(t,e){let n=this.camera,s=n.isOrthographicCamera?n.getWorldDirection(new L):e.clone().sub(n.position).normalize();return Math.abs(t.dot(s))new L(r/2,o/2,0))),n=new Ke({color:Ci.fill,transparent:!0,opacity:.12,side:Ne,depthWrite:!1}),s=new an({color:Ci.frame});this.planeVisuals=Array.from({length:Gr},()=>{let r=new Re;return r.add(new _e(t,n),new nr(e,s)),this.group.add(r),r})}_buildPlaneGizmo(){let t=(n,s)=>n.rotateX(Math.PI/2).translate(0,0,s),e=yl("move",Ci.z,[t(new Oi(.025,.025,1),.5),t(new or(.08,.25),1.125)],t(new Oi(.12,.12,1.25),.625));e.name="arrow",this.arrow=e,this.planeGizmo=new Re,this.planeGizmo.add(e,Fh("ringX","x",n=>n.rotateY(Math.PI/2)),Fh("ringY","y",n=>n.rotateX(Math.PI/2))),this.group.add(this.planeGizmo)}_buildBox(){this.boxWire=new yn(new zi(new dn(1,1,1)),new an({color:Ci.frame})),this.group.add(this.boxWire);let t=new On(1,16,12),e=new On(1.6,8,6);this.boxHandles=[];for(let s of Uh)for(let r of[-1,1]){let o=yl("face",Ci[s],[t],e);o.name=`face${r>0?"+":"-"}${s}`,Object.assign(o.userData,{axis:s,sign:r,normal:new L}),this.boxHandles.push(o)}let n=yl("centre",Ci.centre,[new dn(1.4,1.4,1.4)],e);n.name="centre",this.boxHandles.push(n),this.boxRing=Fh("boxRing","z"),this.group.add(...this.boxHandles,this.boxRing)}_sync(){let t=this.sections,e=t.mode==="planes";this.planeVisuals.forEach((r,o)=>{let a=t.planes[o];if(r.visible=e&&!!a?.enabled,!r.visible)return;r.children[0].visible=!t.fill;let l=_l(t.modelBox,a.quaternion,t.origin(o));r.position.copy(l.center),r.quaternion.copy(a.quaternion),r.scale.set(l.width,l.height,1)});let n=t.planes[t.active];this.planeGizmo.visible=e&&t.gizmoVisible&&!!n?.enabled,this.planeGizmo.visible&&(this.planeGizmo.position.copy(t.origin(t.active)),this.planeGizmo.quaternion.copy(n.quaternion));let s=t.mode==="box"?t.box:null;this.boxWire.visible=!!s,this.boxRing.visible=!!s&&t.gizmoVisible;for(let r of this.boxHandles)r.visible=r.userData.shown=!!s&&t.gizmoVisible;if(s){let r=s.getCenter(new L),o=s.getSize(new L);this.boxWire.position.copy(r),this.boxWire.scale.copy(o).max(new L(1e-6,1e-6,1e-6)),this.boxWire.rotation.z=t.boxYaw,this.boxRing.position.copy(r);for(let a of this.boxHandles){let{axis:l,sign:c,normal:h}=a.userData;h?(h.set(0,0,0).setComponent(Uh.indexOf(l),c).applyAxisAngle(vl,t.boxYaw),a.position.copy(r).addScaledVector(h,o[l]/2)):a.position.copy(r)}}}_worldPerPixel(t){let e=this.camera,n=Math.max(this.dom.clientHeight,1);if(e.isOrthographicCamera)return(e.top-e.bottom)/e.zoom/n;let s=t.clone().sub(e.position).dot(e.getWorldDirection(new L));return 2*Math.max(s,e.near)*Math.tan(ae.degToRad(e.fov/2))/n}_ray(t){let e=this.dom.getBoundingClientRect(),n=new Xt((t.clientX-e.left)/e.width*2-1,1-(t.clientY-e.top)/e.height*2);return this.camera.updateMatrixWorld(),this._raycaster.setFromCamera(n,this.camera),this._raycaster.ray.clone()}_hit(t){if(!this.camera)return null;this.update(this.camera),this.group.updateMatrixWorld(!0);let e=r=>{for(;r&&r!==this.group;r=r.parent)if(!r.visible)return!1;return!0},n=[];this.group.traverse(r=>r.userData.handle&&e(r)&&n.push(r)),this._ray(t);let s=this._raycaster.intersectObjects(n,!1);return(this.sections.mode==="box"?s.find(r=>r.object.userData.handle!==this.boxRing):null)??s[0]??null}_down(t){if(t.target!==this.dom||t.button!==0)return;let e=this._hit(t);if(!e)return;let n=e.object.userData.handle,s=this._start(n,this._raycaster.ray,e.point,t);s&&(t.stopPropagation(),t.preventDefault(),this.dom.setPointerCapture(t.pointerId),this._drag={id:t.pointerId,handle:n,...s},this._highlight(n))}_start(t,e,n,s){let r=this.sections,{kind:o}=t.userData;if(o==="move"){let u=r.active,f=r.origin(u),g=r.normal(u),_=Vr(e,f,g);return _===null?null:{index:u,origin:f,normal:g,offset:r.planes[u].offset,s0:_}}if(o==="rotate"){let u=r.active,f=t===this.boxRing,g=f?t.position.clone():r.origin(u),_=f?null:r.planes[u].quaternion.clone(),m=f?vl:new L().setComponent(Uh.indexOf(t.userData.axis),1).applyQuaternion(_),p={index:u,origin:g,quaternion:_,axis:m,yaw:f?r.boxYaw:null};if(Math.abs(m.dot(e.direction))0&&r===0}function Py(i,t){let{instances:e,geometries:n}=t.meta,s=t.readView(e.geometry),{width:r,height:o}=i.slotUniforms.slotState.value.image,a=new Uint8Array(r*o),l=new Map;for(let h=0;h -${Cr} +${Nr} #include uniform highp sampler2D closedSlots; void main() { - ${Ir} + ${Ur} vec3 transformed = slotPosition; #include #include - ${mh} + ${_h} if ( texelFetch( closedSlots, st, 0 ).r < 0.5 ) gl_Position = vec4( 0.0, 0.0, 2.0, 1.0 ); }`,fragmentShader:` #include void main() { #include gl_FragColor = vec4( 0.0 ); -}`,side:e,stencilZPass:n,stencilWrite:!0,clipping:!0,clippingPlanes:[t],colorWrite:!1,depthTest:!1,depthWrite:!1});return s.index0AttributeName="q",s}var vl=class{constructor(t,e,n,s){this.model=t,this.sections=e,this.data=n,this.drawStencils=s,this._farSide=new we,this._surface=new _e(new yn(1,1),new Ke({color:Ty,side:Ne,forceSinglePass:!0,stencilWrite:!0,stencilFunc:Ic,stencilWriteMask:0}))}render(t,e,n){let{sections:s,model:r}=this,{planes:o,intersection:a}=s.clipping(),l=a?o.map(u=>u.clone().negate()):o,c=u=>Math.abs(u.distanceToPoint(s.center)){if(!c(f))return;let _=u?-f.normal.dot(u):f.distanceToPoint(n.position);if(_===0)return;if(this._farSide.copy(f),_>0&&this._farSide.negate(),t.clearStencil(),this.drawStencils)this.drawStencils(t,n,this._farSide);else for(let p of this._stencils)r.withMaterial(p,()=>t.render(r.root,n),{section:!0});this._surface.quaternion.setFromUnitVectors(Ey,f.normal);let m=pl(s.modelBox,this._surface.quaternion,f.coplanarPoint(new I));this._surface.position.copy(m.center),this._surface.scale.set(m.width,m.height,1),h.clippingPlanes=l.filter((p,b)=>b!==g),t.render(this._surface,n)}),t.render(e,n)}finally{t.autoClear=d}}};function zr(i,t,e){let n=et("div","ioviewer-segmented");n.setAttribute("role","group"),n.setAttribute("aria-label",i);let s=t.map(([o,a])=>{let l=et("button","",a);return l.type="button",l.dataset.value=o,l.addEventListener("click",()=>e(o)),n.append(l),l});return{element:n,update:o=>s.forEach(a=>a.setAttribute("aria-pressed",String(a.dataset.value===o)))}}function Fh(i,t){let e=et("label","ioviewer-check"),n=et("input");return n.type="checkbox",n.addEventListener("change",()=>t(n.checked)),e.append(n,et("span","",i)),{element:e,input:n}}function Cy(i,t){let e=et("li","ioviewer-section-plane");e.addEventListener("pointerdown",()=>i.active!==t&&i.setActivePlane(t));let n=et("span","ioviewer-section-name"),s=Qe("ioviewer-icon-button",ne.flip,$("sections.flip"));s.addEventListener("click",()=>i.updatePlane(t,{flipped:!i.planes[t].flipped}));let r=Fh($("sections.enabled"),h=>i.updatePlane(t,{enabled:h})),o=Qe("ioviewer-icon-button",ne.remove,$("sections.delete"));o.addEventListener("click",()=>i.removePlane(t));let a=et("input","ioviewer-section-slider");a.type="range",a.step="any",a.setAttribute("aria-label",$("sections.position")),a.addEventListener("input",()=>i.updatePlane(t,{offset:Number(a.value)}));let l=et("div","ioviewer-section-head");return l.append(n,s,r.element,o),e.append(l,a),{element:e,update:()=>{let h=i.planes[t],d=h.rotated?` (${$("sections.rotated")})`:"",u=h.axis==="custom"?$("sections.custom"):h.axis.toUpperCase();n.textContent=`${t+1}. ${u}${d}`,e.classList.toggle("active",i.active===t),s.setAttribute("aria-pressed",String(h.flipped)),r.input.checked=h.enabled;let f=i.extent(t);a.min=String(Math.min(-f,h.offset)),a.max=String(Math.max(f,h.offset)),a.value=String(h.offset)}}}function pp({root:i,shell:t,toolbar:e,contextMenu:n,sections:s,selection:r,canFill:o}){let a="z",l=()=>{s.addPlane(a)===null&&(s.setMode("planes"),zs(i,$("sections.maxPlanes")))},c=()=>[...r.values()],h=()=>s.fitBoxToElements(c()),d=zr($("sections.mode"),[["planes",$("sections.planes")],["box",$("sections.box")],["off",$("sections.off")]],C=>s.setMode(C)),u=zr($("sections.axis"),["x","y","z"].map(C=>[C,C.toUpperCase()]),C=>u.update(a=C));u.update(a);let f=et("button","ioviewer-text-button",$("sections.addPlane"));f.type="button",f.addEventListener("click",l);let g=et("ul","ioviewer-section-list"),_=et("div","ioviewer-section-empty",$("sections.noPlanes")),m=et("div","ioviewer-section-block"),p=et("div","ioviewer-section-row");p.append(et("span","",$("sections.axis")),u.element,f),m.append(p,g,_);let b=zr($("sections.box"),[["keepInside",$("sections.keepInside")],["cutInside",$("sections.cutInside")]],C=>s.setBoxMode(C)),w=et("button","ioviewer-text-button",$("sections.fitSelection"));w.type="button",w.addEventListener("click",h);let v=et("input","ioviewer-section-slider");Object.assign(v,{type:"range",min:"-180",max:"180",step:"1"}),v.addEventListener("input",()=>s.setBoxYaw(Number(v.value)*Math.PI/180));let y=et("span");y.setAttribute("aria-hidden","true");let S=et("label","ioviewer-section-row");S.append(et("span","",$("sections.boxYaw")),v,y);let A=et("div","ioviewer-section-block");A.append(b.element,S,w);let x=Fh($("sections.showGizmo"),C=>s.setGizmoVisible(C)),T=Fh($("sections.fill"),C=>s.setFill(C));o||(T.element.title=$("sections.fillUnavailable"));let R=[],D=()=>{d.update(s.mode),m.hidden=s.mode!=="planes",A.hidden=s.mode!=="box",f.disabled=s.planes.length>=Or,R.length!==s.planes.length&&(R=s.planes.map((B,W)=>Cy(s,W)),g.replaceChildren(...R.map(B=>B.element))),R.forEach(B=>B.update()),_.hidden=R.length>0,b.update(s.boxMode),v.value=String(Math.round(s.boxYaw*180/Math.PI)),y.textContent=`${v.value}\xB0`,v.setAttribute("aria-valuetext",y.textContent),x.input.checked=s.gizmoVisible,T.input.checked=s.fill;let C=s.mode==="box"||s.mode==="planes"&&s.planes.some(B=>B.enabled);T.input.disabled=!o||!C,e.setActive("plane",s.mode==="planes"),e.setActive("box",s.mode==="box")},F=()=>w.disabled=r.size===0;if(t.registerPanel("sections",{icon:ne.sections,title:$("panel.sections"),visible:!s.modelBox.isEmpty(),render:C=>C.append(d.element,m,A,T.element,x.element)}),s.addEventListener("change",D),r.addEventListener("change",F),D(),F(),s.modelBox.isEmpty())return;let U=()=>t.openPanel("sections");e.setHandler("plane",()=>{l(),U()}),e.setHandler("box",()=>{(s.mode==="box"||r.size&&h()||s.fitBoxToShown())&&U()}),e.setHandler("resetSections",()=>s.reset()),n.setItem("sectionBox",{handler:C=>{s.fitBoxToElements(r.has(C)?c():[C]),U()}}),n.setItem("resetSections",{handler:()=>s.reset()})}var Iy="#facc15",Py=9;function Bh(i,t=si){return`${new Intl.NumberFormat(t,{minimumFractionDigits:2,maximumFractionDigits:2,useGrouping:!1}).format(i)} ${$("unit.m",t)}`}var yl=class extends EventTarget{constructor(t){super(),this.active=!1,this.points=[],this.preview=null,this.group=new Re,this.group.name="measure";let e=new de;e.setAttribute("position",new Ae(new Float32Array(6),3));let n={color:Iy,depthTest:!1,depthWrite:!1,transparent:!0};this._line=new Fi(e,new an(n)),this._markers=new ei(e,new Fn({...n,size:Py,sizeAttenuation:!1}));for(let s of[this._line,this._markers])s.frustumCulled=!1,s.renderOrder=1001,this.group.add(s);this.label=et("div","ioviewer-measure-label"),this.label.hidden=!0,this._previewMarker=et("div","ioviewer-measure-preview"),this._previewMarker.hidden=!0,this._previewMarker.setAttribute("aria-hidden","true"),t.prepend(this.label,this._previewMarker),this._sync()}get distance(){return this.points.length===2?this.points[0].distanceTo(this.points[1]):null}get box(){return new oe().setFromPoints(this.points)}setActive(t){this.active=!!t,this.active||(this.points=[],this.setPreview(null)),this._sync()}add(t){this.active&&(this.points=this.points.length===1?[this.points[0],t.clone()]:[t.clone()],this._sync())}clear(){return this.points.length===0?!1:(this.points=[],this._sync(),!0)}setPreview(t){!this.preview&&!t||(this.preview=t,this._previewMarker.hidden=!t,t&&(this._previewMarker.dataset.kind=t.kind),this.dispatchEvent(new Event("previewchange")))}update(t,e){this.preview&&Ur(this._previewMarker,this.preview.point,t,e),this.distance!==null&&Ur(this.label,this.points[0].clone().lerp(this.points[1],.5),t,e)}_sync(){let t=this._line.geometry.attributes.position;this.points.forEach((e,n)=>t.setXYZ(n,e.x,e.y,e.z)),t.needsUpdate=!0,this._line.geometry.setDrawRange(0,this.points.length),this._line.visible=this.points.length===2,this._markers.visible=this.points.length>0,this.label.hidden=this.distance===null,this.distance!==null&&(this.label.textContent=Bh(this.distance)),this.dispatchEvent(new Event("change"))}};var mp=8,Ly=1-1e-6,Dy=8,gp={vertex:0,midpoint:1,edge:2},Ny=2e4;function Uy(i,t){let e=new Map,n=new Uint32Array(i.length/3);for(let d=0;d0&&(_.normalize(),l(u,f,_),l(f,g,_),l(g,u,_))}let c=[],h=new Set;for(let{lo:d,hi:u,count:f,crease:g}of s.values())f!==1&&!g||(c.push(d,u),h.add(d),h.add(u));return{edges:c,vertices:h}}function Ml(i,t,e){return t<0&&e<0?!1:(t<0&&(i[0]=Math.max(i[0],t/(t-e))),e<0&&(i[1]=Math.min(i[1],t/(t-e))),i[0]<=i[1])}function Fy(i,t,e,n,s,r){let o=[0,1];if(!Ml(o,e.w+e.z,n.w+n.z)||!Ml(o,e.w-e.z,n.w-n.z))return[];if(!r||!s.length)return s.every(c=>Ml(o,c.distanceToPoint(i),c.distanceToPoint(t)))?[o]:[];let a=o.slice();if(!s.every(c=>{let h=c.distanceToPoint(i),d=c.distanceToPoint(t);return(h<0||d<0)&&Ml(a,-h,-d)}))return[o];let l=[];return o[0]0))return null;let m=re.clamp(((r-c)*f+(o-h)*g)/_,0,1);return e+(n-e)*(m*a.w/((1-m)*l.w+m*a.w))}var bl=class{constructor(t,e,n){this.picker=t,this.sections=e,this.data=n,this.cache=new Map}release(){this.data.releaseBinary(),this.cache.clear()}_geometry(t){let e=this.cache.get(t);if(e)this.cache.delete(t);else{let n=this.data.meta.geometries[t],s=Ja({view:this.data.readView},n);e={positions:s,...Uy(s,this.data.readView(n.indices))}}return this.cache.set(t,e),this.cache.size>Dy&&this.cache.delete(this.cache.keys().next().value),e}target(t,e){let n=this.picker.measureTile(t,e,mp+1);if(!n)return null;let{rect:s}=n,r=t-s.left,o=e-s.top,{camera:a,scene:l}=this.picker,{planes:c,intersection:h}=this.sections.clipping(),d=new Jt().multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),u=a.matrixWorldInverse.elements,f=null;function g(y,S,A,x){if(f&&gp[y]>gp[f.kind]||A.w<=0||A.z<-A.w||A.z>A.w)return;let[T,R]=Oh(A,s);if(!(T>=0&&R>=0&&Tmp**2||f?.kind===y&&D>=f.distance||y!=="edge"&&op(S,c,h))return;let F=-(u[2]*S.x+u[6]*S.y+u[10]*S.z+u[14]);F-n.depthAt(T,R,x)>2*wn+Math.abs(F)*2**-21||(f={kind:y,distance:D,point:S.clone()})}let _=Ny*3,m=new Jt,p=new I,b=new ge,{geometry:w,matrix:v}=this.data.meta.instances;for(let y of n.slots){let S=l.slotInstance(y),[A]=this.data.readView({t:"u32",o:w.o+S*4,n:1}),x=this.data.meta.geometries[A],T=Math.max(x.indices.n,x.positions.n/3);if(T>_)continue;_-=T;let{positions:R,vertices:D,edges:F}=this._geometry(A),U=this.data.readView({t:"f32",o:v.o+S*48,n:12});m.set(U[0],U[3],U[6],U[9],U[1],U[4],U[7],U[10],U[2],U[5],U[8],U[11],0,0,0,1);let C=new Map;for(let B of D){let W=new I().fromArray(R,B*3).applyMatrix4(m),q=new ge(W.x,W.y,W.z,1).applyMatrix4(d);C.set(B,[W,q]),g("vertex",W,q,y)}if(f?.kind!=="vertex")for(let B=0;Br.element)),t.prepend(s),this._layer=s,this.setVisible(this.count>0)}get visible(){return this.group.visible}setVisible(t){this.group.visible=!!t,this._layer.hidden=!t,this.dispatchEvent(new Event("change"))}update(t,e){if(this.visible)for(let{element:n,point:s}of this._labels)Ur(n,s,t,e)}};var Oy=8,_p=4;function zh(i,t,e,n="dialog"){let s=et("div","ioviewer-popover ioviewer-floating");s.setAttribute("role",n),s.setAttribute("aria-label",e),s.hidden=!0,t.setAttribute("aria-haspopup",n),t.setAttribute("aria-expanded","false"),i.append(s);function r(l){s.contains(l.target)||(a(),sl(l))}s.addEventListener("keydown",l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),a(),t.focus())});function o(){s.hidden=!1,t.setAttribute("aria-expanded","true");let l=t.getBoundingClientRect(),{width:c}=s.getBoundingClientRect();s.style.left=`${Math.max(_p,Math.min(l.left+l.width/2-c/2,innerWidth-c-_p))}px`,s.style.bottom=`${innerHeight-l.top+Oy}px`,window.addEventListener("pointerdown",r,!0),window.addEventListener("resize",a)}function a(){return s.hidden?!1:(s.hidden=!0,t.setAttribute("aria-expanded","false"),window.removeEventListener("pointerdown",r,!0),window.removeEventListener("resize",a),!0)}return{element:s,close:a,toggle:()=>s.hidden?o():a(),get isOpen(){return!s.hidden}}}function zy(i){return i?.initialWireframe?"wireframe":i?.initialWhiteMode?"white":"materials"}function xp({root:i,toolbar:t,scene:e,meta:n,grids:s,initialBackground:r,setBackground:o}){let a=x=>t.element.querySelector(`[data-tool="${x}"]`),l=a("displayMode"),c=zh(i,l,$("group.display"));c.element.classList.add("ioviewer-display-modes");let h=et("div");h.setAttribute("role","menu"),h.setAttribute("aria-label",$("tool.displayMode")),c.element.append(h);let d=(n.textures??[]).length>0,u=yh.map(x=>{let T=et("button","ioviewer-menu-item",$(`display.${x}`));return T.type="button",T.dataset.mode=x,T.setAttribute("role","menuitemradio"),T.disabled=x==="textures"&&!d,T.addEventListener("click",()=>{f(x),c.close(),l.focus()}),h.append(T),T}),f=x=>{e.setDisplayMode(x);for(let T of u)T.setAttribute("aria-checked",String(T.dataset.mode===x))};f(zy(n.options)),t.setHandler("displayMode",()=>{c.toggle(),c.isOpen&&h.querySelector('[aria-checked="true"]')?.focus()});let g=et("div","ioviewer-background-setting"),_=et("label","",$("display.background")),m=et("input");Object.assign(m,{type:"color",value:r}),_.append(m);let p=et("button","ioviewer-text-button",$("display.backgroundReset"));p.type="button",p.disabled=!0;let b=()=>{o(m.value),p.disabled=m.value===r};m.addEventListener("input",b),p.addEventListener("click",()=>{m.value=r,m.focus(),b()}),g.append(_,p),c.element.append(g),t.setActive("grids",s.visible),s.count>0&&t.setHandler("grids",()=>{s.setVisible(!s.visible),t.setActive("grids",s.visible)});let w=zh(i,a("opacity"),$("tool.opacity"));w.element.classList.add("ioviewer-opacity");let v=et("input","ioviewer-opacity-slider");Object.assign(v,{type:"range",min:"10",max:"100",step:"1",value:"100"}),v.setAttribute("aria-label",$("opacity.label"));let y=et("output","ioviewer-opacity-value"),S=()=>y.textContent=$("opacity.value").replace("{value}",v.value);v.addEventListener("input",()=>{e.setOpacity(Number(v.value)/100),S()}),S();let A=et("div","ioviewer-opacity-head");return A.append(et("span","",$("opacity.label")),y),w.element.append(A,v),t.setHandler("opacity",w.toggle),[c,w]}var ky=3e3;function wl(i,t){let e=et("button",i);return e.type="button",e.setAttribute("title",t),e.append(et("span","ioviewer-row-name",t)),e}function vp({shell:i,toolbar:t,controls:e,scene:n,sections:s,selection:r,restoreLinkedModels:o,views:a,bcfTopics:l}){let c=null,h=et("button","ioviewer-text-button ioviewer-tour");h.type="button";function d(w){w.sections!=null&&s.restore(w.sections),w.hiddenElements!=null&&n.setHiddenElements(w.hiddenElements),w.visibleElements!=null&&n.isolate(w.visibleElements),w.hiddenModelKeys!=null&&o(w.hiddenModelKeys),w.selectedElements!=null&&r.set(w.selectedElements);let v=w.camera.projection==="orthographic";e.setProjection(v?"orthographic":"perspective"),t.setActive("projection",v),e.restoreViewCamera(w.camera)}function u(){d(a[c.next]),c.next=(c.next+1)%a.length;let w=()=>{e.animating?c.frame=requestAnimationFrame(w):c.timer=setTimeout(u,ky)};c.frame=requestAnimationFrame(w)}let f=w=>h.contains(w.target),g=w=>!f(w)&&m(),_=w=>{f(w)&&(w.key==="Enter"||w.key===" ")||(w.key==="Escape"&&(w.preventDefault(),w.stopPropagation()),m())};function m(){c&&(cancelAnimationFrame(c.frame),clearTimeout(c.timer),c=null,window.removeEventListener("pointerdown",g,!0),window.removeEventListener("wheel",m,!0),window.removeEventListener("keydown",_,!0),b())}function p(){c={next:0,frame:0,timer:0},window.addEventListener("pointerdown",g,!0),window.addEventListener("wheel",m,!0),window.addEventListener("keydown",_,!0),b(),u()}function b(){let w=$(c?"views.stop":"views.tour");h.replaceChildren(),h.insertAdjacentHTML("afterbegin",c?ne.pause:ne.play),h.append(et("span","",w)),h.setAttribute("aria-pressed",String(!!c))}h.addEventListener("click",()=>c?m():p()),b(),i.registerPanel("views",{icon:ne.views,title:$("panel.views"),visible:a.length>0,render:w=>{let v=et("div","ioviewer-row-list");for(let y of a){let S=wl("ioviewer-row ioviewer-view",String(y.name??""));S.addEventListener("click",()=>d(y)),v.append(S)}w.append(h,v)}}),i.registerPanel("bcf",{icon:ne.bcf,title:$("panel.bcf"),visible:l.length>0,render:w=>{let v=et("div","ioviewer-row-list");for(let y of l){let S=et("details","ioviewer-bcf-topic");S.append(et("summary","",y.title)),y.status&&S.append(et("p","ioviewer-bcf-status",y.status)),y.description&&S.append(et("p","ioviewer-bcf-description",y.description)),y.viewpoints.length||S.append(et("p","ioviewer-bcf-status",$("bcf.noView"))),y.viewpoints.forEach((A,x)=>{let T=$("bcf.viewpoint").replace("{index}",String(x+1)),R=wl("ioviewer-row ioviewer-view",T);if(R.addEventListener("click",()=>d(A)),S.append(R),A.missingComponents||A.ambiguousComponents){let D=$("bcf.components").replace("{missing}",String(A.missingComponents)).replace("{ambiguous}",String(A.ambiguousComponents));S.append(et("p","ioviewer-bcf-status",D))}}),v.append(S)}w.append(v)}})}function yp(i,t){let e=[];for(let[n,s]of[[i.element1Id,i.element1Name],[i.element2Id,i.element2Name]]){let r=n!=null?t.findIndex(o=>o.id!=null&&String(o.id)===String(n)&&!o.mesh):Hy(t,s);r>=0&&!e.includes(r)&&e.push(r)}return e}function Hy(i,t){if(t==null)return-1;let e=i.findIndex(n=>n.name===t);return e>=0&&i.findIndex((n,s)=>s>e&&n.name===t)<0?e:-1}var Vy=["New","Active","Reviewed","Approved","Resolved"],kh=27,Gy=8,Wy=14,Xy=2,qy=new I(1,-1,.8).normalize();function Mp({shell:i,tests:t,elements:e,scene:n,controls:s,selection:r}){let o=new Re;o.name="clash-marker";let a=new de;a.setAttribute("position",new Ae(new Float32Array(3),3));let l={color:"#ef4444",depthTest:!1,depthWrite:!1,transparent:!0},c=new ei(a,new Fn({...l,size:Wy,sizeAttenuation:!1}));c.frustumCulled=!1,c.renderOrder=1002,o.add(c),o.visible=!1;let h=null,d=null;function u(){o.visible=!1,h?.removeAttribute("aria-current"),h=null,d=null,s.setExtraBounds("clash",null)}function f(b,w){let v=yp(b,e);v.length?r.set(v):r.clear();let y=new I(...b.point),S=0;for(let T of v){let R=n.elementBox(T);R.isEmpty()||(S=Math.max(S,...R.getSize(new I).toArray()))}let A=s.camera.position.clone().sub(s.target);A.lengthSq()<1e-12&&A.copy(qy);let x=Math.max(3*S,Xy);s.animateTo({position:A.normalize().multiplyScalar(x).add(y),target:y}),a.attributes.position.setXYZ(0,y.x,y.y,y.z),a.attributes.position.needsUpdate=!0,o.visible=!0,h?.removeAttribute("aria-current"),h=w,d=b,w.setAttribute("aria-current","true"),s.setExtraBounds("clash",new oe(y.clone(),y.clone()))}function g(b){let w=wl("ioviewer-row ioviewer-clash",String(b.name??""));w.setAttribute("title",`${b.name??""}: ${b.element1Name??""} \u2014 ${b.element2Name??""}`);let v=Vy.includes(b.status),y=et("span","ioviewer-clash-status",v?$(`clash.${b.status}`):String(b.status??""));v&&(y.dataset.status=b.status);let S=typeof b.distance=="number"?Bh(b.distance):"";return w.append(y,et("span","ioviewer-clash-distance",S)),b===d&&(h=w,w.setAttribute("aria-current","true")),w.addEventListener("click",()=>f(b,w)),w}function _(b,w){let v=et("div","ioviewer-clash-test"),y=et("button","ioviewer-row ioviewer-clash-header");y.type="button",y.setAttribute("aria-expanded","true");let S=`${b.name??""} (${b.clashes.length})`;y.setAttribute("title",S),y.insertAdjacentHTML("afterbegin",ne.chevron),y.append(et("span","ioviewer-row-name",S));let A=et("div","ioviewer-clash-list");return A.style.height=`${Math.max(0,b.clashes.length*kh-1)}px`,y.addEventListener("click",()=>{A.hidden=!A.hidden,y.setAttribute("aria-expanded",String(!A.hidden)),w()}),v.append(y,A),{box:v,list:A,clashes:b.clashes,rows:new Map}}function m({list:b,clashes:w,rows:v},{start:y,end:S}){for(let[x,T]of v)(x=S)&&(T.remove(),v.delete(x));let A=null;for(let x=S-1;x>=y;x--){let T=v.get(x);T||(T=g(w[x]),T.style.top=`${x*kh}px`,b.insertBefore(T,A),v.set(x,T)),A=T}}function p(b){if(!t.length)return;b.classList.add("ioviewer-clashes-body");let w=t.map(y=>_(y,v));for(let y of w)b.append(y.box);function v(){let y=b.scrollTop,S=b.clientHeight,A=w.map(({list:x,clashes:T})=>S&&!x.hidden?Rh(y-x.offsetTop,kh,S,T.length,Gy):{start:0,end:0});w.forEach((x,T)=>m(x,A[T]))}b.addEventListener("scroll",v),b.addEventListener("focusin",v),new ResizeObserver(v).observe(b)}return i.registerPanel("clashes",{icon:ne.clashes,title:$("panel.clashes"),visible:t.length>0,render:p,onClose:()=>o.visible&&u()}),{group:o}}var Yy=["construct","demolish","temporary"],$y=Date.parse("0002-01-01T00:00:00Z");function bp(i){let t=typeof i=="string"?Date.parse(i):NaN;return t>=$y?t:NaN}function Sp(i,t){let e=new Map(t.flatMap((o,a)=>o.mesh||o.id==null?[]:[[String(o.id),a]])),n=[];for(let o of Array.isArray(i?.tasks)?i.tasks:[]){let a=bp(o?.start),l=bp(o?.end);if(!(a<=l))continue;let c=Yy.includes(o.type)?o.type:"construct",h=Array.isArray(o.attachedElements)?o.attachedElements:[];n.push({name:o.name,type:c,start:a,end:l,elements:h.map(d=>e.get(String(d))).filter(d=>d!==void 0)})}let s=n.reduce((o,a)=>Math.min(o,a.start),1/0),r=n.reduce((o,a)=>Math.max(o,a.end),-1/0);return{start:s,end:r,tasks:n}}function wp(i,t){let e=new Set,n=new Map;for(let s of i){let r=ts.end,a=s.type==="construct"?r:s.type==="demolish"?o:r||o;for(let l of s.elements)a?e.add(l):!r&&!o&&n.set(l,s.type)}for(let s of e)n.delete(s);return{hidden:e,active:n}}var Zy=864e5,Jy=["1","5","15"],Ky={construct:"#22c55e",demolish:"#ef4444",temporary:"#a855f7"};function Ep({root:i,shell:t,timeliner:e,elements:n,scene:s}){let r=Sp(e,n);if(r.tasks.length===0)return t.registerPanel("timeliner",{icon:ne.timeliner,title:$("panel.timeliner"),visible:!1,render:()=>{}}),null;let o=new Intl.DateTimeFormat(void 0,{dateStyle:"short",timeZone:"UTC"}),a=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}),l=r.start,c=1,h=0,d=0,u=!1,f=new Set,g=new Map,_=et("div","ioviewer-player ioviewer-floating");_.setAttribute("role","group"),_.setAttribute("aria-label",$("player.title")),_.hidden=!0;let m=Qe("ioviewer-icon-button ioviewer-player-play",ne.play,$("player.play"));m.addEventListener("click",()=>h?F():D());let p=et("output","ioviewer-player-date"),b=et("input","ioviewer-player-slider");Object.assign(b,{type:"range",min:String(r.start),max:String(r.end),step:"any"}),b.setAttribute("aria-label",$("player.date")),b.addEventListener("input",()=>A(Number(b.value)));let w=zr($("player.speed"),Jy.map(C=>[C,`${C}\xD7`]),C=>{c=Number(C),w.update(C)});w.update(String(c));let v=Qe("ioviewer-panel-close",ne.close,$("close"));v.addEventListener("click",T),_.append(m,p,b,w.element,v),i.append(_),new ResizeObserver(()=>{let C=_.hidden?0:_.offsetHeight+8;i.style.setProperty("--player-space",`${C}px`)}).observe(_);function S(){let C=wp(r.tasks,l),B=[...f].filter(L=>!C.hidden.has(L)),W=[...C.hidden].filter(L=>!f.has(L));f=C.hidden;let q=[...g.keys()].filter(L=>C.active.get(L)!==g.get(L)),O=new Map;for(let[L,H]of C.active)g.get(L)!==H&&(O.has(H)||O.set(H,[]),O.get(H).push(L));g=C.active,B.length&&s.setLayerHidden("schedule",B,!1),W.length&&s.setLayerHidden("schedule",W,!0),q.length&&s.setTint(q,null);for(let[L,H]of O)s.setTint(H,Ky[L])}function A(C){l=Math.min(Math.max(C,r.start),r.end),b.value=String(l),p.textContent=a.format(l),u&&S()}function x(){u||(u=!0,_.hidden=!1,A(r.start))}function T(){u&&(F(),u=!1,s.setTint([...g.keys()],null),g=new Map,f=new Set,s.clearLayer("schedule"),_.hidden=!0)}function R(C){A(l+Math.max(C-d,0)/1e3*c*Zy),d=C,l>=r.end?F():h=requestAnimationFrame(R)}function D(){x(),!h&&(l>=r.end&&A(r.start),d=performance.now(),h=requestAnimationFrame(R),U())}function F(){cancelAnimationFrame(h),h=0,U()}function U(){let C=$(h?"player.pause":"player.play");m.innerHTML=h?ne.pause:ne.play,m.title=C,m.setAttribute("aria-label",C)}return t.registerPanel("timeliner",{icon:ne.timeliner,title:$("panel.timeliner"),render:C=>{let B=et("button","ioviewer-text-button ioviewer-player-open");B.type="button",B.insertAdjacentHTML("afterbegin",ne.play),B.append(et("span","",$("player.play"))),B.addEventListener("click",D);let W=et("div","ioviewer-row-list");for(let q of r.tasks){let O=String(q.name??""),L=et("div","ioviewer-row ioviewer-task");L.dataset.type=q.type,L.setAttribute("title",`${O} \xB7 ${$(`task.${q.type}`)}`);let H=`${o.format(q.start)} \u2013 ${o.format(q.end)}`;L.append(et("span","ioviewer-row-name",O),et("span","ioviewer-task-dates",H)),W.append(L)}C.append(B,W)}}),{open:x,close:T,play:D,pause:F,setDate:A,get date(){return l},get isOpen(){return u}}}function Tp({shell:i,files:t,elements:e,scene:n}){let s=t.map(o=>({file:o,members:o.members??e.flatMap((a,l)=>a.link!=null&&(a.link===o.name||a.link===o.path)?[l]:[]),input:et("input")})),r=()=>n.replaceLayerHidden("links",s.flatMap(({input:o,members:a})=>o.checked?[]:a));return i.registerPanel("links",{icon:ne.links,title:$("panel.links"),visible:s.length>0,render:o=>{let a=et("div","ioviewer-row-list");for(let l of s){let c=String(l.file.name??""),h=et("label","ioviewer-row ioviewer-check ioviewer-link");h.setAttribute("title",`${c} (${l.file.path??""})`);let{input:d}=l;d.type="checkbox",d.checked=l.members.length===0||l.file.visible!==!1,d.disabled=l.members.length===0,d.addEventListener("change",r),h.append(d,et("span","ioviewer-row-name",c),et("span","ioviewer-row-count",String(l.members.length))),a.append(h)}o.append(a),r()}}),o=>{let a=new Set(o);for(let{file:l,input:c}of s)c.checked=c.disabled||!a.has(l.key);r()}}function Ap(i,t,e){let n=i.filter(Number.isFinite).sort((o,a)=>o-a),s=[];for(let o of n){let a=s.at(-1);!a||o-a.at(-1)>2?s.push([o]):a.push(o)}if(s.length<2||s.some(o=>o.length<2||o.at(-1)-o[0]>2))return[];let r=[Math.min(t,n[0])];for(let o=1;o({min:r[a],max:o}))}function Rp(i,t){return!i||t>=i.min&&t<=i.max}function Cp(i,t,e,n){let s=Math.min(16,Math.max(.5,i.zoom*t)),r=1/i.zoom-1/s;return{...i,zoom:s,x:i.x+e*i.side*r,y:i.y-n*i.side*r}}var jy=new Intl.NumberFormat(si,{maximumFractionDigits:2,minimumFractionDigits:2}),El=i=>`${jy.format(i)} ${$("scanMap.metres")}`;function Ri(i,t,e){let n=document.createElement("button");return n.type="button",n.textContent=t,n.title=i,n.setAttribute("aria-label",i),n.addEventListener("click",e),n}function Qy(i,t){return[i*.005,t*.005]}function tM(i,t,e){return i.set(Math.cos(e)*Math.cos(t),Math.cos(e)*Math.sin(t),Math.sin(e))}function eM(i,t,e,n,s,r,o){let a=new On;a.setFromCamera(new $t(n,s),i),a.ray.origin.copy(t),a.near=.05,a.params.Points.threshold=.12;let l=new I,c=new I;for(let h of a.intersectObjects(e,!1))if(l.fromBufferAttribute(h.object.geometry.attributes.position,h.index).applyMatrix4(h.object.matrixWorld),c.copy(l).sub(t).project(i),Math.hypot((c.x-n)*r/2,(c.y-s)*o/2)<=14)return l.z}function Ip(i,t,e,n,s){if(!e.count)return;let r=new oe().setFromObject(e.root);if(r.isEmpty())return;let o=r.getSize(new I),a=r.getCenter(new I),l={x:a.x,y:a.y,side:Math.max(o.x,o.y,.01)*1.12,zoom:1},c={...l},h=at=>50+100*(at-c.x)*c.zoom/c.side,d=at=>50-100*(at-c.y)*c.zoom/c.side,u=at=>Math.min(96,Math.max(4,at)),f=(at,Mt,N=!1)=>{let Yt=h(Mt.x),Xt=d(Mt.y);return at.style.left=`${N?u(Yt):Yt}%`,at.style.top=`${N?u(Xt):Xt}%`,Yt>=0&&Yt<=100&&Xt>=0&&Xt<=100},g=t.meta.rtcOffset?.[2]??0,_=t.meta.panoramas??[],m=_.map(at=>new I(...at.position)),p=`ioviewer.scan-levels.v1:${location.pathname}`,b=()=>Ap(m.map(at=>at.z+g),r.min.z+g,r.max.z+g),w=null;try{let at=JSON.parse(localStorage.getItem(p));Array.isArray(at)&&(w=at.filter(Mt=>Number.isFinite(Mt?.min)&&Number.isFinite(Mt.max)&&Mt.max>Mt.min))}catch{w=null}let v=w??b(),y=-1,S=at=>Rp(v[y],at+g),A=document.createElement("details");A.className="ioviewer-floating ioviewer-scan-map",A.open=!matchMedia("(max-width: 600px)").matches;let x=document.createElement("summary");x.textContent=$("scanMap.title");let T=document.createElement("div");T.className="scan-map-plot";let R=document.createElement("canvas");R.width=R.height=300,R.setAttribute("role","img"),R.setAttribute("aria-label",$("scanMap.plan")),R.tabIndex=0;let D=document.createElement("span");D.className="scan-map-camera",D.setAttribute("aria-hidden","true");let F=document.createElement("span");F.className="scan-map-axes",F.textContent="Y \u2191";let U=document.createElement("span");U.className="scan-map-scale",T.append(R,D,F,U),A.append(x,T),i.append(A);let C=e.root.children.reduce((at,Mt)=>at+Mt.geometry.attributes.position.count,0),B=Math.max(1,Math.ceil(C/6e4)),W=e.root.children.map(at=>{let Mt=at.geometry.attributes.position,N=new Float32Array(Math.ceil(Mt.count/B)*3),Yt=new I;for(let Xt=0,P=0;Xt{if(q=0,!A.open)return;let at=R.getContext("2d");if(!at)return;at.clearRect(0,0,300,300),at.fillStyle="rgba(160, 185, 201, .33)";for(let[Yt,Xt]of W.entries())if(e.root.children[Yt].visible)for(let P=0;P{q||(q=requestAnimationFrame(O))},H=new I,X=null,z=()=>{if(X){D.hidden=!S(X.position.z),f(D,X.position,!0),D.style.rotate=`${Math.PI/2-X.yaw}rad`;return}D.hidden=!1,f(D,s.camera.position,!0),s.camera.getWorldDirection(H),D.style.rotate=`${Math.atan2(H.x,H.y)}rad`};A.addEventListener("toggle",L),n.root.addEventListener("change",at=>{at.detail.kind==="visibility"&&L()}),s.addEventListener("change",z);let Q=document.createElement("div");Q.className="scan-map-controls";let lt=document.createElement("select");lt.setAttribute("aria-label",$("scanMap.size"));for(let at of["small","medium","large"])lt.add(new Option($(`scanMap.${at}`),at));lt.value=matchMedia("(max-width: 600px)").matches?"small":"medium",i.dataset.scanMapSize=lt.value,lt.addEventListener("change",()=>{i.dataset.scanMapSize=lt.value});let ut=(at,Mt=0,N=0)=>{c=Cp(c,at,Mt,N),L()},ct=()=>{c={...l},L()};Q.append(lt,Ri($("scanMap.zoomOut"),"\u2212",()=>ut(.8)),Ri($("scanMap.zoomIn"),"+",()=>ut(1.25)),Ri($("scanMap.reset"),"\u21BA",ct)),A.insertBefore(Q,T),R.addEventListener("wheel",at=>{at.preventDefault();let Mt=R.getBoundingClientRect();ut(at.deltaY<0?1.15:1/1.15,(at.clientX-Mt.left)/Mt.width-.5,(at.clientY-Mt.top)/Mt.height-.5)},{passive:!1});let G;R.addEventListener("pointerdown",at=>{at.button!==0||G||(R.setPointerCapture(at.pointerId),G={id:at.pointerId,x:at.clientX,y:at.clientY})}),R.addEventListener("pointermove",at=>{if(G?.id!==at.pointerId)return;let Mt=c.side/(c.zoom*Math.max(1,R.clientWidth));c.x-=(at.clientX-G.x)*Mt,c.y+=(at.clientY-G.y)*Mt,G.x=at.clientX,G.y=at.clientY,L()}),R.addEventListener("lostpointercapture",at=>{at.pointerId===G?.id&&(G=void 0)}),R.addEventListener("keydown",at=>{let Mt={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,1],ArrowDown:[0,-1]}[at.key];if(Mt){let N=c.side/c.zoom/10;c.x+=Mt[0]*N,c.y+=Mt[1]*N,L()}else if(at.key==="+"||at.key==="="||at.key==="-")ut(at.key==="-"?.8:1.25);else if(at.key==="0")ct();else return;at.preventDefault(),at.stopPropagation()});let tt=document.createElement("div");tt.className="scan-map-controls";let rt=document.createElement("select");rt.setAttribute("aria-label",$("scanMap.levels"));let yt=document.createElement("p");yt.className="scan-map-feedback",yt.setAttribute("role","status");function ft(){try{localStorage.setItem(p,JSON.stringify(v))}catch{yt.textContent=$("scanMap.levelTemporary")}}function Ot(){rt.replaceChildren(new Option($("scanMap.allLevels"),"-1")),v.forEach((at,Mt)=>rt.add(new Option(`${$("scanMap.level").replace("{n}",Mt+1)} \xB7 ${El(at.min)} \u2013 ${El(at.max)}`,String(Mt)))),rt.value=String(y),dt.disabled=y<0;for(let[at,Mt]of m.entries())Pt.options[at+1].hidden=!S(Mt.z);L()}rt.addEventListener("change",()=>{y=Number(rt.value),yt.textContent="",Ot()});let ae=Ri($("scanMap.addLevel"),"+",()=>{if(Nt.isClosed()){let at=m.findIndex(Mt=>S(Mt.z));Ee(Math.max(0,at))}Nt.pickLevel()});ae.disabled=!_.length;let Gt=Ri($("scanMap.autoLevels"),$("scanMap.autoButton"),()=>{let at=b(),Mt=at.filter(N=>!v.some(Yt=>Yt.min{y<0||(v.splice(y,1),y=-1,yt.textContent="",ft(),Ot())});tt.append(rt,ae,Gt,dt),A.append(tt,yt);let Nt=_.length?nM(i,t,e,Ee,at=>{X=at,at||fe.forEach(Mt=>Mt.classList.remove("current")),z()},at=>{y=v.push(at)-1,yt.textContent=$("scanMap.levelAdded"),ft(),Ot()}):null,Pt=document.createElement("select");Pt.setAttribute("aria-label",$("scanMap.choosePhoto"));let Wt=new Option($("scanMap.choosePhoto"),"");Wt.disabled=!0,Pt.add(Wt);let fe=[];for(let[at,Mt]of _.entries()){let N=Mt.name||t.meta.elements[Mt.element].name||String(at+1);Pt.add(new Option(N,String(at)));let Yt=document.createElement("button");Yt.type="button",Yt.className="scan-map-station",Yt.title=N,Yt.setAttribute("aria-label",`${$("scanMap.photo")} \xB7 ${N}`),Yt.addEventListener("click",()=>Ee(at)),fe.push(Yt),T.append(Yt)}Pt.value="",Pt.addEventListener("change",()=>Ee(Number(Pt.value))),Pt.hidden=!_.length,A.append(Pt),Ot(),!w&&v.length&&ft();function Ee(at,Mt=!1){A.open=!0,Pt.value=String(at),fe.forEach((N,Yt)=>N.classList.toggle("current",at===Yt)),Nt.open(at,Mt),Pt.value=""}}function nM(i,t,e,n,s,r){let o=document.createElement("section");o.className="ioviewer-floating scan-photo",o.setAttribute("aria-label",$("scanMap.photo")),o.hidden=!0;let a=document.createElement("header"),l=document.createElement("span"),c=document.createElement("div");c.className="scan-photo-actions";let h=Ri($("scanMap.enlargePhoto"),$("scanMap.enlargePhoto"),()=>{let dt=o.classList.toggle("is-expanded"),Nt=$(dt?"scanMap.shrinkPhoto":"scanMap.enlargePhoto");h.textContent=h.title=Nt,h.setAttribute("aria-label",Nt),h.setAttribute("aria-pressed",String(dt))});h.setAttribute("aria-pressed","false");let d=document.createElement("button");d.type="button",d.textContent=$("close"),d.addEventListener("click",rt),c.append(h,d),a.append(l,c);let u=document.createElement("canvas");u.tabIndex=0,u.setAttribute("aria-label",$("scanMap.photoControls"));let f=document.createElement("p");f.setAttribute("role","status");let g=document.createElement("div");g.className="scan-photo-view";let _=document.createElement("span");_.className="scan-photo-crosshair",_.setAttribute("aria-hidden","true");let m=document.createElement("div");m.className="scan-photo-level",m.hidden=!0;let p=document.createElement("span");p.setAttribute("role","status"),m.append(p,Ri($("scanMap.cancel"),$("scanMap.cancel"),ft)),g.append(u,_,f),o.append(a,m,g),i.append(o);let b=t.meta.panoramas.map((dt,Nt)=>{let Pt=dt.name||t.meta.elements[dt.element].name||String(Nt+1),Wt=document.createElement("button");return Wt.className="scan-photo-link",Wt.type="button",Wt.title=Pt,Wt.setAttribute("aria-label",$("scanMap.goToStation").replace("{name}",Pt)),Wt.hidden=!0,Wt.addEventListener("click",()=>n(Nt,!0)),g.append(Wt),{photo:dt,name:Pt,button:Wt,position:new I(...dt.position)}}),w=t.readView(t.meta.points.element),v=new On;v.params.Points.threshold=.12,v.near=.25;let y=new I,S=new I,A=new I,x=[],T=[],R=!1,D,F=t.meta.rtcOffset?.[2]??0,U,C,B=0,W=0,q=0,O=null,L,H,X=new Qn,z=new Oe(72,1,.1,20);z.up.set(0,0,1);let Q=new mi(10,56,28);Q.rotateX(Math.PI/2);let lt=new Ke({side:De}),ut=new _e(Q,lt);X.add(ut);let ct=()=>{if(!(o.hidden||!C)){U.setSize(u.clientWidth,u.clientHeight,!1),z.aspect=u.clientWidth/Math.max(1,u.clientHeight),z.updateProjectionMatrix(),z.lookAt(tM(y,W,q)),U.render(X,z),z.getWorldDirection(y);for(let dt of x){if(R){dt.button.hidden=!0;continue}A.copy(dt.position).sub(L.position).normalize(),S.copy(A).project(z);let Nt=A.dot(y)>0&&Math.abs(S.x)<.92&&Math.abs(S.y)<.88;dt.button.hidden=!Nt,Nt&&(dt.button.style.left=`${(1+S.x)*50}%`,dt.button.style.top=`${(1-S.y)*50}%`)}s({position:L.position,yaw:W})}},G=(dt,Nt)=>{W+=dt,q=re.clamp(q+Nt,-1.55,1.55),ct()};new ResizeObserver(ct).observe(u),u.addEventListener("pointerdown",dt=>{dt.button!==0||O||(u.setPointerCapture(dt.pointerId),O={id:dt.pointerId,x:dt.clientX,y:dt.clientY,moved:!1})}),u.addEventListener("pointermove",dt=>{O?.id===dt.pointerId&&(R&&!O.moved&&Math.hypot(dt.clientX-O.x,dt.clientY-O.y)<5||(O.moved=!0,G(...Qy(dt.clientX-O.x,dt.clientY-O.y)),O.x=dt.clientX,O.y=dt.clientY))}),u.addEventListener("pointerup",dt=>{if(O?.id!==dt.pointerId||O.moved||!R)return;let Nt=u.getBoundingClientRect();ae((dt.clientX-Nt.left)*2/Nt.width-1,1-(dt.clientY-Nt.top)*2/Nt.height)}),u.addEventListener("lostpointercapture",dt=>{O?.id===dt.pointerId&&(O=null)}),u.addEventListener("keydown",dt=>{if(R&&dt.key==="Enter"){dt.preventDefault(),ae(0,0);return}let Nt={ArrowLeft:[.12,0],ArrowRight:[-.12,0],ArrowUp:[0,.12],ArrowDown:[0,-.12]}[dt.key];Nt&&(dt.preventDefault(),dt.stopPropagation(),G(...Nt))}),u.addEventListener("wheel",dt=>{dt.preventDefault(),z.fov=re.clamp(z.fov+Math.sign(dt.deltaY)*5,32,95),ct()},{passive:!1}),o.addEventListener("keydown",dt=>{dt.key==="Escape"&&(R?ft():rt()),dt.stopPropagation()});function rt(){o.hidden=!0,ft(),B++,O=null,yt(),s(null),H?.focus()}function yt(){C?.dispose(),C=void 0,lt.map=null;for(let dt of x)dt.button.hidden=!0;x=[]}function ft(){R=!1,D=void 0,o.classList.remove("is-picking"),m.hidden=!0,ct()}function Ot(){R=!0,D=void 0,o.classList.add("is-picking"),p.textContent=$("scanMap.pickLower"),m.hidden=!1,ct(),C&&u.focus()}function ae(dt,Nt){if(!C)return;let Pt=eM(z,L.position,T,dt,Nt,u.clientWidth,u.clientHeight);if(Pt===void 0){p.textContent=$(D===void 0?"scanMap.noLowerHit":"scanMap.noUpperHit");return}let Wt=Pt+F;D===void 0?(D=Wt,p.textContent=$("scanMap.pickUpper").replace("{z}",El(Wt))):Wt<=D?p.textContent=$("scanMap.upperAboveLower").replace("{z}",El(D)):(r({min:D,max:Wt}),ft())}function Gt(dt,Nt){let Pt=++B,Wt=o.hidden;Wt&&(H=document.activeElement),yt(),L=b[dt],o.hidden=!1,l.textContent=L.name,u.style.visibility="hidden",f.textContent=$("scanMap.loading");let fe=()=>{Pt===B&&(f.textContent=$("scanMap.photoError"))},Ee;try{U??(U=new Si({canvas:u,antialias:!0})),U.setPixelRatio(Math.min(devicePixelRatio,2)),Ee=URL.createObjectURL(new Blob([t.readView(L.photo.image)],{type:"image/jpeg"}))}catch{fe();return}new ar().load(Ee,at=>{if(URL.revokeObjectURL(Ee),Pt!==B||at.image.width!==2*at.image.height){at.dispose(),fe();return}if(C?.dispose(),C=at,C.colorSpace=Te,lt.map=C,lt.needsUpdate=!0,ut.rotation.z=re.degToRad(L.photo.yaw),T=e.root.children.filter((Mt,N)=>w[N]===L.photo.element),x=b.filter(Mt=>{if(Mt===L)return!1;let N=A.copy(Mt.position).sub(L.position).length();return N<=.25?!1:(v.set(L.position,A.multiplyScalar(1/N)),v.far=N-.25,!v.intersectObjects(T,!1).length)}),Wt||!Nt){let Mt=x.reduce((N,Yt)=>!N||Yt.position.distanceToSquared(L.position){URL.revokeObjectURL(Ee),fe()})}return{open:Gt,pickLevel:Ot,isClosed:()=>o.hidden}}document.documentElement.lang=si;var Gn=document.getElementById("ioviewer-canvas"),Hh=window.IOVIEWER_TEST??{},kr=Hh.startup;function Hr(i){let t=document.getElementById("ioviewer-message");t.textContent=i,t.hidden=!1}try{let i=oh(document,kr);i.title&&(document.title=i.title);let t=Gn.getContext("webgl2",{antialias:!0,stencil:!0});t?iM(tf(document,kr,i),t):Hr($("noWebGL"))}catch(i){if(!(i instanceof ie))throw i;Hr($("badData"))}function iM(i,t){let e=new Si({canvas:Gn,context:t,antialias:!0,stencil:!0,logarithmicDepthBuffer:Ff(i.meta)});e.setPixelRatio(window.devicePixelRatio),e.autoClearStencil=!1,e.localClippingEnabled=!0;let n=new Qn,s="#1f2228",r=new Vt(s);e.setClearColor(r,1);let o=new cr("#ffffff","#8a8f99",1.6);o.position.set(0,0,1),n.add(o);let a=new Oe(45,1,.1,1e3);a.up.set(0,0,1),a.position.set(1,-1,.8);let l=new ur("#ffffff",1.4);l.position.set(.3,.6,0),a.add(l,l.target),l.target.position.set(0,0,-1),n.add(a);let c=!1;kr?.("sceneStart");let h=y(),d=new el(i);kr?.("sceneEnd"),i.releaseBinary(),!c&&h.totalCost===0&&d.count===0&&Hr($("noGeometry"));let u=new cl(h,D,Math.min(h.totalCost,2e7));n.add(h.root),n.add(d.root);let f=()=>h.visibleBox(),g=new ml(h,f(),i.meta.sections);d.syncVisibility(h),d.setClipping(g.clipping().planes);let _=t.getContextAttributes()?.stencil===!0,m,p=new xl(g,Gn);n.add(p.group);let b=document.getElementById("ioviewer-ui"),w=new yl(b),v=new Sl(b,i.meta.grids??[]);n.add(w.group,v.group);function y(){try{return new Dr(i,{...Hh,maxTextureSize:e.capabilities.maxTextureSize})}catch(rt){if(!(rt instanceof Lr))throw rt;c=!0,Hr($("tooLarge").replace("{count}",rt.count).replace("{limit}",rt.limit));let yt=Ot=>({o:0,n:0,t:Ot}),ft={count:0,geometry:yt("u32"),material:yt("u32"),element:yt("i32"),matrix:yt("f32")};return new Dr({...i,meta:{...i.meta,instances:ft}})}}let S=!1;Gn.addEventListener("webglcontextlost",()=>{S=!0,Hr($("contextLost"))});let A,x=new Promise(rt=>A=rt),T=kr,R=!1;function D(){R||S||(R=!0,u.requested(performance.now()),requestAnimationFrame(()=>{if(R=!1,S)return;let rt=Gn.getBoundingClientRect();L.camera.updateMatrixWorld(),p.update(L.camera),w.update(L.camera,rt),v.update(L.camera,rt),u.begin(L.camera,rt.height,performance.now()),T?.("renderStart"),g.fill&&_?(m??(m=new vl(h,g,i)),m.render(e,n,L.camera)):e.render(n,L.camera),T&&(T("renderEnd"),T=void 0),u.end(performance.now()),tt.update(),A()}))}h.root.addEventListener("change",D),g.addEventListener("change",()=>{d.setClipping(g.clipping().planes),D()}),p.addEventListener("change",D),w.addEventListener("change",D),w.addEventListener("previewchange",D),v.addEventListener("change",D);let F=new al(e,h,a,{pickFloat:Hh.pickFloat}),U=new bl(F,g,i),C=0,B=null;function W(){cancelAnimationFrame(C),C=0,B=null,w.setPreview(null)}function q(){C=0,B&&w.setPreview(U.target(...B))}function O(){B&&(w.setPreview(null),cancelAnimationFrame(C),C=requestAnimationFrame(()=>{C=requestAnimationFrame(q)}))}Gn.addEventListener("pointermove",rt=>{if(!w.active||rt.buttons)return W();B=[rt.clientX,rt.clientY],C||(C=requestAnimationFrame(q))});for(let rt of["pointerdown","pointerleave","pointercancel","webglcontextlost"])Gn.addEventListener(rt,W);h.root.addEventListener("change",rt=>{rt.detail.kind!=="appearance"&&O()});let L=new il(a,Gn,{pick:(rt,yt)=>F.pick(rt,yt)?.point??null,visibleBox:f});L.addEventListener("change",()=>{F.camera=L.camera,O(),D()}),h.root.addEventListener("change",rt=>{rt.detail.kind==="visibility"&&(d.syncVisibility(h),L.invalidateBounds(),L.resize())});let H=new ul;H.addEventListener("change",()=>h.setHighlighted([...H.values()]));let X=rp({root:b,data:i,scene:h,controls:L,picker:F,selection:H,measure:w});pp({root:b,...X,sections:g,selection:H,canFill:_});let{meta:z}=i,Q=Tp({...X,files:z.linkedFiles??[],elements:z.elements,scene:h});vp({...X,controls:L,scene:h,sections:g,selection:H,restoreLinkedModels:Q,views:z.viewpoints??[],bcfTopics:z.bcfTopics??[]});let lt=Mp({...X,tests:z.clashTests??[],elements:z.elements,scene:h,controls:L,selection:H});n.add(lt.group);let ut=Ep({root:b,...X,timeliner:z.timeliner,elements:z.elements,scene:h}),ct=rt=>{e.setClearColor(r.set(rt),1);let{r:yt,g:ft,b:Ot}=r,Gt=.2126*yt+.7152*ft+.0722*Ot>Math.sqrt(.0525)-.05?"#000":"#fff";b.style.setProperty("--viewport-text",rt===s?"":Gt),D()};for(let rt of xp({root:b,toolbar:X.toolbar,scene:h,meta:z,grids:v,initialBackground:s,setBackground:ct}))X.onEscape(rt.close);X.toolbar.setHandler("distance",()=>{W(),w.setActive(!w.active),w.active||U.release(),X.toolbar.setActive("distance",w.active)}),X.toolbar.setActive("distance",!1),X.onEscape(()=>(W(),w.clear()));let G=()=>{L.setExtraBounds("grids",v.visible?v.box:null),L.setExtraBounds("measure",w.box)};v.addEventListener("change",G),w.addEventListener("change",G),G(),L.addEventListener("click",rt=>{let{x:yt,y:ft,ctrl:Ot,shift:ae}=rt.detail;if(w.active){let Nt=U.target(yt,ft);Nt&&w.add(Nt.point);return}let dt=F.pick(yt,ft)?.element??-1;Ot?dt>=0&&H.toggle(dt):dt>=0?H.set([dt]):ae||H.clear()}),L.addEventListener("boxselect",rt=>{if(w.active)return;let{rect:yt,mode:ft,ctrl:Ot,shift:ae}=rt.detail;if(yt.width<4||yt.height<4){!Ot&&!ae&&H.clear();return}let Gt=new oe,dt=Wf(yt,ft,Xf(h,L.camera,Gn.getBoundingClientRect())),Nt=g.clipping(),Pt=dt.filter(Wt=>!g.isCut(h.elementBox(Wt,Gt),Nt));H.set(Ot?[...H.values(),...Pt]:Pt)}),window.addEventListener("resize",()=>{e.setSize(window.innerWidth,window.innerHeight,!1),L.resize()}),e.setSize(window.innerWidth,window.innerHeight,!1),L.resize(),L.fitBox(f(),!1),Ip(b,i,d,h,L);let tt=new ol(document.getElementById("ioviewer-ui"),a,L);window.addEventListener("pointerdown",rt=>{(rt.target===Gn||tt.element.contains(rt.target))&&document.activeElement?.blur()},!0),window.__ioviewer={scene:h,points:d,motionDetail:u,controls:L,picker:F,selection:H,ui:X,viewCube:tt,sections:g,sectionGizmo:p,measure:w,measureSnap:U,grids:v,clashes:lt,timeliner:ut,ready:x,get camera(){return L.camera}}}})(); +}`,side:e,stencilZPass:n,stencilWrite:!0,clipping:!0,clippingPlanes:[t],colorWrite:!1,depthTest:!1,depthWrite:!1});return s.index0AttributeName="q",s}var bl=class{constructor(t,e,n,s){this.model=t,this.sections=e,this.data=n,this.drawStencils=s,this._farSide=new we,this._surface=new _e(new Mn(1,1),new Ke({color:Cy,side:Ne,forceSinglePass:!0,stencilWrite:!0,stencilFunc:Dc,stencilWriteMask:0}))}render(t,e,n){let{sections:s,model:r}=this,{planes:o,intersection:a}=s.clipping(),l=a?o.map(u=>u.clone().negate()):o,c=u=>Math.abs(u.distanceToPoint(s.center)){if(!c(f))return;let _=u?-f.normal.dot(u):f.distanceToPoint(n.position);if(_===0)return;if(this._farSide.copy(f),_>0&&this._farSide.negate(),t.clearStencil(),this.drawStencils)this.drawStencils(t,n,this._farSide);else for(let p of this._stencils)r.withMaterial(p,()=>t.render(r.root,n),{section:!0});this._surface.quaternion.setFromUnitVectors(Ry,f.normal);let m=_l(s.modelBox,this._surface.quaternion,f.coplanarPoint(new L));this._surface.position.copy(m.center),this._surface.scale.set(m.width,m.height,1),h.clippingPlanes=l.filter((p,b)=>b!==g),t.render(this._surface,n)}),t.render(e,n)}finally{t.autoClear=d}}};function Wr(i,t,e){let n=et("div","ioviewer-segmented");n.setAttribute("role","group"),n.setAttribute("aria-label",i);let s=t.map(([o,a])=>{let l=et("button","",a);return l.type="button",l.dataset.value=o,l.addEventListener("click",()=>e(o)),n.append(l),l});return{element:n,update:o=>s.forEach(a=>a.setAttribute("aria-pressed",String(a.dataset.value===o)))}}function Oh(i,t){let e=et("label","ioviewer-check"),n=et("input");return n.type="checkbox",n.addEventListener("change",()=>t(n.checked)),e.append(n,et("span","",i)),{element:e,input:n}}function Ly(i,t){let e=et("li","ioviewer-section-plane");e.addEventListener("pointerdown",()=>i.active!==t&&i.setActivePlane(t));let n=et("span","ioviewer-section-name"),s=Qe("ioviewer-icon-button",ne.flip,$("sections.flip"));s.addEventListener("click",()=>i.updatePlane(t,{flipped:!i.planes[t].flipped}));let r=Oh($("sections.enabled"),h=>i.updatePlane(t,{enabled:h})),o=Qe("ioviewer-icon-button",ne.remove,$("sections.delete"));o.addEventListener("click",()=>i.removePlane(t));let a=et("input","ioviewer-section-slider");a.type="range",a.step="any",a.setAttribute("aria-label",$("sections.position")),a.addEventListener("input",()=>i.updatePlane(t,{offset:Number(a.value)}));let l=et("div","ioviewer-section-head");return l.append(n,s,r.element,o),e.append(l,a),{element:e,update:()=>{let h=i.planes[t],d=h.rotated?` (${$("sections.rotated")})`:"",u=h.axis==="custom"?$("sections.custom"):h.axis.toUpperCase();n.textContent=`${t+1}. ${u}${d}`,e.classList.toggle("active",i.active===t),s.setAttribute("aria-pressed",String(h.flipped)),r.input.checked=h.enabled;let f=i.extent(t);a.min=String(Math.min(-f,h.offset)),a.max=String(Math.max(f,h.offset)),a.value=String(h.offset)}}}function gp({root:i,shell:t,toolbar:e,contextMenu:n,sections:s,selection:r,canFill:o}){let a="z",l=()=>{s.addPlane(a)===null&&(s.setMode("planes"),zs(i,$("sections.maxPlanes")))},c=()=>[...r.values()],h=()=>s.fitBoxToElements(c()),d=Wr($("sections.mode"),[["planes",$("sections.planes")],["box",$("sections.box")],["off",$("sections.off")]],I=>s.setMode(I)),u=Wr($("sections.axis"),["x","y","z"].map(I=>[I,I.toUpperCase()]),I=>u.update(a=I));u.update(a);let f=et("button","ioviewer-text-button",$("sections.addPlane"));f.type="button",f.addEventListener("click",l);let g=et("ul","ioviewer-section-list"),_=et("div","ioviewer-section-empty",$("sections.noPlanes")),m=et("div","ioviewer-section-block"),p=et("div","ioviewer-section-row");p.append(et("span","",$("sections.axis")),u.element,f),m.append(p,g,_);let b=Wr($("sections.box"),[["keepInside",$("sections.keepInside")],["cutInside",$("sections.cutInside")]],I=>s.setBoxMode(I)),E=et("button","ioviewer-text-button",$("sections.fitSelection"));E.type="button",E.addEventListener("click",h);let v=et("input","ioviewer-section-slider");Object.assign(v,{type:"range",min:"-180",max:"180",step:"1"}),v.addEventListener("input",()=>s.setBoxYaw(Number(v.value)*Math.PI/180));let y=et("span");y.setAttribute("aria-hidden","true");let S=et("label","ioviewer-section-row");S.append(et("span","",$("sections.boxYaw")),v,y);let A=et("div","ioviewer-section-block");A.append(b.element,S,E);let x=Oh($("sections.showGizmo"),I=>s.setGizmoVisible(I)),T=Oh($("sections.fill"),I=>s.setFill(I));o||(T.element.title=$("sections.fillUnavailable"));let C=[],D=()=>{d.update(s.mode),m.hidden=s.mode!=="planes",A.hidden=s.mode!=="box",f.disabled=s.planes.length>=Gr,C.length!==s.planes.length&&(C=s.planes.map((B,G)=>Ly(s,G)),g.replaceChildren(...C.map(B=>B.element))),C.forEach(B=>B.update()),_.hidden=C.length>0,b.update(s.boxMode),v.value=String(Math.round(s.boxYaw*180/Math.PI)),y.textContent=`${v.value}\xB0`,v.setAttribute("aria-valuetext",y.textContent),x.input.checked=s.gizmoVisible,T.input.checked=s.fill;let I=s.mode==="box"||s.mode==="planes"&&s.planes.some(B=>B.enabled);T.input.disabled=!o||!I,e.setActive("plane",s.mode==="planes"),e.setActive("box",s.mode==="box")},U=()=>E.disabled=r.size===0;if(t.registerPanel("sections",{icon:ne.sections,title:$("panel.sections"),visible:!s.modelBox.isEmpty(),render:I=>I.append(d.element,m,A,T.element,x.element)}),s.addEventListener("change",D),r.addEventListener("change",U),D(),U(),s.modelBox.isEmpty())return;let F=()=>t.openPanel("sections");e.setHandler("plane",()=>{l(),F()}),e.setHandler("box",()=>{(s.mode==="box"||r.size&&h()||s.fitBoxToShown())&&F()}),e.setHandler("resetSections",()=>s.reset()),n.setItem("sectionBox",{handler:I=>{s.fitBoxToElements(r.has(I)?c():[I]),F()}}),n.setItem("resetSections",{handler:()=>s.reset()})}var Dy="#facc15",Ny=9;function zh(i,t=ri){return`${new Intl.NumberFormat(t,{minimumFractionDigits:2,maximumFractionDigits:2,useGrouping:!1}).format(i)} ${$("unit.m",t)}`}var Sl=class extends EventTarget{constructor(t){super(),this.active=!1,this.points=[],this.preview=null,this.group=new Re,this.group.name="measure";let e=new fe;e.setAttribute("position",new Ae(new Float32Array(6),3));let n={color:Dy,depthTest:!1,depthWrite:!1,transparent:!0};this._line=new Bi(e,new an(n)),this._markers=new ni(e,new Bn({...n,size:Ny,sizeAttenuation:!1}));for(let s of[this._line,this._markers])s.frustumCulled=!1,s.renderOrder=1001,this.group.add(s);this.label=et("div","ioviewer-measure-label"),this.label.hidden=!0,this._previewMarker=et("div","ioviewer-measure-preview"),this._previewMarker.hidden=!0,this._previewMarker.setAttribute("aria-hidden","true"),t.prepend(this.label,this._previewMarker),this._sync()}get distance(){return this.points.length===2?this.points[0].distanceTo(this.points[1]):null}get box(){return new le().setFromPoints(this.points)}setActive(t){this.active=!!t,this.active||(this.points=[],this.setPreview(null)),this._sync()}add(t){this.active&&(this.points=this.points.length===1?[this.points[0],t.clone()]:[t.clone()],this._sync())}clear(){return this.points.length===0?!1:(this.points=[],this._sync(),!0)}setPreview(t){!this.preview&&!t||(this.preview=t,this._previewMarker.hidden=!t,t&&(this._previewMarker.dataset.kind=t.kind),this.dispatchEvent(new Event("previewchange")))}update(t,e){this.preview&&kr(this._previewMarker,this.preview.point,t,e),this.distance!==null&&kr(this.label,this.points[0].clone().lerp(this.points[1],.5),t,e)}_sync(){let t=this._line.geometry.attributes.position;this.points.forEach((e,n)=>t.setXYZ(n,e.x,e.y,e.z)),t.needsUpdate=!0,this._line.geometry.setDrawRange(0,this.points.length),this._line.visible=this.points.length===2,this._markers.visible=this.points.length>0,this.label.hidden=this.distance===null,this.distance!==null&&(this.label.textContent=zh(this.distance)),this.dispatchEvent(new Event("change"))}};var _p=8,Uy=1-1e-6,Fy=8,xp={vertex:0,midpoint:1,edge:2},By=2e4;function Oy(i,t){let e=new Map,n=new Uint32Array(i.length/3);for(let d=0;d0&&(_.normalize(),l(u,f,_),l(f,g,_),l(g,u,_))}let c=[],h=new Set;for(let{lo:d,hi:u,count:f,crease:g}of s.values())f!==1&&!g||(c.push(d,u),h.add(d),h.add(u));return{edges:c,vertices:h}}function wl(i,t,e){return t<0&&e<0?!1:(t<0&&(i[0]=Math.max(i[0],t/(t-e))),e<0&&(i[1]=Math.min(i[1],t/(t-e))),i[0]<=i[1])}function zy(i,t,e,n,s,r){let o=[0,1];if(!wl(o,e.w+e.z,n.w+n.z)||!wl(o,e.w-e.z,n.w-n.z))return[];if(!r||!s.length)return s.every(c=>wl(o,c.distanceToPoint(i),c.distanceToPoint(t)))?[o]:[];let a=o.slice();if(!s.every(c=>{let h=c.distanceToPoint(i),d=c.distanceToPoint(t);return(h<0||d<0)&&wl(a,-h,-d)}))return[o];let l=[];return o[0]0))return null;let m=ae.clamp(((r-c)*f+(o-h)*g)/_,0,1);return e+(n-e)*(m*a.w/((1-m)*l.w+m*a.w))}var El=class{constructor(t,e,n){this.picker=t,this.sections=e,this.data=n,this.cache=new Map}release(){this.data.releaseBinary(),this.cache.clear()}_geometry(t){let e=this.cache.get(t);if(e)this.cache.delete(t);else{let n=this.data.meta.geometries[t],s=Qa({view:this.data.readView},n);e={positions:s,...Oy(s,this.data.readView(n.indices))}}return this.cache.set(t,e),this.cache.size>Fy&&this.cache.delete(this.cache.keys().next().value),e}target(t,e){let n=this.picker.measureTile(t,e,_p+1);if(!n)return null;let{rect:s}=n,r=t-s.left,o=e-s.top,{camera:a,scene:l}=this.picker,{planes:c,intersection:h}=this.sections.clipping(),d=new Yt().multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),u=a.matrixWorldInverse.elements,f=null;function g(y,S,A,x){if(f&&xp[y]>xp[f.kind]||A.w<=0||A.z<-A.w||A.z>A.w)return;let[T,C]=kh(A,s);if(!(T>=0&&C>=0&&T_p**2||f?.kind===y&&D>=f.distance||y!=="edge"&&lp(S,c,h))return;let U=-(u[2]*S.x+u[6]*S.y+u[10]*S.z+u[14]);U-n.depthAt(T,C,x)>2*En+Math.abs(U)*2**-21||(f={kind:y,distance:D,point:S.clone()})}let _=By*3,m=new Yt,p=new L,b=new ge,{geometry:E,matrix:v}=this.data.meta.instances;for(let y of n.slots){let S=l.slotInstance(y),[A]=this.data.readView({t:"u32",o:E.o+S*4,n:1}),x=this.data.meta.geometries[A],T=Math.max(x.indices.n,x.positions.n/3);if(T>_)continue;_-=T;let{positions:C,vertices:D,edges:U}=this._geometry(A),F=this.data.readView({t:"f32",o:v.o+S*48,n:12});m.set(F[0],F[3],F[6],F[9],F[1],F[4],F[7],F[10],F[2],F[5],F[8],F[11],0,0,0,1);let I=new Map;for(let B of D){let G=new L().fromArray(C,B*3).applyMatrix4(m),q=new ge(G.x,G.y,G.z,1).applyMatrix4(d);I.set(B,[G,q]),g("vertex",G,q,y)}if(f?.kind!=="vertex")for(let B=0;Br.element)),t.prepend(s),this._layer=s,this.setVisible(this.count>0)}get visible(){return this.group.visible}setVisible(t){this.group.visible=!!t,this._layer.hidden=!t,this.dispatchEvent(new Event("change"))}update(t,e){if(this.visible)for(let{element:n,point:s}of this._labels)kr(n,s,t,e)}};var Hy=8,vp=4;function Hh(i,t,e,n="dialog"){let s=et("div","ioviewer-popover ioviewer-floating");s.setAttribute("role",n),s.setAttribute("aria-label",e),s.hidden=!0,t.setAttribute("aria-haspopup",n),t.setAttribute("aria-expanded","false"),i.append(s);function r(l){s.contains(l.target)||(a(),al(l))}s.addEventListener("keydown",l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),a(),t.focus())});function o(){s.hidden=!1,t.setAttribute("aria-expanded","true");let l=t.getBoundingClientRect(),{width:c}=s.getBoundingClientRect();s.style.left=`${Math.max(vp,Math.min(l.left+l.width/2-c/2,innerWidth-c-vp))}px`,s.style.bottom=`${innerHeight-l.top+Hy}px`,window.addEventListener("pointerdown",r,!0),window.addEventListener("resize",a)}function a(){return s.hidden?!1:(s.hidden=!0,t.setAttribute("aria-expanded","false"),window.removeEventListener("pointerdown",r,!0),window.removeEventListener("resize",a),!0)}return{element:s,close:a,toggle:()=>s.hidden?o():a(),get isOpen(){return!s.hidden}}}function Vy(i){return i?.initialWireframe?"wireframe":i?.initialWhiteMode?"white":"materials"}function yp({root:i,toolbar:t,scene:e,meta:n,grids:s,initialBackground:r,setBackground:o}){let a=x=>t.element.querySelector(`[data-tool="${x}"]`),l=a("displayMode"),c=Hh(i,l,$("group.display"));c.element.classList.add("ioviewer-display-modes");let h=et("div");h.setAttribute("role","menu"),h.setAttribute("aria-label",$("tool.displayMode")),c.element.append(h);let d=(n.textures??[]).length>0,u=bh.map(x=>{let T=et("button","ioviewer-menu-item",$(`display.${x}`));return T.type="button",T.dataset.mode=x,T.setAttribute("role","menuitemradio"),T.disabled=x==="textures"&&!d,T.addEventListener("click",()=>{f(x),c.close(),l.focus()}),h.append(T),T}),f=x=>{e.setDisplayMode(x);for(let T of u)T.setAttribute("aria-checked",String(T.dataset.mode===x))};f(Vy(n.options)),t.setHandler("displayMode",()=>{c.toggle(),c.isOpen&&h.querySelector('[aria-checked="true"]')?.focus()});let g=et("div","ioviewer-background-setting"),_=et("label","",$("display.background")),m=et("input");Object.assign(m,{type:"color",value:r}),_.append(m);let p=et("button","ioviewer-text-button",$("display.backgroundReset"));p.type="button",p.disabled=!0;let b=()=>{o(m.value),p.disabled=m.value===r};m.addEventListener("input",b),p.addEventListener("click",()=>{m.value=r,m.focus(),b()}),g.append(_,p),c.element.append(g),t.setActive("grids",s.visible),s.count>0&&t.setHandler("grids",()=>{s.setVisible(!s.visible),t.setActive("grids",s.visible)});let E=Hh(i,a("opacity"),$("tool.opacity"));E.element.classList.add("ioviewer-opacity");let v=et("input","ioviewer-opacity-slider");Object.assign(v,{type:"range",min:"10",max:"100",step:"1",value:"100"}),v.setAttribute("aria-label",$("opacity.label"));let y=et("output","ioviewer-opacity-value"),S=()=>y.textContent=$("opacity.value").replace("{value}",v.value);v.addEventListener("input",()=>{e.setOpacity(Number(v.value)/100),S()}),S();let A=et("div","ioviewer-opacity-head");return A.append(et("span","",$("opacity.label")),y),E.element.append(A,v),t.setHandler("opacity",E.toggle),[c,E]}var Gy=3e3;function Al(i,t){let e=et("button",i);return e.type="button",e.setAttribute("title",t),e.append(et("span","ioviewer-row-name",t)),e}function Mp({shell:i,toolbar:t,controls:e,scene:n,sections:s,selection:r,restoreLinkedModels:o,views:a,bcfTopics:l}){let c=null,h=et("button","ioviewer-text-button ioviewer-tour");h.type="button";function d(E){E.sections!=null&&s.restore(E.sections),E.hiddenElements!=null&&n.setHiddenElements(E.hiddenElements),E.visibleElements!=null&&n.isolate(E.visibleElements),E.hiddenModelKeys!=null&&o(E.hiddenModelKeys),E.selectedElements!=null&&r.set(E.selectedElements);let v=E.camera.projection==="orthographic";e.setProjection(v?"orthographic":"perspective"),t.setActive("projection",v),e.restoreViewCamera(E.camera)}function u(){d(a[c.next]),c.next=(c.next+1)%a.length;let E=()=>{e.animating?c.frame=requestAnimationFrame(E):c.timer=setTimeout(u,Gy)};c.frame=requestAnimationFrame(E)}let f=E=>h.contains(E.target),g=E=>!f(E)&&m(),_=E=>{f(E)&&(E.key==="Enter"||E.key===" ")||(E.key==="Escape"&&(E.preventDefault(),E.stopPropagation()),m())};function m(){c&&(cancelAnimationFrame(c.frame),clearTimeout(c.timer),c=null,window.removeEventListener("pointerdown",g,!0),window.removeEventListener("wheel",m,!0),window.removeEventListener("keydown",_,!0),b())}function p(){c={next:0,frame:0,timer:0},window.addEventListener("pointerdown",g,!0),window.addEventListener("wheel",m,!0),window.addEventListener("keydown",_,!0),b(),u()}function b(){let E=$(c?"views.stop":"views.tour");h.replaceChildren(),h.insertAdjacentHTML("afterbegin",c?ne.pause:ne.play),h.append(et("span","",E)),h.setAttribute("aria-pressed",String(!!c))}h.addEventListener("click",()=>c?m():p()),b(),i.registerPanel("views",{icon:ne.views,title:$("panel.views"),visible:a.length>0,render:E=>{let v=et("div","ioviewer-row-list");for(let y of a){let S=Al("ioviewer-row ioviewer-view",String(y.name??""));S.addEventListener("click",()=>d(y)),v.append(S)}E.append(h,v)}}),i.registerPanel("bcf",{icon:ne.bcf,title:$("panel.bcf"),visible:l.length>0,render:E=>{let v=et("div","ioviewer-row-list");for(let y of l){let S=et("details","ioviewer-bcf-topic");S.append(et("summary","",y.title)),y.status&&S.append(et("p","ioviewer-bcf-status",y.status)),y.description&&S.append(et("p","ioviewer-bcf-description",y.description)),y.viewpoints.length||S.append(et("p","ioviewer-bcf-status",$("bcf.noView"))),y.viewpoints.forEach((A,x)=>{let T=$("bcf.viewpoint").replace("{index}",String(x+1)),C=Al("ioviewer-row ioviewer-view",T);if(C.addEventListener("click",()=>d(A)),S.append(C),A.missingComponents||A.ambiguousComponents){let D=$("bcf.components").replace("{missing}",String(A.missingComponents)).replace("{ambiguous}",String(A.ambiguousComponents));S.append(et("p","ioviewer-bcf-status",D))}}),v.append(S)}E.append(v)}})}function bp(i,t){let e=[];for(let[n,s]of[[i.element1Id,i.element1Name],[i.element2Id,i.element2Name]]){let r=n!=null?t.findIndex(o=>o.id!=null&&String(o.id)===String(n)&&!o.mesh):Wy(t,s);r>=0&&!e.includes(r)&&e.push(r)}return e}function Wy(i,t){if(t==null)return-1;let e=i.findIndex(n=>n.name===t);return e>=0&&i.findIndex((n,s)=>s>e&&n.name===t)<0?e:-1}var Xy=["New","Active","Reviewed","Approved","Resolved"],Vh=27,qy=8,Yy=14,$y=2,Zy=new L(1,-1,.8).normalize();function Sp({shell:i,tests:t,elements:e,scene:n,controls:s,selection:r}){let o=new Re;o.name="clash-marker";let a=new fe;a.setAttribute("position",new Ae(new Float32Array(3),3));let l={color:"#ef4444",depthTest:!1,depthWrite:!1,transparent:!0},c=new ni(a,new Bn({...l,size:Yy,sizeAttenuation:!1}));c.frustumCulled=!1,c.renderOrder=1002,o.add(c),o.visible=!1;let h=null,d=null;function u(){o.visible=!1,h?.removeAttribute("aria-current"),h=null,d=null,s.setExtraBounds("clash",null)}function f(b,E){let v=bp(b,e);v.length?r.set(v):r.clear();let y=new L(...b.point),S=0;for(let T of v){let C=n.elementBox(T);C.isEmpty()||(S=Math.max(S,...C.getSize(new L).toArray()))}let A=s.camera.position.clone().sub(s.target);A.lengthSq()<1e-12&&A.copy(Zy);let x=Math.max(3*S,$y);s.animateTo({position:A.normalize().multiplyScalar(x).add(y),target:y}),a.attributes.position.setXYZ(0,y.x,y.y,y.z),a.attributes.position.needsUpdate=!0,o.visible=!0,h?.removeAttribute("aria-current"),h=E,d=b,E.setAttribute("aria-current","true"),s.setExtraBounds("clash",new le(y.clone(),y.clone()))}function g(b){let E=Al("ioviewer-row ioviewer-clash",String(b.name??""));E.setAttribute("title",`${b.name??""}: ${b.element1Name??""} \u2014 ${b.element2Name??""}`);let v=Xy.includes(b.status),y=et("span","ioviewer-clash-status",v?$(`clash.${b.status}`):String(b.status??""));v&&(y.dataset.status=b.status);let S=typeof b.distance=="number"?zh(b.distance):"";return E.append(y,et("span","ioviewer-clash-distance",S)),b===d&&(h=E,E.setAttribute("aria-current","true")),E.addEventListener("click",()=>f(b,E)),E}function _(b,E){let v=et("div","ioviewer-clash-test"),y=et("button","ioviewer-row ioviewer-clash-header");y.type="button",y.setAttribute("aria-expanded","true");let S=`${b.name??""} (${b.clashes.length})`;y.setAttribute("title",S),y.insertAdjacentHTML("afterbegin",ne.chevron),y.append(et("span","ioviewer-row-name",S));let A=et("div","ioviewer-clash-list");return A.style.height=`${Math.max(0,b.clashes.length*Vh-1)}px`,y.addEventListener("click",()=>{A.hidden=!A.hidden,y.setAttribute("aria-expanded",String(!A.hidden)),E()}),v.append(y,A),{box:v,list:A,clashes:b.clashes,rows:new Map}}function m({list:b,clashes:E,rows:v},{start:y,end:S}){for(let[x,T]of v)(x=S)&&(T.remove(),v.delete(x));let A=null;for(let x=S-1;x>=y;x--){let T=v.get(x);T||(T=g(E[x]),T.style.top=`${x*Vh}px`,b.insertBefore(T,A),v.set(x,T)),A=T}}function p(b){if(!t.length)return;b.classList.add("ioviewer-clashes-body");let E=t.map(y=>_(y,v));for(let y of E)b.append(y.box);function v(){let y=b.scrollTop,S=b.clientHeight,A=E.map(({list:x,clashes:T})=>S&&!x.hidden?Ih(y-x.offsetTop,Vh,S,T.length,qy):{start:0,end:0});E.forEach((x,T)=>m(x,A[T]))}b.addEventListener("scroll",v),b.addEventListener("focusin",v),new ResizeObserver(v).observe(b)}return i.registerPanel("clashes",{icon:ne.clashes,title:$("panel.clashes"),visible:t.length>0,render:p,onClose:()=>o.visible&&u()}),{group:o}}var Jy=["construct","demolish","temporary"],Ky=Date.parse("0002-01-01T00:00:00Z");function wp(i){let t=typeof i=="string"?Date.parse(i):NaN;return t>=Ky?t:NaN}function Ep(i,t){let e=new Map(t.flatMap((o,a)=>o.mesh||o.id==null?[]:[[String(o.id),a]])),n=[];for(let o of Array.isArray(i?.tasks)?i.tasks:[]){let a=wp(o?.start),l=wp(o?.end);if(!(a<=l))continue;let c=Jy.includes(o.type)?o.type:"construct",h=Array.isArray(o.attachedElements)?o.attachedElements:[];n.push({name:o.name,type:c,start:a,end:l,elements:h.map(d=>e.get(String(d))).filter(d=>d!==void 0)})}let s=n.reduce((o,a)=>Math.min(o,a.start),1/0),r=n.reduce((o,a)=>Math.max(o,a.end),-1/0);return{start:s,end:r,tasks:n}}function Tp(i,t){let e=new Set,n=new Map;for(let s of i){let r=ts.end,a=s.type==="construct"?r:s.type==="demolish"?o:r||o;for(let l of s.elements)a?e.add(l):!r&&!o&&n.set(l,s.type)}for(let s of e)n.delete(s);return{hidden:e,active:n}}var jy=864e5,Qy=["1","5","15"],tM={construct:"#22c55e",demolish:"#ef4444",temporary:"#a855f7"};function Ap({root:i,shell:t,timeliner:e,elements:n,scene:s}){let r=Ep(e,n);if(r.tasks.length===0)return t.registerPanel("timeliner",{icon:ne.timeliner,title:$("panel.timeliner"),visible:!1,render:()=>{}}),null;let o=new Intl.DateTimeFormat(void 0,{dateStyle:"short",timeZone:"UTC"}),a=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}),l=r.start,c=1,h=0,d=0,u=!1,f=new Set,g=new Map,_=et("div","ioviewer-player ioviewer-floating");_.setAttribute("role","group"),_.setAttribute("aria-label",$("player.title")),_.hidden=!0;let m=Qe("ioviewer-icon-button ioviewer-player-play",ne.play,$("player.play"));m.addEventListener("click",()=>h?U():D());let p=et("output","ioviewer-player-date"),b=et("input","ioviewer-player-slider");Object.assign(b,{type:"range",min:String(r.start),max:String(r.end),step:"any"}),b.setAttribute("aria-label",$("player.date")),b.addEventListener("input",()=>A(Number(b.value)));let E=Wr($("player.speed"),Qy.map(I=>[I,`${I}\xD7`]),I=>{c=Number(I),E.update(I)});E.update(String(c));let v=Qe("ioviewer-panel-close",ne.close,$("close"));v.addEventListener("click",T),_.append(m,p,b,E.element,v),i.append(_),new ResizeObserver(()=>{let I=_.hidden?0:_.offsetHeight+8;i.style.setProperty("--player-space",`${I}px`)}).observe(_);function S(){let I=Tp(r.tasks,l),B=[...f].filter(N=>!I.hidden.has(N)),G=[...I.hidden].filter(N=>!f.has(N));f=I.hidden;let q=[...g.keys()].filter(N=>I.active.get(N)!==g.get(N)),O=new Map;for(let[N,z]of I.active)g.get(N)!==z&&(O.has(z)||O.set(z,[]),O.get(z).push(N));g=I.active,B.length&&s.setLayerHidden("schedule",B,!1),G.length&&s.setLayerHidden("schedule",G,!0),q.length&&s.setTint(q,null);for(let[N,z]of O)s.setTint(z,tM[N])}function A(I){l=Math.min(Math.max(I,r.start),r.end),b.value=String(l),p.textContent=a.format(l),u&&S()}function x(){u||(u=!0,_.hidden=!1,A(r.start))}function T(){u&&(U(),u=!1,s.setTint([...g.keys()],null),g=new Map,f=new Set,s.clearLayer("schedule"),_.hidden=!0)}function C(I){A(l+Math.max(I-d,0)/1e3*c*jy),d=I,l>=r.end?U():h=requestAnimationFrame(C)}function D(){x(),!h&&(l>=r.end&&A(r.start),d=performance.now(),h=requestAnimationFrame(C),F())}function U(){cancelAnimationFrame(h),h=0,F()}function F(){let I=$(h?"player.pause":"player.play");m.innerHTML=h?ne.pause:ne.play,m.title=I,m.setAttribute("aria-label",I)}return t.registerPanel("timeliner",{icon:ne.timeliner,title:$("panel.timeliner"),render:I=>{let B=et("button","ioviewer-text-button ioviewer-player-open");B.type="button",B.insertAdjacentHTML("afterbegin",ne.play),B.append(et("span","",$("player.play"))),B.addEventListener("click",D);let G=et("div","ioviewer-row-list");for(let q of r.tasks){let O=String(q.name??""),N=et("div","ioviewer-row ioviewer-task");N.dataset.type=q.type,N.setAttribute("title",`${O} \xB7 ${$(`task.${q.type}`)}`);let z=`${o.format(q.start)} \u2013 ${o.format(q.end)}`;N.append(et("span","ioviewer-row-name",O),et("span","ioviewer-task-dates",z)),G.append(N)}I.append(B,G)}}),{open:x,close:T,play:D,pause:U,setDate:A,get date(){return l},get isOpen(){return u}}}function Rp({shell:i,files:t,elements:e,scene:n}){let s=t.map(o=>({file:o,members:o.members??e.flatMap((a,l)=>a.link!=null&&(a.link===o.name||a.link===o.path)?[l]:[]),input:et("input")})),r=()=>n.replaceLayerHidden("links",s.flatMap(({input:o,members:a})=>o.checked?[]:a));return i.registerPanel("links",{icon:ne.links,title:$("panel.links"),visible:s.length>0,render:o=>{let a=et("div","ioviewer-row-list");for(let l of s){let c=String(l.file.name??""),h=et("label","ioviewer-row ioviewer-check ioviewer-link");h.setAttribute("title",`${c} (${l.file.path??""})`);let{input:d}=l;d.type="checkbox",d.checked=l.members.length===0||l.file.visible!==!1,d.disabled=l.members.length===0,d.addEventListener("change",r),h.append(d,et("span","ioviewer-row-name",c),et("span","ioviewer-row-count",String(l.members.length))),a.append(h)}o.append(a),r()}}),o=>{let a=new Set(o);for(let{file:l,input:c}of s)c.checked=c.disabled||!a.has(l.key);r()}}function Cp(i,t,e){let n=i.filter(Number.isFinite).sort((o,a)=>o-a),s=[];for(let o of n){let a=s.at(-1);!a||o-a.at(-1)>2?s.push([o]):a.push(o)}if(s.length<2||s.some(o=>o.length<2||o.at(-1)-o[0]>2))return[];let r=[Math.min(t,n[0])];for(let o=1;o({min:r[a],max:o}))}function Ip(i,t){return!i||t>=i.min&&t<=i.max}function Pp(i,t,e,n){let s=Math.min(16,Math.max(.5,i.zoom*t)),r=1/i.zoom-1/s;return{...i,zoom:s,x:i.x+e*i.side*r,y:i.y-n*i.side*r}}var eM=new Intl.NumberFormat(ri,{maximumFractionDigits:2,minimumFractionDigits:2}),Rl=i=>`${eM.format(i)} ${$("scanMap.metres")}`;function oi(i,t,e){let n=document.createElement("button");return n.type="button",n.textContent=t,n.title=i,n.setAttribute("aria-label",i),n.addEventListener("click",e),n}function nM(i,t){return[i*.005,t*.005]}function iM(i,t,e){return i.set(Math.cos(e)*Math.cos(t),Math.cos(e)*Math.sin(t),Math.sin(e))}function sM(i,t,e,n,s,r,o){let a=new kn;a.setFromCamera(new Xt(n,s),i),a.ray.origin.copy(t),a.near=.05,a.params.Points.threshold=.12;let l=new L,c=new L;for(let h of a.intersectObjects(e,!1))if(l.fromBufferAttribute(h.object.geometry.attributes.position,h.index).applyMatrix4(h.object.matrixWorld),c.copy(l).sub(t).project(i),Math.hypot((c.x-n)*r/2,(c.y-s)*o/2)<=14)return l.z}function Lp(i,t,e,n,s,r){if(!e.count)return;let o=new le().setFromObject(e.root);if(o.isEmpty())return;let a=o.getSize(new L),l=o.getCenter(new L),c={x:l.x,y:l.y,side:Math.max(a.x,a.y,.01)*1.12,zoom:1},h={...c},d=R=>50+100*(R-h.x)*h.zoom/h.side,u=R=>50-100*(R-h.y)*h.zoom/h.side,f=R=>Math.min(96,Math.max(4,R)),g=(R,wt,kt=!1)=>{let P=d(wt.x),M=u(wt.y);return R.style.left=`${kt?f(P):P}%`,R.style.top=`${kt?f(M):M}%`,P>=0&&P<=100&&M>=0&&M<=100},_=t.meta.rtcOffset?.[2]??0,m=t.meta.panoramas??[],p=m.map(R=>new L(...R.position)),b=`ioviewer.scan-levels.v1:${location.pathname}`,E=()=>Cp(p.map(R=>R.z+_),o.min.z+_,o.max.z+_),v=null;try{let R=JSON.parse(localStorage.getItem(b));Array.isArray(R)&&(v=R.filter(wt=>Number.isFinite(wt?.min)&&Number.isFinite(wt.max)&&wt.max>wt.min))}catch{v=null}let y=v??E(),S=-1,A=!0,x=R=>Ip(y[S],R+_),T=document.createElement("details");T.className="ioviewer-floating ioviewer-scan-map",T.open=!matchMedia("(max-width: 600px)").matches;let C=document.createElement("summary");C.textContent=$("scanMap.title");let D=document.createElement("div");D.className="scan-map-plot";let U=document.createElement("canvas");U.width=U.height=300,U.setAttribute("role","img"),U.setAttribute("aria-label",$("scanMap.plan")),U.tabIndex=0;let F=document.createElement("span");F.className="scan-map-camera",F.setAttribute("aria-hidden","true");let I=document.createElement("span");I.className="scan-map-axes",I.textContent="Y \u2191";let B=document.createElement("span");B.className="scan-map-scale",D.append(U,F,I,B),T.append(C,D),i.append(T);let G=e.root.children.reduce((R,wt)=>R+wt.geometry.attributes.position.count,0),q=Math.max(1,Math.ceil(G/6e4)),O=e.root.children.map(R=>{let wt=R.geometry.attributes.position,kt=new Float32Array(Math.ceil(wt.count/q)*3),P=new L;for(let M=0,X=0;M{if(N=0,!T.open)return;let R=U.getContext("2d");if(!R)return;R.clearRect(0,0,300,300),R.fillStyle="rgba(160, 185, 201, .33)";for(let[P,M]of O.entries())if(e.root.children[P].visible)for(let X=0;X{N||(N=requestAnimationFrame(z))},k=new L,K=null,lt=()=>{if(K){F.hidden=!x(K.position.z),g(F,K.position,!0),F.style.rotate=`${Math.PI/2-K.yaw}rad`;return}F.hidden=!1,g(F,s.camera.position,!0),s.camera.getWorldDirection(k),F.style.rotate=`${Math.atan2(k.x,k.y)}rad`};T.addEventListener("toggle",W),n.root.addEventListener("change",R=>{R.detail.kind==="visibility"&&W()}),s.addEventListener("change",lt);let ht=document.createElement("div");ht.className="scan-map-controls";let at=document.createElement("select");at.setAttribute("aria-label",$("scanMap.size"));for(let R of["small","medium","large"])at.add(new Option($(`scanMap.${R}`),R));at.value=matchMedia("(max-width: 600px)").matches?"small":"medium",i.dataset.scanMapSize=at.value,at.addEventListener("change",()=>{i.dataset.scanMapSize=at.value});let Y=(R,wt=0,kt=0)=>{h=Pp(h,R,wt,kt),W()},tt=()=>{h={...c},W()};ht.append(at,oi($("scanMap.zoomOut"),"\u2212",()=>Y(.8)),oi($("scanMap.zoomIn"),"+",()=>Y(1.25)),oi($("scanMap.reset"),"\u21BA",tt)),T.insertBefore(ht,D),U.addEventListener("wheel",R=>{R.preventDefault();let wt=U.getBoundingClientRect();Y(R.deltaY<0?1.15:1/1.15,(R.clientX-wt.left)/wt.width-.5,(R.clientY-wt.top)/wt.height-.5)},{passive:!1});let dt;U.addEventListener("pointerdown",R=>{R.button!==0||dt||(U.setPointerCapture(R.pointerId),dt={id:R.pointerId,x:R.clientX,y:R.clientY})}),U.addEventListener("pointermove",R=>{if(dt?.id!==R.pointerId)return;let wt=h.side/(h.zoom*Math.max(1,U.clientWidth));h.x-=(R.clientX-dt.x)*wt,h.y+=(R.clientY-dt.y)*wt,dt.x=R.clientX,dt.y=R.clientY,W()}),U.addEventListener("lostpointercapture",R=>{R.pointerId===dt?.id&&(dt=void 0)}),U.addEventListener("keydown",R=>{let wt={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,1],ArrowDown:[0,-1]}[R.key];if(wt){let kt=h.side/h.zoom/10;h.x+=wt[0]*kt,h.y+=wt[1]*kt,W()}else if(R.key==="+"||R.key==="="||R.key==="-")Y(R.key==="-"?.8:1.25);else if(R.key==="0")tt();else return;R.preventDefault(),R.stopPropagation()});let It=document.createElement("div");It.className="scan-map-controls";let ot=document.createElement("select");ot.setAttribute("aria-label",$("scanMap.levels"));let Tt=document.createElement("p");Tt.className="scan-map-feedback",Tt.setAttribute("role","status");function jt(){try{localStorage.setItem(b,JSON.stringify(y))}catch{Tt.textContent=$("scanMap.levelTemporary")}}function Bt(){ot.replaceChildren(new Option($("scanMap.allLevels"),"-1")),y.forEach((R,wt)=>ot.add(new Option(`${$("scanMap.level").replace("{n}",wt+1)} \xB7 ${Rl(R.min)} \u2013 ${Rl(R.max)}`,String(wt)))),ot.value=String(S),Ot.disabled=S<0;for(let[R,wt]of p.entries())Zt.options[R+1].hidden=!x(wt.z);W(),r()}ot.addEventListener("change",()=>{S=Number(ot.value),Tt.textContent="",Bt()});let ut=oi($("scanMap.addLevel"),"+",()=>{if(zt.isClosed()){let R=p.findIndex(wt=>x(wt.z));re(Math.max(0,R))}zt.pickLevel()});ut.disabled=!m.length;let Lt=oi($("scanMap.autoLevels"),$("scanMap.autoButton"),()=>{let R=E(),wt=R.filter(kt=>!y.some(P=>P.min{S<0||(y.splice(S,1),S=-1,Tt.textContent="",jt(),Bt())});if(It.append(ot,ut,Lt,Ot),m.length){let R=oi($("scanMap.spheres"),"\u25C9",()=>{A=!A,R.setAttribute("aria-pressed",String(A)),r()});R.setAttribute("aria-pressed","true"),It.append(R)}T.append(It,Tt);let zt=m.length?rM(i,t,e,re,R=>{K=R,R||ie.forEach(wt=>wt.classList.remove("current")),lt()},R=>{S=y.push(R)-1,Tt.textContent=$("scanMap.levelAdded"),jt(),Bt()}):null,Zt=document.createElement("select");Zt.setAttribute("aria-label",$("scanMap.choosePhoto"));let Ee=new Option($("scanMap.choosePhoto"),"");Ee.disabled=!0,Zt.add(Ee);let ie=[];for(let[R,wt]of m.entries()){let kt=wt.name||t.meta.elements[wt.element].name||String(R+1);Zt.add(new Option(kt,String(R)));let P=document.createElement("button");P.type="button",P.className="scan-map-station",P.title=kt,P.setAttribute("aria-label",`${$("scanMap.photo")} \xB7 ${kt}`),P.addEventListener("click",()=>re(R)),ie.push(P),D.append(P)}Zt.value="",Zt.addEventListener("change",()=>re(Number(Zt.value))),Zt.hidden=!m.length,T.append(Zt),Bt(),!v&&y.length&&jt();function re(R,wt=!1){T.open=!0,Zt.value=String(R),ie.forEach((kt,P)=>kt.classList.toggle("current",R===P)),zt.open(R,wt),Zt.value=""}return{open:re,showSphere:(R,wt)=>A&&x(wt)&&n.isVisible(R)}}function rM(i,t,e,n,s,r){let o=document.createElement("section");o.className="ioviewer-floating scan-photo",o.setAttribute("aria-label",$("scanMap.photo")),o.hidden=!0;let a=document.createElement("header"),l=document.createElement("span"),c=document.createElement("div");c.className="scan-photo-actions";let h=oi($("scanMap.enlargePhoto"),$("scanMap.enlargePhoto"),()=>{let ut=o.classList.toggle("is-expanded"),Lt=$(ut?"scanMap.shrinkPhoto":"scanMap.enlargePhoto");h.textContent=h.title=Lt,h.setAttribute("aria-label",Lt),h.setAttribute("aria-pressed",String(ut))});h.setAttribute("aria-pressed","false");let d=document.createElement("button");d.type="button",d.textContent=$("close"),d.addEventListener("click",dt),c.append(h,d),a.append(l,c);let u=document.createElement("canvas");u.tabIndex=0,u.setAttribute("aria-label",$("scanMap.photoControls"));let f=document.createElement("p");f.setAttribute("role","status");let g=document.createElement("div");g.className="scan-photo-view";let _=document.createElement("span");_.className="scan-photo-crosshair",_.setAttribute("aria-hidden","true");let m=document.createElement("div");m.className="scan-photo-level",m.hidden=!0;let p=document.createElement("span");p.setAttribute("role","status"),m.append(p,oi($("scanMap.cancel"),$("scanMap.cancel"),ot)),g.append(u,_,f),o.append(a,m,g),i.append(o);let b=t.meta.panoramas.map((ut,Lt)=>{let Ot=ut.name||t.meta.elements[ut.element].name||String(Lt+1),zt=document.createElement("button");return zt.className="scan-photo-link",zt.type="button",zt.title=Ot,zt.setAttribute("aria-label",$("scanMap.goToStation").replace("{name}",Ot)),zt.hidden=!0,zt.addEventListener("click",()=>n(Lt,!0)),g.append(zt),{photo:ut,name:Ot,button:zt,position:new L(...ut.position)}}),E=t.readView(t.meta.points.element),v=new kn;v.params.Points.threshold=.12,v.near=.25;let y=new L,S=new L,A=new L,x=[],T=[],C=!1,D,U=t.meta.rtcOffset?.[2]??0,F,I,B=0,G=0,q=0,O=null,N,z,W=new ti,k=new ze(72,1,.1,20);k.up.set(0,0,1);let K=new On(10,56,28);K.rotateX(Math.PI/2);let lt=new Ke({side:De}),ht=new _e(K,lt);W.add(ht);let at=()=>{if(!(o.hidden||!I)){F.setSize(u.clientWidth,u.clientHeight,!1),k.aspect=u.clientWidth/Math.max(1,u.clientHeight),k.updateProjectionMatrix(),k.lookAt(iM(y,G,q)),F.render(W,k),k.getWorldDirection(y);for(let ut of x){if(C){ut.button.hidden=!0;continue}A.copy(ut.position).sub(N.position).normalize(),S.copy(A).project(k);let Lt=A.dot(y)>0&&Math.abs(S.x)<.92&&Math.abs(S.y)<.88;ut.button.hidden=!Lt,Lt&&(ut.button.style.left=`${(1+S.x)*50}%`,ut.button.style.top=`${(1-S.y)*50}%`)}s({position:N.position,yaw:G})}},Y=(ut,Lt)=>{G+=ut,q=ae.clamp(q+Lt,-1.55,1.55),at()};new ResizeObserver(at).observe(u),u.addEventListener("pointerdown",ut=>{ut.button!==0||O||(u.setPointerCapture(ut.pointerId),O={id:ut.pointerId,x:ut.clientX,y:ut.clientY,moved:!1})}),u.addEventListener("pointermove",ut=>{O?.id===ut.pointerId&&(C&&!O.moved&&Math.hypot(ut.clientX-O.x,ut.clientY-O.y)<5||(O.moved=!0,Y(...nM(ut.clientX-O.x,ut.clientY-O.y)),O.x=ut.clientX,O.y=ut.clientY))}),u.addEventListener("pointerup",ut=>{if(O?.id!==ut.pointerId||O.moved||!C)return;let Lt=u.getBoundingClientRect();jt((ut.clientX-Lt.left)*2/Lt.width-1,1-(ut.clientY-Lt.top)*2/Lt.height)}),u.addEventListener("lostpointercapture",ut=>{O?.id===ut.pointerId&&(O=null)}),u.addEventListener("keydown",ut=>{if(C&&ut.key==="Enter"){ut.preventDefault(),jt(0,0);return}let Lt={ArrowLeft:[.12,0],ArrowRight:[-.12,0],ArrowUp:[0,.12],ArrowDown:[0,-.12]}[ut.key];Lt&&(ut.preventDefault(),ut.stopPropagation(),Y(...Lt))}),u.addEventListener("wheel",ut=>{ut.preventDefault(),k.fov=ae.clamp(k.fov+Math.sign(ut.deltaY)*5,32,95),at()},{passive:!1}),o.addEventListener("keydown",ut=>{ut.key==="Escape"&&(C?ot():dt()),ut.stopPropagation()});function dt(){o.hidden=!0,ot(),B++,O=null,It(),s(null),z?.focus()}function It(){I?.dispose(),I=void 0,lt.map=null;for(let ut of x)ut.button.hidden=!0;x=[]}function ot(){C=!1,D=void 0,o.classList.remove("is-picking"),m.hidden=!0,at()}function Tt(){C=!0,D=void 0,o.classList.add("is-picking"),p.textContent=$("scanMap.pickLower"),m.hidden=!1,at(),I&&u.focus()}function jt(ut,Lt){if(!I)return;let Ot=sM(k,N.position,T,ut,Lt,u.clientWidth,u.clientHeight);if(Ot===void 0){p.textContent=$(D===void 0?"scanMap.noLowerHit":"scanMap.noUpperHit");return}let zt=Ot+U;D===void 0?(D=zt,p.textContent=$("scanMap.pickUpper").replace("{z}",Rl(zt))):zt<=D?p.textContent=$("scanMap.upperAboveLower").replace("{z}",Rl(D)):(r({min:D,max:zt}),ot())}function Bt(ut,Lt){let Ot=++B,zt=o.hidden;zt&&(z=document.activeElement),It(),N=b[ut],o.hidden=!1,l.textContent=N.name,u.style.visibility="hidden",f.textContent=$("scanMap.loading");let Zt=()=>{Ot===B&&(f.textContent=$("scanMap.photoError"))},Ee;try{F??(F=new Ei({canvas:u,antialias:!0})),F.setPixelRatio(Math.min(devicePixelRatio,2)),Ee=URL.createObjectURL(new Blob([t.readView(N.photo.image)],{type:"image/jpeg"}))}catch{Zt();return}new cr().load(Ee,ie=>{if(URL.revokeObjectURL(Ee),Ot!==B||ie.image.width!==2*ie.image.height){ie.dispose(),Zt();return}if(I?.dispose(),I=ie,I.colorSpace=Te,lt.map=I,lt.needsUpdate=!0,ht.rotation.z=ae.degToRad(N.photo.yaw),T=e.root.children.filter((re,R)=>E[R]===N.photo.element),x=b.filter(re=>{if(re===N)return!1;let R=A.copy(re.position).sub(N.position).length();return R<=.25?!1:(v.set(N.position,A.multiplyScalar(1/R)),v.far=R-.25,!v.intersectObjects(T,!1).length)}),zt||!Lt){let re=x.reduce((R,wt)=>!R||wt.position.distanceToSquared(N.position){URL.revokeObjectURL(Ee),Zt()})}return{open:Bt,pickLevel:Tt,isClosed:()=>o.hidden}}var ks=7;function Dp(i){if(!i?.length)return null;let t=i.map(({position:l})=>new L(...l)),e=new ar({color:"#72bfff",depthTest:!1,depthWrite:!1}),n=new gi(new On(1,12,8),e,i.length);n.count=0,n.frustumCulled=!1,n.renderOrder=10,n.instanceMatrix.setUsage(Tr);let s=[],r=new Yt,o=new L,a=new Xt;return{mesh:n,update(l,c,h){if(n.count=0,s.length=0,!(c.width<=0||c.height<=0)){for(let[d,u]of t.entries()){if(!h(i[d].element,u.z))continue;let f=-o.copy(u).applyMatrix4(l.matrixWorldInverse).z;if(f<=l.near||f>=l.far||(o.copy(u).project(l),!Number.isFinite(o.x)||!Number.isFinite(o.y)))continue;let g=(o.x+1)*c.width/2,_=(1-o.y)*c.height/2;if(g<-ks||g>c.width+ks||_<-ks||_>c.height+ks)continue;let m=l.isOrthographicCamera?(l.top-l.bottom)/l.zoom:l.getViewSize(f,a).y,p=ks*m/c.height;n.setMatrixAt(n.count++,r.makeScale(p,p,p).setPosition(u)),s.push({index:d,depth:f,x:g+c.left,y:_+c.top})}n.instanceMatrix.needsUpdate=n.count>0}},pick(l,c){let h;for(let d of s)(!h||d.depthh.visibleBox(),_=new xl(h,g(),i.meta.sections);d.syncVisibility(h),d.setClipping(_.clipping().planes);let m=t.getContextAttributes()?.stencil===!0,p,b=new Ml(_,Xn);n.add(b.group);let E=document.getElementById("ioviewer-ui"),v=new Sl(E),y=new Tl(E,i.meta.grids??[]);n.add(v.group,y.group);function S(){try{return new Or(i,{...Gh,maxTextureSize:e.capabilities.maxTextureSize})}catch(ot){if(!(ot instanceof Br))throw ot;c=!0,qr($("tooLarge").replace("{count}",ot.count).replace("{limit}",ot.limit));let Tt=Bt=>({o:0,n:0,t:Bt}),jt={count:0,geometry:Tt("u32"),material:Tt("u32"),element:Tt("i32"),matrix:Tt("f32")};return new Or({...i,meta:{...i.meta,instances:jt}})}}let A=!1;Xn.addEventListener("webglcontextlost",()=>{A=!0,qr($("contextLost"))});let x,T=new Promise(ot=>x=ot),C=Xr,D=!1;function U(){D||A||(D=!0,u.requested(performance.now()),requestAnimationFrame(()=>{if(D=!1,A)return;let ot=Xn.getBoundingClientRect();z.camera.updateMatrixWorld(),dt&&f?.update(z.camera,ot,dt.showSphere),b.update(z.camera),v.update(z.camera,ot),y.update(z.camera,ot),u.begin(z.camera,ot.height,performance.now()),C?.("renderStart"),_.fill&&m?(p??(p=new bl(h,_,i)),p.render(e,n,z.camera)):e.render(n,z.camera),C&&(C("renderEnd"),C=void 0),u.end(performance.now()),It.update(),x()}))}h.root.addEventListener("change",U),_.addEventListener("change",()=>{d.setClipping(_.clipping().planes),U()}),b.addEventListener("change",U),v.addEventListener("change",U),v.addEventListener("previewchange",U),y.addEventListener("change",U);let F=new hl(e,h,a,{pickFloat:Gh.pickFloat}),I=new El(F,_,i),B=0,G=null;function q(){cancelAnimationFrame(B),B=0,G=null,v.setPreview(null)}function O(){B=0,G&&v.setPreview(I.target(...G))}function N(){G&&(v.setPreview(null),cancelAnimationFrame(B),B=requestAnimationFrame(()=>{B=requestAnimationFrame(O)}))}Xn.addEventListener("pointermove",ot=>{if(!v.active||ot.buttons)return q();G=[ot.clientX,ot.clientY],B||(B=requestAnimationFrame(O))});for(let ot of["pointerdown","pointerleave","pointercancel","webglcontextlost"])Xn.addEventListener(ot,q);h.root.addEventListener("change",ot=>{ot.detail.kind!=="appearance"&&N()});let z=new ol(a,Xn,{pick:(ot,Tt)=>F.pick(ot,Tt)?.point??null,visibleBox:g});z.addEventListener("change",()=>{F.camera=z.camera,N(),U()}),h.root.addEventListener("change",ot=>{ot.detail.kind==="visibility"&&(d.syncVisibility(h),z.invalidateBounds(),z.resize())});let W=new pl;W.addEventListener("change",()=>h.setHighlighted([...W.values()]));let k=ap({root:E,data:i,scene:h,controls:z,picker:F,selection:W,measure:v});gp({root:E,...k,sections:_,selection:W,canFill:m});let{meta:K}=i,lt=Rp({...k,files:K.linkedFiles??[],elements:K.elements,scene:h});Mp({...k,controls:z,scene:h,sections:_,selection:W,restoreLinkedModels:lt,views:K.viewpoints??[],bcfTopics:K.bcfTopics??[]});let ht=Sp({...k,tests:K.clashTests??[],elements:K.elements,scene:h,controls:z,selection:W});n.add(ht.group);let at=Ap({root:E,...k,timeliner:K.timeliner,elements:K.elements,scene:h}),Y=ot=>{e.setClearColor(r.set(ot),1);let{r:Tt,g:jt,b:Bt}=r,Lt=.2126*Tt+.7152*jt+.0722*Bt>Math.sqrt(.0525)-.05?"#000":"#fff";E.style.setProperty("--viewport-text",ot===s?"":Lt),U()};for(let ot of yp({root:E,toolbar:k.toolbar,scene:h,meta:K,grids:y,initialBackground:s,setBackground:Y}))k.onEscape(ot.close);k.toolbar.setHandler("distance",()=>{q(),v.setActive(!v.active),v.active||I.release(),k.toolbar.setActive("distance",v.active)}),k.toolbar.setActive("distance",!1),k.onEscape(()=>(q(),v.clear()));let tt=()=>{z.setExtraBounds("grids",y.visible?y.box:null),z.setExtraBounds("measure",v.box)};y.addEventListener("change",tt),v.addEventListener("change",tt),tt(),z.addEventListener("click",ot=>{let{x:Tt,y:jt,ctrl:Bt,shift:ut}=ot.detail;if(v.active){let Zt=I.target(Tt,jt);Zt&&v.add(Zt.point);return}let Lt=!Bt&&!ut?f?.pick(Tt,jt):void 0;if(Lt!==void 0){dt.open(Lt);return}let zt=F.pick(Tt,jt)?.element??-1;Bt?zt>=0&&W.toggle(zt):zt>=0?W.set([zt]):ut||W.clear()}),z.addEventListener("boxselect",ot=>{if(v.active)return;let{rect:Tt,mode:jt,ctrl:Bt,shift:ut}=ot.detail;if(Tt.width<4||Tt.height<4){!Bt&&!ut&&W.clear();return}let Lt=new le,Ot=qf(Tt,jt,Yf(h,z.camera,Xn.getBoundingClientRect())),zt=_.clipping(),Zt=Ot.filter(Ee=>!_.isCut(h.elementBox(Ee,Lt),zt));W.set(Bt?[...W.values(),...Zt]:Zt)}),window.addEventListener("resize",()=>{e.setSize(window.innerWidth,window.innerHeight,!1),z.resize()}),e.setSize(window.innerWidth,window.innerHeight,!1),z.resize(),z.fitBox(g(),!1);let dt=Lp(E,i,d,h,z,U),It=new cl(document.getElementById("ioviewer-ui"),a,z);window.addEventListener("pointerdown",ot=>{(ot.target===Xn||It.element.contains(ot.target))&&document.activeElement?.blur()},!0),window.__ioviewer={scene:h,points:d,motionDetail:u,controls:z,picker:F,selection:W,ui:k,viewCube:It,sections:_,sectionGizmo:b,measure:v,measureSnap:I,grids:y,clashes:ht,timeliner:at,ready:T,get camera(){return z.camera}}}})(); /*! Bundled license information: three/build/three.core.js: diff --git a/src/IOViewer/Viewer/src/i18n.js b/src/IOViewer/Viewer/src/i18n.js index fa044e9..03238c5 100644 --- a/src/IOViewer/Viewer/src/i18n.js +++ b/src/IOViewer/Viewer/src/i18n.js @@ -12,6 +12,7 @@ const dictionaries = { 'scanMap.plan': 'План облака точек', 'scanMap.metres': 'м', 'scanMap.choosePhoto': 'Открыть фотопанораму…', + 'scanMap.spheres': 'Сферы панорам в 3D', 'scanMap.photo': 'Фотопанорама', 'scanMap.goToStation': 'Перейти к станции {name}', 'scanMap.photoControls': 'Фотопанорама. Стрелки поворачивают камеру, колесо меняет масштаб.', @@ -174,6 +175,7 @@ const dictionaries = { 'scanMap.plan': 'Point cloud floor plan', 'scanMap.metres': 'm', 'scanMap.choosePhoto': 'Open photo panorama…', + 'scanMap.spheres': 'Panorama spheres in 3D', 'scanMap.photo': 'Photo panorama', 'scanMap.goToStation': 'Move to station {name}', 'scanMap.photoControls': 'Photo panorama. Arrow keys turn the camera, the wheel zooms.', diff --git a/src/IOViewer/Viewer/src/main.js b/src/IOViewer/Viewer/src/main.js index 209e197..2603e97 100644 --- a/src/IOViewer/Viewer/src/main.js +++ b/src/IOViewer/Viewer/src/main.js @@ -23,6 +23,7 @@ import { mountClashes } from './ui/clashesPanel.js'; import { mountTimeliner } from './ui/timeliner.js'; import { mountLinks } from './ui/linksPanel.js'; import { mountScanMap } from './ui/scanMap.js'; +import { createPanoramaSpheres } from './ui/panoramaSpheres.js'; document.documentElement.lang = lang; const canvas = document.getElementById('ioviewer-canvas'); @@ -89,6 +90,8 @@ function start(data, context) { const motionDetail = new MotionDetail(scene, requestRender, Math.min(scene.totalCost, 20e6)); world.add(scene.root); world.add(points.root); + const panoramaSpheres = points.count ? createPanoramaSpheres(data.meta.panoramas) : null; + if (panoramaSpheres) world.add(panoramaSpheres.mesh); const visibleBox = () => scene.visibleBox(); // Sections never change which elements are shown, so they leave the bounds (orbit pivot, near/far) as they are. const sections = new Sections(scene, visibleBox(), data.meta.sections); @@ -138,6 +141,7 @@ function start(data, context) { if (contextLost) return; const rect = canvas.getBoundingClientRect(); controls.camera.updateMatrixWorld(); // the screen labels project with it before render() would update it + if (scanMap) panoramaSpheres?.update(controls.camera, rect, scanMap.showSphere); sectionGizmo.update(controls.camera); measure.update(controls.camera, rect); grids.update(controls.camera, rect); @@ -264,6 +268,11 @@ function start(data, context) { if (target) measure.add(target.point); return; } + const station = !ctrl && !shift ? panoramaSpheres?.pick(x, y) : undefined; + if (station !== undefined) { + scanMap.open(station); + return; + } const hit = picker.pick(x, y); const element = hit?.element ?? -1; if (ctrl) { @@ -294,7 +303,7 @@ function start(data, context) { renderer.setSize(window.innerWidth, window.innerHeight, false); controls.resize(); // also schedules the first frame for an empty model controls.fitBox(visibleBox(), false); - mountScanMap(uiRoot, data, points, scene, controls); + const scanMap = mountScanMap(uiRoot, data, points, scene, controls, requestRender); const viewCube = new ViewCube(document.getElementById('ioviewer-ui'), camera, controls); // home = this load view // The canvas and the view cube take no focus, so a press on them takes it from a panel field or a toolbar button: diff --git a/src/IOViewer/Viewer/src/ui/panoramaSpheres.js b/src/IOViewer/Viewer/src/ui/panoramaSpheres.js new file mode 100644 index 0000000..09322e6 --- /dev/null +++ b/src/IOViewer/Viewer/src/ui/panoramaSpheres.js @@ -0,0 +1,56 @@ +import * as THREE from 'three'; + +const radiusPixels = 7; + +export function createPanoramaSpheres(panoramas) { + if (!panoramas?.length) return null; + const positions = panoramas.map(({ position }) => new THREE.Vector3(...position)); + // Keep camera stations discoverable inside rooms and behind dense point clouds. + const material = new THREE.MeshPhongMaterial({ color: '#72bfff', depthTest: false, depthWrite: false }); + const mesh = new THREE.InstancedMesh(new THREE.SphereGeometry(1, 12, 8), material, panoramas.length); + mesh.count = 0; + mesh.frustumCulled = false; + mesh.renderOrder = 10; + mesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage); + + const screen = []; + const matrix = new THREE.Matrix4(); + const point = new THREE.Vector3(); + const view = new THREE.Vector2(); + + return { + mesh, + update(camera, rect, visible) { + mesh.count = 0; + screen.length = 0; + if (rect.width <= 0 || rect.height <= 0) return; + for (const [index, position] of positions.entries()) { + if (!visible(panoramas[index].element, position.z)) continue; + const depth = -point.copy(position).applyMatrix4(camera.matrixWorldInverse).z; + if (depth <= camera.near || depth >= camera.far) continue; + point.copy(position).project(camera); + if (!Number.isFinite(point.x) || !Number.isFinite(point.y)) continue; + const x = (point.x + 1) * rect.width / 2; + const y = (1 - point.y) * rect.height / 2; + if (x < -radiusPixels || x > rect.width + radiusPixels || + y < -radiusPixels || y > rect.height + radiusPixels) continue; + + const height = camera.isOrthographicCamera + ? (camera.top - camera.bottom) / camera.zoom + : camera.getViewSize(depth, view).y; + const radius = radiusPixels * height / rect.height; + mesh.setMatrixAt(mesh.count++, matrix.makeScale(radius, radius, radius).setPosition(position)); + screen.push({ index, depth, x: x + rect.left, y: y + rect.top }); + } + mesh.instanceMatrix.needsUpdate = mesh.count > 0; + }, + pick(x, y) { + let nearest; + for (const station of screen) { + if ((!nearest || station.depth < nearest.depth) && + Math.hypot(station.x - x, station.y - y) <= radiusPixels) nearest = station; + } + return nearest?.index; + }, + }; +} diff --git a/src/IOViewer/Viewer/src/ui/scanMap.js b/src/IOViewer/Viewer/src/ui/scanMap.js index b760fbd..d246391 100644 --- a/src/IOViewer/Viewer/src/ui/scanMap.js +++ b/src/IOViewer/Viewer/src/ui/scanMap.js @@ -40,7 +40,7 @@ export function pickPhotoElevation(camera, origin, objects, x, y, width, height) return undefined; } -export function mountScanMap(root, data, points, scene, controls) { +export function mountScanMap(root, data, points, scene, controls, requestRender) { if (!points.count) return; const bounds = new THREE.Box3().setFromObject(points.root); if (bounds.isEmpty()) return; @@ -72,6 +72,7 @@ export function mountScanMap(root, data, points, scene, controls) { } let levels = saved ?? autoLevels(); let selectedLevel = -1; + let showSpheres = true; const inLevel = (z) => levelContains(levels[selectedLevel], z + offsetZ); const panel = document.createElement('details'); @@ -227,6 +228,7 @@ export function mountScanMap(root, data, points, scene, controls) { removeLevel.disabled = selectedLevel < 0; for (const [i, position] of positions.entries()) selector.options[i + 1].hidden = !inLevel(position.z); redraw(); + requestRender(); } levelSelect.addEventListener('change', () => { selectedLevel = Number(levelSelect.value); @@ -261,6 +263,15 @@ export function mountScanMap(root, data, points, scene, controls) { refreshLevels(); }); levelControls.append(levelSelect, addLevel, auto, removeLevel); + if (panoramas.length) { + const spheres = mapButton(t('scanMap.spheres'), '◉', () => { + showSpheres = !showSpheres; + spheres.setAttribute('aria-pressed', String(showSpheres)); + requestRender(); + }); + spheres.setAttribute('aria-pressed', 'true'); + levelControls.append(spheres); + } panel.append(levelControls, levelStatus); const photo = panoramas.length ? photoPanel(root, data, points, show, (pose) => { photoPose = pose; @@ -304,6 +315,7 @@ export function mountScanMap(root, data, points, scene, controls) { // Selecting the same station again should open its photo. selector.value = ''; } + return { open: show, showSphere: (element, z) => showSpheres && inLevel(z) && scene.isVisible(element) }; } function photoPanel(root, data, points, show, onPose, onLevel) { diff --git a/src/IOViewer/Viewer/styles/viewer.css b/src/IOViewer/Viewer/styles/viewer.css index 55d1045..166bf34 100644 --- a/src/IOViewer/Viewer/styles/viewer.css +++ b/src/IOViewer/Viewer/styles/viewer.css @@ -214,6 +214,10 @@ input:focus-visible { cursor: pointer; } +.scan-map-controls button[aria-pressed='true'] { + color: #72bfff; +} + .scan-map-controls button:disabled { opacity: .48; cursor: default; diff --git a/src/IOViewer/Viewer/test/unit/scanMap.test.js b/src/IOViewer/Viewer/test/unit/scanMap.test.js index b19ae56..b98aeaa 100644 --- a/src/IOViewer/Viewer/test/unit/scanMap.test.js +++ b/src/IOViewer/Viewer/test/unit/scanMap.test.js @@ -3,6 +3,40 @@ import assert from 'node:assert/strict'; import * as THREE from 'three'; import { photoDirection, photoDrag, pickPhotoElevation } from '../../src/ui/scanMap.js'; import { detectScanLevels, levelContains, mapZoom } from '../../src/ui/scanLevels.js'; +import { createPanoramaSpheres } from '../../src/ui/panoramaSpheres.js'; + +test('panorama spheres pick the nearest station, respect visibility and stay small when zooming', () => { + const stations = createPanoramaSpheres([ + { position: [0, 0, -4], element: 0 }, + { position: [0, 0, -10], element: 1 }, + { position: [0, 0, 4], element: 2 }, + ]); + const rect = { left: 50, top: 20, width: 800, height: 600 }; + const camera = new THREE.PerspectiveCamera(45, 4 / 3, .1, 20); + camera.updateMatrixWorld(); + stations.update(camera, rect, () => true); + assert.equal(stations.mesh.count, 2); + assert.equal(stations.pick(450, 320), 0); + assert.equal(stations.pick(458, 320), undefined); + + camera.zoom = 2; + camera.updateProjectionMatrix(); + stations.update(camera, rect, (element) => element !== 0); + assert.equal(stations.mesh.count, 1); + assert.equal(stations.pick(456, 320), 1); + assert.equal(stations.pick(458, 320), undefined); + + stations.update(camera, rect, () => false); + assert.equal(stations.mesh.count, 0); + assert.equal(stations.pick(450, 320), undefined); + + const ortho = new THREE.OrthographicCamera(-4, 4, 3, -3, .1, 20); + ortho.updateMatrixWorld(); + stations.update(ortho, rect, () => true); + assert.equal(stations.mesh.count, 2); + assert.equal(stations.pick(450, 320), 0); + assert.equal(createPanoramaSpheres([]), null); +}); test('a panorama feature follows the pointer on both screen axes', () => { const camera = new THREE.PerspectiveCamera(72, 1.5, .1, 20);